babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Extracts text content from a DOM element hierarchy
  284. * @param element defines the root element
  285. * @returns a string
  286. */
  287. static GetDOMTextContent(element: HTMLElement): string;
  288. }
  289. }
  290. declare module "babylonjs/Misc/logger" {
  291. /**
  292. * Logger used througouht the application to allow configuration of
  293. * the log level required for the messages.
  294. */
  295. export class Logger {
  296. /**
  297. * No log
  298. */
  299. static readonly NoneLogLevel: number;
  300. /**
  301. * Only message logs
  302. */
  303. static readonly MessageLogLevel: number;
  304. /**
  305. * Only warning logs
  306. */
  307. static readonly WarningLogLevel: number;
  308. /**
  309. * Only error logs
  310. */
  311. static readonly ErrorLogLevel: number;
  312. /**
  313. * All logs
  314. */
  315. static readonly AllLogLevel: number;
  316. private static _LogCache;
  317. /**
  318. * Gets a value indicating the number of loading errors
  319. * @ignorenaming
  320. */
  321. static errorsCount: number;
  322. /**
  323. * Callback called when a new log is added
  324. */
  325. static OnNewCacheEntry: (entry: string) => void;
  326. private static _AddLogEntry;
  327. private static _FormatMessage;
  328. private static _LogDisabled;
  329. private static _LogEnabled;
  330. private static _WarnDisabled;
  331. private static _WarnEnabled;
  332. private static _ErrorDisabled;
  333. private static _ErrorEnabled;
  334. /**
  335. * Log a message to the console
  336. */
  337. static Log: (message: string) => void;
  338. /**
  339. * Write a warning message to the console
  340. */
  341. static Warn: (message: string) => void;
  342. /**
  343. * Write an error message to the console
  344. */
  345. static Error: (message: string) => void;
  346. /**
  347. * Gets current log cache (list of logs)
  348. */
  349. static readonly LogCache: string;
  350. /**
  351. * Clears the log cache
  352. */
  353. static ClearLogCache(): void;
  354. /**
  355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  356. */
  357. static LogLevels: number;
  358. }
  359. }
  360. declare module "babylonjs/Misc/typeStore" {
  361. /** @hidden */
  362. export class _TypeStore {
  363. /** @hidden */
  364. static RegisteredTypes: {
  365. [key: string]: Object;
  366. };
  367. /** @hidden */
  368. static GetClass(fqdn: string): any;
  369. }
  370. }
  371. declare module "babylonjs/Misc/deepCopier" {
  372. /**
  373. * Class containing a set of static utilities functions for deep copy.
  374. */
  375. export class DeepCopier {
  376. /**
  377. * Tries to copy an object by duplicating every property
  378. * @param source defines the source object
  379. * @param destination defines the target object
  380. * @param doNotCopyList defines a list of properties to avoid
  381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  382. */
  383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  384. }
  385. }
  386. declare module "babylonjs/Misc/precisionDate" {
  387. /**
  388. * Class containing a set of static utilities functions for precision date
  389. */
  390. export class PrecisionDate {
  391. /**
  392. * Gets either window.performance.now() if supported or Date.now() else
  393. */
  394. static readonly Now: number;
  395. }
  396. }
  397. declare module "babylonjs/Misc/devTools" {
  398. /** @hidden */
  399. export class _DevTools {
  400. static WarnImport(name: string): string;
  401. }
  402. }
  403. declare module "babylonjs/Misc/webRequest" {
  404. /**
  405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  406. */
  407. export class WebRequest {
  408. private _xhr;
  409. /**
  410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  411. * i.e. when loading files, where the server/service expects an Authorization header
  412. */
  413. static CustomRequestHeaders: {
  414. [key: string]: string;
  415. };
  416. /**
  417. * Add callback functions in this array to update all the requests before they get sent to the network
  418. */
  419. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  420. private _injectCustomRequestHeaders;
  421. /**
  422. * Gets or sets a function to be called when loading progress changes
  423. */
  424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  425. /**
  426. * Returns client's state
  427. */
  428. readonly readyState: number;
  429. /**
  430. * Returns client's status
  431. */
  432. readonly status: number;
  433. /**
  434. * Returns client's status as a text
  435. */
  436. readonly statusText: string;
  437. /**
  438. * Returns client's response
  439. */
  440. readonly response: any;
  441. /**
  442. * Returns client's response url
  443. */
  444. readonly responseURL: string;
  445. /**
  446. * Returns client's response as text
  447. */
  448. readonly responseText: string;
  449. /**
  450. * Gets or sets the expected response type
  451. */
  452. responseType: XMLHttpRequestResponseType;
  453. /** @hidden */
  454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  455. /** @hidden */
  456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  457. /**
  458. * Cancels any network activity
  459. */
  460. abort(): void;
  461. /**
  462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  463. * @param body defines an optional request body
  464. */
  465. send(body?: Document | BodyInit | null): void;
  466. /**
  467. * Sets the request method, request URL
  468. * @param method defines the method to use (GET, POST, etc..)
  469. * @param url defines the url to connect with
  470. */
  471. open(method: string, url: string): void;
  472. }
  473. }
  474. declare module "babylonjs/Misc/fileRequest" {
  475. import { Observable } from "babylonjs/Misc/observable";
  476. /**
  477. * File request interface
  478. */
  479. export interface IFileRequest {
  480. /**
  481. * Raised when the request is complete (success or error).
  482. */
  483. onCompleteObservable: Observable<IFileRequest>;
  484. /**
  485. * Aborts the request for a file.
  486. */
  487. abort: () => void;
  488. }
  489. }
  490. declare module "babylonjs/Misc/performanceMonitor" {
  491. /**
  492. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  493. */
  494. export class PerformanceMonitor {
  495. private _enabled;
  496. private _rollingFrameTime;
  497. private _lastFrameTimeMs;
  498. /**
  499. * constructor
  500. * @param frameSampleSize The number of samples required to saturate the sliding window
  501. */
  502. constructor(frameSampleSize?: number);
  503. /**
  504. * Samples current frame
  505. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  506. */
  507. sampleFrame(timeMs?: number): void;
  508. /**
  509. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  510. */
  511. readonly averageFrameTime: number;
  512. /**
  513. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  514. */
  515. readonly averageFrameTimeVariance: number;
  516. /**
  517. * Returns the frame time of the most recent frame
  518. */
  519. readonly instantaneousFrameTime: number;
  520. /**
  521. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  522. */
  523. readonly averageFPS: number;
  524. /**
  525. * Returns the average framerate in frames per second using the most recent frame time
  526. */
  527. readonly instantaneousFPS: number;
  528. /**
  529. * Returns true if enough samples have been taken to completely fill the sliding window
  530. */
  531. readonly isSaturated: boolean;
  532. /**
  533. * Enables contributions to the sliding window sample set
  534. */
  535. enable(): void;
  536. /**
  537. * Disables contributions to the sliding window sample set
  538. * Samples will not be interpolated over the disabled period
  539. */
  540. disable(): void;
  541. /**
  542. * Returns true if sampling is enabled
  543. */
  544. readonly isEnabled: boolean;
  545. /**
  546. * Resets performance monitor
  547. */
  548. reset(): void;
  549. }
  550. /**
  551. * RollingAverage
  552. *
  553. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  554. */
  555. export class RollingAverage {
  556. /**
  557. * Current average
  558. */
  559. average: number;
  560. /**
  561. * Current variance
  562. */
  563. variance: number;
  564. protected _samples: Array<number>;
  565. protected _sampleCount: number;
  566. protected _pos: number;
  567. protected _m2: number;
  568. /**
  569. * constructor
  570. * @param length The number of samples required to saturate the sliding window
  571. */
  572. constructor(length: number);
  573. /**
  574. * Adds a sample to the sample set
  575. * @param v The sample value
  576. */
  577. add(v: number): void;
  578. /**
  579. * Returns previously added values or null if outside of history or outside the sliding window domain
  580. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  581. * @return Value previously recorded with add() or null if outside of range
  582. */
  583. history(i: number): number;
  584. /**
  585. * Returns true if enough samples have been taken to completely fill the sliding window
  586. * @return true if sample-set saturated
  587. */
  588. isSaturated(): boolean;
  589. /**
  590. * Resets the rolling average (equivalent to 0 samples taken so far)
  591. */
  592. reset(): void;
  593. /**
  594. * Wraps a value around the sample range boundaries
  595. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  596. * @return Wrapped position in sample range
  597. */
  598. protected _wrapPosition(i: number): number;
  599. }
  600. }
  601. declare module "babylonjs/Misc/stringDictionary" {
  602. import { Nullable } from "babylonjs/types";
  603. /**
  604. * This class implement a typical dictionary using a string as key and the generic type T as value.
  605. * The underlying implementation relies on an associative array to ensure the best performances.
  606. * The value can be anything including 'null' but except 'undefined'
  607. */
  608. export class StringDictionary<T> {
  609. /**
  610. * This will clear this dictionary and copy the content from the 'source' one.
  611. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  612. * @param source the dictionary to take the content from and copy to this dictionary
  613. */
  614. copyFrom(source: StringDictionary<T>): void;
  615. /**
  616. * Get a value based from its key
  617. * @param key the given key to get the matching value from
  618. * @return the value if found, otherwise undefined is returned
  619. */
  620. get(key: string): T | undefined;
  621. /**
  622. * Get a value from its key or add it if it doesn't exist.
  623. * This method will ensure you that a given key/data will be present in the dictionary.
  624. * @param key the given key to get the matching value from
  625. * @param factory the factory that will create the value if the key is not present in the dictionary.
  626. * The factory will only be invoked if there's no data for the given key.
  627. * @return the value corresponding to the key.
  628. */
  629. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  630. /**
  631. * Get a value from its key if present in the dictionary otherwise add it
  632. * @param key the key to get the value from
  633. * @param val if there's no such key/value pair in the dictionary add it with this value
  634. * @return the value corresponding to the key
  635. */
  636. getOrAdd(key: string, val: T): T;
  637. /**
  638. * Check if there's a given key in the dictionary
  639. * @param key the key to check for
  640. * @return true if the key is present, false otherwise
  641. */
  642. contains(key: string): boolean;
  643. /**
  644. * Add a new key and its corresponding value
  645. * @param key the key to add
  646. * @param value the value corresponding to the key
  647. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  648. */
  649. add(key: string, value: T): boolean;
  650. /**
  651. * Update a specific value associated to a key
  652. * @param key defines the key to use
  653. * @param value defines the value to store
  654. * @returns true if the value was updated (or false if the key was not found)
  655. */
  656. set(key: string, value: T): boolean;
  657. /**
  658. * Get the element of the given key and remove it from the dictionary
  659. * @param key defines the key to search
  660. * @returns the value associated with the key or null if not found
  661. */
  662. getAndRemove(key: string): Nullable<T>;
  663. /**
  664. * Remove a key/value from the dictionary.
  665. * @param key the key to remove
  666. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  667. */
  668. remove(key: string): boolean;
  669. /**
  670. * Clear the whole content of the dictionary
  671. */
  672. clear(): void;
  673. /**
  674. * Gets the current count
  675. */
  676. readonly count: number;
  677. /**
  678. * Execute a callback on each key/val of the dictionary.
  679. * Note that you can remove any element in this dictionary in the callback implementation
  680. * @param callback the callback to execute on a given key/value pair
  681. */
  682. forEach(callback: (key: string, val: T) => void): void;
  683. /**
  684. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  685. * If the callback returns null or undefined the method will iterate to the next key/value pair
  686. * Note that you can remove any element in this dictionary in the callback implementation
  687. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  688. * @returns the first item
  689. */
  690. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  691. private _count;
  692. private _data;
  693. }
  694. }
  695. declare module "babylonjs/Meshes/dataBuffer" {
  696. /**
  697. * Class used to store gfx data (like WebGLBuffer)
  698. */
  699. export class DataBuffer {
  700. /**
  701. * Gets or sets the number of objects referencing this buffer
  702. */
  703. references: number;
  704. /** Gets or sets the size of the underlying buffer */
  705. capacity: number;
  706. /**
  707. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  708. */
  709. is32Bits: boolean;
  710. /**
  711. * Gets the underlying buffer
  712. */
  713. readonly underlyingResource: any;
  714. }
  715. }
  716. declare module "babylonjs/Meshes/buffer" {
  717. import { Nullable, DataArray } from "babylonjs/types";
  718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module "babylonjs/Maths/math.scalar" {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module "babylonjs/Maths/math.constants" {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. export { Epsilon };
  1248. }
  1249. declare module "babylonjs/Maths/math.viewport" {
  1250. /**
  1251. * Class used to represent a viewport on screen
  1252. */
  1253. export class Viewport {
  1254. /** viewport left coordinate */
  1255. x: number;
  1256. /** viewport top coordinate */
  1257. y: number;
  1258. /**viewport width */
  1259. width: number;
  1260. /** viewport height */
  1261. height: number;
  1262. /**
  1263. * Creates a Viewport object located at (x, y) and sized (width, height)
  1264. * @param x defines viewport left coordinate
  1265. * @param y defines viewport top coordinate
  1266. * @param width defines the viewport width
  1267. * @param height defines the viewport height
  1268. */
  1269. constructor(
  1270. /** viewport left coordinate */
  1271. x: number,
  1272. /** viewport top coordinate */
  1273. y: number,
  1274. /**viewport width */
  1275. width: number,
  1276. /** viewport height */
  1277. height: number);
  1278. /**
  1279. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1280. * @param renderWidth defines the rendering width
  1281. * @param renderHeight defines the rendering height
  1282. * @returns a new Viewport
  1283. */
  1284. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1285. /**
  1286. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1287. * @param renderWidth defines the rendering width
  1288. * @param renderHeight defines the rendering height
  1289. * @param ref defines the target viewport
  1290. * @returns the current viewport
  1291. */
  1292. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1293. /**
  1294. * Returns a new Viewport copied from the current one
  1295. * @returns a new Viewport
  1296. */
  1297. clone(): Viewport;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/arrayTools" {
  1301. /**
  1302. * Class containing a set of static utilities functions for arrays.
  1303. */
  1304. export class ArrayTools {
  1305. /**
  1306. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1307. * @param size the number of element to construct and put in the array
  1308. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1309. * @returns a new array filled with new objects
  1310. */
  1311. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1312. }
  1313. }
  1314. declare module "babylonjs/Maths/math.like" {
  1315. import { float, int, DeepImmutable } from "babylonjs/types";
  1316. /**
  1317. * @hidden
  1318. */
  1319. export interface IColor4Like {
  1320. r: float;
  1321. g: float;
  1322. b: float;
  1323. a: float;
  1324. }
  1325. /**
  1326. * @hidden
  1327. */
  1328. export interface IColor3Like {
  1329. r: float;
  1330. g: float;
  1331. b: float;
  1332. }
  1333. /**
  1334. * @hidden
  1335. */
  1336. export interface IVector4Like {
  1337. x: float;
  1338. y: float;
  1339. z: float;
  1340. w: float;
  1341. }
  1342. /**
  1343. * @hidden
  1344. */
  1345. export interface IVector3Like {
  1346. x: float;
  1347. y: float;
  1348. z: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IVector2Like {
  1354. x: float;
  1355. y: float;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IMatrixLike {
  1361. toArray(): DeepImmutable<Float32Array>;
  1362. updateFlag: int;
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export interface IViewportLike {
  1368. x: float;
  1369. y: float;
  1370. width: float;
  1371. height: float;
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export interface IPlaneLike {
  1377. normal: IVector3Like;
  1378. d: float;
  1379. normalize(): void;
  1380. }
  1381. }
  1382. declare module "babylonjs/Maths/math.vector" {
  1383. import { Viewport } from "babylonjs/Maths/math.viewport";
  1384. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1385. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1386. /**
  1387. * Class representing a vector containing 2 coordinates
  1388. */
  1389. export class Vector2 {
  1390. /** defines the first coordinate */
  1391. x: number;
  1392. /** defines the second coordinate */
  1393. y: number;
  1394. /**
  1395. * Creates a new Vector2 from the given x and y coordinates
  1396. * @param x defines the first coordinate
  1397. * @param y defines the second coordinate
  1398. */
  1399. constructor(
  1400. /** defines the first coordinate */
  1401. x?: number,
  1402. /** defines the second coordinate */
  1403. y?: number);
  1404. /**
  1405. * Gets a string with the Vector2 coordinates
  1406. * @returns a string with the Vector2 coordinates
  1407. */
  1408. toString(): string;
  1409. /**
  1410. * Gets class name
  1411. * @returns the string "Vector2"
  1412. */
  1413. getClassName(): string;
  1414. /**
  1415. * Gets current vector hash code
  1416. * @returns the Vector2 hash code as a number
  1417. */
  1418. getHashCode(): number;
  1419. /**
  1420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1421. * @param array defines the source array
  1422. * @param index defines the offset in source array
  1423. * @returns the current Vector2
  1424. */
  1425. toArray(array: FloatArray, index?: number): Vector2;
  1426. /**
  1427. * Copy the current vector to an array
  1428. * @returns a new array with 2 elements: the Vector2 coordinates.
  1429. */
  1430. asArray(): number[];
  1431. /**
  1432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1433. * @param source defines the source Vector2
  1434. * @returns the current updated Vector2
  1435. */
  1436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1437. /**
  1438. * Sets the Vector2 coordinates with the given floats
  1439. * @param x defines the first coordinate
  1440. * @param y defines the second coordinate
  1441. * @returns the current updated Vector2
  1442. */
  1443. copyFromFloats(x: number, y: number): Vector2;
  1444. /**
  1445. * Sets the Vector2 coordinates with the given floats
  1446. * @param x defines the first coordinate
  1447. * @param y defines the second coordinate
  1448. * @returns the current updated Vector2
  1449. */
  1450. set(x: number, y: number): Vector2;
  1451. /**
  1452. * Add another vector with the current one
  1453. * @param otherVector defines the other vector
  1454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1455. */
  1456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1457. /**
  1458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1459. * @param otherVector defines the other vector
  1460. * @param result defines the target vector
  1461. * @returns the unmodified current Vector2
  1462. */
  1463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1464. /**
  1465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1466. * @param otherVector defines the other vector
  1467. * @returns the current updated Vector2
  1468. */
  1469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1470. /**
  1471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1472. * @param otherVector defines the other vector
  1473. * @returns a new Vector2
  1474. */
  1475. addVector3(otherVector: Vector3): Vector2;
  1476. /**
  1477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1478. * @param otherVector defines the other vector
  1479. * @returns a new Vector2
  1480. */
  1481. subtract(otherVector: Vector2): Vector2;
  1482. /**
  1483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1484. * @param otherVector defines the other vector
  1485. * @param result defines the target vector
  1486. * @returns the unmodified current Vector2
  1487. */
  1488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1489. /**
  1490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1491. * @param otherVector defines the other vector
  1492. * @returns the current updated Vector2
  1493. */
  1494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1495. /**
  1496. * Multiplies in place the current Vector2 coordinates by the given ones
  1497. * @param otherVector defines the other vector
  1498. * @returns the current updated Vector2
  1499. */
  1500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1501. /**
  1502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1503. * @param otherVector defines the other vector
  1504. * @returns a new Vector2
  1505. */
  1506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1507. /**
  1508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1509. * @param otherVector defines the other vector
  1510. * @param result defines the target vector
  1511. * @returns the unmodified current Vector2
  1512. */
  1513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1514. /**
  1515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1516. * @param x defines the first coordinate
  1517. * @param y defines the second coordinate
  1518. * @returns a new Vector2
  1519. */
  1520. multiplyByFloats(x: number, y: number): Vector2;
  1521. /**
  1522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1523. * @param otherVector defines the other vector
  1524. * @returns a new Vector2
  1525. */
  1526. divide(otherVector: Vector2): Vector2;
  1527. /**
  1528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1529. * @param otherVector defines the other vector
  1530. * @param result defines the target vector
  1531. * @returns the unmodified current Vector2
  1532. */
  1533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1534. /**
  1535. * Divides the current Vector2 coordinates by the given ones
  1536. * @param otherVector defines the other vector
  1537. * @returns the current updated Vector2
  1538. */
  1539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1540. /**
  1541. * Gets a new Vector2 with current Vector2 negated coordinates
  1542. * @returns a new Vector2
  1543. */
  1544. negate(): Vector2;
  1545. /**
  1546. * Multiply the Vector2 coordinates by scale
  1547. * @param scale defines the scaling factor
  1548. * @returns the current updated Vector2
  1549. */
  1550. scaleInPlace(scale: number): Vector2;
  1551. /**
  1552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1553. * @param scale defines the scaling factor
  1554. * @returns a new Vector2
  1555. */
  1556. scale(scale: number): Vector2;
  1557. /**
  1558. * Scale the current Vector2 values by a factor to a given Vector2
  1559. * @param scale defines the scale factor
  1560. * @param result defines the Vector2 object where to store the result
  1561. * @returns the unmodified current Vector2
  1562. */
  1563. scaleToRef(scale: number, result: Vector2): Vector2;
  1564. /**
  1565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1566. * @param scale defines the scale factor
  1567. * @param result defines the Vector2 object where to store the result
  1568. * @returns the unmodified current Vector2
  1569. */
  1570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1571. /**
  1572. * Gets a boolean if two vectors are equals
  1573. * @param otherVector defines the other vector
  1574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1575. */
  1576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1577. /**
  1578. * Gets a boolean if two vectors are equals (using an epsilon value)
  1579. * @param otherVector defines the other vector
  1580. * @param epsilon defines the minimal distance to consider equality
  1581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1582. */
  1583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. floor(): Vector2;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. fract(): Vector2;
  1594. /**
  1595. * Gets the length of the vector
  1596. * @returns the vector length (float)
  1597. */
  1598. length(): number;
  1599. /**
  1600. * Gets the vector squared length
  1601. * @returns the vector squared length (float)
  1602. */
  1603. lengthSquared(): number;
  1604. /**
  1605. * Normalize the vector
  1606. * @returns the current updated Vector2
  1607. */
  1608. normalize(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 copied from the Vector2
  1611. * @returns a new Vector2
  1612. */
  1613. clone(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(0, 0)
  1616. * @returns a new Vector2
  1617. */
  1618. static Zero(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(1, 1)
  1621. * @returns a new Vector2
  1622. */
  1623. static One(): Vector2;
  1624. /**
  1625. * Gets a new Vector2 set from the given index element of the given array
  1626. * @param array defines the data source
  1627. * @param offset defines the offset in the data source
  1628. * @returns a new Vector2
  1629. */
  1630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1631. /**
  1632. * Sets "result" from the given index element of the given array
  1633. * @param array defines the data source
  1634. * @param offset defines the offset in the data source
  1635. * @param result defines the target vector
  1636. */
  1637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1638. /**
  1639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1640. * @param value1 defines 1st point of control
  1641. * @param value2 defines 2nd point of control
  1642. * @param value3 defines 3rd point of control
  1643. * @param value4 defines 4th point of control
  1644. * @param amount defines the interpolation factor
  1645. * @returns a new Vector2
  1646. */
  1647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1648. /**
  1649. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1652. * @param value defines the value to clamp
  1653. * @param min defines the lower limit
  1654. * @param max defines the upper limit
  1655. * @returns a new Vector2
  1656. */
  1657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1660. * @param value1 defines the 1st control point
  1661. * @param tangent1 defines the outgoing tangent
  1662. * @param value2 defines the 2nd control point
  1663. * @param tangent2 defines the incoming tangent
  1664. * @param amount defines the interpolation factor
  1665. * @returns a new Vector2
  1666. */
  1667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1668. /**
  1669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1670. * @param start defines the start vector
  1671. * @param end defines the end vector
  1672. * @param amount defines the interpolation factor
  1673. * @returns a new Vector2
  1674. */
  1675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1676. /**
  1677. * Gets the dot product of the vector "left" and the vector "right"
  1678. * @param left defines first vector
  1679. * @param right defines second vector
  1680. * @returns the dot product (float)
  1681. */
  1682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1683. /**
  1684. * Returns a new Vector2 equal to the normalized given vector
  1685. * @param vector defines the vector to normalize
  1686. * @returns a new Vector2
  1687. */
  1688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1689. /**
  1690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1691. * @param left defines 1st vector
  1692. * @param right defines 2nd vector
  1693. * @returns a new Vector2
  1694. */
  1695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1696. /**
  1697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1698. * @param left defines 1st vector
  1699. * @param right defines 2nd vector
  1700. * @returns a new Vector2
  1701. */
  1702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1703. /**
  1704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1705. * @param vector defines the vector to transform
  1706. * @param transformation defines the matrix to apply
  1707. * @returns a new Vector2
  1708. */
  1709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1710. /**
  1711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1712. * @param vector defines the vector to transform
  1713. * @param transformation defines the matrix to apply
  1714. * @param result defines the target vector
  1715. */
  1716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1717. /**
  1718. * Determines if a given vector is included in a triangle
  1719. * @param p defines the vector to test
  1720. * @param p0 defines 1st triangle point
  1721. * @param p1 defines 2nd triangle point
  1722. * @param p2 defines 3rd triangle point
  1723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1724. */
  1725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1726. /**
  1727. * Gets the distance between the vectors "value1" and "value2"
  1728. * @param value1 defines first vector
  1729. * @param value2 defines second vector
  1730. * @returns the distance between vectors
  1731. */
  1732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1733. /**
  1734. * Returns the squared distance between the vectors "value1" and "value2"
  1735. * @param value1 defines first vector
  1736. * @param value2 defines second vector
  1737. * @returns the squared distance between vectors
  1738. */
  1739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1740. /**
  1741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1742. * @param value1 defines first vector
  1743. * @param value2 defines second vector
  1744. * @returns a new Vector2
  1745. */
  1746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1747. /**
  1748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1749. * @param p defines the middle point
  1750. * @param segA defines one point of the segment
  1751. * @param segB defines the other point of the segment
  1752. * @returns the shortest distance
  1753. */
  1754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1755. }
  1756. /**
  1757. * Classed used to store (x,y,z) vector representation
  1758. * A Vector3 is the main object used in 3D geometry
  1759. * It can represent etiher the coordinates of a point the space, either a direction
  1760. * Reminder: js uses a left handed forward facing system
  1761. */
  1762. export class Vector3 {
  1763. /**
  1764. * Defines the first coordinates (on X axis)
  1765. */
  1766. x: number;
  1767. /**
  1768. * Defines the second coordinates (on Y axis)
  1769. */
  1770. y: number;
  1771. /**
  1772. * Defines the third coordinates (on Z axis)
  1773. */
  1774. z: number;
  1775. private static _UpReadOnly;
  1776. private static _ZeroReadOnly;
  1777. /**
  1778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1779. * @param x defines the first coordinates (on X axis)
  1780. * @param y defines the second coordinates (on Y axis)
  1781. * @param z defines the third coordinates (on Z axis)
  1782. */
  1783. constructor(
  1784. /**
  1785. * Defines the first coordinates (on X axis)
  1786. */
  1787. x?: number,
  1788. /**
  1789. * Defines the second coordinates (on Y axis)
  1790. */
  1791. y?: number,
  1792. /**
  1793. * Defines the third coordinates (on Z axis)
  1794. */
  1795. z?: number);
  1796. /**
  1797. * Creates a string representation of the Vector3
  1798. * @returns a string with the Vector3 coordinates.
  1799. */
  1800. toString(): string;
  1801. /**
  1802. * Gets the class name
  1803. * @returns the string "Vector3"
  1804. */
  1805. getClassName(): string;
  1806. /**
  1807. * Creates the Vector3 hash code
  1808. * @returns a number which tends to be unique between Vector3 instances
  1809. */
  1810. getHashCode(): number;
  1811. /**
  1812. * Creates an array containing three elements : the coordinates of the Vector3
  1813. * @returns a new array of numbers
  1814. */
  1815. asArray(): number[];
  1816. /**
  1817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1818. * @param array defines the destination array
  1819. * @param index defines the offset in the destination array
  1820. * @returns the current Vector3
  1821. */
  1822. toArray(array: FloatArray, index?: number): Vector3;
  1823. /**
  1824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1826. */
  1827. toQuaternion(): Quaternion;
  1828. /**
  1829. * Adds the given vector to the current Vector3
  1830. * @param otherVector defines the second operand
  1831. * @returns the current updated Vector3
  1832. */
  1833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Adds the given coordinates to the current Vector3
  1836. * @param x defines the x coordinate of the operand
  1837. * @param y defines the y coordinate of the operand
  1838. * @param z defines the z coordinate of the operand
  1839. * @returns the current updated Vector3
  1840. */
  1841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1842. /**
  1843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1844. * @param otherVector defines the second operand
  1845. * @returns the resulting Vector3
  1846. */
  1847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1850. * @param otherVector defines the second operand
  1851. * @param result defines the Vector3 object where to store the result
  1852. * @returns the current Vector3
  1853. */
  1854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1855. /**
  1856. * Subtract the given vector from the current Vector3
  1857. * @param otherVector defines the second operand
  1858. * @returns the current updated Vector3
  1859. */
  1860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1861. /**
  1862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1863. * @param otherVector defines the second operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1867. /**
  1868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1869. * @param otherVector defines the second operand
  1870. * @param result defines the Vector3 object where to store the result
  1871. * @returns the current Vector3
  1872. */
  1873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1874. /**
  1875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1876. * @param x defines the x coordinate of the operand
  1877. * @param y defines the y coordinate of the operand
  1878. * @param z defines the z coordinate of the operand
  1879. * @returns the resulting Vector3
  1880. */
  1881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1882. /**
  1883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1884. * @param x defines the x coordinate of the operand
  1885. * @param y defines the y coordinate of the operand
  1886. * @param z defines the z coordinate of the operand
  1887. * @param result defines the Vector3 object where to store the result
  1888. * @returns the current Vector3
  1889. */
  1890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1891. /**
  1892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1893. * @returns a new Vector3
  1894. */
  1895. negate(): Vector3;
  1896. /**
  1897. * Multiplies the Vector3 coordinates by the float "scale"
  1898. * @param scale defines the multiplier factor
  1899. * @returns the current updated Vector3
  1900. */
  1901. scaleInPlace(scale: number): Vector3;
  1902. /**
  1903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1904. * @param scale defines the multiplier factor
  1905. * @returns a new Vector3
  1906. */
  1907. scale(scale: number): Vector3;
  1908. /**
  1909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1910. * @param scale defines the multiplier factor
  1911. * @param result defines the Vector3 object where to store the result
  1912. * @returns the current Vector3
  1913. */
  1914. scaleToRef(scale: number, result: Vector3): Vector3;
  1915. /**
  1916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1917. * @param scale defines the scale factor
  1918. * @param result defines the Vector3 object where to store the result
  1919. * @returns the unmodified current Vector3
  1920. */
  1921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1922. /**
  1923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1924. * @param otherVector defines the second operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1928. /**
  1929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1930. * @param otherVector defines the second operand
  1931. * @param epsilon defines the minimal distance to define values as equals
  1932. * @returns true if both vectors are distant less than epsilon
  1933. */
  1934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1935. /**
  1936. * Returns true if the current Vector3 coordinates equals the given floats
  1937. * @param x defines the x coordinate of the operand
  1938. * @param y defines the y coordinate of the operand
  1939. * @param z defines the z coordinate of the operand
  1940. * @returns true if both vectors are equals
  1941. */
  1942. equalsToFloats(x: number, y: number, z: number): boolean;
  1943. /**
  1944. * Multiplies the current Vector3 coordinates by the given ones
  1945. * @param otherVector defines the second operand
  1946. * @returns the current updated Vector3
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1949. /**
  1950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1951. * @param otherVector defines the second operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1957. * @param otherVector defines the second operand
  1958. * @param result defines the Vector3 object where to store the result
  1959. * @returns the current Vector3
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1962. /**
  1963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1964. * @param x defines the x coordinate of the operand
  1965. * @param y defines the y coordinate of the operand
  1966. * @param z defines the z coordinate of the operand
  1967. * @returns the new Vector3
  1968. */
  1969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1970. /**
  1971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1972. * @param otherVector defines the second operand
  1973. * @returns the new Vector3
  1974. */
  1975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1976. /**
  1977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1978. * @param otherVector defines the second operand
  1979. * @param result defines the Vector3 object where to store the result
  1980. * @returns the current Vector3
  1981. */
  1982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1983. /**
  1984. * Divides the current Vector3 coordinates by the given ones.
  1985. * @param otherVector defines the second operand
  1986. * @returns the current updated Vector3
  1987. */
  1988. divideInPlace(otherVector: Vector3): Vector3;
  1989. /**
  1990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1991. * @param other defines the second operand
  1992. * @returns the current updated Vector3
  1993. */
  1994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1995. /**
  1996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1997. * @param other defines the second operand
  1998. * @returns the current updated Vector3
  1999. */
  2000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2001. /**
  2002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2003. * @param x defines the x coordinate of the operand
  2004. * @param y defines the y coordinate of the operand
  2005. * @param z defines the z coordinate of the operand
  2006. * @returns the current updated Vector3
  2007. */
  2008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2009. /**
  2010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2011. * @param x defines the x coordinate of the operand
  2012. * @param y defines the y coordinate of the operand
  2013. * @param z defines the z coordinate of the operand
  2014. * @returns the current updated Vector3
  2015. */
  2016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2017. /**
  2018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2019. * Check if is non uniform within a certain amount of decimal places to account for this
  2020. * @param epsilon the amount the values can differ
  2021. * @returns if the the vector is non uniform to a certain number of decimal places
  2022. */
  2023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2024. /**
  2025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2026. */
  2027. readonly isNonUniform: boolean;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. floor(): Vector3;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. fract(): Vector3;
  2038. /**
  2039. * Gets the length of the Vector3
  2040. * @returns the length of the Vector3
  2041. */
  2042. length(): number;
  2043. /**
  2044. * Gets the squared length of the Vector3
  2045. * @returns squared length of the Vector3
  2046. */
  2047. lengthSquared(): number;
  2048. /**
  2049. * Normalize the current Vector3.
  2050. * Please note that this is an in place operation.
  2051. * @returns the current updated Vector3
  2052. */
  2053. normalize(): Vector3;
  2054. /**
  2055. * Reorders the x y z properties of the vector in place
  2056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2057. * @returns the current updated vector
  2058. */
  2059. reorderInPlace(order: string): this;
  2060. /**
  2061. * Rotates the vector around 0,0,0 by a quaternion
  2062. * @param quaternion the rotation quaternion
  2063. * @param result vector to store the result
  2064. * @returns the resulting vector
  2065. */
  2066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2067. /**
  2068. * Rotates a vector around a given point
  2069. * @param quaternion the rotation quaternion
  2070. * @param point the point to rotate around
  2071. * @param result vector to store the result
  2072. * @returns the resulting vector
  2073. */
  2074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2075. /**
  2076. * Normalize the current Vector3 with the given input length.
  2077. * Please note that this is an in place operation.
  2078. * @param len the length of the vector
  2079. * @returns the current updated Vector3
  2080. */
  2081. normalizeFromLength(len: number): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to a new vector
  2084. * @returns the new Vector3
  2085. */
  2086. normalizeToNew(): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to the reference
  2089. * @param reference define the Vector3 to update
  2090. * @returns the updated Vector3
  2091. */
  2092. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2093. /**
  2094. * Creates a new Vector3 copied from the current Vector3
  2095. * @returns the new Vector3
  2096. */
  2097. clone(): Vector3;
  2098. /**
  2099. * Copies the given vector coordinates to the current Vector3 ones
  2100. * @param source defines the source Vector3
  2101. * @returns the current updated Vector3
  2102. */
  2103. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2104. /**
  2105. * Copies the given floats to the current Vector3 coordinates
  2106. * @param x defines the x coordinate of the operand
  2107. * @param y defines the y coordinate of the operand
  2108. * @param z defines the z coordinate of the operand
  2109. * @returns the current updated Vector3
  2110. */
  2111. copyFromFloats(x: number, y: number, z: number): Vector3;
  2112. /**
  2113. * Copies the given floats to the current Vector3 coordinates
  2114. * @param x defines the x coordinate of the operand
  2115. * @param y defines the y coordinate of the operand
  2116. * @param z defines the z coordinate of the operand
  2117. * @returns the current updated Vector3
  2118. */
  2119. set(x: number, y: number, z: number): Vector3;
  2120. /**
  2121. * Copies the given float to the current Vector3 coordinates
  2122. * @param v defines the x, y and z coordinates of the operand
  2123. * @returns the current updated Vector3
  2124. */
  2125. setAll(v: number): Vector3;
  2126. /**
  2127. * Get the clip factor between two vectors
  2128. * @param vector0 defines the first operand
  2129. * @param vector1 defines the second operand
  2130. * @param axis defines the axis to use
  2131. * @param size defines the size along the axis
  2132. * @returns the clip factor
  2133. */
  2134. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2135. /**
  2136. * Get angle between two vectors
  2137. * @param vector0 angle between vector0 and vector1
  2138. * @param vector1 angle between vector0 and vector1
  2139. * @param normal direction of the normal
  2140. * @return the angle between vector0 and vector1
  2141. */
  2142. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2143. /**
  2144. * Returns a new Vector3 set from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @returns the new Vector3
  2148. */
  2149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2150. /**
  2151. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArray instead
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @returns the new Vector3
  2156. */
  2157. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2158. /**
  2159. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2160. * @param array defines the source array
  2161. * @param offset defines the offset in the source array
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2165. /**
  2166. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2167. * This function is deprecated. Use FromArrayToRef instead.
  2168. * @param array defines the source array
  2169. * @param offset defines the offset in the source array
  2170. * @param result defines the Vector3 where to store the result
  2171. */
  2172. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2173. /**
  2174. * Sets the given vector "result" with the given floats.
  2175. * @param x defines the x coordinate of the source
  2176. * @param y defines the y coordinate of the source
  2177. * @param z defines the z coordinate of the source
  2178. * @param result defines the Vector3 where to store the result
  2179. */
  2180. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2183. * @returns a new empty Vector3
  2184. */
  2185. static Zero(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2188. * @returns a new unit Vector3
  2189. */
  2190. static One(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2193. * @returns a new up Vector3
  2194. */
  2195. static Up(): Vector3;
  2196. /**
  2197. * Gets a up Vector3 that must not be updated
  2198. */
  2199. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2200. /**
  2201. * Gets a zero Vector3 that must not be updated
  2202. */
  2203. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2206. * @returns a new down Vector3
  2207. */
  2208. static Down(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Forward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Backward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2221. * @returns a new right Vector3
  2222. */
  2223. static Right(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2226. * @returns a new left Vector3
  2227. */
  2228. static Left(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2231. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2232. * @param vector defines the Vector3 to transform
  2233. * @param transformation defines the transformation matrix
  2234. * @returns the transformed Vector3
  2235. */
  2236. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2237. /**
  2238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2239. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2240. * @param vector defines the Vector3 to transform
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2247. * This method computes tranformed coordinates only, not transformed direction vectors
  2248. * @param x define the x coordinate of the source vector
  2249. * @param y define the y coordinate of the source vector
  2250. * @param z define the z coordinate of the source vector
  2251. * @param transformation defines the transformation matrix
  2252. * @param result defines the Vector3 where to store the result
  2253. */
  2254. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2255. /**
  2256. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2258. * @param vector defines the Vector3 to transform
  2259. * @param transformation defines the transformation matrix
  2260. * @returns the new Vector3
  2261. */
  2262. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2263. /**
  2264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2265. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2266. * @param vector defines the Vector3 to transform
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2274. * @param x define the x coordinate of the source vector
  2275. * @param y define the y coordinate of the source vector
  2276. * @param z define the z coordinate of the source vector
  2277. * @param transformation defines the transformation matrix
  2278. * @param result defines the Vector3 where to store the result
  2279. */
  2280. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2281. /**
  2282. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2283. * @param value1 defines the first control point
  2284. * @param value2 defines the second control point
  2285. * @param value3 defines the third control point
  2286. * @param value4 defines the fourth control point
  2287. * @param amount defines the amount on the spline to use
  2288. * @returns the new Vector3
  2289. */
  2290. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2291. /**
  2292. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @returns the new Vector3
  2299. */
  2300. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2301. /**
  2302. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2305. * @param value defines the current value
  2306. * @param min defines the lower range value
  2307. * @param max defines the upper range value
  2308. * @param result defines the Vector3 where to store the result
  2309. */
  2310. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2311. /**
  2312. * Checks if a given vector is inside a specific range
  2313. * @param v defines the vector to test
  2314. * @param min defines the minimum range
  2315. * @param max defines the maximum range
  2316. */
  2317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2320. * @param value1 defines the first control point
  2321. * @param tangent1 defines the first tangent vector
  2322. * @param value2 defines the second control point
  2323. * @param tangent2 defines the second tangent vector
  2324. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2325. * @returns the new Vector3
  2326. */
  2327. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2328. /**
  2329. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2330. * @param start defines the start value
  2331. * @param end defines the end value
  2332. * @param amount max defines amount between both (between 0 and 1)
  2333. * @returns the new Vector3
  2334. */
  2335. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2336. /**
  2337. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2338. * @param start defines the start value
  2339. * @param end defines the end value
  2340. * @param amount max defines amount between both (between 0 and 1)
  2341. * @param result defines the Vector3 where to store the result
  2342. */
  2343. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2344. /**
  2345. * Returns the dot product (float) between the vectors "left" and "right"
  2346. * @param left defines the left operand
  2347. * @param right defines the right operand
  2348. * @returns the dot product
  2349. */
  2350. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2351. /**
  2352. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2353. * The cross product is then orthogonal to both "left" and "right"
  2354. * @param left defines the left operand
  2355. * @param right defines the right operand
  2356. * @returns the cross product
  2357. */
  2358. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Sets the given vector "result" with the cross product of "left" and "right"
  2361. * The cross product is then orthogonal to both "left" and "right"
  2362. * @param left defines the left operand
  2363. * @param right defines the right operand
  2364. * @param result defines the Vector3 where to store the result
  2365. */
  2366. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2367. /**
  2368. * Returns a new Vector3 as the normalization of the given vector
  2369. * @param vector defines the Vector3 to normalize
  2370. * @returns the new Vector3
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Sets the given vector "result" with the normalization of the given first vector
  2375. * @param vector defines the Vector3 to normalize
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2379. /**
  2380. * Project a Vector3 onto screen space
  2381. * @param vector defines the Vector3 to project
  2382. * @param world defines the world matrix to use
  2383. * @param transform defines the transform (view x projection) matrix to use
  2384. * @param viewport defines the screen viewport to use
  2385. * @returns the new Vector3
  2386. */
  2387. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2388. /** @hidden */
  2389. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param transform defines the transform (view x projection) matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @returns the new Vector3
  2409. */
  2410. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param source defines the screen space Vector3 to use
  2414. * @param viewportWidth defines the current width of the viewport
  2415. * @param viewportHeight defines the current height of the viewport
  2416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2417. * @param view defines the view matrix to use
  2418. * @param projection defines the projection matrix to use
  2419. * @param result defines the Vector3 where to store the result
  2420. */
  2421. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2422. /**
  2423. * Unproject from screen space to object space
  2424. * @param sourceX defines the screen space x coordinate to use
  2425. * @param sourceY defines the screen space y coordinate to use
  2426. * @param sourceZ defines the screen space z coordinate to use
  2427. * @param viewportWidth defines the current width of the viewport
  2428. * @param viewportHeight defines the current height of the viewport
  2429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2430. * @param view defines the view matrix to use
  2431. * @param projection defines the projection matrix to use
  2432. * @param result defines the Vector3 where to store the result
  2433. */
  2434. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2435. /**
  2436. * Gets the minimal coordinate values between two Vector3
  2437. * @param left defines the first operand
  2438. * @param right defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Gets the maximal coordinate values between two Vector3
  2444. * @param left defines the first operand
  2445. * @param right defines the second operand
  2446. * @returns the new Vector3
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Returns the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines the first operand
  2452. * @param value2 defines the second operand
  2453. * @returns the distance
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines the first operand
  2459. * @param value2 defines the second operand
  2460. * @returns the squared distance
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2463. /**
  2464. * Returns a new Vector3 located at the center between "value1" and "value2"
  2465. * @param value1 defines the first operand
  2466. * @param value2 defines the second operand
  2467. * @returns the new Vector3
  2468. */
  2469. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2472. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2473. * to something in order to rotate it from its local system to the given target system
  2474. * Note: axis1, axis2 and axis3 are normalized during this operation
  2475. * @param axis1 defines the first axis
  2476. * @param axis2 defines the second axis
  2477. * @param axis3 defines the third axis
  2478. * @returns a new Vector3
  2479. */
  2480. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2481. /**
  2482. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2483. * @param axis1 defines the first axis
  2484. * @param axis2 defines the second axis
  2485. * @param axis3 defines the third axis
  2486. * @param ref defines the Vector3 where to store the result
  2487. */
  2488. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2489. }
  2490. /**
  2491. * Vector4 class created for EulerAngle class conversion to Quaternion
  2492. */
  2493. export class Vector4 {
  2494. /** x value of the vector */
  2495. x: number;
  2496. /** y value of the vector */
  2497. y: number;
  2498. /** z value of the vector */
  2499. z: number;
  2500. /** w value of the vector */
  2501. w: number;
  2502. /**
  2503. * Creates a Vector4 object from the given floats.
  2504. * @param x x value of the vector
  2505. * @param y y value of the vector
  2506. * @param z z value of the vector
  2507. * @param w w value of the vector
  2508. */
  2509. constructor(
  2510. /** x value of the vector */
  2511. x: number,
  2512. /** y value of the vector */
  2513. y: number,
  2514. /** z value of the vector */
  2515. z: number,
  2516. /** w value of the vector */
  2517. w: number);
  2518. /**
  2519. * Returns the string with the Vector4 coordinates.
  2520. * @returns a string containing all the vector values
  2521. */
  2522. toString(): string;
  2523. /**
  2524. * Returns the string "Vector4".
  2525. * @returns "Vector4"
  2526. */
  2527. getClassName(): string;
  2528. /**
  2529. * Returns the Vector4 hash code.
  2530. * @returns a unique hash code
  2531. */
  2532. getHashCode(): number;
  2533. /**
  2534. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2535. * @returns the resulting array
  2536. */
  2537. asArray(): number[];
  2538. /**
  2539. * Populates the given array from the given index with the Vector4 coordinates.
  2540. * @param array array to populate
  2541. * @param index index of the array to start at (default: 0)
  2542. * @returns the Vector4.
  2543. */
  2544. toArray(array: FloatArray, index?: number): Vector4;
  2545. /**
  2546. * Adds the given vector to the current Vector4.
  2547. * @param otherVector the vector to add
  2548. * @returns the updated Vector4.
  2549. */
  2550. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2551. /**
  2552. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2553. * @param otherVector the vector to add
  2554. * @returns the resulting vector
  2555. */
  2556. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2557. /**
  2558. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2559. * @param otherVector the vector to add
  2560. * @param result the vector to store the result
  2561. * @returns the current Vector4.
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2564. /**
  2565. * Subtract in place the given vector from the current Vector4.
  2566. * @param otherVector the vector to subtract
  2567. * @returns the updated Vector4.
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2570. /**
  2571. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2572. * @param otherVector the vector to add
  2573. * @returns the new vector with the result
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2576. /**
  2577. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @param result the vector to store the result
  2580. * @returns the current Vector4.
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2583. /**
  2584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2585. */
  2586. /**
  2587. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2588. * @param x value to subtract
  2589. * @param y value to subtract
  2590. * @param z value to subtract
  2591. * @param w value to subtract
  2592. * @returns new vector containing the result
  2593. */
  2594. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2595. /**
  2596. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. * @param x value to subtract
  2598. * @param y value to subtract
  2599. * @param z value to subtract
  2600. * @param w value to subtract
  2601. * @param result the vector to store the result in
  2602. * @returns the current Vector4.
  2603. */
  2604. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2607. * @returns a new vector with the negated values
  2608. */
  2609. negate(): Vector4;
  2610. /**
  2611. * Multiplies the current Vector4 coordinates by scale (float).
  2612. * @param scale the number to scale with
  2613. * @returns the updated Vector4.
  2614. */
  2615. scaleInPlace(scale: number): Vector4;
  2616. /**
  2617. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2618. * @param scale the number to scale with
  2619. * @returns a new vector with the result
  2620. */
  2621. scale(scale: number): Vector4;
  2622. /**
  2623. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2624. * @param scale the number to scale with
  2625. * @param result a vector to store the result in
  2626. * @returns the current Vector4.
  2627. */
  2628. scaleToRef(scale: number, result: Vector4): Vector4;
  2629. /**
  2630. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2631. * @param scale defines the scale factor
  2632. * @param result defines the Vector4 object where to store the result
  2633. * @returns the unmodified current Vector4
  2634. */
  2635. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2636. /**
  2637. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2638. * @param otherVector the vector to compare against
  2639. * @returns true if they are equal
  2640. */
  2641. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2642. /**
  2643. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2644. * @param otherVector vector to compare against
  2645. * @param epsilon (Default: very small number)
  2646. * @returns true if they are equal
  2647. */
  2648. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2649. /**
  2650. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2651. * @param x x value to compare against
  2652. * @param y y value to compare against
  2653. * @param z z value to compare against
  2654. * @param w w value to compare against
  2655. * @returns true if equal
  2656. */
  2657. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2658. /**
  2659. * Multiplies in place the current Vector4 by the given one.
  2660. * @param otherVector vector to multiple with
  2661. * @returns the updated Vector4.
  2662. */
  2663. multiplyInPlace(otherVector: Vector4): Vector4;
  2664. /**
  2665. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2666. * @param otherVector vector to multiple with
  2667. * @returns resulting new vector
  2668. */
  2669. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2670. /**
  2671. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @param result vector to store the result
  2674. * @returns the current Vector4.
  2675. */
  2676. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2677. /**
  2678. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2679. * @param x x value multiply with
  2680. * @param y y value multiply with
  2681. * @param z z value multiply with
  2682. * @param w w value multiply with
  2683. * @returns resulting new vector
  2684. */
  2685. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2686. /**
  2687. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2688. * @param otherVector vector to devide with
  2689. * @returns resulting new vector
  2690. */
  2691. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2692. /**
  2693. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2694. * @param otherVector vector to devide with
  2695. * @param result vector to store the result
  2696. * @returns the current Vector4.
  2697. */
  2698. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2699. /**
  2700. * Divides the current Vector3 coordinates by the given ones.
  2701. * @param otherVector vector to devide with
  2702. * @returns the updated Vector3.
  2703. */
  2704. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2705. /**
  2706. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2707. * @param other defines the second operand
  2708. * @returns the current updated Vector4
  2709. */
  2710. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2711. /**
  2712. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2713. * @param other defines the second operand
  2714. * @returns the current updated Vector4
  2715. */
  2716. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector4 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. floor(): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector3 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. fract(): Vector4;
  2727. /**
  2728. * Returns the Vector4 length (float).
  2729. * @returns the length
  2730. */
  2731. length(): number;
  2732. /**
  2733. * Returns the Vector4 squared length (float).
  2734. * @returns the length squared
  2735. */
  2736. lengthSquared(): number;
  2737. /**
  2738. * Normalizes in place the Vector4.
  2739. * @returns the updated Vector4.
  2740. */
  2741. normalize(): Vector4;
  2742. /**
  2743. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2744. * @returns this converted to a new vector3
  2745. */
  2746. toVector3(): Vector3;
  2747. /**
  2748. * Returns a new Vector4 copied from the current one.
  2749. * @returns the new cloned vector
  2750. */
  2751. clone(): Vector4;
  2752. /**
  2753. * Updates the current Vector4 with the given one coordinates.
  2754. * @param source the source vector to copy from
  2755. * @returns the updated Vector4.
  2756. */
  2757. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2758. /**
  2759. * Updates the current Vector4 coordinates with the given floats.
  2760. * @param x float to copy from
  2761. * @param y float to copy from
  2762. * @param z float to copy from
  2763. * @param w float to copy from
  2764. * @returns the updated Vector4.
  2765. */
  2766. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2767. /**
  2768. * Updates the current Vector4 coordinates with the given floats.
  2769. * @param x float to set from
  2770. * @param y float to set from
  2771. * @param z float to set from
  2772. * @param w float to set from
  2773. * @returns the updated Vector4.
  2774. */
  2775. set(x: number, y: number, z: number, w: number): Vector4;
  2776. /**
  2777. * Copies the given float to the current Vector3 coordinates
  2778. * @param v defines the x, y, z and w coordinates of the operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. setAll(v: number): Vector4;
  2782. /**
  2783. * Returns a new Vector4 set from the starting index of the given array.
  2784. * @param array the array to pull values from
  2785. * @param offset the offset into the array to start at
  2786. * @returns the new vector
  2787. */
  2788. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2789. /**
  2790. * Updates the given vector "result" from the starting index of the given array.
  2791. * @param array the array to pull values from
  2792. * @param offset the offset into the array to start at
  2793. * @param result the vector to store the result in
  2794. */
  2795. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2796. /**
  2797. * Updates the given vector "result" from the starting index of the given Float32Array.
  2798. * @param array the array to pull values from
  2799. * @param offset the offset into the array to start at
  2800. * @param result the vector to store the result in
  2801. */
  2802. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2803. /**
  2804. * Updates the given vector "result" coordinates from the given floats.
  2805. * @param x float to set from
  2806. * @param y float to set from
  2807. * @param z float to set from
  2808. * @param w float to set from
  2809. * @param result the vector to the floats in
  2810. */
  2811. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2812. /**
  2813. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2814. * @returns the new vector
  2815. */
  2816. static Zero(): Vector4;
  2817. /**
  2818. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2819. * @returns the new vector
  2820. */
  2821. static One(): Vector4;
  2822. /**
  2823. * Returns a new normalized Vector4 from the given one.
  2824. * @param vector the vector to normalize
  2825. * @returns the vector
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2828. /**
  2829. * Updates the given vector "result" from the normalization of the given one.
  2830. * @param vector the vector to normalize
  2831. * @param result the vector to store the result in
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2834. /**
  2835. * Returns a vector with the minimum values from the left and right vectors
  2836. * @param left left vector to minimize
  2837. * @param right right vector to minimize
  2838. * @returns a new vector with the minimum of the left and right vector values
  2839. */
  2840. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2841. /**
  2842. * Returns a vector with the maximum values from the left and right vectors
  2843. * @param left left vector to maximize
  2844. * @param right right vector to maximize
  2845. * @returns a new vector with the maximum of the left and right vector values
  2846. */
  2847. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2848. /**
  2849. * Returns the distance (float) between the vectors "value1" and "value2".
  2850. * @param value1 value to calulate the distance between
  2851. * @param value2 value to calulate the distance between
  2852. * @return the distance between the two vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2855. /**
  2856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2857. * @param value1 value to calulate the distance between
  2858. * @param value2 value to calulate the distance between
  2859. * @return the distance between the two vectors squared
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2862. /**
  2863. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2864. * @param value1 value to calulate the center between
  2865. * @param value2 value to calulate the center between
  2866. * @return the center between the two vectors
  2867. */
  2868. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2869. /**
  2870. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param vector the vector to transform
  2873. * @param transformation the transformation matrix to apply
  2874. * @returns the new vector
  2875. */
  2876. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2877. /**
  2878. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2879. * This methods computes transformed normalized direction vectors only.
  2880. * @param vector the vector to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the result in
  2883. */
  2884. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2887. * This methods computes transformed normalized direction vectors only.
  2888. * @param x value to transform
  2889. * @param y value to transform
  2890. * @param z value to transform
  2891. * @param w value to transform
  2892. * @param transformation the transformation matrix to apply
  2893. * @param result the vector to store the results in
  2894. */
  2895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2896. /**
  2897. * Creates a new Vector4 from a Vector3
  2898. * @param source defines the source data
  2899. * @param w defines the 4th component (default is 0)
  2900. * @returns a new Vector4
  2901. */
  2902. static FromVector3(source: Vector3, w?: number): Vector4;
  2903. }
  2904. /**
  2905. * Class used to store quaternion data
  2906. * @see https://en.wikipedia.org/wiki/Quaternion
  2907. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2908. */
  2909. export class Quaternion {
  2910. /** defines the first component (0 by default) */
  2911. x: number;
  2912. /** defines the second component (0 by default) */
  2913. y: number;
  2914. /** defines the third component (0 by default) */
  2915. z: number;
  2916. /** defines the fourth component (1.0 by default) */
  2917. w: number;
  2918. /**
  2919. * Creates a new Quaternion from the given floats
  2920. * @param x defines the first component (0 by default)
  2921. * @param y defines the second component (0 by default)
  2922. * @param z defines the third component (0 by default)
  2923. * @param w defines the fourth component (1.0 by default)
  2924. */
  2925. constructor(
  2926. /** defines the first component (0 by default) */
  2927. x?: number,
  2928. /** defines the second component (0 by default) */
  2929. y?: number,
  2930. /** defines the third component (0 by default) */
  2931. z?: number,
  2932. /** defines the fourth component (1.0 by default) */
  2933. w?: number);
  2934. /**
  2935. * Gets a string representation for the current quaternion
  2936. * @returns a string with the Quaternion coordinates
  2937. */
  2938. toString(): string;
  2939. /**
  2940. * Gets the class name of the quaternion
  2941. * @returns the string "Quaternion"
  2942. */
  2943. getClassName(): string;
  2944. /**
  2945. * Gets a hash code for this quaternion
  2946. * @returns the quaternion hash code
  2947. */
  2948. getHashCode(): number;
  2949. /**
  2950. * Copy the quaternion to an array
  2951. * @returns a new array populated with 4 elements from the quaternion coordinates
  2952. */
  2953. asArray(): number[];
  2954. /**
  2955. * Check if two quaternions are equals
  2956. * @param otherQuaternion defines the second operand
  2957. * @return true if the current quaternion and the given one coordinates are strictly equals
  2958. */
  2959. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2960. /**
  2961. * Clone the current quaternion
  2962. * @returns a new quaternion copied from the current one
  2963. */
  2964. clone(): Quaternion;
  2965. /**
  2966. * Copy a quaternion to the current one
  2967. * @param other defines the other quaternion
  2968. * @returns the updated current quaternion
  2969. */
  2970. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2971. /**
  2972. * Updates the current quaternion with the given float coordinates
  2973. * @param x defines the x coordinate
  2974. * @param y defines the y coordinate
  2975. * @param z defines the z coordinate
  2976. * @param w defines the w coordinate
  2977. * @returns the updated current quaternion
  2978. */
  2979. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2980. /**
  2981. * Updates the current quaternion from the given float coordinates
  2982. * @param x defines the x coordinate
  2983. * @param y defines the y coordinate
  2984. * @param z defines the z coordinate
  2985. * @param w defines the w coordinate
  2986. * @returns the updated current quaternion
  2987. */
  2988. set(x: number, y: number, z: number, w: number): Quaternion;
  2989. /**
  2990. * Adds two quaternions
  2991. * @param other defines the second operand
  2992. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2993. */
  2994. add(other: DeepImmutable<Quaternion>): Quaternion;
  2995. /**
  2996. * Add a quaternion to the current one
  2997. * @param other defines the quaternion to add
  2998. * @returns the current quaternion
  2999. */
  3000. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3001. /**
  3002. * Subtract two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the subtraction result of the given one from the current one
  3005. */
  3006. subtract(other: Quaternion): Quaternion;
  3007. /**
  3008. * Multiplies the current quaternion by a scale factor
  3009. * @param value defines the scale factor
  3010. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3011. */
  3012. scale(value: number): Quaternion;
  3013. /**
  3014. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3015. * @param scale defines the scale factor
  3016. * @param result defines the Quaternion object where to store the result
  3017. * @returns the unmodified current quaternion
  3018. */
  3019. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3020. /**
  3021. * Multiplies in place the current quaternion by a scale factor
  3022. * @param value defines the scale factor
  3023. * @returns the current modified quaternion
  3024. */
  3025. scaleInPlace(value: number): Quaternion;
  3026. /**
  3027. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3028. * @param scale defines the scale factor
  3029. * @param result defines the Quaternion object where to store the result
  3030. * @returns the unmodified current quaternion
  3031. */
  3032. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3033. /**
  3034. * Multiplies two quaternions
  3035. * @param q1 defines the second operand
  3036. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3037. */
  3038. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3039. /**
  3040. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3041. * @param q1 defines the second operand
  3042. * @param result defines the target quaternion
  3043. * @returns the current quaternion
  3044. */
  3045. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3046. /**
  3047. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3048. * @param q1 defines the second operand
  3049. * @returns the currentupdated quaternion
  3050. */
  3051. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3052. /**
  3053. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3054. * @param ref defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. conjugateToRef(ref: Quaternion): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns the current updated quaternion
  3061. */
  3062. conjugateInPlace(): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns a new quaternion
  3066. */
  3067. conjugate(): Quaternion;
  3068. /**
  3069. * Gets length of current quaternion
  3070. * @returns the quaternion length (float)
  3071. */
  3072. length(): number;
  3073. /**
  3074. * Normalize in place the current quaternion
  3075. * @returns the current updated quaternion
  3076. */
  3077. normalize(): Quaternion;
  3078. /**
  3079. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3080. * @param order is a reserved parameter and is ignore for now
  3081. * @returns a new Vector3 containing the Euler angles
  3082. */
  3083. toEulerAngles(order?: string): Vector3;
  3084. /**
  3085. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3086. * @param result defines the vector which will be filled with the Euler angles
  3087. * @param order is a reserved parameter and is ignore for now
  3088. * @returns the current unchanged quaternion
  3089. */
  3090. toEulerAnglesToRef(result: Vector3): Quaternion;
  3091. /**
  3092. * Updates the given rotation matrix with the current quaternion values
  3093. * @param result defines the target matrix
  3094. * @returns the current unchanged quaternion
  3095. */
  3096. toRotationMatrix(result: Matrix): Quaternion;
  3097. /**
  3098. * Updates the current quaternion from the given rotation matrix values
  3099. * @param matrix defines the source matrix
  3100. * @returns the current updated quaternion
  3101. */
  3102. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3103. /**
  3104. * Creates a new quaternion from a rotation matrix
  3105. * @param matrix defines the source matrix
  3106. * @returns a new quaternion created from the given rotation matrix values
  3107. */
  3108. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3109. /**
  3110. * Updates the given quaternion with the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @param result defines the target quaternion
  3113. */
  3114. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3115. /**
  3116. * Returns the dot product (float) between the quaternions "left" and "right"
  3117. * @param left defines the left operand
  3118. * @param right defines the right operand
  3119. * @returns the dot product
  3120. */
  3121. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3122. /**
  3123. * Checks if the two quaternions are close to each other
  3124. * @param quat0 defines the first quaternion to check
  3125. * @param quat1 defines the second quaternion to check
  3126. * @returns true if the two quaternions are close to each other
  3127. */
  3128. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3129. /**
  3130. * Creates an empty quaternion
  3131. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3132. */
  3133. static Zero(): Quaternion;
  3134. /**
  3135. * Inverse a given quaternion
  3136. * @param q defines the source quaternion
  3137. * @returns a new quaternion as the inverted current quaternion
  3138. */
  3139. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3140. /**
  3141. * Inverse a given quaternion
  3142. * @param q defines the source quaternion
  3143. * @param result the quaternion the result will be stored in
  3144. * @returns the result quaternion
  3145. */
  3146. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3147. /**
  3148. * Creates an identity quaternion
  3149. * @returns the identity quaternion
  3150. */
  3151. static Identity(): Quaternion;
  3152. /**
  3153. * Gets a boolean indicating if the given quaternion is identity
  3154. * @param quaternion defines the quaternion to check
  3155. * @returns true if the quaternion is identity
  3156. */
  3157. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3158. /**
  3159. * Creates a quaternion from a rotation around an axis
  3160. * @param axis defines the axis to use
  3161. * @param angle defines the angle to use
  3162. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3163. */
  3164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3165. /**
  3166. * Creates a rotation around an axis and stores it into the given quaternion
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle to use
  3169. * @param result defines the target quaternion
  3170. * @returns the target quaternion
  3171. */
  3172. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3173. /**
  3174. * Creates a new quaternion from data stored into an array
  3175. * @param array defines the data source
  3176. * @param offset defines the offset in the source array where the data starts
  3177. * @returns a new quaternion
  3178. */
  3179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3180. /**
  3181. * Create a quaternion from Euler rotation angles
  3182. * @param x Pitch
  3183. * @param y Yaw
  3184. * @param z Roll
  3185. * @returns the new Quaternion
  3186. */
  3187. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3188. /**
  3189. * Updates a quaternion from Euler rotation angles
  3190. * @param x Pitch
  3191. * @param y Yaw
  3192. * @param z Roll
  3193. * @param result the quaternion to store the result
  3194. * @returns the updated quaternion
  3195. */
  3196. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3197. /**
  3198. * Create a quaternion from Euler rotation vector
  3199. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3200. * @returns the new Quaternion
  3201. */
  3202. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3203. /**
  3204. * Updates a quaternion from Euler rotation vector
  3205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3206. * @param result the quaternion to store the result
  3207. * @returns the updated quaternion
  3208. */
  3209. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3212. * @param yaw defines the rotation around Y axis
  3213. * @param pitch defines the rotation around X axis
  3214. * @param roll defines the rotation around Z axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3218. /**
  3219. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3220. * @param yaw defines the rotation around Y axis
  3221. * @param pitch defines the rotation around X axis
  3222. * @param roll defines the rotation around Z axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3228. * @param alpha defines the rotation around first axis
  3229. * @param beta defines the rotation around second axis
  3230. * @param gamma defines the rotation around third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3234. /**
  3235. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3236. * @param alpha defines the rotation around first axis
  3237. * @param beta defines the rotation around second axis
  3238. * @param gamma defines the rotation around third axis
  3239. * @param result defines the target quaternion
  3240. */
  3241. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3242. /**
  3243. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3244. * @param axis1 defines the first axis
  3245. * @param axis2 defines the second axis
  3246. * @param axis3 defines the third axis
  3247. * @returns the new quaternion
  3248. */
  3249. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3250. /**
  3251. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3252. * @param axis1 defines the first axis
  3253. * @param axis2 defines the second axis
  3254. * @param axis3 defines the third axis
  3255. * @param ref defines the target quaternion
  3256. */
  3257. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3258. /**
  3259. * Interpolates between two quaternions
  3260. * @param left defines first quaternion
  3261. * @param right defines second quaternion
  3262. * @param amount defines the gradient to use
  3263. * @returns the new interpolated quaternion
  3264. */
  3265. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3266. /**
  3267. * Interpolates between two quaternions and stores it into a target quaternion
  3268. * @param left defines first quaternion
  3269. * @param right defines second quaternion
  3270. * @param amount defines the gradient to use
  3271. * @param result defines the target quaternion
  3272. */
  3273. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3274. /**
  3275. * Interpolate between two quaternions using Hermite interpolation
  3276. * @param value1 defines first quaternion
  3277. * @param tangent1 defines the incoming tangent
  3278. * @param value2 defines second quaternion
  3279. * @param tangent2 defines the outgoing tangent
  3280. * @param amount defines the target quaternion
  3281. * @returns the new interpolated quaternion
  3282. */
  3283. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3284. }
  3285. /**
  3286. * Class used to store matrix data (4x4)
  3287. */
  3288. export class Matrix {
  3289. private static _updateFlagSeed;
  3290. private static _identityReadOnly;
  3291. private _isIdentity;
  3292. private _isIdentityDirty;
  3293. private _isIdentity3x2;
  3294. private _isIdentity3x2Dirty;
  3295. /**
  3296. * Gets the update flag of the matrix which is an unique number for the matrix.
  3297. * It will be incremented every time the matrix data change.
  3298. * You can use it to speed the comparison between two versions of the same matrix.
  3299. */
  3300. updateFlag: number;
  3301. private readonly _m;
  3302. /**
  3303. * Gets the internal data of the matrix
  3304. */
  3305. readonly m: DeepImmutable<Float32Array>;
  3306. /** @hidden */
  3307. _markAsUpdated(): void;
  3308. /** @hidden */
  3309. private _updateIdentityStatus;
  3310. /**
  3311. * Creates an empty matrix (filled with zeros)
  3312. */
  3313. constructor();
  3314. /**
  3315. * Check if the current matrix is identity
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentity(): boolean;
  3319. /**
  3320. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentityAs3x2(): boolean;
  3324. /**
  3325. * Gets the determinant of the matrix
  3326. * @returns the matrix determinant
  3327. */
  3328. determinant(): number;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array
  3332. */
  3333. toArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array.
  3337. */
  3338. asArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Inverts the current matrix in place
  3341. * @returns the current inverted matrix
  3342. */
  3343. invert(): Matrix;
  3344. /**
  3345. * Sets all the matrix elements to zero
  3346. * @returns the current matrix
  3347. */
  3348. reset(): Matrix;
  3349. /**
  3350. * Adds the current matrix with a second one
  3351. * @param other defines the matrix to add
  3352. * @returns a new matrix as the addition of the current matrix and the given one
  3353. */
  3354. add(other: DeepImmutable<Matrix>): Matrix;
  3355. /**
  3356. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3357. * @param other defines the matrix to add
  3358. * @param result defines the target matrix
  3359. * @returns the current matrix
  3360. */
  3361. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3362. /**
  3363. * Adds in place the given matrix to the current matrix
  3364. * @param other defines the second operand
  3365. * @returns the current updated matrix
  3366. */
  3367. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3368. /**
  3369. * Sets the given matrix to the current inverted Matrix
  3370. * @param other defines the target matrix
  3371. * @returns the unmodified current matrix
  3372. */
  3373. invertToRef(other: Matrix): Matrix;
  3374. /**
  3375. * add a value at the specified position in the current Matrix
  3376. * @param index the index of the value within the matrix. between 0 and 15.
  3377. * @param value the value to be added
  3378. * @returns the current updated matrix
  3379. */
  3380. addAtIndex(index: number, value: number): Matrix;
  3381. /**
  3382. * mutiply the specified position in the current Matrix by a value
  3383. * @param index the index of the value within the matrix. between 0 and 15.
  3384. * @param value the value to be added
  3385. * @returns the current updated matrix
  3386. */
  3387. multiplyAtIndex(index: number, value: number): Matrix;
  3388. /**
  3389. * Inserts the translation vector (using 3 floats) in the current matrix
  3390. * @param x defines the 1st component of the translation
  3391. * @param y defines the 2nd component of the translation
  3392. * @param z defines the 3rd component of the translation
  3393. * @returns the current updated matrix
  3394. */
  3395. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3396. /**
  3397. * Adds the translation vector (using 3 floats) in the current matrix
  3398. * @param x defines the 1st component of the translation
  3399. * @param y defines the 2nd component of the translation
  3400. * @param z defines the 3rd component of the translation
  3401. * @returns the current updated matrix
  3402. */
  3403. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3404. /**
  3405. * Inserts the translation vector in the current matrix
  3406. * @param vector3 defines the translation to insert
  3407. * @returns the current updated matrix
  3408. */
  3409. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3410. /**
  3411. * Gets the translation value of the current matrix
  3412. * @returns a new Vector3 as the extracted translation from the matrix
  3413. */
  3414. getTranslation(): Vector3;
  3415. /**
  3416. * Fill a Vector3 with the extracted translation from the matrix
  3417. * @param result defines the Vector3 where to store the translation
  3418. * @returns the current matrix
  3419. */
  3420. getTranslationToRef(result: Vector3): Matrix;
  3421. /**
  3422. * Remove rotation and scaling part from the matrix
  3423. * @returns the updated matrix
  3424. */
  3425. removeRotationAndScaling(): Matrix;
  3426. /**
  3427. * Multiply two matrices
  3428. * @param other defines the second operand
  3429. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3430. */
  3431. multiply(other: DeepImmutable<Matrix>): Matrix;
  3432. /**
  3433. * Copy the current matrix from the given one
  3434. * @param other defines the source matrix
  3435. * @returns the current updated matrix
  3436. */
  3437. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3438. /**
  3439. * Populates the given array from the starting index with the current matrix values
  3440. * @param array defines the target array
  3441. * @param offset defines the offset in the target array where to start storing values
  3442. * @returns the current matrix
  3443. */
  3444. copyToArray(array: Float32Array, offset?: number): Matrix;
  3445. /**
  3446. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3447. * @param other defines the second operand
  3448. * @param result defines the matrix where to store the multiplication
  3449. * @returns the current matrix
  3450. */
  3451. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3452. /**
  3453. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3454. * @param other defines the second operand
  3455. * @param result defines the array where to store the multiplication
  3456. * @param offset defines the offset in the target array where to start storing values
  3457. * @returns the current matrix
  3458. */
  3459. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3460. /**
  3461. * Check equality between this matrix and a second one
  3462. * @param value defines the second matrix to compare
  3463. * @returns true is the current matrix and the given one values are strictly equal
  3464. */
  3465. equals(value: DeepImmutable<Matrix>): boolean;
  3466. /**
  3467. * Clone the current matrix
  3468. * @returns a new matrix from the current matrix
  3469. */
  3470. clone(): Matrix;
  3471. /**
  3472. * Returns the name of the current matrix class
  3473. * @returns the string "Matrix"
  3474. */
  3475. getClassName(): string;
  3476. /**
  3477. * Gets the hash code of the current matrix
  3478. * @returns the hash code
  3479. */
  3480. getHashCode(): number;
  3481. /**
  3482. * Decomposes the current Matrix into a translation, rotation and scaling components
  3483. * @param scale defines the scale vector3 given as a reference to update
  3484. * @param rotation defines the rotation quaternion given as a reference to update
  3485. * @param translation defines the translation vector3 given as a reference to update
  3486. * @returns true if operation was successful
  3487. */
  3488. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3489. /**
  3490. * Gets specific row of the matrix
  3491. * @param index defines the number of the row to get
  3492. * @returns the index-th row of the current matrix as a new Vector4
  3493. */
  3494. getRow(index: number): Nullable<Vector4>;
  3495. /**
  3496. * Sets the index-th row of the current matrix to the vector4 values
  3497. * @param index defines the number of the row to set
  3498. * @param row defines the target vector4
  3499. * @returns the updated current matrix
  3500. */
  3501. setRow(index: number, row: Vector4): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix
  3504. * @returns the new transposed matrix
  3505. */
  3506. transpose(): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix and store it in a given matrix
  3509. * @param result defines the target matrix
  3510. * @returns the current matrix
  3511. */
  3512. transposeToRef(result: Matrix): Matrix;
  3513. /**
  3514. * Sets the index-th row of the current matrix with the given 4 x float values
  3515. * @param index defines the row index
  3516. * @param x defines the x component to set
  3517. * @param y defines the y component to set
  3518. * @param z defines the z component to set
  3519. * @param w defines the w component to set
  3520. * @returns the updated current matrix
  3521. */
  3522. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3523. /**
  3524. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3525. * @param scale defines the scale factor
  3526. * @returns a new matrix
  3527. */
  3528. scale(scale: number): Matrix;
  3529. /**
  3530. * Scale the current matrix values by a factor to a given result matrix
  3531. * @param scale defines the scale factor
  3532. * @param result defines the matrix to store the result
  3533. * @returns the current matrix
  3534. */
  3535. scaleToRef(scale: number, result: Matrix): Matrix;
  3536. /**
  3537. * Scale the current matrix values by a factor and add the result to a given matrix
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Matrix to store the result
  3540. * @returns the current matrix
  3541. */
  3542. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3543. /**
  3544. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3545. * @param ref matrix to store the result
  3546. */
  3547. toNormalMatrix(ref: Matrix): void;
  3548. /**
  3549. * Gets only rotation part of the current matrix
  3550. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3551. */
  3552. getRotationMatrix(): Matrix;
  3553. /**
  3554. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3555. * @param result defines the target matrix to store data to
  3556. * @returns the current matrix
  3557. */
  3558. getRotationMatrixToRef(result: Matrix): Matrix;
  3559. /**
  3560. * Toggles model matrix from being right handed to left handed in place and vice versa
  3561. */
  3562. toggleModelMatrixHandInPlace(): void;
  3563. /**
  3564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3565. */
  3566. toggleProjectionMatrixHandInPlace(): void;
  3567. /**
  3568. * Creates a matrix from an array
  3569. * @param array defines the source array
  3570. * @param offset defines an offset in the source array
  3571. * @returns a new Matrix set from the starting index of the given array
  3572. */
  3573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3574. /**
  3575. * Copy the content of an array into a given matrix
  3576. * @param array defines the source array
  3577. * @param offset defines an offset in the source array
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3581. /**
  3582. * Stores an array into a matrix after having multiplied each component by a given factor
  3583. * @param array defines the source array
  3584. * @param offset defines the offset in the source array
  3585. * @param scale defines the scaling factor
  3586. * @param result defines the target matrix
  3587. */
  3588. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3589. /**
  3590. * Gets an identity matrix that must not be updated
  3591. */
  3592. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3593. /**
  3594. * Stores a list of values (16) inside a given matrix
  3595. * @param initialM11 defines 1st value of 1st row
  3596. * @param initialM12 defines 2nd value of 1st row
  3597. * @param initialM13 defines 3rd value of 1st row
  3598. * @param initialM14 defines 4th value of 1st row
  3599. * @param initialM21 defines 1st value of 2nd row
  3600. * @param initialM22 defines 2nd value of 2nd row
  3601. * @param initialM23 defines 3rd value of 2nd row
  3602. * @param initialM24 defines 4th value of 2nd row
  3603. * @param initialM31 defines 1st value of 3rd row
  3604. * @param initialM32 defines 2nd value of 3rd row
  3605. * @param initialM33 defines 3rd value of 3rd row
  3606. * @param initialM34 defines 4th value of 3rd row
  3607. * @param initialM41 defines 1st value of 4th row
  3608. * @param initialM42 defines 2nd value of 4th row
  3609. * @param initialM43 defines 3rd value of 4th row
  3610. * @param initialM44 defines 4th value of 4th row
  3611. * @param result defines the target matrix
  3612. */
  3613. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3614. /**
  3615. * Creates new matrix from a list of values (16)
  3616. * @param initialM11 defines 1st value of 1st row
  3617. * @param initialM12 defines 2nd value of 1st row
  3618. * @param initialM13 defines 3rd value of 1st row
  3619. * @param initialM14 defines 4th value of 1st row
  3620. * @param initialM21 defines 1st value of 2nd row
  3621. * @param initialM22 defines 2nd value of 2nd row
  3622. * @param initialM23 defines 3rd value of 2nd row
  3623. * @param initialM24 defines 4th value of 2nd row
  3624. * @param initialM31 defines 1st value of 3rd row
  3625. * @param initialM32 defines 2nd value of 3rd row
  3626. * @param initialM33 defines 3rd value of 3rd row
  3627. * @param initialM34 defines 4th value of 3rd row
  3628. * @param initialM41 defines 1st value of 4th row
  3629. * @param initialM42 defines 2nd value of 4th row
  3630. * @param initialM43 defines 3rd value of 4th row
  3631. * @param initialM44 defines 4th value of 4th row
  3632. * @returns the new matrix
  3633. */
  3634. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3635. /**
  3636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3637. * @param scale defines the scale vector3
  3638. * @param rotation defines the rotation quaternion
  3639. * @param translation defines the translation vector3
  3640. * @returns a new matrix
  3641. */
  3642. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3643. /**
  3644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3645. * @param scale defines the scale vector3
  3646. * @param rotation defines the rotation quaternion
  3647. * @param translation defines the translation vector3
  3648. * @param result defines the target matrix
  3649. */
  3650. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3651. /**
  3652. * Creates a new identity matrix
  3653. * @returns a new identity matrix
  3654. */
  3655. static Identity(): Matrix;
  3656. /**
  3657. * Creates a new identity matrix and stores the result in a given matrix
  3658. * @param result defines the target matrix
  3659. */
  3660. static IdentityToRef(result: Matrix): void;
  3661. /**
  3662. * Creates a new zero matrix
  3663. * @returns a new zero matrix
  3664. */
  3665. static Zero(): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis
  3668. * @param angle defines the angle (in radians) to use
  3669. * @return the new matrix
  3670. */
  3671. static RotationX(angle: number): Matrix;
  3672. /**
  3673. * Creates a new matrix as the invert of a given matrix
  3674. * @param source defines the source matrix
  3675. * @returns the new matrix
  3676. */
  3677. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationXToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Y axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationY(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationYToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Z axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationZ(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationZToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the given axis
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle (in radians) to use
  3712. * @return the new matrix
  3713. */
  3714. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3715. /**
  3716. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3717. * @param axis defines the axis to use
  3718. * @param angle defines the angle (in radians) to use
  3719. * @param result defines the target matrix
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3722. /**
  3723. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3724. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3725. * @param from defines the vector to align
  3726. * @param to defines the vector to align to
  3727. * @param result defines the target matrix
  3728. */
  3729. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3730. /**
  3731. * Creates a rotation matrix
  3732. * @param yaw defines the yaw angle in radians (Y axis)
  3733. * @param pitch defines the pitch angle in radians (X axis)
  3734. * @param roll defines the roll angle in radians (X axis)
  3735. * @returns the new rotation matrix
  3736. */
  3737. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3738. /**
  3739. * Creates a rotation matrix and stores it in a given matrix
  3740. * @param yaw defines the yaw angle in radians (Y axis)
  3741. * @param pitch defines the pitch angle in radians (X axis)
  3742. * @param roll defines the roll angle in radians (X axis)
  3743. * @param result defines the target matrix
  3744. */
  3745. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3746. /**
  3747. * Creates a scaling matrix
  3748. * @param x defines the scale factor on X axis
  3749. * @param y defines the scale factor on Y axis
  3750. * @param z defines the scale factor on Z axis
  3751. * @returns the new matrix
  3752. */
  3753. static Scaling(x: number, y: number, z: number): Matrix;
  3754. /**
  3755. * Creates a scaling matrix and stores it in a given matrix
  3756. * @param x defines the scale factor on X axis
  3757. * @param y defines the scale factor on Y axis
  3758. * @param z defines the scale factor on Z axis
  3759. * @param result defines the target matrix
  3760. */
  3761. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3762. /**
  3763. * Creates a translation matrix
  3764. * @param x defines the translation on X axis
  3765. * @param y defines the translation on Y axis
  3766. * @param z defines the translationon Z axis
  3767. * @returns the new matrix
  3768. */
  3769. static Translation(x: number, y: number, z: number): Matrix;
  3770. /**
  3771. * Creates a translation matrix and stores it in a given matrix
  3772. * @param x defines the translation on X axis
  3773. * @param y defines the translation on Y axis
  3774. * @param z defines the translationon Z axis
  3775. * @param result defines the target matrix
  3776. */
  3777. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3778. /**
  3779. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3780. * @param startValue defines the start value
  3781. * @param endValue defines the end value
  3782. * @param gradient defines the gradient factor
  3783. * @returns the new matrix
  3784. */
  3785. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3786. /**
  3787. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3788. * @param startValue defines the start value
  3789. * @param endValue defines the end value
  3790. * @param gradient defines the gradient factor
  3791. * @param result defines the Matrix object where to store data
  3792. */
  3793. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3794. /**
  3795. * Builds a new matrix whose values are computed by:
  3796. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3797. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3798. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3799. * @param startValue defines the first matrix
  3800. * @param endValue defines the second matrix
  3801. * @param gradient defines the gradient between the two matrices
  3802. * @returns the new matrix
  3803. */
  3804. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3805. /**
  3806. * Update a matrix to values which are computed by:
  3807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3810. * @param startValue defines the first matrix
  3811. * @param endValue defines the second matrix
  3812. * @param gradient defines the gradient between the two matrices
  3813. * @param result defines the target matrix
  3814. */
  3815. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3816. /**
  3817. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3818. * This function works in left handed mode
  3819. * @param eye defines the final position of the entity
  3820. * @param target defines where the entity should look at
  3821. * @param up defines the up vector for the entity
  3822. * @returns the new matrix
  3823. */
  3824. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3825. /**
  3826. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3827. * This function works in left handed mode
  3828. * @param eye defines the final position of the entity
  3829. * @param target defines where the entity should look at
  3830. * @param up defines the up vector for the entity
  3831. * @param result defines the target matrix
  3832. */
  3833. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3834. /**
  3835. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3836. * This function works in right handed mode
  3837. * @param eye defines the final position of the entity
  3838. * @param target defines where the entity should look at
  3839. * @param up defines the up vector for the entity
  3840. * @returns the new matrix
  3841. */
  3842. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3843. /**
  3844. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3845. * This function works in right handed mode
  3846. * @param eye defines the final position of the entity
  3847. * @param target defines where the entity should look at
  3848. * @param up defines the up vector for the entity
  3849. * @param result defines the target matrix
  3850. */
  3851. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3852. /**
  3853. * Create a left-handed orthographic projection matrix
  3854. * @param width defines the viewport width
  3855. * @param height defines the viewport height
  3856. * @param znear defines the near clip plane
  3857. * @param zfar defines the far clip plane
  3858. * @returns a new matrix as a left-handed orthographic projection matrix
  3859. */
  3860. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3861. /**
  3862. * Store a left-handed orthographic projection to a given matrix
  3863. * @param width defines the viewport width
  3864. * @param height defines the viewport height
  3865. * @param znear defines the near clip plane
  3866. * @param zfar defines the far clip plane
  3867. * @param result defines the target matrix
  3868. */
  3869. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3870. /**
  3871. * Create a left-handed orthographic projection matrix
  3872. * @param left defines the viewport left coordinate
  3873. * @param right defines the viewport right coordinate
  3874. * @param bottom defines the viewport bottom coordinate
  3875. * @param top defines the viewport top coordinate
  3876. * @param znear defines the near clip plane
  3877. * @param zfar defines the far clip plane
  3878. * @returns a new matrix as a left-handed orthographic projection matrix
  3879. */
  3880. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3881. /**
  3882. * Stores a left-handed orthographic projection into a given matrix
  3883. * @param left defines the viewport left coordinate
  3884. * @param right defines the viewport right coordinate
  3885. * @param bottom defines the viewport bottom coordinate
  3886. * @param top defines the viewport top coordinate
  3887. * @param znear defines the near clip plane
  3888. * @param zfar defines the far clip plane
  3889. * @param result defines the target matrix
  3890. */
  3891. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3892. /**
  3893. * Creates a right-handed orthographic projection matrix
  3894. * @param left defines the viewport left coordinate
  3895. * @param right defines the viewport right coordinate
  3896. * @param bottom defines the viewport bottom coordinate
  3897. * @param top defines the viewport top coordinate
  3898. * @param znear defines the near clip plane
  3899. * @param zfar defines the far clip plane
  3900. * @returns a new matrix as a right-handed orthographic projection matrix
  3901. */
  3902. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3903. /**
  3904. * Stores a right-handed orthographic projection into a given matrix
  3905. * @param left defines the viewport left coordinate
  3906. * @param right defines the viewport right coordinate
  3907. * @param bottom defines the viewport bottom coordinate
  3908. * @param top defines the viewport top coordinate
  3909. * @param znear defines the near clip plane
  3910. * @param zfar defines the far clip plane
  3911. * @param result defines the target matrix
  3912. */
  3913. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3914. /**
  3915. * Creates a left-handed perspective projection matrix
  3916. * @param width defines the viewport width
  3917. * @param height defines the viewport height
  3918. * @param znear defines the near clip plane
  3919. * @param zfar defines the far clip plane
  3920. * @returns a new matrix as a left-handed perspective projection matrix
  3921. */
  3922. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3923. /**
  3924. * Creates a left-handed perspective projection matrix
  3925. * @param fov defines the horizontal field of view
  3926. * @param aspect defines the aspect ratio
  3927. * @param znear defines the near clip plane
  3928. * @param zfar defines the far clip plane
  3929. * @returns a new matrix as a left-handed perspective projection matrix
  3930. */
  3931. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3932. /**
  3933. * Stores a left-handed perspective projection into a given matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @param result defines the target matrix
  3939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3940. */
  3941. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3942. /**
  3943. * Creates a right-handed perspective projection matrix
  3944. * @param fov defines the horizontal field of view
  3945. * @param aspect defines the aspect ratio
  3946. * @param znear defines the near clip plane
  3947. * @param zfar defines the far clip plane
  3948. * @returns a new matrix as a right-handed perspective projection matrix
  3949. */
  3950. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3951. /**
  3952. * Stores a right-handed perspective projection into a given matrix
  3953. * @param fov defines the horizontal field of view
  3954. * @param aspect defines the aspect ratio
  3955. * @param znear defines the near clip plane
  3956. * @param zfar defines the far clip plane
  3957. * @param result defines the target matrix
  3958. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3959. */
  3960. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3961. /**
  3962. * Stores a perspective projection for WebVR info a given matrix
  3963. * @param fov defines the field of view
  3964. * @param znear defines the near clip plane
  3965. * @param zfar defines the far clip plane
  3966. * @param result defines the target matrix
  3967. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3968. */
  3969. static PerspectiveFovWebVRToRef(fov: {
  3970. upDegrees: number;
  3971. downDegrees: number;
  3972. leftDegrees: number;
  3973. rightDegrees: number;
  3974. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3975. /**
  3976. * Computes a complete transformation matrix
  3977. * @param viewport defines the viewport to use
  3978. * @param world defines the world matrix
  3979. * @param view defines the view matrix
  3980. * @param projection defines the projection matrix
  3981. * @param zmin defines the near clip plane
  3982. * @param zmax defines the far clip plane
  3983. * @returns the transformation matrix
  3984. */
  3985. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3986. /**
  3987. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3988. * @param matrix defines the matrix to use
  3989. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3990. */
  3991. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3992. /**
  3993. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3994. * @param matrix defines the matrix to use
  3995. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3996. */
  3997. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3998. /**
  3999. * Compute the transpose of a given matrix
  4000. * @param matrix defines the matrix to transpose
  4001. * @returns the new matrix
  4002. */
  4003. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Compute the transpose of a matrix and store it in a target matrix
  4006. * @param matrix defines the matrix to transpose
  4007. * @param result defines the target matrix
  4008. */
  4009. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4010. /**
  4011. * Computes a reflection matrix from a plane
  4012. * @param plane defines the reflection plane
  4013. * @returns a new matrix
  4014. */
  4015. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4016. /**
  4017. * Computes a reflection matrix from a plane
  4018. * @param plane defines the reflection plane
  4019. * @param result defines the target matrix
  4020. */
  4021. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4022. /**
  4023. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4024. * @param xaxis defines the value of the 1st axis
  4025. * @param yaxis defines the value of the 2nd axis
  4026. * @param zaxis defines the value of the 3rd axis
  4027. * @param result defines the target matrix
  4028. */
  4029. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4030. /**
  4031. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4032. * @param quat defines the quaternion to use
  4033. * @param result defines the target matrix
  4034. */
  4035. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4036. }
  4037. /**
  4038. * @hidden
  4039. */
  4040. export class TmpVectors {
  4041. static Vector2: Vector2[];
  4042. static Vector3: Vector3[];
  4043. static Vector4: Vector4[];
  4044. static Quaternion: Quaternion[];
  4045. static Matrix: Matrix[];
  4046. }
  4047. }
  4048. declare module "babylonjs/Engines/constants" {
  4049. /** Defines the cross module used constants to avoid circular dependncies */
  4050. export class Constants {
  4051. /** Defines that alpha blending is disabled */
  4052. static readonly ALPHA_DISABLE: number;
  4053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4054. static readonly ALPHA_ADD: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_COMBINE: number;
  4057. /** Defines that alpha blending to DEST - SRC * DEST */
  4058. static readonly ALPHA_SUBTRACT: number;
  4059. /** Defines that alpha blending to SRC * DEST */
  4060. static readonly ALPHA_MULTIPLY: number;
  4061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4062. static readonly ALPHA_MAXIMIZED: number;
  4063. /** Defines that alpha blending to SRC + DEST */
  4064. static readonly ALPHA_ONEONE: number;
  4065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4066. static readonly ALPHA_PREMULTIPLIED: number;
  4067. /**
  4068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4070. */
  4071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4073. static readonly ALPHA_INTERPOLATE: number;
  4074. /**
  4075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4077. */
  4078. static readonly ALPHA_SCREENMODE: number;
  4079. /** Defines that the ressource is not delayed*/
  4080. static readonly DELAYLOADSTATE_NONE: number;
  4081. /** Defines that the ressource was successfully delay loaded */
  4082. static readonly DELAYLOADSTATE_LOADED: number;
  4083. /** Defines that the ressource is currently delay loading */
  4084. static readonly DELAYLOADSTATE_LOADING: number;
  4085. /** Defines that the ressource is delayed and has not started loading */
  4086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4088. static readonly NEVER: number;
  4089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4090. static readonly ALWAYS: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4092. static readonly LESS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4094. static readonly EQUAL: number;
  4095. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4096. static readonly LEQUAL: number;
  4097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4098. static readonly GREATER: number;
  4099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4100. static readonly GEQUAL: number;
  4101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4102. static readonly NOTEQUAL: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be kept */
  4104. static readonly KEEP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4106. static readonly REPLACE: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4108. static readonly INCR: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4110. static readonly DECR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4112. static readonly INVERT: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4114. static readonly INCR_WRAP: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4116. static readonly DECR_WRAP: number;
  4117. /** Texture is not repeating outside of 0..1 UVs */
  4118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4119. /** Texture is repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4121. /** Texture is repeating and mirrored */
  4122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4123. /** ALPHA */
  4124. static readonly TEXTUREFORMAT_ALPHA: number;
  4125. /** LUMINANCE */
  4126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4127. /** LUMINANCE_ALPHA */
  4128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4129. /** RGB */
  4130. static readonly TEXTUREFORMAT_RGB: number;
  4131. /** RGBA */
  4132. static readonly TEXTUREFORMAT_RGBA: number;
  4133. /** RED */
  4134. static readonly TEXTUREFORMAT_RED: number;
  4135. /** RED (2nd reference) */
  4136. static readonly TEXTUREFORMAT_R: number;
  4137. /** RG */
  4138. static readonly TEXTUREFORMAT_RG: number;
  4139. /** RED_INTEGER */
  4140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4141. /** RED_INTEGER (2nd reference) */
  4142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4143. /** RG_INTEGER */
  4144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4145. /** RGB_INTEGER */
  4146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4147. /** RGBA_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4149. /** UNSIGNED_BYTE */
  4150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4151. /** UNSIGNED_BYTE (2nd reference) */
  4152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4153. /** FLOAT */
  4154. static readonly TEXTURETYPE_FLOAT: number;
  4155. /** HALF_FLOAT */
  4156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4157. /** BYTE */
  4158. static readonly TEXTURETYPE_BYTE: number;
  4159. /** SHORT */
  4160. static readonly TEXTURETYPE_SHORT: number;
  4161. /** UNSIGNED_SHORT */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4163. /** INT */
  4164. static readonly TEXTURETYPE_INT: number;
  4165. /** UNSIGNED_INT */
  4166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4167. /** UNSIGNED_SHORT_4_4_4_4 */
  4168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4169. /** UNSIGNED_SHORT_5_5_5_1 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4171. /** UNSIGNED_SHORT_5_6_5 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4173. /** UNSIGNED_INT_2_10_10_10_REV */
  4174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4175. /** UNSIGNED_INT_24_8 */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4177. /** UNSIGNED_INT_10F_11F_11F_REV */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4179. /** UNSIGNED_INT_5_9_9_9_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4183. /** nearest is mag = nearest and min = nearest and mip = linear */
  4184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4187. /** Trilinear is mag = linear and min = linear and mip = linear */
  4188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4189. /** nearest is mag = nearest and min = nearest and mip = linear */
  4190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4193. /** Trilinear is mag = linear and min = linear and mip = linear */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4195. /** mag = nearest and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4197. /** mag = nearest and min = linear and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = linear */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4201. /** mag = nearest and min = linear and mip = none */
  4202. static readonly TEXTURE_NEAREST_LINEAR: number;
  4203. /** mag = nearest and min = nearest and mip = none */
  4204. static readonly TEXTURE_NEAREST_NEAREST: number;
  4205. /** mag = linear and min = nearest and mip = nearest */
  4206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4207. /** mag = linear and min = nearest and mip = linear */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4209. /** mag = linear and min = linear and mip = none */
  4210. static readonly TEXTURE_LINEAR_LINEAR: number;
  4211. /** mag = linear and min = nearest and mip = none */
  4212. static readonly TEXTURE_LINEAR_NEAREST: number;
  4213. /** Explicit coordinates mode */
  4214. static readonly TEXTURE_EXPLICIT_MODE: number;
  4215. /** Spherical coordinates mode */
  4216. static readonly TEXTURE_SPHERICAL_MODE: number;
  4217. /** Planar coordinates mode */
  4218. static readonly TEXTURE_PLANAR_MODE: number;
  4219. /** Cubic coordinates mode */
  4220. static readonly TEXTURE_CUBIC_MODE: number;
  4221. /** Projection coordinates mode */
  4222. static readonly TEXTURE_PROJECTION_MODE: number;
  4223. /** Skybox coordinates mode */
  4224. static readonly TEXTURE_SKYBOX_MODE: number;
  4225. /** Inverse Cubic coordinates mode */
  4226. static readonly TEXTURE_INVCUBIC_MODE: number;
  4227. /** Equirectangular coordinates mode */
  4228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4229. /** Equirectangular Fixed coordinates mode */
  4230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed Mirrored coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4234. static readonly SCALEMODE_FLOOR: number;
  4235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4236. static readonly SCALEMODE_NEAREST: number;
  4237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4238. static readonly SCALEMODE_CEILING: number;
  4239. /**
  4240. * The dirty texture flag value
  4241. */
  4242. static readonly MATERIAL_TextureDirtyFlag: number;
  4243. /**
  4244. * The dirty light flag value
  4245. */
  4246. static readonly MATERIAL_LightDirtyFlag: number;
  4247. /**
  4248. * The dirty fresnel flag value
  4249. */
  4250. static readonly MATERIAL_FresnelDirtyFlag: number;
  4251. /**
  4252. * The dirty attribute flag value
  4253. */
  4254. static readonly MATERIAL_AttributesDirtyFlag: number;
  4255. /**
  4256. * The dirty misc flag value
  4257. */
  4258. static readonly MATERIAL_MiscDirtyFlag: number;
  4259. /**
  4260. * The all dirty flag value
  4261. */
  4262. static readonly MATERIAL_AllDirtyFlag: number;
  4263. /**
  4264. * Returns the triangle fill mode
  4265. */
  4266. static readonly MATERIAL_TriangleFillMode: number;
  4267. /**
  4268. * Returns the wireframe mode
  4269. */
  4270. static readonly MATERIAL_WireFrameFillMode: number;
  4271. /**
  4272. * Returns the point fill mode
  4273. */
  4274. static readonly MATERIAL_PointFillMode: number;
  4275. /**
  4276. * Returns the point list draw mode
  4277. */
  4278. static readonly MATERIAL_PointListDrawMode: number;
  4279. /**
  4280. * Returns the line list draw mode
  4281. */
  4282. static readonly MATERIAL_LineListDrawMode: number;
  4283. /**
  4284. * Returns the line loop draw mode
  4285. */
  4286. static readonly MATERIAL_LineLoopDrawMode: number;
  4287. /**
  4288. * Returns the line strip draw mode
  4289. */
  4290. static readonly MATERIAL_LineStripDrawMode: number;
  4291. /**
  4292. * Returns the triangle strip draw mode
  4293. */
  4294. static readonly MATERIAL_TriangleStripDrawMode: number;
  4295. /**
  4296. * Returns the triangle fan draw mode
  4297. */
  4298. static readonly MATERIAL_TriangleFanDrawMode: number;
  4299. /**
  4300. * Stores the clock-wise side orientation
  4301. */
  4302. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4303. /**
  4304. * Stores the counter clock-wise side orientation
  4305. */
  4306. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4307. /**
  4308. * Nothing
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_NothingTrigger: number;
  4312. /**
  4313. * On pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnPickTrigger: number;
  4317. /**
  4318. * On left pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnLeftPickTrigger: number;
  4322. /**
  4323. * On right pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnRightPickTrigger: number;
  4327. /**
  4328. * On center pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnCenterPickTrigger: number;
  4332. /**
  4333. * On pick down
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickDownTrigger: number;
  4337. /**
  4338. * On double pick
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnDoublePickTrigger: number;
  4342. /**
  4343. * On pick up
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnPickUpTrigger: number;
  4347. /**
  4348. * On pick out.
  4349. * This trigger will only be raised if you also declared a OnPickDown
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPickOutTrigger: number;
  4353. /**
  4354. * On long press
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnLongPressTrigger: number;
  4358. /**
  4359. * On pointer over
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOverTrigger: number;
  4363. /**
  4364. * On pointer out
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOutTrigger: number;
  4368. /**
  4369. * On every frame
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnEveryFrameTrigger: number;
  4373. /**
  4374. * On intersection enter
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4378. /**
  4379. * On intersection exit
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionExitTrigger: number;
  4383. /**
  4384. * On key down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyDownTrigger: number;
  4388. /**
  4389. * On key up
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyUpTrigger: number;
  4393. /**
  4394. * Billboard mode will only apply to Y axis
  4395. */
  4396. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4397. /**
  4398. * Billboard mode will apply to all axes
  4399. */
  4400. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4401. /**
  4402. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4403. */
  4404. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4405. /**
  4406. * Gets or sets base Assets URL
  4407. */
  4408. static PARTICLES_BaseAssetsUrl: string;
  4409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4410. * Test order :
  4411. * Is the bounding sphere outside the frustum ?
  4412. * If not, are the bounding box vertices outside the frustum ?
  4413. * It not, then the cullable object is in the frustum.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4416. /** Culling strategy : Bounding Sphere Only.
  4417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4418. * It's also less accurate than the standard because some not visible objects can still be selected.
  4419. * Test : is the bounding sphere outside the frustum ?
  4420. * If not, then the cullable object is in the frustum.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4423. /** Culling strategy : Optimistic Inclusion.
  4424. * This in an inclusion test first, then the standard exclusion test.
  4425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4426. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4427. * Anyway, it's as accurate as the standard strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the default culling strategy.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4436. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4438. * Test :
  4439. * Is the cullable object bounding sphere center in the frustum ?
  4440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4441. */
  4442. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4443. /**
  4444. * No logging while loading
  4445. */
  4446. static readonly SCENELOADER_NO_LOGGING: number;
  4447. /**
  4448. * Minimal logging while loading
  4449. */
  4450. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4451. /**
  4452. * Summary logging while loading
  4453. */
  4454. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4455. /**
  4456. * Detailled logging while loading
  4457. */
  4458. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4459. }
  4460. }
  4461. declare module "babylonjs/Engines/IPipelineContext" {
  4462. /**
  4463. * Class used to store and describe the pipeline context associated with an effect
  4464. */
  4465. export interface IPipelineContext {
  4466. /**
  4467. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4468. */
  4469. isAsync: boolean;
  4470. /**
  4471. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4472. */
  4473. isReady: boolean;
  4474. /** @hidden */
  4475. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4476. }
  4477. }
  4478. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4479. /** @hidden */
  4480. export interface IShaderProcessor {
  4481. attributeProcessor?: (attribute: string) => string;
  4482. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4483. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4486. lineProcessor?: (line: string, isFragment: boolean) => string;
  4487. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4488. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4489. }
  4490. }
  4491. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4492. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4493. /** @hidden */
  4494. export interface ProcessingOptions {
  4495. defines: string[];
  4496. indexParameters: any;
  4497. isFragment: boolean;
  4498. shouldUseHighPrecisionShader: boolean;
  4499. supportsUniformBuffers: boolean;
  4500. shadersRepository: string;
  4501. includesShadersStore: {
  4502. [key: string]: string;
  4503. };
  4504. processor?: IShaderProcessor;
  4505. version: string;
  4506. platformName: string;
  4507. lookForClosingBracketForUniformBuffer?: boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Misc/stringTools" {
  4511. /**
  4512. * Helper to manipulate strings
  4513. */
  4514. export class StringTools {
  4515. /**
  4516. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static EndsWith(str: string, suffix: string): boolean;
  4522. /**
  4523. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4524. * @param str Source string
  4525. * @param suffix Suffix to search for in the source string
  4526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4527. */
  4528. static StartsWith(str: string, suffix: string): boolean;
  4529. }
  4530. }
  4531. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4532. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4558. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4559. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4560. /** @hidden */
  4561. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4562. process(preprocessors: {
  4563. [key: string]: string;
  4564. }, options: ProcessingOptions): string;
  4565. }
  4566. }
  4567. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4568. /** @hidden */
  4569. export class ShaderDefineExpression {
  4570. isTrue(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4576. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4577. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4578. /** @hidden */
  4579. export class ShaderCodeTestNode extends ShaderCodeNode {
  4580. testExpression: ShaderDefineExpression;
  4581. isValid(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4587. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4588. /** @hidden */
  4589. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4590. define: string;
  4591. not: boolean;
  4592. constructor(define: string, not?: boolean);
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4602. leftOperand: ShaderDefineExpression;
  4603. rightOperand: ShaderDefineExpression;
  4604. isTrue(preprocessors: {
  4605. [key: string]: string;
  4606. }): boolean;
  4607. }
  4608. }
  4609. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4610. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4611. /** @hidden */
  4612. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4613. leftOperand: ShaderDefineExpression;
  4614. rightOperand: ShaderDefineExpression;
  4615. isTrue(preprocessors: {
  4616. [key: string]: string;
  4617. }): boolean;
  4618. }
  4619. }
  4620. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4621. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4622. /** @hidden */
  4623. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. operand: string;
  4626. testValue: string;
  4627. constructor(define: string, operand: string, testValue: string);
  4628. isTrue(preprocessors: {
  4629. [key: string]: string;
  4630. }): boolean;
  4631. }
  4632. }
  4633. declare module "babylonjs/Misc/loadFileError" {
  4634. import { WebRequest } from "babylonjs/Misc/webRequest";
  4635. /**
  4636. * @ignore
  4637. * Application error to support additional information when loading a file
  4638. */
  4639. export class LoadFileError extends Error {
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined;
  4642. private static _setPrototypeOf;
  4643. /**
  4644. * Creates a new LoadFileError
  4645. * @param message defines the message of the error
  4646. * @param request defines the optional web request
  4647. */
  4648. constructor(message: string,
  4649. /** defines the optional web request */
  4650. request?: WebRequest | undefined);
  4651. }
  4652. }
  4653. declare module "babylonjs/Offline/IOfflineProvider" {
  4654. /**
  4655. * Class used to enable access to offline support
  4656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4657. */
  4658. export interface IOfflineProvider {
  4659. /**
  4660. * Gets a boolean indicating if scene must be saved in the database
  4661. */
  4662. enableSceneOffline: boolean;
  4663. /**
  4664. * Gets a boolean indicating if textures must be saved in the database
  4665. */
  4666. enableTexturesOffline: boolean;
  4667. /**
  4668. * Open the offline support and make it available
  4669. * @param successCallback defines the callback to call on success
  4670. * @param errorCallback defines the callback to call on error
  4671. */
  4672. open(successCallback: () => void, errorCallback: () => void): void;
  4673. /**
  4674. * Loads an image from the offline support
  4675. * @param url defines the url to load from
  4676. * @param image defines the target DOM image
  4677. */
  4678. loadImage(url: string, image: HTMLImageElement): void;
  4679. /**
  4680. * Loads a file from offline support
  4681. * @param url defines the URL to load from
  4682. * @param sceneLoaded defines a callback to call on success
  4683. * @param progressCallBack defines a callback to call when progress changed
  4684. * @param errorCallback defines a callback to call on error
  4685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4686. */
  4687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4688. }
  4689. }
  4690. declare module "babylonjs/Misc/filesInputStore" {
  4691. /**
  4692. * Class used to help managing file picking and drag'n'drop
  4693. * File Storage
  4694. */
  4695. export class FilesInputStore {
  4696. /**
  4697. * List of files ready to be loaded
  4698. */
  4699. static FilesToLoad: {
  4700. [key: string]: File;
  4701. };
  4702. }
  4703. }
  4704. declare module "babylonjs/Misc/retryStrategy" {
  4705. import { WebRequest } from "babylonjs/Misc/webRequest";
  4706. /**
  4707. * Class used to define a retry strategy when error happens while loading assets
  4708. */
  4709. export class RetryStrategy {
  4710. /**
  4711. * Function used to defines an exponential back off strategy
  4712. * @param maxRetries defines the maximum number of retries (3 by default)
  4713. * @param baseInterval defines the interval between retries
  4714. * @returns the strategy function to use
  4715. */
  4716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4717. }
  4718. }
  4719. declare module "babylonjs/Misc/fileTools" {
  4720. import { WebRequest } from "babylonjs/Misc/webRequest";
  4721. import { Nullable } from "babylonjs/types";
  4722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4723. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4724. /**
  4725. * @hidden
  4726. */
  4727. export class FileTools {
  4728. /**
  4729. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4730. */
  4731. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4732. /**
  4733. * Gets or sets the base URL to use to load assets
  4734. */
  4735. static BaseUrl: string;
  4736. /**
  4737. * Default behaviour for cors in the application.
  4738. * It can be a string if the expected behavior is identical in the entire app.
  4739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4740. */
  4741. static CorsBehavior: string | ((url: string | string[]) => string);
  4742. /**
  4743. * Gets or sets a function used to pre-process url before using them to load assets
  4744. */
  4745. static PreprocessUrl: (url: string) => string;
  4746. /**
  4747. * Removes unwanted characters from an url
  4748. * @param url defines the url to clean
  4749. * @returns the cleaned url
  4750. */
  4751. private static _CleanUrl;
  4752. /**
  4753. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4754. * @param url define the url we are trying
  4755. * @param element define the dom element where to configure the cors policy
  4756. */
  4757. static SetCorsBehavior(url: string | string[], element: {
  4758. crossOrigin: string | null;
  4759. }): void;
  4760. /**
  4761. * Loads an image as an HTMLImageElement.
  4762. * @param input url string, ArrayBuffer, or Blob to load
  4763. * @param onLoad callback called when the image successfully loads
  4764. * @param onError callback called when the image fails to load
  4765. * @param offlineProvider offline provider for caching
  4766. * @returns the HTMLImageElement of the loaded image
  4767. */
  4768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4769. /**
  4770. * Loads a file
  4771. * @param fileToLoad defines the file to load
  4772. * @param callback defines the callback to call when data is loaded
  4773. * @param progressCallBack defines the callback to call during loading process
  4774. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4775. * @returns a file request object
  4776. */
  4777. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4778. /**
  4779. * Loads a file
  4780. * @param url url string, ArrayBuffer, or Blob to load
  4781. * @param onSuccess callback called when the file successfully loads
  4782. * @param onProgress callback called while file is loading (if the server supports this mode)
  4783. * @param offlineProvider defines the offline provider for caching
  4784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4785. * @param onError callback called when the file fails to load
  4786. * @returns a file request object
  4787. */
  4788. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4789. /**
  4790. * Checks if the loaded document was accessed via `file:`-Protocol.
  4791. * @returns boolean
  4792. */
  4793. static IsFileURL(): boolean;
  4794. }
  4795. }
  4796. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4797. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4798. /** @hidden */
  4799. export class ShaderProcessor {
  4800. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4801. private static _ProcessPrecision;
  4802. private static _ExtractOperation;
  4803. private static _BuildSubExpression;
  4804. private static _BuildExpression;
  4805. private static _MoveCursorWithinIf;
  4806. private static _MoveCursor;
  4807. private static _EvaluatePreProcessors;
  4808. private static _PreparePreProcessors;
  4809. private static _ProcessShaderConversion;
  4810. private static _ProcessIncludes;
  4811. }
  4812. }
  4813. declare module "babylonjs/Maths/math.color" {
  4814. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4815. /**
  4816. * Class used to hold a RBG color
  4817. */
  4818. export class Color3 {
  4819. /**
  4820. * Defines the red component (between 0 and 1, default is 0)
  4821. */
  4822. r: number;
  4823. /**
  4824. * Defines the green component (between 0 and 1, default is 0)
  4825. */
  4826. g: number;
  4827. /**
  4828. * Defines the blue component (between 0 and 1, default is 0)
  4829. */
  4830. b: number;
  4831. /**
  4832. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4833. * @param r defines the red component (between 0 and 1, default is 0)
  4834. * @param g defines the green component (between 0 and 1, default is 0)
  4835. * @param b defines the blue component (between 0 and 1, default is 0)
  4836. */
  4837. constructor(
  4838. /**
  4839. * Defines the red component (between 0 and 1, default is 0)
  4840. */
  4841. r?: number,
  4842. /**
  4843. * Defines the green component (between 0 and 1, default is 0)
  4844. */
  4845. g?: number,
  4846. /**
  4847. * Defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. b?: number);
  4850. /**
  4851. * Creates a string with the Color3 current values
  4852. * @returns the string representation of the Color3 object
  4853. */
  4854. toString(): string;
  4855. /**
  4856. * Returns the string "Color3"
  4857. * @returns "Color3"
  4858. */
  4859. getClassName(): string;
  4860. /**
  4861. * Compute the Color3 hash code
  4862. * @returns an unique number that can be used to hash Color3 objects
  4863. */
  4864. getHashCode(): number;
  4865. /**
  4866. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4867. * @param array defines the array where to store the r,g,b components
  4868. * @param index defines an optional index in the target array to define where to start storing values
  4869. * @returns the current Color3 object
  4870. */
  4871. toArray(array: FloatArray, index?: number): Color3;
  4872. /**
  4873. * Returns a new Color4 object from the current Color3 and the given alpha
  4874. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4875. * @returns a new Color4 object
  4876. */
  4877. toColor4(alpha?: number): Color4;
  4878. /**
  4879. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4880. * @returns the new array
  4881. */
  4882. asArray(): number[];
  4883. /**
  4884. * Returns the luminance value
  4885. * @returns a float value
  4886. */
  4887. toLuminance(): number;
  4888. /**
  4889. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4890. * @param otherColor defines the second operand
  4891. * @returns the new Color3 object
  4892. */
  4893. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4894. /**
  4895. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4896. * @param otherColor defines the second operand
  4897. * @param result defines the Color3 object where to store the result
  4898. * @returns the current Color3
  4899. */
  4900. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4901. /**
  4902. * Determines equality between Color3 objects
  4903. * @param otherColor defines the second operand
  4904. * @returns true if the rgb values are equal to the given ones
  4905. */
  4906. equals(otherColor: DeepImmutable<Color3>): boolean;
  4907. /**
  4908. * Determines equality between the current Color3 object and a set of r,b,g values
  4909. * @param r defines the red component to check
  4910. * @param g defines the green component to check
  4911. * @param b defines the blue component to check
  4912. * @returns true if the rgb values are equal to the given ones
  4913. */
  4914. equalsFloats(r: number, g: number, b: number): boolean;
  4915. /**
  4916. * Multiplies in place each rgb value by scale
  4917. * @param scale defines the scaling factor
  4918. * @returns the updated Color3
  4919. */
  4920. scale(scale: number): Color3;
  4921. /**
  4922. * Multiplies the rgb values by scale and stores the result into "result"
  4923. * @param scale defines the scaling factor
  4924. * @param result defines the Color3 object where to store the result
  4925. * @returns the unmodified current Color3
  4926. */
  4927. scaleToRef(scale: number, result: Color3): Color3;
  4928. /**
  4929. * Scale the current Color3 values by a factor and add the result to a given Color3
  4930. * @param scale defines the scale factor
  4931. * @param result defines color to store the result into
  4932. * @returns the unmodified current Color3
  4933. */
  4934. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4935. /**
  4936. * Clamps the rgb values by the min and max values and stores the result into "result"
  4937. * @param min defines minimum clamping value (default is 0)
  4938. * @param max defines maximum clamping value (default is 1)
  4939. * @param result defines color to store the result into
  4940. * @returns the original Color3
  4941. */
  4942. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4943. /**
  4944. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4945. * @param otherColor defines the second operand
  4946. * @returns the new Color3
  4947. */
  4948. add(otherColor: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4951. * @param otherColor defines the second operand
  4952. * @param result defines Color3 object to store the result into
  4953. * @returns the unmodified current Color3
  4954. */
  4955. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4956. /**
  4957. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4958. * @param otherColor defines the second operand
  4959. * @returns the new Color3
  4960. */
  4961. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4962. /**
  4963. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4964. * @param otherColor defines the second operand
  4965. * @param result defines Color3 object to store the result into
  4966. * @returns the unmodified current Color3
  4967. */
  4968. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4969. /**
  4970. * Copy the current object
  4971. * @returns a new Color3 copied the current one
  4972. */
  4973. clone(): Color3;
  4974. /**
  4975. * Copies the rgb values from the source in the current Color3
  4976. * @param source defines the source Color3 object
  4977. * @returns the updated Color3 object
  4978. */
  4979. copyFrom(source: DeepImmutable<Color3>): Color3;
  4980. /**
  4981. * Updates the Color3 rgb values from the given floats
  4982. * @param r defines the red component to read from
  4983. * @param g defines the green component to read from
  4984. * @param b defines the blue component to read from
  4985. * @returns the current Color3 object
  4986. */
  4987. copyFromFloats(r: number, g: number, b: number): Color3;
  4988. /**
  4989. * Updates the Color3 rgb values from the given floats
  4990. * @param r defines the red component to read from
  4991. * @param g defines the green component to read from
  4992. * @param b defines the blue component to read from
  4993. * @returns the current Color3 object
  4994. */
  4995. set(r: number, g: number, b: number): Color3;
  4996. /**
  4997. * Compute the Color3 hexadecimal code as a string
  4998. * @returns a string containing the hexadecimal representation of the Color3 object
  4999. */
  5000. toHexString(): string;
  5001. /**
  5002. * Computes a new Color3 converted from the current one to linear space
  5003. * @returns a new Color3 object
  5004. */
  5005. toLinearSpace(): Color3;
  5006. /**
  5007. * Converts current color in rgb space to HSV values
  5008. * @returns a new color3 representing the HSV values
  5009. */
  5010. toHSV(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @param result defines the Color3 where to store the HSV values
  5014. */
  5015. toHSVToRef(result: Color3): void;
  5016. /**
  5017. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5018. * @param convertedColor defines the Color3 object where to store the linear space version
  5019. * @returns the unmodified Color3
  5020. */
  5021. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5022. /**
  5023. * Computes a new Color3 converted from the current one to gamma space
  5024. * @returns a new Color3 object
  5025. */
  5026. toGammaSpace(): Color3;
  5027. /**
  5028. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5029. * @param convertedColor defines the Color3 object where to store the gamma space version
  5030. * @returns the unmodified Color3
  5031. */
  5032. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5033. private static _BlackReadOnly;
  5034. /**
  5035. * Convert Hue, saturation and value to a Color3 (RGB)
  5036. * @param hue defines the hue
  5037. * @param saturation defines the saturation
  5038. * @param value defines the value
  5039. * @param result defines the Color3 where to store the RGB values
  5040. */
  5041. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5042. /**
  5043. * Creates a new Color3 from the string containing valid hexadecimal values
  5044. * @param hex defines a string containing valid hexadecimal values
  5045. * @returns a new Color3 object
  5046. */
  5047. static FromHexString(hex: string): Color3;
  5048. /**
  5049. * Creates a new Color3 from the starting index of the given array
  5050. * @param array defines the source array
  5051. * @param offset defines an offset in the source array
  5052. * @returns a new Color3 object
  5053. */
  5054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5055. /**
  5056. * Creates a new Color3 from integer values (< 256)
  5057. * @param r defines the red component to read from (value between 0 and 255)
  5058. * @param g defines the green component to read from (value between 0 and 255)
  5059. * @param b defines the blue component to read from (value between 0 and 255)
  5060. * @returns a new Color3 object
  5061. */
  5062. static FromInts(r: number, g: number, b: number): Color3;
  5063. /**
  5064. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5065. * @param start defines the start Color3 value
  5066. * @param end defines the end Color3 value
  5067. * @param amount defines the gradient value between start and end
  5068. * @returns a new Color3 object
  5069. */
  5070. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5071. /**
  5072. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5073. * @param left defines the start value
  5074. * @param right defines the end value
  5075. * @param amount defines the gradient factor
  5076. * @param result defines the Color3 object where to store the result
  5077. */
  5078. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5079. /**
  5080. * Returns a Color3 value containing a red color
  5081. * @returns a new Color3 object
  5082. */
  5083. static Red(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a green color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Green(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a blue color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Blue(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a black color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Black(): Color3;
  5099. /**
  5100. * Gets a Color3 value containing a black color that must not be updated
  5101. */
  5102. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5103. /**
  5104. * Returns a Color3 value containing a white color
  5105. * @returns a new Color3 object
  5106. */
  5107. static White(): Color3;
  5108. /**
  5109. * Returns a Color3 value containing a purple color
  5110. * @returns a new Color3 object
  5111. */
  5112. static Purple(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a magenta color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Magenta(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a yellow color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Yellow(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a gray color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Gray(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a teal color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Teal(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a random color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Random(): Color3;
  5138. }
  5139. /**
  5140. * Class used to hold a RBGA color
  5141. */
  5142. export class Color4 {
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r: number;
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g: number;
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b: number;
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a: number;
  5159. /**
  5160. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5161. * @param r defines the red component (between 0 and 1, default is 0)
  5162. * @param g defines the green component (between 0 and 1, default is 0)
  5163. * @param b defines the blue component (between 0 and 1, default is 0)
  5164. * @param a defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. constructor(
  5167. /**
  5168. * Defines the red component (between 0 and 1, default is 0)
  5169. */
  5170. r?: number,
  5171. /**
  5172. * Defines the green component (between 0 and 1, default is 0)
  5173. */
  5174. g?: number,
  5175. /**
  5176. * Defines the blue component (between 0 and 1, default is 0)
  5177. */
  5178. b?: number,
  5179. /**
  5180. * Defines the alpha component (between 0 and 1, default is 1)
  5181. */
  5182. a?: number);
  5183. /**
  5184. * Adds in place the given Color4 values to the current Color4 object
  5185. * @param right defines the second operand
  5186. * @returns the current updated Color4 object
  5187. */
  5188. addInPlace(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5191. * @returns the new array
  5192. */
  5193. asArray(): number[];
  5194. /**
  5195. * Stores from the starting index in the given array the Color4 successive values
  5196. * @param array defines the array where to store the r,g,b components
  5197. * @param index defines an optional index in the target array to define where to start storing values
  5198. * @returns the current Color4 object
  5199. */
  5200. toArray(array: number[], index?: number): Color4;
  5201. /**
  5202. * Determines equality between Color4 objects
  5203. * @param otherColor defines the second operand
  5204. * @returns true if the rgba values are equal to the given ones
  5205. */
  5206. equals(otherColor: DeepImmutable<Color4>): boolean;
  5207. /**
  5208. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5209. * @param right defines the second operand
  5210. * @returns a new Color4 object
  5211. */
  5212. add(right: DeepImmutable<Color4>): Color4;
  5213. /**
  5214. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5215. * @param right defines the second operand
  5216. * @returns a new Color4 object
  5217. */
  5218. subtract(right: DeepImmutable<Color4>): Color4;
  5219. /**
  5220. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5221. * @param right defines the second operand
  5222. * @param result defines the Color4 object where to store the result
  5223. * @returns the current Color4 object
  5224. */
  5225. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5226. /**
  5227. * Creates a new Color4 with the current Color4 values multiplied by scale
  5228. * @param scale defines the scaling factor to apply
  5229. * @returns a new Color4 object
  5230. */
  5231. scale(scale: number): Color4;
  5232. /**
  5233. * Multiplies the current Color4 values by scale and stores the result in "result"
  5234. * @param scale defines the scaling factor to apply
  5235. * @param result defines the Color4 object where to store the result
  5236. * @returns the current unmodified Color4
  5237. */
  5238. scaleToRef(scale: number, result: Color4): Color4;
  5239. /**
  5240. * Scale the current Color4 values by a factor and add the result to a given Color4
  5241. * @param scale defines the scale factor
  5242. * @param result defines the Color4 object where to store the result
  5243. * @returns the unmodified current Color4
  5244. */
  5245. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5246. /**
  5247. * Clamps the rgb values by the min and max values and stores the result into "result"
  5248. * @param min defines minimum clamping value (default is 0)
  5249. * @param max defines maximum clamping value (default is 1)
  5250. * @param result defines color to store the result into.
  5251. * @returns the cuurent Color4
  5252. */
  5253. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5254. /**
  5255. * Multipy an Color4 value by another and return a new Color4 object
  5256. * @param color defines the Color4 value to multiply by
  5257. * @returns a new Color4 object
  5258. */
  5259. multiply(color: Color4): Color4;
  5260. /**
  5261. * Multipy a Color4 value by another and push the result in a reference value
  5262. * @param color defines the Color4 value to multiply by
  5263. * @param result defines the Color4 to fill the result in
  5264. * @returns the result Color4
  5265. */
  5266. multiplyToRef(color: Color4, result: Color4): Color4;
  5267. /**
  5268. * Creates a string with the Color4 current values
  5269. * @returns the string representation of the Color4 object
  5270. */
  5271. toString(): string;
  5272. /**
  5273. * Returns the string "Color4"
  5274. * @returns "Color4"
  5275. */
  5276. getClassName(): string;
  5277. /**
  5278. * Compute the Color4 hash code
  5279. * @returns an unique number that can be used to hash Color4 objects
  5280. */
  5281. getHashCode(): number;
  5282. /**
  5283. * Creates a new Color4 copied from the current one
  5284. * @returns a new Color4 object
  5285. */
  5286. clone(): Color4;
  5287. /**
  5288. * Copies the given Color4 values into the current one
  5289. * @param source defines the source Color4 object
  5290. * @returns the current updated Color4 object
  5291. */
  5292. copyFrom(source: Color4): Color4;
  5293. /**
  5294. * Copies the given float values into the current one
  5295. * @param r defines the red component to read from
  5296. * @param g defines the green component to read from
  5297. * @param b defines the blue component to read from
  5298. * @param a defines the alpha component to read from
  5299. * @returns the current updated Color4 object
  5300. */
  5301. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5302. /**
  5303. * Copies the given float values into the current one
  5304. * @param r defines the red component to read from
  5305. * @param g defines the green component to read from
  5306. * @param b defines the blue component to read from
  5307. * @param a defines the alpha component to read from
  5308. * @returns the current updated Color4 object
  5309. */
  5310. set(r: number, g: number, b: number, a: number): Color4;
  5311. /**
  5312. * Compute the Color4 hexadecimal code as a string
  5313. * @returns a string containing the hexadecimal representation of the Color4 object
  5314. */
  5315. toHexString(): string;
  5316. /**
  5317. * Computes a new Color4 converted from the current one to linear space
  5318. * @returns a new Color4 object
  5319. */
  5320. toLinearSpace(): Color4;
  5321. /**
  5322. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5323. * @param convertedColor defines the Color4 object where to store the linear space version
  5324. * @returns the unmodified Color4
  5325. */
  5326. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5327. /**
  5328. * Computes a new Color4 converted from the current one to gamma space
  5329. * @returns a new Color4 object
  5330. */
  5331. toGammaSpace(): Color4;
  5332. /**
  5333. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5334. * @param convertedColor defines the Color4 object where to store the gamma space version
  5335. * @returns the unmodified Color4
  5336. */
  5337. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5338. /**
  5339. * Creates a new Color4 from the string containing valid hexadecimal values
  5340. * @param hex defines a string containing valid hexadecimal values
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromHexString(hex: string): Color4;
  5344. /**
  5345. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5346. * @param left defines the start value
  5347. * @param right defines the end value
  5348. * @param amount defines the gradient factor
  5349. * @returns a new Color4 object
  5350. */
  5351. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5352. /**
  5353. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5354. * @param left defines the start value
  5355. * @param right defines the end value
  5356. * @param amount defines the gradient factor
  5357. * @param result defines the Color4 object where to store data
  5358. */
  5359. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5360. /**
  5361. * Creates a new Color4 from a Color3 and an alpha value
  5362. * @param color3 defines the source Color3 to read from
  5363. * @param alpha defines the alpha component (1.0 by default)
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5367. /**
  5368. * Creates a new Color4 from the starting index element of the given array
  5369. * @param array defines the source array to read from
  5370. * @param offset defines the offset in the source array
  5371. * @returns a new Color4 object
  5372. */
  5373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5374. /**
  5375. * Creates a new Color3 from integer values (< 256)
  5376. * @param r defines the red component to read from (value between 0 and 255)
  5377. * @param g defines the green component to read from (value between 0 and 255)
  5378. * @param b defines the blue component to read from (value between 0 and 255)
  5379. * @param a defines the alpha component to read from (value between 0 and 255)
  5380. * @returns a new Color3 object
  5381. */
  5382. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5383. /**
  5384. * Check the content of a given array and convert it to an array containing RGBA data
  5385. * If the original array was already containing count * 4 values then it is returned directly
  5386. * @param colors defines the array to check
  5387. * @param count defines the number of RGBA data to expect
  5388. * @returns an array containing count * 4 values (RGBA)
  5389. */
  5390. static CheckColors4(colors: number[], count: number): number[];
  5391. }
  5392. /**
  5393. * @hidden
  5394. */
  5395. export class TmpColors {
  5396. static Color3: Color3[];
  5397. static Color4: Color4[];
  5398. }
  5399. }
  5400. declare module "babylonjs/Maths/sphericalPolynomial" {
  5401. import { Vector3 } from "babylonjs/Maths/math.vector";
  5402. import { Color3 } from "babylonjs/Maths/math.color";
  5403. /**
  5404. * Class representing spherical harmonics coefficients to the 3rd degree
  5405. */
  5406. export class SphericalHarmonics {
  5407. /**
  5408. * Defines whether or not the harmonics have been prescaled for rendering.
  5409. */
  5410. preScaled: boolean;
  5411. /**
  5412. * The l0,0 coefficients of the spherical harmonics
  5413. */
  5414. l00: Vector3;
  5415. /**
  5416. * The l1,-1 coefficients of the spherical harmonics
  5417. */
  5418. l1_1: Vector3;
  5419. /**
  5420. * The l1,0 coefficients of the spherical harmonics
  5421. */
  5422. l10: Vector3;
  5423. /**
  5424. * The l1,1 coefficients of the spherical harmonics
  5425. */
  5426. l11: Vector3;
  5427. /**
  5428. * The l2,-2 coefficients of the spherical harmonics
  5429. */
  5430. l2_2: Vector3;
  5431. /**
  5432. * The l2,-1 coefficients of the spherical harmonics
  5433. */
  5434. l2_1: Vector3;
  5435. /**
  5436. * The l2,0 coefficients of the spherical harmonics
  5437. */
  5438. l20: Vector3;
  5439. /**
  5440. * The l2,1 coefficients of the spherical harmonics
  5441. */
  5442. l21: Vector3;
  5443. /**
  5444. * The l2,2 coefficients of the spherical harmonics
  5445. */
  5446. l22: Vector3;
  5447. /**
  5448. * Adds a light to the spherical harmonics
  5449. * @param direction the direction of the light
  5450. * @param color the color of the light
  5451. * @param deltaSolidAngle the delta solid angle of the light
  5452. */
  5453. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5454. /**
  5455. * Scales the spherical harmonics by the given amount
  5456. * @param scale the amount to scale
  5457. */
  5458. scaleInPlace(scale: number): void;
  5459. /**
  5460. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5461. *
  5462. * ```
  5463. * E_lm = A_l * L_lm
  5464. * ```
  5465. *
  5466. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5467. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5468. * the scaling factors are given in equation 9.
  5469. */
  5470. convertIncidentRadianceToIrradiance(): void;
  5471. /**
  5472. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5473. *
  5474. * ```
  5475. * L = (1/pi) * E * rho
  5476. * ```
  5477. *
  5478. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5479. */
  5480. convertIrradianceToLambertianRadiance(): void;
  5481. /**
  5482. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5483. * required operations at run time.
  5484. *
  5485. * This is simply done by scaling back the SH with Ylm constants parameter.
  5486. * The trigonometric part being applied by the shader at run time.
  5487. */
  5488. preScaleForRendering(): void;
  5489. /**
  5490. * Constructs a spherical harmonics from an array.
  5491. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5492. * @returns the spherical harmonics
  5493. */
  5494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5495. /**
  5496. * Gets the spherical harmonics from polynomial
  5497. * @param polynomial the spherical polynomial
  5498. * @returns the spherical harmonics
  5499. */
  5500. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5501. }
  5502. /**
  5503. * Class representing spherical polynomial coefficients to the 3rd degree
  5504. */
  5505. export class SphericalPolynomial {
  5506. private _harmonics;
  5507. /**
  5508. * The spherical harmonics used to create the polynomials.
  5509. */
  5510. readonly preScaledHarmonics: SphericalHarmonics;
  5511. /**
  5512. * The x coefficients of the spherical polynomial
  5513. */
  5514. x: Vector3;
  5515. /**
  5516. * The y coefficients of the spherical polynomial
  5517. */
  5518. y: Vector3;
  5519. /**
  5520. * The z coefficients of the spherical polynomial
  5521. */
  5522. z: Vector3;
  5523. /**
  5524. * The xx coefficients of the spherical polynomial
  5525. */
  5526. xx: Vector3;
  5527. /**
  5528. * The yy coefficients of the spherical polynomial
  5529. */
  5530. yy: Vector3;
  5531. /**
  5532. * The zz coefficients of the spherical polynomial
  5533. */
  5534. zz: Vector3;
  5535. /**
  5536. * The xy coefficients of the spherical polynomial
  5537. */
  5538. xy: Vector3;
  5539. /**
  5540. * The yz coefficients of the spherical polynomial
  5541. */
  5542. yz: Vector3;
  5543. /**
  5544. * The zx coefficients of the spherical polynomial
  5545. */
  5546. zx: Vector3;
  5547. /**
  5548. * Adds an ambient color to the spherical polynomial
  5549. * @param color the color to add
  5550. */
  5551. addAmbient(color: Color3): void;
  5552. /**
  5553. * Scales the spherical polynomial by the given amount
  5554. * @param scale the amount to scale
  5555. */
  5556. scaleInPlace(scale: number): void;
  5557. /**
  5558. * Gets the spherical polynomial from harmonics
  5559. * @param harmonics the spherical harmonics
  5560. * @returns the spherical polynomial
  5561. */
  5562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5563. /**
  5564. * Constructs a spherical polynomial from an array.
  5565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5566. * @returns the spherical polynomial
  5567. */
  5568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5569. }
  5570. }
  5571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5572. /**
  5573. * Define options used to create a render target texture
  5574. */
  5575. export class RenderTargetCreationOptions {
  5576. /**
  5577. * Specifies is mipmaps must be generated
  5578. */
  5579. generateMipMaps?: boolean;
  5580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5581. generateDepthBuffer?: boolean;
  5582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5583. generateStencilBuffer?: boolean;
  5584. /** Defines texture type (int by default) */
  5585. type?: number;
  5586. /** Defines sampling mode (trilinear by default) */
  5587. samplingMode?: number;
  5588. /** Defines format (RGBA by default) */
  5589. format?: number;
  5590. }
  5591. }
  5592. declare module "babylonjs/States/alphaCullingState" {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _AlphaState {
  5597. private _isAlphaBlendDirty;
  5598. private _isBlendFunctionParametersDirty;
  5599. private _isBlendEquationParametersDirty;
  5600. private _isBlendConstantsDirty;
  5601. private _alphaBlend;
  5602. private _blendFunctionParameters;
  5603. private _blendEquationParameters;
  5604. private _blendConstants;
  5605. /**
  5606. * Initializes the state.
  5607. */
  5608. constructor();
  5609. readonly isDirty: boolean;
  5610. alphaBlend: boolean;
  5611. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5612. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5613. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5614. reset(): void;
  5615. apply(gl: WebGLRenderingContext): void;
  5616. }
  5617. }
  5618. declare module "babylonjs/States/depthCullingState" {
  5619. import { Nullable } from "babylonjs/types";
  5620. /**
  5621. * @hidden
  5622. **/
  5623. export class _DepthCullingState {
  5624. private _isDepthTestDirty;
  5625. private _isDepthMaskDirty;
  5626. private _isDepthFuncDirty;
  5627. private _isCullFaceDirty;
  5628. private _isCullDirty;
  5629. private _isZOffsetDirty;
  5630. private _isFrontFaceDirty;
  5631. private _depthTest;
  5632. private _depthMask;
  5633. private _depthFunc;
  5634. private _cull;
  5635. private _cullFace;
  5636. private _zOffset;
  5637. private _frontFace;
  5638. /**
  5639. * Initializes the state.
  5640. */
  5641. constructor();
  5642. readonly isDirty: boolean;
  5643. zOffset: number;
  5644. cullFace: Nullable<number>;
  5645. cull: Nullable<boolean>;
  5646. depthFunc: Nullable<number>;
  5647. depthMask: boolean;
  5648. depthTest: boolean;
  5649. frontFace: Nullable<number>;
  5650. reset(): void;
  5651. apply(gl: WebGLRenderingContext): void;
  5652. }
  5653. }
  5654. declare module "babylonjs/States/stencilState" {
  5655. /**
  5656. * @hidden
  5657. **/
  5658. export class _StencilState {
  5659. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5660. static readonly ALWAYS: number;
  5661. /** Passed to stencilOperation to specify that stencil value must be kept */
  5662. static readonly KEEP: number;
  5663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5664. static readonly REPLACE: number;
  5665. private _isStencilTestDirty;
  5666. private _isStencilMaskDirty;
  5667. private _isStencilFuncDirty;
  5668. private _isStencilOpDirty;
  5669. private _stencilTest;
  5670. private _stencilMask;
  5671. private _stencilFunc;
  5672. private _stencilFuncRef;
  5673. private _stencilFuncMask;
  5674. private _stencilOpStencilFail;
  5675. private _stencilOpDepthFail;
  5676. private _stencilOpStencilDepthPass;
  5677. readonly isDirty: boolean;
  5678. stencilFunc: number;
  5679. stencilFuncRef: number;
  5680. stencilFuncMask: number;
  5681. stencilOpStencilFail: number;
  5682. stencilOpDepthFail: number;
  5683. stencilOpStencilDepthPass: number;
  5684. stencilMask: number;
  5685. stencilTest: boolean;
  5686. constructor();
  5687. reset(): void;
  5688. apply(gl: WebGLRenderingContext): void;
  5689. }
  5690. }
  5691. declare module "babylonjs/States/index" {
  5692. export * from "babylonjs/States/alphaCullingState";
  5693. export * from "babylonjs/States/depthCullingState";
  5694. export * from "babylonjs/States/stencilState";
  5695. }
  5696. declare module "babylonjs/Instrumentation/timeToken" {
  5697. import { Nullable } from "babylonjs/types";
  5698. /**
  5699. * @hidden
  5700. **/
  5701. export class _TimeToken {
  5702. _startTimeQuery: Nullable<WebGLQuery>;
  5703. _endTimeQuery: Nullable<WebGLQuery>;
  5704. _timeElapsedQuery: Nullable<WebGLQuery>;
  5705. _timeElapsedQueryEnded: boolean;
  5706. }
  5707. }
  5708. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5709. /**
  5710. * Class used to evalaute queries containing `and` and `or` operators
  5711. */
  5712. export class AndOrNotEvaluator {
  5713. /**
  5714. * Evaluate a query
  5715. * @param query defines the query to evaluate
  5716. * @param evaluateCallback defines the callback used to filter result
  5717. * @returns true if the query matches
  5718. */
  5719. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5720. private static _HandleParenthesisContent;
  5721. private static _SimplifyNegation;
  5722. }
  5723. }
  5724. declare module "babylonjs/Misc/tags" {
  5725. /**
  5726. * Class used to store custom tags
  5727. */
  5728. export class Tags {
  5729. /**
  5730. * Adds support for tags on the given object
  5731. * @param obj defines the object to use
  5732. */
  5733. static EnableFor(obj: any): void;
  5734. /**
  5735. * Removes tags support
  5736. * @param obj defines the object to use
  5737. */
  5738. static DisableFor(obj: any): void;
  5739. /**
  5740. * Gets a boolean indicating if the given object has tags
  5741. * @param obj defines the object to use
  5742. * @returns a boolean
  5743. */
  5744. static HasTags(obj: any): boolean;
  5745. /**
  5746. * Gets the tags available on a given object
  5747. * @param obj defines the object to use
  5748. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5749. * @returns the tags
  5750. */
  5751. static GetTags(obj: any, asString?: boolean): any;
  5752. /**
  5753. * Adds tags to an object
  5754. * @param obj defines the object to use
  5755. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5756. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5757. */
  5758. static AddTagsTo(obj: any, tagsString: string): void;
  5759. /**
  5760. * @hidden
  5761. */
  5762. static _AddTagTo(obj: any, tag: string): void;
  5763. /**
  5764. * Removes specific tags from a specific object
  5765. * @param obj defines the object to use
  5766. * @param tagsString defines the tags to remove
  5767. */
  5768. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5769. /**
  5770. * @hidden
  5771. */
  5772. static _RemoveTagFrom(obj: any, tag: string): void;
  5773. /**
  5774. * Defines if tags hosted on an object match a given query
  5775. * @param obj defines the object to use
  5776. * @param tagsQuery defines the tag query
  5777. * @returns a boolean
  5778. */
  5779. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5780. }
  5781. }
  5782. declare module "babylonjs/Maths/math.path" {
  5783. import { DeepImmutable, Nullable } from "babylonjs/types";
  5784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5785. /**
  5786. * Defines potential orientation for back face culling
  5787. */
  5788. export enum Orientation {
  5789. /**
  5790. * Clockwise
  5791. */
  5792. CW = 0,
  5793. /** Counter clockwise */
  5794. CCW = 1
  5795. }
  5796. /** Class used to represent a Bezier curve */
  5797. export class BezierCurve {
  5798. /**
  5799. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5800. * @param t defines the time
  5801. * @param x1 defines the left coordinate on X axis
  5802. * @param y1 defines the left coordinate on Y axis
  5803. * @param x2 defines the right coordinate on X axis
  5804. * @param y2 defines the right coordinate on Y axis
  5805. * @returns the interpolated value
  5806. */
  5807. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5808. }
  5809. /**
  5810. * Defines angle representation
  5811. */
  5812. export class Angle {
  5813. private _radians;
  5814. /**
  5815. * Creates an Angle object of "radians" radians (float).
  5816. * @param radians the angle in radians
  5817. */
  5818. constructor(radians: number);
  5819. /**
  5820. * Get value in degrees
  5821. * @returns the Angle value in degrees (float)
  5822. */
  5823. degrees(): number;
  5824. /**
  5825. * Get value in radians
  5826. * @returns the Angle value in radians (float)
  5827. */
  5828. radians(): number;
  5829. /**
  5830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5831. * @param a defines first vector
  5832. * @param b defines second vector
  5833. * @returns a new Angle
  5834. */
  5835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5836. /**
  5837. * Gets a new Angle object from the given float in radians
  5838. * @param radians defines the angle value in radians
  5839. * @returns a new Angle
  5840. */
  5841. static FromRadians(radians: number): Angle;
  5842. /**
  5843. * Gets a new Angle object from the given float in degrees
  5844. * @param degrees defines the angle value in degrees
  5845. * @returns a new Angle
  5846. */
  5847. static FromDegrees(degrees: number): Angle;
  5848. }
  5849. /**
  5850. * This represents an arc in a 2d space.
  5851. */
  5852. export class Arc2 {
  5853. /** Defines the start point of the arc */
  5854. startPoint: Vector2;
  5855. /** Defines the mid point of the arc */
  5856. midPoint: Vector2;
  5857. /** Defines the end point of the arc */
  5858. endPoint: Vector2;
  5859. /**
  5860. * Defines the center point of the arc.
  5861. */
  5862. centerPoint: Vector2;
  5863. /**
  5864. * Defines the radius of the arc.
  5865. */
  5866. radius: number;
  5867. /**
  5868. * Defines the angle of the arc (from mid point to end point).
  5869. */
  5870. angle: Angle;
  5871. /**
  5872. * Defines the start angle of the arc (from start point to middle point).
  5873. */
  5874. startAngle: Angle;
  5875. /**
  5876. * Defines the orientation of the arc (clock wise/counter clock wise).
  5877. */
  5878. orientation: Orientation;
  5879. /**
  5880. * Creates an Arc object from the three given points : start, middle and end.
  5881. * @param startPoint Defines the start point of the arc
  5882. * @param midPoint Defines the midlle point of the arc
  5883. * @param endPoint Defines the end point of the arc
  5884. */
  5885. constructor(
  5886. /** Defines the start point of the arc */
  5887. startPoint: Vector2,
  5888. /** Defines the mid point of the arc */
  5889. midPoint: Vector2,
  5890. /** Defines the end point of the arc */
  5891. endPoint: Vector2);
  5892. }
  5893. /**
  5894. * Represents a 2D path made up of multiple 2D points
  5895. */
  5896. export class Path2 {
  5897. private _points;
  5898. private _length;
  5899. /**
  5900. * If the path start and end point are the same
  5901. */
  5902. closed: boolean;
  5903. /**
  5904. * Creates a Path2 object from the starting 2D coordinates x and y.
  5905. * @param x the starting points x value
  5906. * @param y the starting points y value
  5907. */
  5908. constructor(x: number, y: number);
  5909. /**
  5910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5911. * @param x the added points x value
  5912. * @param y the added points y value
  5913. * @returns the updated Path2.
  5914. */
  5915. addLineTo(x: number, y: number): Path2;
  5916. /**
  5917. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5918. * @param midX middle point x value
  5919. * @param midY middle point y value
  5920. * @param endX end point x value
  5921. * @param endY end point y value
  5922. * @param numberOfSegments (default: 36)
  5923. * @returns the updated Path2.
  5924. */
  5925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5926. /**
  5927. * Closes the Path2.
  5928. * @returns the Path2.
  5929. */
  5930. close(): Path2;
  5931. /**
  5932. * Gets the sum of the distance between each sequential point in the path
  5933. * @returns the Path2 total length (float).
  5934. */
  5935. length(): number;
  5936. /**
  5937. * Gets the points which construct the path
  5938. * @returns the Path2 internal array of points.
  5939. */
  5940. getPoints(): Vector2[];
  5941. /**
  5942. * Retreives the point at the distance aways from the starting point
  5943. * @param normalizedLengthPosition the length along the path to retreive the point from
  5944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5945. */
  5946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5947. /**
  5948. * Creates a new path starting from an x and y position
  5949. * @param x starting x value
  5950. * @param y starting y value
  5951. * @returns a new Path2 starting at the coordinates (x, y).
  5952. */
  5953. static StartingAt(x: number, y: number): Path2;
  5954. }
  5955. /**
  5956. * Represents a 3D path made up of multiple 3D points
  5957. */
  5958. export class Path3D {
  5959. /**
  5960. * an array of Vector3, the curve axis of the Path3D
  5961. */
  5962. path: Vector3[];
  5963. private _curve;
  5964. private _distances;
  5965. private _tangents;
  5966. private _normals;
  5967. private _binormals;
  5968. private _raw;
  5969. /**
  5970. * new Path3D(path, normal, raw)
  5971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5973. * @param path an array of Vector3, the curve axis of the Path3D
  5974. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5976. */
  5977. constructor(
  5978. /**
  5979. * an array of Vector3, the curve axis of the Path3D
  5980. */
  5981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5982. /**
  5983. * Returns the Path3D array of successive Vector3 designing its curve.
  5984. * @returns the Path3D array of successive Vector3 designing its curve.
  5985. */
  5986. getCurve(): Vector3[];
  5987. /**
  5988. * Returns an array populated with tangent vectors on each Path3D curve point.
  5989. * @returns an array populated with tangent vectors on each Path3D curve point.
  5990. */
  5991. getTangents(): Vector3[];
  5992. /**
  5993. * Returns an array populated with normal vectors on each Path3D curve point.
  5994. * @returns an array populated with normal vectors on each Path3D curve point.
  5995. */
  5996. getNormals(): Vector3[];
  5997. /**
  5998. * Returns an array populated with binormal vectors on each Path3D curve point.
  5999. * @returns an array populated with binormal vectors on each Path3D curve point.
  6000. */
  6001. getBinormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6005. */
  6006. getDistances(): number[];
  6007. /**
  6008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6009. * @param path path which all values are copied into the curves points
  6010. * @param firstNormal which should be projected onto the curve
  6011. * @returns the same object updated.
  6012. */
  6013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6014. private _compute;
  6015. private _getFirstNonNullVector;
  6016. private _getLastNonNullVector;
  6017. private _normalVector;
  6018. }
  6019. /**
  6020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6021. * A Curve3 is designed from a series of successive Vector3.
  6022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6023. */
  6024. export class Curve3 {
  6025. private _points;
  6026. private _length;
  6027. /**
  6028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6030. * @param v1 (Vector3) the control point
  6031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6032. * @param nbPoints (integer) the wanted number of points in the curve
  6033. * @returns the created Curve3
  6034. */
  6035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6036. /**
  6037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6039. * @param v1 (Vector3) the first control point
  6040. * @param v2 (Vector3) the second control point
  6041. * @param v3 (Vector3) the end point of the Cubic Bezier
  6042. * @param nbPoints (integer) the wanted number of points in the curve
  6043. * @returns the created Curve3
  6044. */
  6045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6046. /**
  6047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6048. * @param p1 (Vector3) the origin point of the Hermite Spline
  6049. * @param t1 (Vector3) the tangent vector at the origin point
  6050. * @param p2 (Vector3) the end point of the Hermite Spline
  6051. * @param t2 (Vector3) the tangent vector at the end point
  6052. * @param nbPoints (integer) the wanted number of points in the curve
  6053. * @returns the created Curve3
  6054. */
  6055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6056. /**
  6057. * Returns a Curve3 object along a CatmullRom Spline curve :
  6058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6059. * @param nbPoints (integer) the wanted number of points between each curve control points
  6060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6061. * @returns the created Curve3
  6062. */
  6063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6064. /**
  6065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6066. * A Curve3 is designed from a series of successive Vector3.
  6067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6068. * @param points points which make up the curve
  6069. */
  6070. constructor(points: Vector3[]);
  6071. /**
  6072. * @returns the Curve3 stored array of successive Vector3
  6073. */
  6074. getPoints(): Vector3[];
  6075. /**
  6076. * @returns the computed length (float) of the curve.
  6077. */
  6078. length(): number;
  6079. /**
  6080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6082. * curveA and curveB keep unchanged.
  6083. * @param curve the curve to continue from this curve
  6084. * @returns the newly constructed curve
  6085. */
  6086. continue(curve: DeepImmutable<Curve3>): Curve3;
  6087. private _computeLength;
  6088. }
  6089. }
  6090. declare module "babylonjs/Animations/easing" {
  6091. /**
  6092. * This represents the main contract an easing function should follow.
  6093. * Easing functions are used throughout the animation system.
  6094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6095. */
  6096. export interface IEasingFunction {
  6097. /**
  6098. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6099. * of the easing function.
  6100. * The link below provides some of the most common examples of easing functions.
  6101. * @see https://easings.net/
  6102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6103. * @returns the corresponding value on the curve defined by the easing function
  6104. */
  6105. ease(gradient: number): number;
  6106. }
  6107. /**
  6108. * Base class used for every default easing function.
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class EasingFunction implements IEasingFunction {
  6112. /**
  6113. * Interpolation follows the mathematical formula associated with the easing function.
  6114. */
  6115. static readonly EASINGMODE_EASEIN: number;
  6116. /**
  6117. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6118. */
  6119. static readonly EASINGMODE_EASEOUT: number;
  6120. /**
  6121. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6122. */
  6123. static readonly EASINGMODE_EASEINOUT: number;
  6124. private _easingMode;
  6125. /**
  6126. * Sets the easing mode of the current function.
  6127. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6128. */
  6129. setEasingMode(easingMode: number): void;
  6130. /**
  6131. * Gets the current easing mode.
  6132. * @returns the easing mode
  6133. */
  6134. getEasingMode(): number;
  6135. /**
  6136. * @hidden
  6137. */
  6138. easeInCore(gradient: number): number;
  6139. /**
  6140. * Given an input gradient between 0 and 1, this returns the corresponding value
  6141. * of the easing function.
  6142. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6143. * @returns the corresponding value on the curve defined by the easing function
  6144. */
  6145. ease(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a circle shape (see link below).
  6149. * @see https://easings.net/#easeInCirc
  6150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class CircleEase extends EasingFunction implements IEasingFunction {
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a ease back shape (see link below).
  6158. * @see https://easings.net/#easeInBack
  6159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class BackEase extends EasingFunction implements IEasingFunction {
  6162. /** Defines the amplitude of the function */
  6163. amplitude: number;
  6164. /**
  6165. * Instantiates a back ease easing
  6166. * @see https://easings.net/#easeInBack
  6167. * @param amplitude Defines the amplitude of the function
  6168. */
  6169. constructor(
  6170. /** Defines the amplitude of the function */
  6171. amplitude?: number);
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bouncing shape (see link below).
  6177. * @see https://easings.net/#easeInBounce
  6178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BounceEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the number of bounces */
  6182. bounces: number;
  6183. /** Defines the amplitude of the bounce */
  6184. bounciness: number;
  6185. /**
  6186. * Instantiates a bounce easing
  6187. * @see https://easings.net/#easeInBounce
  6188. * @param bounces Defines the number of bounces
  6189. * @param bounciness Defines the amplitude of the bounce
  6190. */
  6191. constructor(
  6192. /** Defines the number of bounces */
  6193. bounces?: number,
  6194. /** Defines the amplitude of the bounce */
  6195. bounciness?: number);
  6196. /** @hidden */
  6197. easeInCore(gradient: number): number;
  6198. }
  6199. /**
  6200. * Easing function with a power of 3 shape (see link below).
  6201. * @see https://easings.net/#easeInCubic
  6202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6203. */
  6204. export class CubicEase extends EasingFunction implements IEasingFunction {
  6205. /** @hidden */
  6206. easeInCore(gradient: number): number;
  6207. }
  6208. /**
  6209. * Easing function with an elastic shape (see link below).
  6210. * @see https://easings.net/#easeInElastic
  6211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6212. */
  6213. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6214. /** Defines the number of oscillations*/
  6215. oscillations: number;
  6216. /** Defines the amplitude of the oscillations*/
  6217. springiness: number;
  6218. /**
  6219. * Instantiates an elastic easing function
  6220. * @see https://easings.net/#easeInElastic
  6221. * @param oscillations Defines the number of oscillations
  6222. * @param springiness Defines the amplitude of the oscillations
  6223. */
  6224. constructor(
  6225. /** Defines the number of oscillations*/
  6226. oscillations?: number,
  6227. /** Defines the amplitude of the oscillations*/
  6228. springiness?: number);
  6229. /** @hidden */
  6230. easeInCore(gradient: number): number;
  6231. }
  6232. /**
  6233. * Easing function with an exponential shape (see link below).
  6234. * @see https://easings.net/#easeInExpo
  6235. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6236. */
  6237. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6238. /** Defines the exponent of the function */
  6239. exponent: number;
  6240. /**
  6241. * Instantiates an exponential easing function
  6242. * @see https://easings.net/#easeInExpo
  6243. * @param exponent Defines the exponent of the function
  6244. */
  6245. constructor(
  6246. /** Defines the exponent of the function */
  6247. exponent?: number);
  6248. /** @hidden */
  6249. easeInCore(gradient: number): number;
  6250. }
  6251. /**
  6252. * Easing function with a power shape (see link below).
  6253. * @see https://easings.net/#easeInQuad
  6254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6255. */
  6256. export class PowerEase extends EasingFunction implements IEasingFunction {
  6257. /** Defines the power of the function */
  6258. power: number;
  6259. /**
  6260. * Instantiates an power base easing function
  6261. * @see https://easings.net/#easeInQuad
  6262. * @param power Defines the power of the function
  6263. */
  6264. constructor(
  6265. /** Defines the power of the function */
  6266. power?: number);
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a power of 2 shape (see link below).
  6272. * @see https://easings.net/#easeInQuad
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a power of 4 shape (see link below).
  6281. * @see https://easings.net/#easeInQuart
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6285. /** @hidden */
  6286. easeInCore(gradient: number): number;
  6287. }
  6288. /**
  6289. * Easing function with a power of 5 shape (see link below).
  6290. * @see https://easings.net/#easeInQuint
  6291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6292. */
  6293. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6294. /** @hidden */
  6295. easeInCore(gradient: number): number;
  6296. }
  6297. /**
  6298. * Easing function with a sin shape (see link below).
  6299. * @see https://easings.net/#easeInSine
  6300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6301. */
  6302. export class SineEase extends EasingFunction implements IEasingFunction {
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. /**
  6307. * Easing function with a bezier shape (see link below).
  6308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6312. /** Defines the x component of the start tangent in the bezier curve */
  6313. x1: number;
  6314. /** Defines the y component of the start tangent in the bezier curve */
  6315. y1: number;
  6316. /** Defines the x component of the end tangent in the bezier curve */
  6317. x2: number;
  6318. /** Defines the y component of the end tangent in the bezier curve */
  6319. y2: number;
  6320. /**
  6321. * Instantiates a bezier function
  6322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6323. * @param x1 Defines the x component of the start tangent in the bezier curve
  6324. * @param y1 Defines the y component of the start tangent in the bezier curve
  6325. * @param x2 Defines the x component of the end tangent in the bezier curve
  6326. * @param y2 Defines the y component of the end tangent in the bezier curve
  6327. */
  6328. constructor(
  6329. /** Defines the x component of the start tangent in the bezier curve */
  6330. x1?: number,
  6331. /** Defines the y component of the start tangent in the bezier curve */
  6332. y1?: number,
  6333. /** Defines the x component of the end tangent in the bezier curve */
  6334. x2?: number,
  6335. /** Defines the y component of the end tangent in the bezier curve */
  6336. y2?: number);
  6337. /** @hidden */
  6338. easeInCore(gradient: number): number;
  6339. }
  6340. }
  6341. declare module "babylonjs/Animations/animationKey" {
  6342. /**
  6343. * Defines an interface which represents an animation key frame
  6344. */
  6345. export interface IAnimationKey {
  6346. /**
  6347. * Frame of the key frame
  6348. */
  6349. frame: number;
  6350. /**
  6351. * Value at the specifies key frame
  6352. */
  6353. value: any;
  6354. /**
  6355. * The input tangent for the cubic hermite spline
  6356. */
  6357. inTangent?: any;
  6358. /**
  6359. * The output tangent for the cubic hermite spline
  6360. */
  6361. outTangent?: any;
  6362. /**
  6363. * The animation interpolation type
  6364. */
  6365. interpolation?: AnimationKeyInterpolation;
  6366. }
  6367. /**
  6368. * Enum for the animation key frame interpolation type
  6369. */
  6370. export enum AnimationKeyInterpolation {
  6371. /**
  6372. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6373. */
  6374. STEP = 1
  6375. }
  6376. }
  6377. declare module "babylonjs/Animations/animationRange" {
  6378. /**
  6379. * Represents the range of an animation
  6380. */
  6381. export class AnimationRange {
  6382. /**The name of the animation range**/
  6383. name: string;
  6384. /**The starting frame of the animation */
  6385. from: number;
  6386. /**The ending frame of the animation*/
  6387. to: number;
  6388. /**
  6389. * Initializes the range of an animation
  6390. * @param name The name of the animation range
  6391. * @param from The starting frame of the animation
  6392. * @param to The ending frame of the animation
  6393. */
  6394. constructor(
  6395. /**The name of the animation range**/
  6396. name: string,
  6397. /**The starting frame of the animation */
  6398. from: number,
  6399. /**The ending frame of the animation*/
  6400. to: number);
  6401. /**
  6402. * Makes a copy of the animation range
  6403. * @returns A copy of the animation range
  6404. */
  6405. clone(): AnimationRange;
  6406. }
  6407. }
  6408. declare module "babylonjs/Animations/animationEvent" {
  6409. /**
  6410. * Composed of a frame, and an action function
  6411. */
  6412. export class AnimationEvent {
  6413. /** The frame for which the event is triggered **/
  6414. frame: number;
  6415. /** The event to perform when triggered **/
  6416. action: (currentFrame: number) => void;
  6417. /** Specifies if the event should be triggered only once**/
  6418. onlyOnce?: boolean | undefined;
  6419. /**
  6420. * Specifies if the animation event is done
  6421. */
  6422. isDone: boolean;
  6423. /**
  6424. * Initializes the animation event
  6425. * @param frame The frame for which the event is triggered
  6426. * @param action The event to perform when triggered
  6427. * @param onlyOnce Specifies if the event should be triggered only once
  6428. */
  6429. constructor(
  6430. /** The frame for which the event is triggered **/
  6431. frame: number,
  6432. /** The event to perform when triggered **/
  6433. action: (currentFrame: number) => void,
  6434. /** Specifies if the event should be triggered only once**/
  6435. onlyOnce?: boolean | undefined);
  6436. /** @hidden */
  6437. _clone(): AnimationEvent;
  6438. }
  6439. }
  6440. declare module "babylonjs/Behaviors/behavior" {
  6441. import { Nullable } from "babylonjs/types";
  6442. /**
  6443. * Interface used to define a behavior
  6444. */
  6445. export interface Behavior<T> {
  6446. /** gets or sets behavior's name */
  6447. name: string;
  6448. /**
  6449. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6450. */
  6451. init(): void;
  6452. /**
  6453. * Called when the behavior is attached to a target
  6454. * @param target defines the target where the behavior is attached to
  6455. */
  6456. attach(target: T): void;
  6457. /**
  6458. * Called when the behavior is detached from its target
  6459. */
  6460. detach(): void;
  6461. }
  6462. /**
  6463. * Interface implemented by classes supporting behaviors
  6464. */
  6465. export interface IBehaviorAware<T> {
  6466. /**
  6467. * Attach a behavior
  6468. * @param behavior defines the behavior to attach
  6469. * @returns the current host
  6470. */
  6471. addBehavior(behavior: Behavior<T>): T;
  6472. /**
  6473. * Remove a behavior from the current object
  6474. * @param behavior defines the behavior to detach
  6475. * @returns the current host
  6476. */
  6477. removeBehavior(behavior: Behavior<T>): T;
  6478. /**
  6479. * Gets a behavior using its name to search
  6480. * @param name defines the name to search
  6481. * @returns the behavior or null if not found
  6482. */
  6483. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6484. }
  6485. }
  6486. declare module "babylonjs/Misc/smartArray" {
  6487. /**
  6488. * Defines an array and its length.
  6489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6490. */
  6491. export interface ISmartArrayLike<T> {
  6492. /**
  6493. * The data of the array.
  6494. */
  6495. data: Array<T>;
  6496. /**
  6497. * The active length of the array.
  6498. */
  6499. length: number;
  6500. }
  6501. /**
  6502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6503. */
  6504. export class SmartArray<T> implements ISmartArrayLike<T> {
  6505. /**
  6506. * The full set of data from the array.
  6507. */
  6508. data: Array<T>;
  6509. /**
  6510. * The active length of the array.
  6511. */
  6512. length: number;
  6513. protected _id: number;
  6514. /**
  6515. * Instantiates a Smart Array.
  6516. * @param capacity defines the default capacity of the array.
  6517. */
  6518. constructor(capacity: number);
  6519. /**
  6520. * Pushes a value at the end of the active data.
  6521. * @param value defines the object to push in the array.
  6522. */
  6523. push(value: T): void;
  6524. /**
  6525. * Iterates over the active data and apply the lambda to them.
  6526. * @param func defines the action to apply on each value.
  6527. */
  6528. forEach(func: (content: T) => void): void;
  6529. /**
  6530. * Sorts the full sets of data.
  6531. * @param compareFn defines the comparison function to apply.
  6532. */
  6533. sort(compareFn: (a: T, b: T) => number): void;
  6534. /**
  6535. * Resets the active data to an empty array.
  6536. */
  6537. reset(): void;
  6538. /**
  6539. * Releases all the data from the array as well as the array.
  6540. */
  6541. dispose(): void;
  6542. /**
  6543. * Concats the active data with a given array.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concat(array: any): void;
  6547. /**
  6548. * Returns the position of a value in the active data.
  6549. * @param value defines the value to find the index for
  6550. * @returns the index if found in the active data otherwise -1
  6551. */
  6552. indexOf(value: T): number;
  6553. /**
  6554. * Returns whether an element is part of the active data.
  6555. * @param value defines the value to look for
  6556. * @returns true if found in the active data otherwise false
  6557. */
  6558. contains(value: T): boolean;
  6559. private static _GlobalId;
  6560. }
  6561. /**
  6562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6563. * The data in this array can only be present once
  6564. */
  6565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6566. private _duplicateId;
  6567. /**
  6568. * Pushes a value at the end of the active data.
  6569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6570. * @param value defines the object to push in the array.
  6571. */
  6572. push(value: T): void;
  6573. /**
  6574. * Pushes a value at the end of the active data.
  6575. * If the data is already present, it won t be added again
  6576. * @param value defines the object to push in the array.
  6577. * @returns true if added false if it was already present
  6578. */
  6579. pushNoDuplicate(value: T): boolean;
  6580. /**
  6581. * Resets the active data to an empty array.
  6582. */
  6583. reset(): void;
  6584. /**
  6585. * Concats the active data with a given array.
  6586. * This ensures no dupplicate will be present in the result.
  6587. * @param array defines the data to concatenate with.
  6588. */
  6589. concatWithNoDuplicate(array: any): void;
  6590. }
  6591. }
  6592. declare module "babylonjs/Cameras/cameraInputsManager" {
  6593. import { Nullable } from "babylonjs/types";
  6594. import { Camera } from "babylonjs/Cameras/camera";
  6595. /**
  6596. * @ignore
  6597. * This is a list of all the different input types that are available in the application.
  6598. * Fo instance: ArcRotateCameraGamepadInput...
  6599. */
  6600. export var CameraInputTypes: {};
  6601. /**
  6602. * This is the contract to implement in order to create a new input class.
  6603. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6604. */
  6605. export interface ICameraInput<TCamera extends Camera> {
  6606. /**
  6607. * Defines the camera the input is attached to.
  6608. */
  6609. camera: Nullable<TCamera>;
  6610. /**
  6611. * Gets the class name of the current intput.
  6612. * @returns the class name
  6613. */
  6614. getClassName(): string;
  6615. /**
  6616. * Get the friendly name associated with the input class.
  6617. * @returns the input friendly name
  6618. */
  6619. getSimpleName(): string;
  6620. /**
  6621. * Attach the input controls to a specific dom element to get the input from.
  6622. * @param element Defines the element the controls should be listened from
  6623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6624. */
  6625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6626. /**
  6627. * Detach the current controls from the specified dom element.
  6628. * @param element Defines the element to stop listening the inputs from
  6629. */
  6630. detachControl(element: Nullable<HTMLElement>): void;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs?: () => void;
  6636. }
  6637. /**
  6638. * Represents a map of input types to input instance or input index to input instance.
  6639. */
  6640. export interface CameraInputsMap<TCamera extends Camera> {
  6641. /**
  6642. * Accessor to the input by input type.
  6643. */
  6644. [name: string]: ICameraInput<TCamera>;
  6645. /**
  6646. * Accessor to the input by input index.
  6647. */
  6648. [idx: number]: ICameraInput<TCamera>;
  6649. }
  6650. /**
  6651. * This represents the input manager used within a camera.
  6652. * It helps dealing with all the different kind of input attached to a camera.
  6653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6654. */
  6655. export class CameraInputsManager<TCamera extends Camera> {
  6656. /**
  6657. * Defines the list of inputs attahed to the camera.
  6658. */
  6659. attached: CameraInputsMap<TCamera>;
  6660. /**
  6661. * Defines the dom element the camera is collecting inputs from.
  6662. * This is null if the controls have not been attached.
  6663. */
  6664. attachedElement: Nullable<HTMLElement>;
  6665. /**
  6666. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6667. */
  6668. noPreventDefault: boolean;
  6669. /**
  6670. * Defined the camera the input manager belongs to.
  6671. */
  6672. camera: TCamera;
  6673. /**
  6674. * Update the current camera state depending on the inputs that have been used this frame.
  6675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6676. */
  6677. checkInputs: () => void;
  6678. /**
  6679. * Instantiate a new Camera Input Manager.
  6680. * @param camera Defines the camera the input manager blongs to
  6681. */
  6682. constructor(camera: TCamera);
  6683. /**
  6684. * Add an input method to a camera
  6685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6686. * @param input camera input method
  6687. */
  6688. add(input: ICameraInput<TCamera>): void;
  6689. /**
  6690. * Remove a specific input method from a camera
  6691. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6692. * @param inputToRemove camera input method
  6693. */
  6694. remove(inputToRemove: ICameraInput<TCamera>): void;
  6695. /**
  6696. * Remove a specific input type from a camera
  6697. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6698. * @param inputType the type of the input to remove
  6699. */
  6700. removeByType(inputType: string): void;
  6701. private _addCheckInputs;
  6702. /**
  6703. * Attach the input controls to the currently attached dom element to listen the events from.
  6704. * @param input Defines the input to attach
  6705. */
  6706. attachInput(input: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6709. * @param element Defines the dom element to collect the events from
  6710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6711. */
  6712. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6713. /**
  6714. * Detach the current manager inputs controls from a specific dom element.
  6715. * @param element Defines the dom element to collect the events from
  6716. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6717. */
  6718. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6719. /**
  6720. * Rebuild the dynamic inputCheck function from the current list of
  6721. * defined inputs in the manager.
  6722. */
  6723. rebuildInputCheck(): void;
  6724. /**
  6725. * Remove all attached input methods from a camera
  6726. */
  6727. clear(): void;
  6728. /**
  6729. * Serialize the current input manager attached to a camera.
  6730. * This ensures than once parsed,
  6731. * the input associated to the camera will be identical to the current ones
  6732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6733. */
  6734. serialize(serializedCamera: any): void;
  6735. /**
  6736. * Parses an input manager serialized JSON to restore the previous list of inputs
  6737. * and states associated to a camera.
  6738. * @param parsedCamera Defines the JSON to parse
  6739. */
  6740. parse(parsedCamera: any): void;
  6741. }
  6742. }
  6743. declare module "babylonjs/Collisions/intersectionInfo" {
  6744. import { Nullable } from "babylonjs/types";
  6745. /**
  6746. * @hidden
  6747. */
  6748. export class IntersectionInfo {
  6749. bu: Nullable<number>;
  6750. bv: Nullable<number>;
  6751. distance: number;
  6752. faceId: number;
  6753. subMeshId: number;
  6754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6755. }
  6756. }
  6757. declare module "babylonjs/Maths/math.plane" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6760. /**
  6761. * Represens a plane by the equation ax + by + cz + d = 0
  6762. */
  6763. export class Plane {
  6764. private static _TmpMatrix;
  6765. /**
  6766. * Normal of the plane (a,b,c)
  6767. */
  6768. normal: Vector3;
  6769. /**
  6770. * d component of the plane
  6771. */
  6772. d: number;
  6773. /**
  6774. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6775. * @param a a component of the plane
  6776. * @param b b component of the plane
  6777. * @param c c component of the plane
  6778. * @param d d component of the plane
  6779. */
  6780. constructor(a: number, b: number, c: number, d: number);
  6781. /**
  6782. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6783. */
  6784. asArray(): number[];
  6785. /**
  6786. * @returns a new plane copied from the current Plane.
  6787. */
  6788. clone(): Plane;
  6789. /**
  6790. * @returns the string "Plane".
  6791. */
  6792. getClassName(): string;
  6793. /**
  6794. * @returns the Plane hash code.
  6795. */
  6796. getHashCode(): number;
  6797. /**
  6798. * Normalize the current Plane in place.
  6799. * @returns the updated Plane.
  6800. */
  6801. normalize(): Plane;
  6802. /**
  6803. * Applies a transformation the plane and returns the result
  6804. * @param transformation the transformation matrix to be applied to the plane
  6805. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6806. */
  6807. transform(transformation: DeepImmutable<Matrix>): Plane;
  6808. /**
  6809. * Calcualtte the dot product between the point and the plane normal
  6810. * @param point point to calculate the dot product with
  6811. * @returns the dot product (float) of the point coordinates and the plane normal.
  6812. */
  6813. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6814. /**
  6815. * Updates the current Plane from the plane defined by the three given points.
  6816. * @param point1 one of the points used to contruct the plane
  6817. * @param point2 one of the points used to contruct the plane
  6818. * @param point3 one of the points used to contruct the plane
  6819. * @returns the updated Plane.
  6820. */
  6821. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6822. /**
  6823. * Checks if the plane is facing a given direction
  6824. * @param direction the direction to check if the plane is facing
  6825. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6826. * @returns True is the vector "direction" is the same side than the plane normal.
  6827. */
  6828. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6829. /**
  6830. * Calculates the distance to a point
  6831. * @param point point to calculate distance to
  6832. * @returns the signed distance (float) from the given point to the Plane.
  6833. */
  6834. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6835. /**
  6836. * Creates a plane from an array
  6837. * @param array the array to create a plane from
  6838. * @returns a new Plane from the given array.
  6839. */
  6840. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6841. /**
  6842. * Creates a plane from three points
  6843. * @param point1 point used to create the plane
  6844. * @param point2 point used to create the plane
  6845. * @param point3 point used to create the plane
  6846. * @returns a new Plane defined by the three given points.
  6847. */
  6848. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6849. /**
  6850. * Creates a plane from an origin point and a normal
  6851. * @param origin origin of the plane to be constructed
  6852. * @param normal normal of the plane to be constructed
  6853. * @returns a new Plane the normal vector to this plane at the given origin point.
  6854. * Note : the vector "normal" is updated because normalized.
  6855. */
  6856. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6857. /**
  6858. * Calculates the distance from a plane and a point
  6859. * @param origin origin of the plane to be constructed
  6860. * @param normal normal of the plane to be constructed
  6861. * @param point point to calculate distance to
  6862. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6863. */
  6864. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6865. }
  6866. }
  6867. declare module "babylonjs/Culling/boundingSphere" {
  6868. import { DeepImmutable } from "babylonjs/types";
  6869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6870. import { Plane } from "babylonjs/Maths/math.plane";
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module "babylonjs/Culling/boundingBox" {
  6957. import { DeepImmutable } from "babylonjs/types";
  6958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6959. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6960. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6961. import { Plane } from "babylonjs/Maths/math.plane";
  6962. /**
  6963. * Class used to store bounding box information
  6964. */
  6965. export class BoundingBox implements ICullable {
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in local space
  6968. */
  6969. readonly vectors: Vector3[];
  6970. /**
  6971. * Gets the center of the bounding box in local space
  6972. */
  6973. readonly center: Vector3;
  6974. /**
  6975. * Gets the center of the bounding box in world space
  6976. */
  6977. readonly centerWorld: Vector3;
  6978. /**
  6979. * Gets the extend size in local space
  6980. */
  6981. readonly extendSize: Vector3;
  6982. /**
  6983. * Gets the extend size in world space
  6984. */
  6985. readonly extendSizeWorld: Vector3;
  6986. /**
  6987. * Gets the OBB (object bounding box) directions
  6988. */
  6989. readonly directions: Vector3[];
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in world space
  6992. */
  6993. readonly vectorsWorld: Vector3[];
  6994. /**
  6995. * Gets the minimum vector in world space
  6996. */
  6997. readonly minimumWorld: Vector3;
  6998. /**
  6999. * Gets the maximum vector in world space
  7000. */
  7001. readonly maximumWorld: Vector3;
  7002. /**
  7003. * Gets the minimum vector in local space
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * Gets the maximum vector in local space
  7008. */
  7009. readonly maximum: Vector3;
  7010. private _worldMatrix;
  7011. private static readonly TmpVector3;
  7012. /**
  7013. * @hidden
  7014. */
  7015. _tag: number;
  7016. /**
  7017. * Creates a new bounding box
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding box by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingBox;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */
  7042. _update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Tests if the bounding box is intersecting the frustum planes
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if the bounding box is entirely inside the frustum planes
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if there is an inclusion
  7053. */
  7054. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding box
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding box
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if the bounding box intersects with a bounding sphere
  7063. * @param sphere defines the sphere to test
  7064. * @returns true if there is an intersection
  7065. */
  7066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7067. /**
  7068. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7069. * @param min defines the min vector to use
  7070. * @param max defines the max vector to use
  7071. * @returns true if there is an intersection
  7072. */
  7073. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if two bounding boxes are intersections
  7076. * @param box0 defines the first box to test
  7077. * @param box1 defines the second box to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7081. /**
  7082. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7083. * @param minPoint defines the minimum vector of the bounding box
  7084. * @param maxPoint defines the maximum vector of the bounding box
  7085. * @param sphereCenter defines the sphere center
  7086. * @param sphereRadius defines the sphere radius
  7087. * @returns true if there is an intersection
  7088. */
  7089. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7090. /**
  7091. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7092. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7093. * @param frustumPlanes defines the frustum planes to test
  7094. * @return true if there is an inclusion
  7095. */
  7096. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7097. /**
  7098. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7099. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7100. * @param frustumPlanes defines the frustum planes to test
  7101. * @return true if there is an intersection
  7102. */
  7103. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. }
  7105. }
  7106. declare module "babylonjs/Collisions/collider" {
  7107. import { Nullable, IndicesArray } from "babylonjs/types";
  7108. import { Vector3 } from "babylonjs/Maths/math.vector";
  7109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7110. import { Plane } from "babylonjs/Maths/math.plane";
  7111. /** @hidden */
  7112. export class Collider {
  7113. /** Define if a collision was found */
  7114. collisionFound: boolean;
  7115. /**
  7116. * Define last intersection point in local space
  7117. */
  7118. intersectionPoint: Vector3;
  7119. /**
  7120. * Define last collided mesh
  7121. */
  7122. collidedMesh: Nullable<AbstractMesh>;
  7123. private _collisionPoint;
  7124. private _planeIntersectionPoint;
  7125. private _tempVector;
  7126. private _tempVector2;
  7127. private _tempVector3;
  7128. private _tempVector4;
  7129. private _edge;
  7130. private _baseToVertex;
  7131. private _destinationPoint;
  7132. private _slidePlaneNormal;
  7133. private _displacementVector;
  7134. /** @hidden */
  7135. _radius: Vector3;
  7136. /** @hidden */
  7137. _retry: number;
  7138. private _velocity;
  7139. private _basePoint;
  7140. private _epsilon;
  7141. /** @hidden */
  7142. _velocityWorldLength: number;
  7143. /** @hidden */
  7144. _basePointWorld: Vector3;
  7145. private _velocityWorld;
  7146. private _normalizedVelocity;
  7147. /** @hidden */
  7148. _initialVelocity: Vector3;
  7149. /** @hidden */
  7150. _initialPosition: Vector3;
  7151. private _nearestDistance;
  7152. private _collisionMask;
  7153. collisionMask: number;
  7154. /**
  7155. * Gets the plane normal used to compute the sliding response (in local space)
  7156. */
  7157. readonly slidePlaneNormal: Vector3;
  7158. /** @hidden */
  7159. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7160. /** @hidden */
  7161. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7162. /** @hidden */
  7163. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7164. /** @hidden */
  7165. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7166. /** @hidden */
  7167. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7168. /** @hidden */
  7169. _getResponse(pos: Vector3, vel: Vector3): void;
  7170. }
  7171. }
  7172. declare module "babylonjs/Culling/boundingInfo" {
  7173. import { DeepImmutable } from "babylonjs/types";
  7174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7175. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7176. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7177. import { Plane } from "babylonjs/Maths/math.plane";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Maths/math.functions" {
  7294. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7296. /**
  7297. * Extracts minimum and maximum values from a list of indexed positions
  7298. * @param positions defines the positions to use
  7299. * @param indices defines the indices to the positions
  7300. * @param indexStart defines the start index
  7301. * @param indexCount defines the end index
  7302. * @param bias defines bias value to add to the result
  7303. * @return minimum and maximum values
  7304. */
  7305. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7306. minimum: Vector3;
  7307. maximum: Vector3;
  7308. };
  7309. /**
  7310. * Extracts minimum and maximum values from a list of positions
  7311. * @param positions defines the positions to use
  7312. * @param start defines the start index in the positions array
  7313. * @param count defines the number of positions to handle
  7314. * @param bias defines bias value to add to the result
  7315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. }
  7323. declare module "babylonjs/Misc/iInspectable" {
  7324. /**
  7325. * Enum that determines the text-wrapping mode to use.
  7326. */
  7327. export enum InspectableType {
  7328. /**
  7329. * Checkbox for booleans
  7330. */
  7331. Checkbox = 0,
  7332. /**
  7333. * Sliders for numbers
  7334. */
  7335. Slider = 1,
  7336. /**
  7337. * Vector3
  7338. */
  7339. Vector3 = 2,
  7340. /**
  7341. * Quaternions
  7342. */
  7343. Quaternion = 3,
  7344. /**
  7345. * Color3
  7346. */
  7347. Color3 = 4,
  7348. /**
  7349. * String
  7350. */
  7351. String = 5
  7352. }
  7353. /**
  7354. * Interface used to define custom inspectable properties.
  7355. * This interface is used by the inspector to display custom property grids
  7356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7357. */
  7358. export interface IInspectable {
  7359. /**
  7360. * Gets the label to display
  7361. */
  7362. label: string;
  7363. /**
  7364. * Gets the name of the property to edit
  7365. */
  7366. propertyName: string;
  7367. /**
  7368. * Gets the type of the editor to use
  7369. */
  7370. type: InspectableType;
  7371. /**
  7372. * Gets the minimum value of the property when using in "slider" mode
  7373. */
  7374. min?: number;
  7375. /**
  7376. * Gets the maximum value of the property when using in "slider" mode
  7377. */
  7378. max?: number;
  7379. /**
  7380. * Gets the setp to use when using in "slider" mode
  7381. */
  7382. step?: number;
  7383. }
  7384. }
  7385. declare module "babylonjs/Misc/timingTools" {
  7386. /**
  7387. * Class used to provide helper for timing
  7388. */
  7389. export class TimingTools {
  7390. /**
  7391. * Polyfill for setImmediate
  7392. * @param action defines the action to execute after the current execution block
  7393. */
  7394. static SetImmediate(action: () => void): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/instantiationTools" {
  7398. /**
  7399. * Class used to enable instatition of objects by class name
  7400. */
  7401. export class InstantiationTools {
  7402. /**
  7403. * Use this object to register external classes like custom textures or material
  7404. * to allow the laoders to instantiate them
  7405. */
  7406. static RegisteredExternalClasses: {
  7407. [key: string]: Object;
  7408. };
  7409. /**
  7410. * Tries to instantiate a new object from a given class name
  7411. * @param className defines the class name to instantiate
  7412. * @returns the new object or null if the system was not able to do the instantiation
  7413. */
  7414. static Instantiate(className: string): any;
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7418. import { Nullable } from "babylonjs/types";
  7419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7420. /**
  7421. * This represents the required contract to create a new type of texture loader.
  7422. */
  7423. export interface IInternalTextureLoader {
  7424. /**
  7425. * Defines wether the loader supports cascade loading the different faces.
  7426. */
  7427. supportCascades: boolean;
  7428. /**
  7429. * This returns if the loader support the current file information.
  7430. * @param extension defines the file extension of the file being loaded
  7431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7432. * @param fallback defines the fallback internal texture if any
  7433. * @param isBase64 defines whether the texture is encoded as a base64
  7434. * @param isBuffer defines whether the texture data are stored as a buffer
  7435. * @returns true if the loader can load the specified file
  7436. */
  7437. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7438. /**
  7439. * Transform the url before loading if required.
  7440. * @param rootUrl the url of the texture
  7441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7442. * @returns the transformed texture
  7443. */
  7444. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7445. /**
  7446. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7447. * @param rootUrl the url of the texture
  7448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7449. * @returns the fallback texture
  7450. */
  7451. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7452. /**
  7453. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7454. * @param data contains the texture data
  7455. * @param texture defines the BabylonJS internal texture
  7456. * @param createPolynomials will be true if polynomials have been requested
  7457. * @param onLoad defines the callback to trigger once the texture is ready
  7458. * @param onError defines the callback to trigger in case of error
  7459. */
  7460. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7461. /**
  7462. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7463. * @param data contains the texture data
  7464. * @param texture defines the BabylonJS internal texture
  7465. * @param callback defines the method to call once ready to upload
  7466. */
  7467. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7468. }
  7469. }
  7470. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7472. import { Nullable } from "babylonjs/types";
  7473. import { Scene } from "babylonjs/scene";
  7474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7475. module "babylonjs/Engines/engine" {
  7476. interface Engine {
  7477. /**
  7478. * Creates a depth stencil cube texture.
  7479. * This is only available in WebGL 2.
  7480. * @param size The size of face edge in the cube texture.
  7481. * @param options The options defining the cube texture.
  7482. * @returns The cube texture
  7483. */
  7484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7500. * @returns the cube texture as an InternalTexture
  7501. */
  7502. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7503. /**
  7504. * Creates a cube texture
  7505. * @param rootUrl defines the url where the files to load is located
  7506. * @param scene defines the current scene
  7507. * @param files defines the list of files to load (1 per face)
  7508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7509. * @param onLoad defines an optional callback raised when the texture is loaded
  7510. * @param onError defines an optional callback raised if there is an issue to load the texture
  7511. * @param format defines the format of the data
  7512. * @param forcedExtension defines the extension to use to pick the right loader
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7529. * @returns the cube texture as an InternalTexture
  7530. */
  7531. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7532. /** @hidden */
  7533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7534. /** @hidden */
  7535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7536. /** @hidden */
  7537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7538. /** @hidden */
  7539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7540. }
  7541. }
  7542. }
  7543. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7544. import { Nullable } from "babylonjs/types";
  7545. import { Scene } from "babylonjs/scene";
  7546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7548. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7549. /**
  7550. * Class for creating a cube texture
  7551. */
  7552. export class CubeTexture extends BaseTexture {
  7553. private _delayedOnLoad;
  7554. /**
  7555. * The url of the texture
  7556. */
  7557. url: string;
  7558. /**
  7559. * Gets or sets the center of the bounding box associated with the cube texture.
  7560. * It must define where the camera used to render the texture was set
  7561. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7562. */
  7563. boundingBoxPosition: Vector3;
  7564. private _boundingBoxSize;
  7565. /**
  7566. * Gets or sets the size of the bounding box associated with the cube texture
  7567. * When defined, the cubemap will switch to local mode
  7568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7569. * @example https://www.babylonjs-playground.com/#RNASML
  7570. */
  7571. /**
  7572. * Returns the bounding box size
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxSize: Vector3;
  7576. protected _rotationY: number;
  7577. /**
  7578. * Sets texture matrix rotation angle around Y axis in radians.
  7579. */
  7580. /**
  7581. * Gets texture matrix rotation angle around Y axis radians.
  7582. */
  7583. rotationY: number;
  7584. /**
  7585. * Are mip maps generated for this texture or not.
  7586. */
  7587. readonly noMipmap: boolean;
  7588. private _noMipmap;
  7589. private _files;
  7590. private _extensions;
  7591. private _textureMatrix;
  7592. private _format;
  7593. private _createPolynomials;
  7594. /** @hidden */
  7595. _prefiltered: boolean;
  7596. /**
  7597. * Creates a cube texture from an array of image urls
  7598. * @param files defines an array of image urls
  7599. * @param scene defines the hosting scene
  7600. * @param noMipmap specifies if mip maps are not used
  7601. * @returns a cube texture
  7602. */
  7603. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7604. /**
  7605. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7606. * @param url defines the url of the prefiltered texture
  7607. * @param scene defines the scene the texture is attached to
  7608. * @param forcedExtension defines the extension of the file if different from the url
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @return the prefiltered texture
  7611. */
  7612. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7613. /**
  7614. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7615. * as prefiltered data.
  7616. * @param rootUrl defines the url of the texture or the root name of the six images
  7617. * @param scene defines the scene the texture is attached to
  7618. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7619. * @param noMipmap defines if mipmaps should be created or not
  7620. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7621. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7622. * @param onError defines a callback triggered in case of error during load
  7623. * @param format defines the internal format to use for the texture once loaded
  7624. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7625. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7626. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @return the cube texture
  7630. */
  7631. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7632. /**
  7633. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7634. */
  7635. readonly isPrefiltered: boolean;
  7636. /**
  7637. * Get the current class name of the texture useful for serialization or dynamic coding.
  7638. * @returns "CubeTexture"
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Update the url (and optional buffer) of this texture if url was null during construction.
  7643. * @param url the url of the texture
  7644. * @param forcedExtension defines the extension to use
  7645. * @param onLoad callback called when the texture is loaded (defaults to null)
  7646. */
  7647. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7648. /**
  7649. * Delays loading of the cube texture
  7650. * @param forcedExtension defines the extension to use
  7651. */
  7652. delayLoad(forcedExtension?: string): void;
  7653. /**
  7654. * Returns the reflection texture matrix
  7655. * @returns the reflection texture matrix
  7656. */
  7657. getReflectionTextureMatrix(): Matrix;
  7658. /**
  7659. * Sets the reflection texture matrix
  7660. * @param value Reflection texture matrix
  7661. */
  7662. setReflectionTextureMatrix(value: Matrix): void;
  7663. /**
  7664. * Parses text to create a cube texture
  7665. * @param parsedTexture define the serialized text to read from
  7666. * @param scene defines the hosting scene
  7667. * @param rootUrl defines the root url of the cube texture
  7668. * @returns a cube texture
  7669. */
  7670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7671. /**
  7672. * Makes a clone, or deep copy, of the cube texture
  7673. * @returns a new cube texture
  7674. */
  7675. clone(): CubeTexture;
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/materialDefines" {
  7679. /**
  7680. * Manages the defines for the Material
  7681. */
  7682. export class MaterialDefines {
  7683. /** @hidden */
  7684. protected _keys: string[];
  7685. private _isDirty;
  7686. /** @hidden */
  7687. _renderId: number;
  7688. /** @hidden */
  7689. _areLightsDirty: boolean;
  7690. /** @hidden */
  7691. _areAttributesDirty: boolean;
  7692. /** @hidden */
  7693. _areTexturesDirty: boolean;
  7694. /** @hidden */
  7695. _areFresnelDirty: boolean;
  7696. /** @hidden */
  7697. _areMiscDirty: boolean;
  7698. /** @hidden */
  7699. _areImageProcessingDirty: boolean;
  7700. /** @hidden */
  7701. _normals: boolean;
  7702. /** @hidden */
  7703. _uvs: boolean;
  7704. /** @hidden */
  7705. _needNormals: boolean;
  7706. /** @hidden */
  7707. _needUVs: boolean;
  7708. [id: string]: any;
  7709. /**
  7710. * Specifies if the material needs to be re-calculated
  7711. */
  7712. readonly isDirty: boolean;
  7713. /**
  7714. * Marks the material to indicate that it has been re-calculated
  7715. */
  7716. markAsProcessed(): void;
  7717. /**
  7718. * Marks the material to indicate that it needs to be re-calculated
  7719. */
  7720. markAsUnprocessed(): void;
  7721. /**
  7722. * Marks the material to indicate all of its defines need to be re-calculated
  7723. */
  7724. markAllAsDirty(): void;
  7725. /**
  7726. * Marks the material to indicate that image processing needs to be re-calculated
  7727. */
  7728. markAsImageProcessingDirty(): void;
  7729. /**
  7730. * Marks the material to indicate the lights need to be re-calculated
  7731. */
  7732. markAsLightDirty(): void;
  7733. /**
  7734. * Marks the attribute state as changed
  7735. */
  7736. markAsAttributesDirty(): void;
  7737. /**
  7738. * Marks the texture state as changed
  7739. */
  7740. markAsTexturesDirty(): void;
  7741. /**
  7742. * Marks the fresnel state as changed
  7743. */
  7744. markAsFresnelDirty(): void;
  7745. /**
  7746. * Marks the misc state as changed
  7747. */
  7748. markAsMiscDirty(): void;
  7749. /**
  7750. * Rebuilds the material defines
  7751. */
  7752. rebuild(): void;
  7753. /**
  7754. * Specifies if two material defines are equal
  7755. * @param other - A material define instance to compare to
  7756. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7757. */
  7758. isEqual(other: MaterialDefines): boolean;
  7759. /**
  7760. * Clones this instance's defines to another instance
  7761. * @param other - material defines to clone values to
  7762. */
  7763. cloneTo(other: MaterialDefines): void;
  7764. /**
  7765. * Resets the material define values
  7766. */
  7767. reset(): void;
  7768. /**
  7769. * Converts the material define values to a string
  7770. * @returns - String of material define information
  7771. */
  7772. toString(): string;
  7773. }
  7774. }
  7775. declare module "babylonjs/Materials/colorCurves" {
  7776. import { Effect } from "babylonjs/Materials/effect";
  7777. /**
  7778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7780. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7782. */
  7783. export class ColorCurves {
  7784. private _dirty;
  7785. private _tempColor;
  7786. private _globalCurve;
  7787. private _highlightsCurve;
  7788. private _midtonesCurve;
  7789. private _shadowsCurve;
  7790. private _positiveCurve;
  7791. private _negativeCurve;
  7792. private _globalHue;
  7793. private _globalDensity;
  7794. private _globalSaturation;
  7795. private _globalExposure;
  7796. /**
  7797. * Gets the global Hue value.
  7798. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7799. */
  7800. /**
  7801. * Sets the global Hue value.
  7802. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7803. */
  7804. globalHue: number;
  7805. /**
  7806. * Gets the global Density value.
  7807. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7808. * Values less than zero provide a filter of opposite hue.
  7809. */
  7810. /**
  7811. * Sets the global Density value.
  7812. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. globalDensity: number;
  7816. /**
  7817. * Gets the global Saturation value.
  7818. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7819. */
  7820. /**
  7821. * Sets the global Saturation value.
  7822. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7823. */
  7824. globalSaturation: number;
  7825. /**
  7826. * Gets the global Exposure value.
  7827. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7828. */
  7829. /**
  7830. * Sets the global Exposure value.
  7831. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7832. */
  7833. globalExposure: number;
  7834. private _highlightsHue;
  7835. private _highlightsDensity;
  7836. private _highlightsSaturation;
  7837. private _highlightsExposure;
  7838. /**
  7839. * Gets the highlights Hue value.
  7840. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7841. */
  7842. /**
  7843. * Sets the highlights Hue value.
  7844. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7845. */
  7846. highlightsHue: number;
  7847. /**
  7848. * Gets the highlights Density value.
  7849. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7850. * Values less than zero provide a filter of opposite hue.
  7851. */
  7852. /**
  7853. * Sets the highlights Density value.
  7854. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. highlightsDensity: number;
  7858. /**
  7859. * Gets the highlights Saturation value.
  7860. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7861. */
  7862. /**
  7863. * Sets the highlights Saturation value.
  7864. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7865. */
  7866. highlightsSaturation: number;
  7867. /**
  7868. * Gets the highlights Exposure value.
  7869. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7870. */
  7871. /**
  7872. * Sets the highlights Exposure value.
  7873. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7874. */
  7875. highlightsExposure: number;
  7876. private _midtonesHue;
  7877. private _midtonesDensity;
  7878. private _midtonesSaturation;
  7879. private _midtonesExposure;
  7880. /**
  7881. * Gets the midtones Hue value.
  7882. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7883. */
  7884. /**
  7885. * Sets the midtones Hue value.
  7886. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7887. */
  7888. midtonesHue: number;
  7889. /**
  7890. * Gets the midtones Density value.
  7891. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7892. * Values less than zero provide a filter of opposite hue.
  7893. */
  7894. /**
  7895. * Sets the midtones Density value.
  7896. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7897. * Values less than zero provide a filter of opposite hue.
  7898. */
  7899. midtonesDensity: number;
  7900. /**
  7901. * Gets the midtones Saturation value.
  7902. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7903. */
  7904. /**
  7905. * Sets the midtones Saturation value.
  7906. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7907. */
  7908. midtonesSaturation: number;
  7909. /**
  7910. * Gets the midtones Exposure value.
  7911. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7912. */
  7913. /**
  7914. * Sets the midtones Exposure value.
  7915. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7916. */
  7917. midtonesExposure: number;
  7918. private _shadowsHue;
  7919. private _shadowsDensity;
  7920. private _shadowsSaturation;
  7921. private _shadowsExposure;
  7922. /**
  7923. * Gets the shadows Hue value.
  7924. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7925. */
  7926. /**
  7927. * Sets the shadows Hue value.
  7928. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7929. */
  7930. shadowsHue: number;
  7931. /**
  7932. * Gets the shadows Density value.
  7933. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7934. * Values less than zero provide a filter of opposite hue.
  7935. */
  7936. /**
  7937. * Sets the shadows Density value.
  7938. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. shadowsDensity: number;
  7942. /**
  7943. * Gets the shadows Saturation value.
  7944. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7945. */
  7946. /**
  7947. * Sets the shadows Saturation value.
  7948. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7949. */
  7950. shadowsSaturation: number;
  7951. /**
  7952. * Gets the shadows Exposure value.
  7953. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7954. */
  7955. /**
  7956. * Sets the shadows Exposure value.
  7957. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7958. */
  7959. shadowsExposure: number;
  7960. /**
  7961. * Returns the class name
  7962. * @returns The class name
  7963. */
  7964. getClassName(): string;
  7965. /**
  7966. * Binds the color curves to the shader.
  7967. * @param colorCurves The color curve to bind
  7968. * @param effect The effect to bind to
  7969. * @param positiveUniform The positive uniform shader parameter
  7970. * @param neutralUniform The neutral uniform shader parameter
  7971. * @param negativeUniform The negative uniform shader parameter
  7972. */
  7973. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7974. /**
  7975. * Prepare the list of uniforms associated with the ColorCurves effects.
  7976. * @param uniformsList The list of uniforms used in the effect
  7977. */
  7978. static PrepareUniforms(uniformsList: string[]): void;
  7979. /**
  7980. * Returns color grading data based on a hue, density, saturation and exposure value.
  7981. * @param filterHue The hue of the color filter.
  7982. * @param filterDensity The density of the color filter.
  7983. * @param saturation The saturation.
  7984. * @param exposure The exposure.
  7985. * @param result The result data container.
  7986. */
  7987. private getColorGradingDataToRef;
  7988. /**
  7989. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7990. * @param value The input slider value in range [-100,100].
  7991. * @returns Adjusted value.
  7992. */
  7993. private static applyColorGradingSliderNonlinear;
  7994. /**
  7995. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7996. * @param hue The hue (H) input.
  7997. * @param saturation The saturation (S) input.
  7998. * @param brightness The brightness (B) input.
  7999. * @result An RGBA color represented as Vector4.
  8000. */
  8001. private static fromHSBToRef;
  8002. /**
  8003. * Returns a value clamped between min and max
  8004. * @param value The value to clamp
  8005. * @param min The minimum of value
  8006. * @param max The maximum of value
  8007. * @returns The clamped value.
  8008. */
  8009. private static clamp;
  8010. /**
  8011. * Clones the current color curve instance.
  8012. * @return The cloned curves
  8013. */
  8014. clone(): ColorCurves;
  8015. /**
  8016. * Serializes the current color curve instance to a json representation.
  8017. * @return a JSON representation
  8018. */
  8019. serialize(): any;
  8020. /**
  8021. * Parses the color curve from a json representation.
  8022. * @param source the JSON source to parse
  8023. * @return The parsed curves
  8024. */
  8025. static Parse(source: any): ColorCurves;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8029. import { Observable } from "babylonjs/Misc/observable";
  8030. import { Nullable } from "babylonjs/types";
  8031. import { Color4 } from "babylonjs/Maths/math.color";
  8032. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8033. import { Effect } from "babylonjs/Materials/effect";
  8034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8035. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8036. /**
  8037. * Interface to follow in your material defines to integrate easily the
  8038. * Image proccessing functions.
  8039. * @hidden
  8040. */
  8041. export interface IImageProcessingConfigurationDefines {
  8042. IMAGEPROCESSING: boolean;
  8043. VIGNETTE: boolean;
  8044. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8045. VIGNETTEBLENDMODEOPAQUE: boolean;
  8046. TONEMAPPING: boolean;
  8047. TONEMAPPING_ACES: boolean;
  8048. CONTRAST: boolean;
  8049. EXPOSURE: boolean;
  8050. COLORCURVES: boolean;
  8051. COLORGRADING: boolean;
  8052. COLORGRADING3D: boolean;
  8053. SAMPLER3DGREENDEPTH: boolean;
  8054. SAMPLER3DBGRMAP: boolean;
  8055. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8056. }
  8057. /**
  8058. * @hidden
  8059. */
  8060. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8061. IMAGEPROCESSING: boolean;
  8062. VIGNETTE: boolean;
  8063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8064. VIGNETTEBLENDMODEOPAQUE: boolean;
  8065. TONEMAPPING: boolean;
  8066. TONEMAPPING_ACES: boolean;
  8067. CONTRAST: boolean;
  8068. COLORCURVES: boolean;
  8069. COLORGRADING: boolean;
  8070. COLORGRADING3D: boolean;
  8071. SAMPLER3DGREENDEPTH: boolean;
  8072. SAMPLER3DBGRMAP: boolean;
  8073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8074. EXPOSURE: boolean;
  8075. constructor();
  8076. }
  8077. /**
  8078. * This groups together the common properties used for image processing either in direct forward pass
  8079. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8080. * or not.
  8081. */
  8082. export class ImageProcessingConfiguration {
  8083. /**
  8084. * Default tone mapping applied in BabylonJS.
  8085. */
  8086. static readonly TONEMAPPING_STANDARD: number;
  8087. /**
  8088. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8089. * to other engines rendering to increase portability.
  8090. */
  8091. static readonly TONEMAPPING_ACES: number;
  8092. /**
  8093. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8094. */
  8095. colorCurves: Nullable<ColorCurves>;
  8096. private _colorCurvesEnabled;
  8097. /**
  8098. * Gets wether the color curves effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color curves effect is enabled.
  8102. */
  8103. colorCurvesEnabled: boolean;
  8104. private _colorGradingTexture;
  8105. /**
  8106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8107. */
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. colorGradingTexture: Nullable<BaseTexture>;
  8112. private _colorGradingEnabled;
  8113. /**
  8114. * Gets wether the color grading effect is enabled.
  8115. */
  8116. /**
  8117. * Sets wether the color grading effect is enabled.
  8118. */
  8119. colorGradingEnabled: boolean;
  8120. private _colorGradingWithGreenDepth;
  8121. /**
  8122. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. colorGradingWithGreenDepth: boolean;
  8128. private _colorGradingBGR;
  8129. /**
  8130. * Gets wether the color grading texture contains BGR values.
  8131. */
  8132. /**
  8133. * Sets wether the color grading texture contains BGR values.
  8134. */
  8135. colorGradingBGR: boolean;
  8136. /** @hidden */
  8137. _exposure: number;
  8138. /**
  8139. * Gets the Exposure used in the effect.
  8140. */
  8141. /**
  8142. * Sets the Exposure used in the effect.
  8143. */
  8144. exposure: number;
  8145. private _toneMappingEnabled;
  8146. /**
  8147. * Gets wether the tone mapping effect is enabled.
  8148. */
  8149. /**
  8150. * Sets wether the tone mapping effect is enabled.
  8151. */
  8152. toneMappingEnabled: boolean;
  8153. private _toneMappingType;
  8154. /**
  8155. * Gets the type of tone mapping effect.
  8156. */
  8157. /**
  8158. * Sets the type of tone mapping effect used in BabylonJS.
  8159. */
  8160. toneMappingType: number;
  8161. protected _contrast: number;
  8162. /**
  8163. * Gets the contrast used in the effect.
  8164. */
  8165. /**
  8166. * Sets the contrast used in the effect.
  8167. */
  8168. contrast: number;
  8169. /**
  8170. * Vignette stretch size.
  8171. */
  8172. vignetteStretch: number;
  8173. /**
  8174. * Vignette centre X Offset.
  8175. */
  8176. vignetteCentreX: number;
  8177. /**
  8178. * Vignette centre Y Offset.
  8179. */
  8180. vignetteCentreY: number;
  8181. /**
  8182. * Vignette weight or intensity of the vignette effect.
  8183. */
  8184. vignetteWeight: number;
  8185. /**
  8186. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8187. * if vignetteEnabled is set to true.
  8188. */
  8189. vignetteColor: Color4;
  8190. /**
  8191. * Camera field of view used by the Vignette effect.
  8192. */
  8193. vignetteCameraFov: number;
  8194. private _vignetteBlendMode;
  8195. /**
  8196. * Gets the vignette blend mode allowing different kind of effect.
  8197. */
  8198. /**
  8199. * Sets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. vignetteBlendMode: number;
  8202. private _vignetteEnabled;
  8203. /**
  8204. * Gets wether the vignette effect is enabled.
  8205. */
  8206. /**
  8207. * Sets wether the vignette effect is enabled.
  8208. */
  8209. vignetteEnabled: boolean;
  8210. private _applyByPostProcess;
  8211. /**
  8212. * Gets wether the image processing is applied through a post process or not.
  8213. */
  8214. /**
  8215. * Sets wether the image processing is applied through a post process or not.
  8216. */
  8217. applyByPostProcess: boolean;
  8218. private _isEnabled;
  8219. /**
  8220. * Gets wether the image processing is enabled or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is enabled or not.
  8224. */
  8225. isEnabled: boolean;
  8226. /**
  8227. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8228. */
  8229. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8230. /**
  8231. * Method called each time the image processing information changes requires to recompile the effect.
  8232. */
  8233. protected _updateParameters(): void;
  8234. /**
  8235. * Gets the current class name.
  8236. * @return "ImageProcessingConfiguration"
  8237. */
  8238. getClassName(): string;
  8239. /**
  8240. * Prepare the list of uniforms associated with the Image Processing effects.
  8241. * @param uniforms The list of uniforms used in the effect
  8242. * @param defines the list of defines currently in use
  8243. */
  8244. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8245. /**
  8246. * Prepare the list of samplers associated with the Image Processing effects.
  8247. * @param samplersList The list of uniforms used in the effect
  8248. * @param defines the list of defines currently in use
  8249. */
  8250. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8251. /**
  8252. * Prepare the list of defines associated to the shader.
  8253. * @param defines the list of defines to complete
  8254. * @param forPostProcess Define if we are currently in post process mode or not
  8255. */
  8256. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8257. /**
  8258. * Returns true if all the image processing information are ready.
  8259. * @returns True if ready, otherwise, false
  8260. */
  8261. isReady(): boolean;
  8262. /**
  8263. * Binds the image processing to the shader.
  8264. * @param effect The effect to bind to
  8265. * @param aspectRatio Define the current aspect ratio of the effect
  8266. */
  8267. bind(effect: Effect, aspectRatio?: number): void;
  8268. /**
  8269. * Clones the current image processing instance.
  8270. * @return The cloned image processing
  8271. */
  8272. clone(): ImageProcessingConfiguration;
  8273. /**
  8274. * Serializes the current image processing instance to a json representation.
  8275. * @return a JSON representation
  8276. */
  8277. serialize(): any;
  8278. /**
  8279. * Parses the image processing from a json representation.
  8280. * @param source the JSON source to parse
  8281. * @return The parsed image processing
  8282. */
  8283. static Parse(source: any): ImageProcessingConfiguration;
  8284. private static _VIGNETTEMODE_MULTIPLY;
  8285. private static _VIGNETTEMODE_OPAQUE;
  8286. /**
  8287. * Used to apply the vignette as a mix with the pixel color.
  8288. */
  8289. static readonly VIGNETTEMODE_MULTIPLY: number;
  8290. /**
  8291. * Used to apply the vignette as a replacement of the pixel color.
  8292. */
  8293. static readonly VIGNETTEMODE_OPAQUE: number;
  8294. }
  8295. }
  8296. declare module "babylonjs/Shaders/postprocess.vertex" {
  8297. /** @hidden */
  8298. export var postprocessVertexShader: {
  8299. name: string;
  8300. shader: string;
  8301. };
  8302. }
  8303. declare module "babylonjs/Maths/math.axis" {
  8304. import { Vector3 } from "babylonjs/Maths/math.vector";
  8305. /** Defines supported spaces */
  8306. export enum Space {
  8307. /** Local (object) space */
  8308. LOCAL = 0,
  8309. /** World space */
  8310. WORLD = 1,
  8311. /** Bone space */
  8312. BONE = 2
  8313. }
  8314. /** Defines the 3 main axes */
  8315. export class Axis {
  8316. /** X axis */
  8317. static X: Vector3;
  8318. /** Y axis */
  8319. static Y: Vector3;
  8320. /** Z axis */
  8321. static Z: Vector3;
  8322. }
  8323. }
  8324. declare module "babylonjs/Cameras/targetCamera" {
  8325. import { Nullable } from "babylonjs/types";
  8326. import { Camera } from "babylonjs/Cameras/camera";
  8327. import { Scene } from "babylonjs/scene";
  8328. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8329. /**
  8330. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8331. * This is the base of the follow, arc rotate cameras and Free camera
  8332. * @see http://doc.babylonjs.com/features/cameras
  8333. */
  8334. export class TargetCamera extends Camera {
  8335. private static _RigCamTransformMatrix;
  8336. private static _TargetTransformMatrix;
  8337. private static _TargetFocalPoint;
  8338. /**
  8339. * Define the current direction the camera is moving to
  8340. */
  8341. cameraDirection: Vector3;
  8342. /**
  8343. * Define the current rotation the camera is rotating to
  8344. */
  8345. cameraRotation: Vector2;
  8346. /**
  8347. * When set, the up vector of the camera will be updated by the rotation of the camera
  8348. */
  8349. updateUpVectorFromRotation: boolean;
  8350. private _tmpQuaternion;
  8351. /**
  8352. * Define the current rotation of the camera
  8353. */
  8354. rotation: Vector3;
  8355. /**
  8356. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8357. */
  8358. rotationQuaternion: Quaternion;
  8359. /**
  8360. * Define the current speed of the camera
  8361. */
  8362. speed: number;
  8363. /**
  8364. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8365. * around all axis.
  8366. */
  8367. noRotationConstraint: boolean;
  8368. /**
  8369. * Define the current target of the camera as an object or a position.
  8370. */
  8371. lockedTarget: any;
  8372. /** @hidden */
  8373. _currentTarget: Vector3;
  8374. /** @hidden */
  8375. _initialFocalDistance: number;
  8376. /** @hidden */
  8377. _viewMatrix: Matrix;
  8378. /** @hidden */
  8379. _camMatrix: Matrix;
  8380. /** @hidden */
  8381. _cameraTransformMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraRotationMatrix: Matrix;
  8384. /** @hidden */
  8385. _referencePoint: Vector3;
  8386. /** @hidden */
  8387. _transformedReferencePoint: Vector3;
  8388. protected _globalCurrentTarget: Vector3;
  8389. protected _globalCurrentUpVector: Vector3;
  8390. /** @hidden */
  8391. _reset: () => void;
  8392. private _defaultUp;
  8393. /**
  8394. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8395. * This is the base of the follow, arc rotate cameras and Free camera
  8396. * @see http://doc.babylonjs.com/features/cameras
  8397. * @param name Defines the name of the camera in the scene
  8398. * @param position Defines the start position of the camera in the scene
  8399. * @param scene Defines the scene the camera belongs to
  8400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8401. */
  8402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8403. /**
  8404. * Gets the position in front of the camera at a given distance.
  8405. * @param distance The distance from the camera we want the position to be
  8406. * @returns the position
  8407. */
  8408. getFrontPosition(distance: number): Vector3;
  8409. /** @hidden */
  8410. _getLockedTargetPosition(): Nullable<Vector3>;
  8411. private _storedPosition;
  8412. private _storedRotation;
  8413. private _storedRotationQuaternion;
  8414. /**
  8415. * Store current camera state of the camera (fov, position, rotation, etc..)
  8416. * @returns the camera
  8417. */
  8418. storeState(): Camera;
  8419. /**
  8420. * Restored camera state. You must call storeState() first
  8421. * @returns whether it was successful or not
  8422. * @hidden
  8423. */
  8424. _restoreStateValues(): boolean;
  8425. /** @hidden */
  8426. _initCache(): void;
  8427. /** @hidden */
  8428. _updateCache(ignoreParentClass?: boolean): void;
  8429. /** @hidden */
  8430. _isSynchronizedViewMatrix(): boolean;
  8431. /** @hidden */
  8432. _computeLocalCameraSpeed(): number;
  8433. /**
  8434. * Defines the target the camera should look at.
  8435. * @param target Defines the new target as a Vector or a mesh
  8436. */
  8437. setTarget(target: Vector3): void;
  8438. /**
  8439. * Return the current target position of the camera. This value is expressed in local space.
  8440. * @returns the target position
  8441. */
  8442. getTarget(): Vector3;
  8443. /** @hidden */
  8444. _decideIfNeedsToMove(): boolean;
  8445. /** @hidden */
  8446. _updatePosition(): void;
  8447. /** @hidden */
  8448. _checkInputs(): void;
  8449. protected _updateCameraRotationMatrix(): void;
  8450. /**
  8451. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8452. * @returns the current camera
  8453. */
  8454. private _rotateUpVectorWithCameraRotationMatrix;
  8455. private _cachedRotationZ;
  8456. private _cachedQuaternionRotationZ;
  8457. /** @hidden */
  8458. _getViewMatrix(): Matrix;
  8459. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8460. /**
  8461. * @hidden
  8462. */
  8463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8464. /**
  8465. * @hidden
  8466. */
  8467. _updateRigCameras(): void;
  8468. private _getRigCamPositionAndTarget;
  8469. /**
  8470. * Gets the current object class name.
  8471. * @return the class name
  8472. */
  8473. getClassName(): string;
  8474. }
  8475. }
  8476. declare module "babylonjs/Events/keyboardEvents" {
  8477. /**
  8478. * Gather the list of keyboard event types as constants.
  8479. */
  8480. export class KeyboardEventTypes {
  8481. /**
  8482. * The keydown event is fired when a key becomes active (pressed).
  8483. */
  8484. static readonly KEYDOWN: number;
  8485. /**
  8486. * The keyup event is fired when a key has been released.
  8487. */
  8488. static readonly KEYUP: number;
  8489. }
  8490. /**
  8491. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8492. */
  8493. export class KeyboardInfo {
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number;
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent;
  8502. /**
  8503. * Instantiates a new keyboard info.
  8504. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8505. * @param type Defines the type of event (KeyboardEventTypes)
  8506. * @param event Defines the related dom event
  8507. */
  8508. constructor(
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number,
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent);
  8517. }
  8518. /**
  8519. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8520. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8521. */
  8522. export class KeyboardInfoPre extends KeyboardInfo {
  8523. /**
  8524. * Defines the type of event (KeyboardEventTypes)
  8525. */
  8526. type: number;
  8527. /**
  8528. * Defines the related dom event
  8529. */
  8530. event: KeyboardEvent;
  8531. /**
  8532. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8533. */
  8534. skipOnPointerObservable: boolean;
  8535. /**
  8536. * Instantiates a new keyboard pre info.
  8537. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8538. * @param type Defines the type of event (KeyboardEventTypes)
  8539. * @param event Defines the related dom event
  8540. */
  8541. constructor(
  8542. /**
  8543. * Defines the type of event (KeyboardEventTypes)
  8544. */
  8545. type: number,
  8546. /**
  8547. * Defines the related dom event
  8548. */
  8549. event: KeyboardEvent);
  8550. }
  8551. }
  8552. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8553. import { Nullable } from "babylonjs/types";
  8554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8556. /**
  8557. * Manage the keyboard inputs to control the movement of a free camera.
  8558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8559. */
  8560. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8561. /**
  8562. * Defines the camera the input is attached to.
  8563. */
  8564. camera: FreeCamera;
  8565. /**
  8566. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8567. */
  8568. keysUp: number[];
  8569. /**
  8570. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8571. */
  8572. keysDown: number[];
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8575. */
  8576. keysLeft: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8579. */
  8580. keysRight: number[];
  8581. private _keys;
  8582. private _onCanvasBlurObserver;
  8583. private _onKeyboardObserver;
  8584. private _engine;
  8585. private _scene;
  8586. /**
  8587. * Attach the input controls to a specific dom element to get the input from.
  8588. * @param element Defines the element the controls should be listened from
  8589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8590. */
  8591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8592. /**
  8593. * Detach the current controls from the specified dom element.
  8594. * @param element Defines the element to stop listening the inputs from
  8595. */
  8596. detachControl(element: Nullable<HTMLElement>): void;
  8597. /**
  8598. * Update the current camera state depending on the inputs that have been used this frame.
  8599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8600. */
  8601. checkInputs(): void;
  8602. /**
  8603. * Gets the class name of the current intput.
  8604. * @returns the class name
  8605. */
  8606. getClassName(): string;
  8607. /** @hidden */
  8608. _onLostFocus(): void;
  8609. /**
  8610. * Get the friendly name associated with the input class.
  8611. * @returns the input friendly name
  8612. */
  8613. getSimpleName(): string;
  8614. }
  8615. }
  8616. declare module "babylonjs/Lights/shadowLight" {
  8617. import { Camera } from "babylonjs/Cameras/camera";
  8618. import { Scene } from "babylonjs/scene";
  8619. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8621. import { Light } from "babylonjs/Lights/light";
  8622. /**
  8623. * Interface describing all the common properties and methods a shadow light needs to implement.
  8624. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8625. * as well as binding the different shadow properties to the effects.
  8626. */
  8627. export interface IShadowLight extends Light {
  8628. /**
  8629. * The light id in the scene (used in scene.findLighById for instance)
  8630. */
  8631. id: string;
  8632. /**
  8633. * The position the shdow will be casted from.
  8634. */
  8635. position: Vector3;
  8636. /**
  8637. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8638. */
  8639. direction: Vector3;
  8640. /**
  8641. * The transformed position. Position of the light in world space taking parenting in account.
  8642. */
  8643. transformedPosition: Vector3;
  8644. /**
  8645. * The transformed direction. Direction of the light in world space taking parenting in account.
  8646. */
  8647. transformedDirection: Vector3;
  8648. /**
  8649. * The friendly name of the light in the scene.
  8650. */
  8651. name: string;
  8652. /**
  8653. * Defines the shadow projection clipping minimum z value.
  8654. */
  8655. shadowMinZ: number;
  8656. /**
  8657. * Defines the shadow projection clipping maximum z value.
  8658. */
  8659. shadowMaxZ: number;
  8660. /**
  8661. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8662. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8663. */
  8664. computeTransformedInformation(): boolean;
  8665. /**
  8666. * Gets the scene the light belongs to.
  8667. * @returns The scene
  8668. */
  8669. getScene(): Scene;
  8670. /**
  8671. * Callback defining a custom Projection Matrix Builder.
  8672. * This can be used to override the default projection matrix computation.
  8673. */
  8674. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8675. /**
  8676. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8677. * @param matrix The materix to updated with the projection information
  8678. * @param viewMatrix The transform matrix of the light
  8679. * @param renderList The list of mesh to render in the map
  8680. * @returns The current light
  8681. */
  8682. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8683. /**
  8684. * Gets the current depth scale used in ESM.
  8685. * @returns The scale
  8686. */
  8687. getDepthScale(): number;
  8688. /**
  8689. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8690. * @returns true if a cube texture needs to be use
  8691. */
  8692. needCube(): boolean;
  8693. /**
  8694. * Detects if the projection matrix requires to be recomputed this frame.
  8695. * @returns true if it requires to be recomputed otherwise, false.
  8696. */
  8697. needProjectionMatrixCompute(): boolean;
  8698. /**
  8699. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8700. */
  8701. forceProjectionMatrixCompute(): void;
  8702. /**
  8703. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8706. */
  8707. getShadowDirection(faceIndex?: number): Vector3;
  8708. /**
  8709. * Gets the minZ used for shadow according to both the scene and the light.
  8710. * @param activeCamera The camera we are returning the min for
  8711. * @returns the depth min z
  8712. */
  8713. getDepthMinZ(activeCamera: Camera): number;
  8714. /**
  8715. * Gets the maxZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the max for
  8717. * @returns the depth max z
  8718. */
  8719. getDepthMaxZ(activeCamera: Camera): number;
  8720. }
  8721. /**
  8722. * Base implementation IShadowLight
  8723. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8724. */
  8725. export abstract class ShadowLight extends Light implements IShadowLight {
  8726. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8727. protected _position: Vector3;
  8728. protected _setPosition(value: Vector3): void;
  8729. /**
  8730. * Sets the position the shadow will be casted from. Also use as the light position for both
  8731. * point and spot lights.
  8732. */
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  8737. position: Vector3;
  8738. protected _direction: Vector3;
  8739. protected _setDirection(value: Vector3): void;
  8740. /**
  8741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8742. * Also use as the light direction on spot and directional lights.
  8743. */
  8744. /**
  8745. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. direction: Vector3;
  8749. private _shadowMinZ;
  8750. /**
  8751. * Gets the shadow projection clipping minimum z value.
  8752. */
  8753. /**
  8754. * Sets the shadow projection clipping minimum z value.
  8755. */
  8756. shadowMinZ: number;
  8757. private _shadowMaxZ;
  8758. /**
  8759. * Sets the shadow projection clipping maximum z value.
  8760. */
  8761. /**
  8762. * Gets the shadow projection clipping maximum z value.
  8763. */
  8764. shadowMaxZ: number;
  8765. /**
  8766. * Callback defining a custom Projection Matrix Builder.
  8767. * This can be used to override the default projection matrix computation.
  8768. */
  8769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8770. /**
  8771. * The transformed position. Position of the light in world space taking parenting in account.
  8772. */
  8773. transformedPosition: Vector3;
  8774. /**
  8775. * The transformed direction. Direction of the light in world space taking parenting in account.
  8776. */
  8777. transformedDirection: Vector3;
  8778. private _needProjectionMatrixCompute;
  8779. /**
  8780. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8781. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8782. */
  8783. computeTransformedInformation(): boolean;
  8784. /**
  8785. * Return the depth scale used for the shadow map.
  8786. * @returns the depth scale.
  8787. */
  8788. getDepthScale(): number;
  8789. /**
  8790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8793. */
  8794. getShadowDirection(faceIndex?: number): Vector3;
  8795. /**
  8796. * Returns the ShadowLight absolute position in the World.
  8797. * @returns the position vector in world space
  8798. */
  8799. getAbsolutePosition(): Vector3;
  8800. /**
  8801. * Sets the ShadowLight direction toward the passed target.
  8802. * @param target The point to target in local space
  8803. * @returns the updated ShadowLight direction
  8804. */
  8805. setDirectionToTarget(target: Vector3): Vector3;
  8806. /**
  8807. * Returns the light rotation in euler definition.
  8808. * @returns the x y z rotation in local space.
  8809. */
  8810. getRotation(): Vector3;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /** @hidden */
  8826. _initCache(): void;
  8827. /** @hidden */
  8828. _isSynchronized(): boolean;
  8829. /**
  8830. * Computes the world matrix of the node
  8831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8832. * @returns the world matrix
  8833. */
  8834. computeWorldMatrix(force?: boolean): Matrix;
  8835. /**
  8836. * Gets the minZ used for shadow according to both the scene and the light.
  8837. * @param activeCamera The camera we are returning the min for
  8838. * @returns the depth min z
  8839. */
  8840. getDepthMinZ(activeCamera: Camera): number;
  8841. /**
  8842. * Gets the maxZ used for shadow according to both the scene and the light.
  8843. * @param activeCamera The camera we are returning the max for
  8844. * @returns the depth max z
  8845. */
  8846. getDepthMaxZ(activeCamera: Camera): number;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/materialHelper" {
  8858. import { Nullable } from "babylonjs/types";
  8859. import { Scene } from "babylonjs/scene";
  8860. import { Engine } from "babylonjs/Engines/engine";
  8861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8862. import { Light } from "babylonjs/Lights/light";
  8863. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8864. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8866. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8867. /**
  8868. * "Static Class" containing the most commonly used helper while dealing with material for
  8869. * rendering purpose.
  8870. *
  8871. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8872. *
  8873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8874. */
  8875. export class MaterialHelper {
  8876. /**
  8877. * Bind the current view position to an effect.
  8878. * @param effect The effect to be bound
  8879. * @param scene The scene the eyes position is used from
  8880. */
  8881. static BindEyePosition(effect: Effect, scene: Scene): void;
  8882. /**
  8883. * Helps preparing the defines values about the UVs in used in the effect.
  8884. * UVs are shared as much as we can accross channels in the shaders.
  8885. * @param texture The texture we are preparing the UVs for
  8886. * @param defines The defines to update
  8887. * @param key The channel key "diffuse", "specular"... used in the shader
  8888. */
  8889. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8890. /**
  8891. * Binds a texture matrix value to its corrsponding uniform
  8892. * @param texture The texture to bind the matrix for
  8893. * @param uniformBuffer The uniform buffer receivin the data
  8894. * @param key The channel key "diffuse", "specular"... used in the shader
  8895. */
  8896. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8897. /**
  8898. * Gets the current status of the fog (should it be enabled?)
  8899. * @param mesh defines the mesh to evaluate for fog support
  8900. * @param scene defines the hosting scene
  8901. * @returns true if fog must be enabled
  8902. */
  8903. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8904. /**
  8905. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8906. * @param mesh defines the current mesh
  8907. * @param scene defines the current scene
  8908. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8909. * @param pointsCloud defines if point cloud rendering has to be turned on
  8910. * @param fogEnabled defines if fog has to be turned on
  8911. * @param alphaTest defines if alpha testing has to be turned on
  8912. * @param defines defines the current list of defines
  8913. */
  8914. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8915. /**
  8916. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8917. * @param scene defines the current scene
  8918. * @param engine defines the current engine
  8919. * @param defines specifies the list of active defines
  8920. * @param useInstances defines if instances have to be turned on
  8921. * @param useClipPlane defines if clip plane have to be turned on
  8922. */
  8923. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8924. /**
  8925. * Prepares the defines for bones
  8926. * @param mesh The mesh containing the geometry data we will draw
  8927. * @param defines The defines to update
  8928. */
  8929. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8930. /**
  8931. * Prepares the defines for morph targets
  8932. * @param mesh The mesh containing the geometry data we will draw
  8933. * @param defines The defines to update
  8934. */
  8935. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8936. /**
  8937. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8938. * @param mesh The mesh containing the geometry data we will draw
  8939. * @param defines The defines to update
  8940. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8941. * @param useBones Precise whether bones should be used or not (override mesh info)
  8942. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8943. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8944. * @returns false if defines are considered not dirty and have not been checked
  8945. */
  8946. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8947. /**
  8948. * Prepares the defines related to multiview
  8949. * @param scene The scene we are intending to draw
  8950. * @param defines The defines to update
  8951. */
  8952. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8953. /**
  8954. * Prepares the defines related to the light information passed in parameter
  8955. * @param scene The scene we are intending to draw
  8956. * @param mesh The mesh the effect is compiling for
  8957. * @param light The light the effect is compiling for
  8958. * @param lightIndex The index of the light
  8959. * @param defines The defines to update
  8960. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8961. * @param state Defines the current state regarding what is needed (normals, etc...)
  8962. */
  8963. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8964. needNormals: boolean;
  8965. needRebuild: boolean;
  8966. shadowEnabled: boolean;
  8967. specularEnabled: boolean;
  8968. lightmapMode: boolean;
  8969. }): void;
  8970. /**
  8971. * Prepares the defines related to the light information passed in parameter
  8972. * @param scene The scene we are intending to draw
  8973. * @param mesh The mesh the effect is compiling for
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8977. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8978. * @returns true if normals will be required for the rest of the effect
  8979. */
  8980. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8981. /**
  8982. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8983. * @param lightIndex defines the light index
  8984. * @param uniformsList The uniform list
  8985. * @param samplersList The sampler list
  8986. * @param projectedLightTexture defines if projected texture must be used
  8987. * @param uniformBuffersList defines an optional list of uniform buffers
  8988. */
  8989. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8990. /**
  8991. * Prepares the uniforms and samplers list to be used in the effect
  8992. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8993. * @param samplersList The sampler list
  8994. * @param defines The defines helping in the list generation
  8995. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8996. */
  8997. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8998. /**
  8999. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9000. * @param defines The defines to update while falling back
  9001. * @param fallbacks The authorized effect fallbacks
  9002. * @param maxSimultaneousLights The maximum number of lights allowed
  9003. * @param rank the current rank of the Effect
  9004. * @returns The newly affected rank
  9005. */
  9006. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9007. private static _TmpMorphInfluencers;
  9008. /**
  9009. * Prepares the list of attributes required for morph targets according to the effect defines.
  9010. * @param attribs The current list of supported attribs
  9011. * @param mesh The mesh to prepare the morph targets attributes for
  9012. * @param influencers The number of influencers
  9013. */
  9014. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9015. /**
  9016. * Prepares the list of attributes required for morph targets according to the effect defines.
  9017. * @param attribs The current list of supported attribs
  9018. * @param mesh The mesh to prepare the morph targets attributes for
  9019. * @param defines The current Defines of the effect
  9020. */
  9021. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9022. /**
  9023. * Prepares the list of attributes required for bones according to the effect defines.
  9024. * @param attribs The current list of supported attribs
  9025. * @param mesh The mesh to prepare the bones attributes for
  9026. * @param defines The current Defines of the effect
  9027. * @param fallbacks The current efffect fallback strategy
  9028. */
  9029. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9030. /**
  9031. * Check and prepare the list of attributes required for instances according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param defines The current MaterialDefines of the effect
  9034. */
  9035. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9036. /**
  9037. * Add the list of attributes required for instances to the attribs array.
  9038. * @param attribs The current list of supported attribs
  9039. */
  9040. static PushAttributesForInstances(attribs: string[]): void;
  9041. /**
  9042. * Binds the light shadow information to the effect for the given mesh.
  9043. * @param light The light containing the generator
  9044. * @param scene The scene the lights belongs to
  9045. * @param mesh The mesh we are binding the information to render
  9046. * @param lightIndex The light index in the effect used to render the mesh
  9047. * @param effect The effect we are binding the data to
  9048. */
  9049. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9050. /**
  9051. * Binds the light information to the effect.
  9052. * @param light The light containing the generator
  9053. * @param effect The effect we are binding the data to
  9054. * @param lightIndex The light index in the effect used to render
  9055. */
  9056. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9057. /**
  9058. * Binds the lights information from the scene to the effect for the given mesh.
  9059. * @param light Light to bind
  9060. * @param lightIndex Light index
  9061. * @param scene The scene where the light belongs to
  9062. * @param mesh The mesh we are binding the information to render
  9063. * @param effect The effect we are binding the data to
  9064. * @param useSpecular Defines if specular is supported
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. */
  9067. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  9068. /**
  9069. * Binds the lights information from the scene to the effect for the given mesh.
  9070. * @param scene The scene the lights belongs to
  9071. * @param mesh The mesh we are binding the information to render
  9072. * @param effect The effect we are binding the data to
  9073. * @param defines The generated defines for the effect
  9074. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9075. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9076. */
  9077. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9078. private static _tempFogColor;
  9079. /**
  9080. * Binds the fog information from the scene to the effect for the given mesh.
  9081. * @param scene The scene the lights belongs to
  9082. * @param mesh The mesh we are binding the information to render
  9083. * @param effect The effect we are binding the data to
  9084. * @param linearSpace Defines if the fog effect is applied in linear space
  9085. */
  9086. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9087. /**
  9088. * Binds the bones information from the mesh to the effect.
  9089. * @param mesh The mesh we are binding the information to render
  9090. * @param effect The effect we are binding the data to
  9091. */
  9092. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9093. /**
  9094. * Binds the morph targets information from the mesh to the effect.
  9095. * @param abstractMesh The mesh we are binding the information to render
  9096. * @param effect The effect we are binding the data to
  9097. */
  9098. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9099. /**
  9100. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9101. * @param defines The generated defines used in the effect
  9102. * @param effect The effect we are binding the data to
  9103. * @param scene The scene we are willing to render with logarithmic scale for
  9104. */
  9105. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Binds the clip plane information from the scene to the effect.
  9108. * @param scene The scene the clip plane information are extracted from
  9109. * @param effect The effect we are binding the data to
  9110. */
  9111. static BindClipPlane(effect: Effect, scene: Scene): void;
  9112. }
  9113. }
  9114. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9115. /** @hidden */
  9116. export var packingFunctions: {
  9117. name: string;
  9118. shader: string;
  9119. };
  9120. }
  9121. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9122. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9123. /** @hidden */
  9124. export var shadowMapPixelShader: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9130. /** @hidden */
  9131. export var bonesDeclaration: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9137. /** @hidden */
  9138. export var morphTargetsVertexGlobalDeclaration: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9144. /** @hidden */
  9145. export var morphTargetsVertexDeclaration: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9151. /** @hidden */
  9152. export var instancesDeclaration: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9158. /** @hidden */
  9159. export var helperFunctions: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9165. /** @hidden */
  9166. export var morphTargetsVertex: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9172. /** @hidden */
  9173. export var instancesVertex: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9179. /** @hidden */
  9180. export var bonesVertex: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9186. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9189. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9192. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9193. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9194. /** @hidden */
  9195. export var shadowMapVertexShader: {
  9196. name: string;
  9197. shader: string;
  9198. };
  9199. }
  9200. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9201. /** @hidden */
  9202. export var depthBoxBlurPixelShader: {
  9203. name: string;
  9204. shader: string;
  9205. };
  9206. }
  9207. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Matrix } from "babylonjs/Maths/math.vector";
  9211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9213. import { Mesh } from "babylonjs/Meshes/mesh";
  9214. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9215. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9216. import { Effect } from "babylonjs/Materials/effect";
  9217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9218. import "babylonjs/Shaders/shadowMap.fragment";
  9219. import "babylonjs/Shaders/shadowMap.vertex";
  9220. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9221. import { Observable } from "babylonjs/Misc/observable";
  9222. /**
  9223. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9224. */
  9225. export interface ICustomShaderOptions {
  9226. /**
  9227. * Gets or sets the custom shader name to use
  9228. */
  9229. shaderName: string;
  9230. /**
  9231. * The list of attribute names used in the shader
  9232. */
  9233. attributes?: string[];
  9234. /**
  9235. * The list of unifrom names used in the shader
  9236. */
  9237. uniforms?: string[];
  9238. /**
  9239. * The list of sampler names used in the shader
  9240. */
  9241. samplers?: string[];
  9242. /**
  9243. * The list of defines used in the shader
  9244. */
  9245. defines?: string[];
  9246. }
  9247. /**
  9248. * Interface to implement to create a shadow generator compatible with BJS.
  9249. */
  9250. export interface IShadowGenerator {
  9251. /**
  9252. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9253. * @returns The render target texture if present otherwise, null
  9254. */
  9255. getShadowMap(): Nullable<RenderTargetTexture>;
  9256. /**
  9257. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9258. * @returns The render target texture if the shadow map is present otherwise, null
  9259. */
  9260. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9263. * @param subMesh The submesh we want to render in the shadow map
  9264. * @param useInstances Defines wether will draw in the map using instances
  9265. * @returns true if ready otherwise, false
  9266. */
  9267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9268. /**
  9269. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9270. * @param defines Defines of the material we want to update
  9271. * @param lightIndex Index of the light in the enabled light list of the material
  9272. */
  9273. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9274. /**
  9275. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9276. * defined in the generator but impacting the effect).
  9277. * It implies the unifroms available on the materials are the standard BJS ones.
  9278. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9279. * @param effect The effect we are binfing the information for
  9280. */
  9281. bindShadowLight(lightIndex: string, effect: Effect): void;
  9282. /**
  9283. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9284. * (eq to shadow prjection matrix * light transform matrix)
  9285. * @returns The transform matrix used to create the shadow map
  9286. */
  9287. getTransformMatrix(): Matrix;
  9288. /**
  9289. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9290. * Cube and 2D textures for instance.
  9291. */
  9292. recreateShadowMap(): void;
  9293. /**
  9294. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9295. * @param onCompiled Callback triggered at the and of the effects compilation
  9296. * @param options Sets of optional options forcing the compilation with different modes
  9297. */
  9298. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9299. useInstances: boolean;
  9300. }>): void;
  9301. /**
  9302. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9303. * @param options Sets of optional options forcing the compilation with different modes
  9304. * @returns A promise that resolves when the compilation completes
  9305. */
  9306. forceCompilationAsync(options?: Partial<{
  9307. useInstances: boolean;
  9308. }>): Promise<void>;
  9309. /**
  9310. * Serializes the shadow generator setup to a json object.
  9311. * @returns The serialized JSON object
  9312. */
  9313. serialize(): any;
  9314. /**
  9315. * Disposes the Shadow map and related Textures and effects.
  9316. */
  9317. dispose(): void;
  9318. }
  9319. /**
  9320. * Default implementation IShadowGenerator.
  9321. * This is the main object responsible of generating shadows in the framework.
  9322. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9323. */
  9324. export class ShadowGenerator implements IShadowGenerator {
  9325. /**
  9326. * Shadow generator mode None: no filtering applied.
  9327. */
  9328. static readonly FILTER_NONE: number;
  9329. /**
  9330. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9332. */
  9333. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9334. /**
  9335. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9336. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9337. */
  9338. static readonly FILTER_POISSONSAMPLING: number;
  9339. /**
  9340. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9346. * edge artifacts on steep falloff.
  9347. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9348. */
  9349. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9350. /**
  9351. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9352. * edge artifacts on steep falloff.
  9353. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9354. */
  9355. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9356. /**
  9357. * Shadow generator mode PCF: Percentage Closer Filtering
  9358. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9359. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9360. */
  9361. static readonly FILTER_PCF: number;
  9362. /**
  9363. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9364. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9365. * Contact Hardening
  9366. */
  9367. static readonly FILTER_PCSS: number;
  9368. /**
  9369. * Reserved for PCF and PCSS
  9370. * Highest Quality.
  9371. *
  9372. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9373. *
  9374. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9375. */
  9376. static readonly QUALITY_HIGH: number;
  9377. /**
  9378. * Reserved for PCF and PCSS
  9379. * Good tradeoff for quality/perf cross devices
  9380. *
  9381. * Execute PCF on a 3*3 kernel.
  9382. *
  9383. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9384. */
  9385. static readonly QUALITY_MEDIUM: number;
  9386. /**
  9387. * Reserved for PCF and PCSS
  9388. * The lowest quality but the fastest.
  9389. *
  9390. * Execute PCF on a 1*1 kernel.
  9391. *
  9392. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9393. */
  9394. static readonly QUALITY_LOW: number;
  9395. /** Gets or sets the custom shader name to use */
  9396. customShaderOptions: ICustomShaderOptions;
  9397. /**
  9398. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9399. */
  9400. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9401. /**
  9402. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9403. */
  9404. onAfterShadowMapRenderObservable: Observable<Effect>;
  9405. /**
  9406. * Observable triggered before a mesh is rendered in the shadow map.
  9407. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9408. */
  9409. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9410. /**
  9411. * Observable triggered after a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9413. */
  9414. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. private _bias;
  9416. /**
  9417. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9418. */
  9419. /**
  9420. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9421. */
  9422. bias: number;
  9423. private _normalBias;
  9424. /**
  9425. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9426. */
  9427. /**
  9428. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9429. */
  9430. normalBias: number;
  9431. private _blurBoxOffset;
  9432. /**
  9433. * Gets the blur box offset: offset applied during the blur pass.
  9434. * Only useful if useKernelBlur = false
  9435. */
  9436. /**
  9437. * Sets the blur box offset: offset applied during the blur pass.
  9438. * Only useful if useKernelBlur = false
  9439. */
  9440. blurBoxOffset: number;
  9441. private _blurScale;
  9442. /**
  9443. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9444. * 2 means half of the size.
  9445. */
  9446. /**
  9447. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9448. * 2 means half of the size.
  9449. */
  9450. blurScale: number;
  9451. private _blurKernel;
  9452. /**
  9453. * Gets the blur kernel: kernel size of the blur pass.
  9454. * Only useful if useKernelBlur = true
  9455. */
  9456. /**
  9457. * Sets the blur kernel: kernel size of the blur pass.
  9458. * Only useful if useKernelBlur = true
  9459. */
  9460. blurKernel: number;
  9461. private _useKernelBlur;
  9462. /**
  9463. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9464. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9465. */
  9466. /**
  9467. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9468. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9469. */
  9470. useKernelBlur: boolean;
  9471. private _depthScale;
  9472. /**
  9473. * Gets the depth scale used in ESM mode.
  9474. */
  9475. /**
  9476. * Sets the depth scale used in ESM mode.
  9477. * This can override the scale stored on the light.
  9478. */
  9479. depthScale: number;
  9480. private _filter;
  9481. /**
  9482. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9483. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9484. */
  9485. /**
  9486. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9487. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9488. */
  9489. filter: number;
  9490. /**
  9491. * Gets if the current filter is set to Poisson Sampling.
  9492. */
  9493. /**
  9494. * Sets the current filter to Poisson Sampling.
  9495. */
  9496. usePoissonSampling: boolean;
  9497. /**
  9498. * Gets if the current filter is set to ESM.
  9499. */
  9500. /**
  9501. * Sets the current filter is to ESM.
  9502. */
  9503. useExponentialShadowMap: boolean;
  9504. /**
  9505. * Gets if the current filter is set to filtered ESM.
  9506. */
  9507. /**
  9508. * Gets if the current filter is set to filtered ESM.
  9509. */
  9510. useBlurExponentialShadowMap: boolean;
  9511. /**
  9512. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9513. * exponential to prevent steep falloff artifacts).
  9514. */
  9515. /**
  9516. * Sets the current filter to "close ESM" (using the inverse of the
  9517. * exponential to prevent steep falloff artifacts).
  9518. */
  9519. useCloseExponentialShadowMap: boolean;
  9520. /**
  9521. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. /**
  9525. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9526. * exponential to prevent steep falloff artifacts).
  9527. */
  9528. useBlurCloseExponentialShadowMap: boolean;
  9529. /**
  9530. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9531. */
  9532. /**
  9533. * Sets the current filter to "PCF" (percentage closer filtering).
  9534. */
  9535. usePercentageCloserFiltering: boolean;
  9536. private _filteringQuality;
  9537. /**
  9538. * Gets the PCF or PCSS Quality.
  9539. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9540. */
  9541. /**
  9542. * Sets the PCF or PCSS Quality.
  9543. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9544. */
  9545. filteringQuality: number;
  9546. /**
  9547. * Gets if the current filter is set to "PCSS" (contact hardening).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCSS" (contact hardening).
  9551. */
  9552. useContactHardeningShadow: boolean;
  9553. private _contactHardeningLightSizeUVRatio;
  9554. /**
  9555. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9556. * Using a ratio helps keeping shape stability independently of the map size.
  9557. *
  9558. * It does not account for the light projection as it was having too much
  9559. * instability during the light setup or during light position changes.
  9560. *
  9561. * Only valid if useContactHardeningShadow is true.
  9562. */
  9563. /**
  9564. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9565. * Using a ratio helps keeping shape stability independently of the map size.
  9566. *
  9567. * It does not account for the light projection as it was having too much
  9568. * instability during the light setup or during light position changes.
  9569. *
  9570. * Only valid if useContactHardeningShadow is true.
  9571. */
  9572. contactHardeningLightSizeUVRatio: number;
  9573. private _darkness;
  9574. /** Gets or sets the actual darkness of a shadow */
  9575. darkness: number;
  9576. /**
  9577. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9578. * 0 means strongest and 1 would means no shadow.
  9579. * @returns the darkness.
  9580. */
  9581. getDarkness(): number;
  9582. /**
  9583. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9584. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9585. * @returns the shadow generator allowing fluent coding.
  9586. */
  9587. setDarkness(darkness: number): ShadowGenerator;
  9588. private _transparencyShadow;
  9589. /** Gets or sets the ability to have transparent shadow */
  9590. transparencyShadow: boolean;
  9591. /**
  9592. * Sets the ability to have transparent shadow (boolean).
  9593. * @param transparent True if transparent else False
  9594. * @returns the shadow generator allowing fluent coding
  9595. */
  9596. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9597. private _shadowMap;
  9598. private _shadowMap2;
  9599. /**
  9600. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9601. * @returns The render target texture if present otherwise, null
  9602. */
  9603. getShadowMap(): Nullable<RenderTargetTexture>;
  9604. /**
  9605. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9606. * @returns The render target texture if the shadow map is present otherwise, null
  9607. */
  9608. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the class name of that object
  9611. * @returns "ShadowGenerator"
  9612. */
  9613. getClassName(): string;
  9614. /**
  9615. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9616. * @param mesh Mesh to add
  9617. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9618. * @returns the Shadow Generator itself
  9619. */
  9620. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9621. /**
  9622. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9623. * @param mesh Mesh to remove
  9624. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9625. * @returns the Shadow Generator itself
  9626. */
  9627. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9628. /**
  9629. * Controls the extent to which the shadows fade out at the edge of the frustum
  9630. * Used only by directionals and spots
  9631. */
  9632. frustumEdgeFalloff: number;
  9633. private _light;
  9634. /**
  9635. * Returns the associated light object.
  9636. * @returns the light generating the shadow
  9637. */
  9638. getLight(): IShadowLight;
  9639. /**
  9640. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9641. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9642. * It might on the other hand introduce peter panning.
  9643. */
  9644. forceBackFacesOnly: boolean;
  9645. private _scene;
  9646. private _lightDirection;
  9647. private _effect;
  9648. private _viewMatrix;
  9649. private _projectionMatrix;
  9650. private _transformMatrix;
  9651. private _cachedPosition;
  9652. private _cachedDirection;
  9653. private _cachedDefines;
  9654. private _currentRenderID;
  9655. private _boxBlurPostprocess;
  9656. private _kernelBlurXPostprocess;
  9657. private _kernelBlurYPostprocess;
  9658. private _blurPostProcesses;
  9659. private _mapSize;
  9660. private _currentFaceIndex;
  9661. private _currentFaceIndexCache;
  9662. private _textureType;
  9663. private _defaultTextureMatrix;
  9664. /** @hidden */
  9665. static _SceneComponentInitialization: (scene: Scene) => void;
  9666. /**
  9667. * Creates a ShadowGenerator object.
  9668. * A ShadowGenerator is the required tool to use the shadows.
  9669. * Each light casting shadows needs to use its own ShadowGenerator.
  9670. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9671. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9672. * @param light The light object generating the shadows.
  9673. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9674. */
  9675. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9676. private _initializeGenerator;
  9677. private _initializeShadowMap;
  9678. private _initializeBlurRTTAndPostProcesses;
  9679. private _renderForShadowMap;
  9680. private _renderSubMeshForShadowMap;
  9681. private _applyFilterValues;
  9682. /**
  9683. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9684. * @param onCompiled Callback triggered at the and of the effects compilation
  9685. * @param options Sets of optional options forcing the compilation with different modes
  9686. */
  9687. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9688. useInstances: boolean;
  9689. }>): void;
  9690. /**
  9691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9692. * @param options Sets of optional options forcing the compilation with different modes
  9693. * @returns A promise that resolves when the compilation completes
  9694. */
  9695. forceCompilationAsync(options?: Partial<{
  9696. useInstances: boolean;
  9697. }>): Promise<void>;
  9698. /**
  9699. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9700. * @param subMesh The submesh we want to render in the shadow map
  9701. * @param useInstances Defines wether will draw in the map using instances
  9702. * @returns true if ready otherwise, false
  9703. */
  9704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9705. /**
  9706. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9707. * @param defines Defines of the material we want to update
  9708. * @param lightIndex Index of the light in the enabled light list of the material
  9709. */
  9710. prepareDefines(defines: any, lightIndex: number): void;
  9711. /**
  9712. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9713. * defined in the generator but impacting the effect).
  9714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9715. * @param effect The effect we are binfing the information for
  9716. */
  9717. bindShadowLight(lightIndex: string, effect: Effect): void;
  9718. /**
  9719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9720. * (eq to shadow prjection matrix * light transform matrix)
  9721. * @returns The transform matrix used to create the shadow map
  9722. */
  9723. getTransformMatrix(): Matrix;
  9724. /**
  9725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9726. * Cube and 2D textures for instance.
  9727. */
  9728. recreateShadowMap(): void;
  9729. private _disposeBlurPostProcesses;
  9730. private _disposeRTTandPostProcesses;
  9731. /**
  9732. * Disposes the ShadowGenerator.
  9733. * Returns nothing.
  9734. */
  9735. dispose(): void;
  9736. /**
  9737. * Serializes the shadow generator setup to a json object.
  9738. * @returns The serialized JSON object
  9739. */
  9740. serialize(): any;
  9741. /**
  9742. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9743. * @param parsedShadowGenerator The JSON object to parse
  9744. * @param scene The scene to create the shadow map for
  9745. * @returns The parsed shadow generator
  9746. */
  9747. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9748. }
  9749. }
  9750. declare module "babylonjs/Lights/light" {
  9751. import { Nullable } from "babylonjs/types";
  9752. import { Scene } from "babylonjs/scene";
  9753. import { Vector3 } from "babylonjs/Maths/math.vector";
  9754. import { Color3 } from "babylonjs/Maths/math.color";
  9755. import { Node } from "babylonjs/node";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { Effect } from "babylonjs/Materials/effect";
  9758. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9759. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9760. /**
  9761. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9762. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9763. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9764. */
  9765. export abstract class Light extends Node {
  9766. /**
  9767. * Falloff Default: light is falling off following the material specification:
  9768. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9769. */
  9770. static readonly FALLOFF_DEFAULT: number;
  9771. /**
  9772. * Falloff Physical: light is falling off following the inverse squared distance law.
  9773. */
  9774. static readonly FALLOFF_PHYSICAL: number;
  9775. /**
  9776. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9777. * to enhance interoperability with other engines.
  9778. */
  9779. static readonly FALLOFF_GLTF: number;
  9780. /**
  9781. * Falloff Standard: light is falling off like in the standard material
  9782. * to enhance interoperability with other materials.
  9783. */
  9784. static readonly FALLOFF_STANDARD: number;
  9785. /**
  9786. * If every light affecting the material is in this lightmapMode,
  9787. * material.lightmapTexture adds or multiplies
  9788. * (depends on material.useLightmapAsShadowmap)
  9789. * after every other light calculations.
  9790. */
  9791. static readonly LIGHTMAP_DEFAULT: number;
  9792. /**
  9793. * material.lightmapTexture as only diffuse lighting from this light
  9794. * adds only specular lighting from this light
  9795. * adds dynamic shadows
  9796. */
  9797. static readonly LIGHTMAP_SPECULAR: number;
  9798. /**
  9799. * material.lightmapTexture as only lighting
  9800. * no light calculation from this light
  9801. * only adds dynamic shadows from this light
  9802. */
  9803. static readonly LIGHTMAP_SHADOWSONLY: number;
  9804. /**
  9805. * Each light type uses the default quantity according to its type:
  9806. * point/spot lights use luminous intensity
  9807. * directional lights use illuminance
  9808. */
  9809. static readonly INTENSITYMODE_AUTOMATIC: number;
  9810. /**
  9811. * lumen (lm)
  9812. */
  9813. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9814. /**
  9815. * candela (lm/sr)
  9816. */
  9817. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9818. /**
  9819. * lux (lm/m^2)
  9820. */
  9821. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9822. /**
  9823. * nit (cd/m^2)
  9824. */
  9825. static readonly INTENSITYMODE_LUMINANCE: number;
  9826. /**
  9827. * Light type const id of the point light.
  9828. */
  9829. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9830. /**
  9831. * Light type const id of the directional light.
  9832. */
  9833. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9834. /**
  9835. * Light type const id of the spot light.
  9836. */
  9837. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9838. /**
  9839. * Light type const id of the hemispheric light.
  9840. */
  9841. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9842. /**
  9843. * Diffuse gives the basic color to an object.
  9844. */
  9845. diffuse: Color3;
  9846. /**
  9847. * Specular produces a highlight color on an object.
  9848. * Note: This is note affecting PBR materials.
  9849. */
  9850. specular: Color3;
  9851. /**
  9852. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9853. * falling off base on range or angle.
  9854. * This can be set to any values in Light.FALLOFF_x.
  9855. *
  9856. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9857. * other types of materials.
  9858. */
  9859. falloffType: number;
  9860. /**
  9861. * Strength of the light.
  9862. * Note: By default it is define in the framework own unit.
  9863. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9864. */
  9865. intensity: number;
  9866. private _range;
  9867. protected _inverseSquaredRange: number;
  9868. /**
  9869. * Defines how far from the source the light is impacting in scene units.
  9870. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9871. */
  9872. /**
  9873. * Defines how far from the source the light is impacting in scene units.
  9874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9875. */
  9876. range: number;
  9877. /**
  9878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9879. * of light.
  9880. */
  9881. private _photometricScale;
  9882. private _intensityMode;
  9883. /**
  9884. * Gets the photometric scale used to interpret the intensity.
  9885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9886. */
  9887. /**
  9888. * Sets the photometric scale used to interpret the intensity.
  9889. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9890. */
  9891. intensityMode: number;
  9892. private _radius;
  9893. /**
  9894. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9895. */
  9896. /**
  9897. * sets the light radius used by PBR Materials to simulate soft area lights.
  9898. */
  9899. radius: number;
  9900. private _renderPriority;
  9901. /**
  9902. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9903. * exceeding the number allowed of the materials.
  9904. */
  9905. renderPriority: number;
  9906. private _shadowEnabled;
  9907. /**
  9908. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9909. * the current shadow generator.
  9910. */
  9911. /**
  9912. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9913. * the current shadow generator.
  9914. */
  9915. shadowEnabled: boolean;
  9916. private _includedOnlyMeshes;
  9917. /**
  9918. * Gets the only meshes impacted by this light.
  9919. */
  9920. /**
  9921. * Sets the only meshes impacted by this light.
  9922. */
  9923. includedOnlyMeshes: AbstractMesh[];
  9924. private _excludedMeshes;
  9925. /**
  9926. * Gets the meshes not impacted by this light.
  9927. */
  9928. /**
  9929. * Sets the meshes not impacted by this light.
  9930. */
  9931. excludedMeshes: AbstractMesh[];
  9932. private _excludeWithLayerMask;
  9933. /**
  9934. * Gets the layer id use to find what meshes are not impacted by the light.
  9935. * Inactive if 0
  9936. */
  9937. /**
  9938. * Sets the layer id use to find what meshes are not impacted by the light.
  9939. * Inactive if 0
  9940. */
  9941. excludeWithLayerMask: number;
  9942. private _includeOnlyWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. includeOnlyWithLayerMask: number;
  9952. private _lightmapMode;
  9953. /**
  9954. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9955. */
  9956. /**
  9957. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9958. */
  9959. lightmapMode: number;
  9960. /**
  9961. * Shadow generator associted to the light.
  9962. * @hidden Internal use only.
  9963. */
  9964. _shadowGenerator: Nullable<IShadowGenerator>;
  9965. /**
  9966. * @hidden Internal use only.
  9967. */
  9968. _excludedMeshesIds: string[];
  9969. /**
  9970. * @hidden Internal use only.
  9971. */
  9972. _includedOnlyMeshesIds: string[];
  9973. /**
  9974. * The current light unifom buffer.
  9975. * @hidden Internal use only.
  9976. */
  9977. _uniformBuffer: UniformBuffer;
  9978. /**
  9979. * Creates a Light object in the scene.
  9980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9981. * @param name The firendly name of the light
  9982. * @param scene The scene the light belongs too
  9983. */
  9984. constructor(name: string, scene: Scene);
  9985. protected abstract _buildUniformLayout(): void;
  9986. /**
  9987. * Sets the passed Effect "effect" with the Light information.
  9988. * @param effect The effect to update
  9989. * @param lightIndex The index of the light in the effect to update
  9990. * @returns The light
  9991. */
  9992. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9993. /**
  9994. * Returns the string "Light".
  9995. * @returns the class name
  9996. */
  9997. getClassName(): string;
  9998. /** @hidden */
  9999. readonly _isLight: boolean;
  10000. /**
  10001. * Converts the light information to a readable string for debug purpose.
  10002. * @param fullDetails Supports for multiple levels of logging within scene loading
  10003. * @returns the human readable light info
  10004. */
  10005. toString(fullDetails?: boolean): string;
  10006. /** @hidden */
  10007. protected _syncParentEnabledState(): void;
  10008. /**
  10009. * Set the enabled state of this node.
  10010. * @param value - the new enabled state
  10011. */
  10012. setEnabled(value: boolean): void;
  10013. /**
  10014. * Returns the Light associated shadow generator if any.
  10015. * @return the associated shadow generator.
  10016. */
  10017. getShadowGenerator(): Nullable<IShadowGenerator>;
  10018. /**
  10019. * Returns a Vector3, the absolute light position in the World.
  10020. * @returns the world space position of the light
  10021. */
  10022. getAbsolutePosition(): Vector3;
  10023. /**
  10024. * Specifies if the light will affect the passed mesh.
  10025. * @param mesh The mesh to test against the light
  10026. * @return true the mesh is affected otherwise, false.
  10027. */
  10028. canAffectMesh(mesh: AbstractMesh): boolean;
  10029. /**
  10030. * Sort function to order lights for rendering.
  10031. * @param a First Light object to compare to second.
  10032. * @param b Second Light object to compare first.
  10033. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10034. */
  10035. static CompareLightsPriority(a: Light, b: Light): number;
  10036. /**
  10037. * Releases resources associated with this node.
  10038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10040. */
  10041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10042. /**
  10043. * Returns the light type ID (integer).
  10044. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10045. */
  10046. getTypeID(): number;
  10047. /**
  10048. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10049. * @returns the scaled intensity in intensity mode unit
  10050. */
  10051. getScaledIntensity(): number;
  10052. /**
  10053. * Returns a new Light object, named "name", from the current one.
  10054. * @param name The name of the cloned light
  10055. * @returns the new created light
  10056. */
  10057. clone(name: string): Nullable<Light>;
  10058. /**
  10059. * Serializes the current light into a Serialization object.
  10060. * @returns the serialized object.
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10065. * This new light is named "name" and added to the passed scene.
  10066. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10067. * @param name The friendly name of the light
  10068. * @param scene The scene the new light will belong to
  10069. * @returns the constructor function
  10070. */
  10071. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10072. /**
  10073. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10074. * @param parsedLight The JSON representation of the light
  10075. * @param scene The scene to create the parsed light in
  10076. * @returns the created light after parsing
  10077. */
  10078. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10079. private _hookArrayForExcluded;
  10080. private _hookArrayForIncludedOnly;
  10081. private _resyncMeshes;
  10082. /**
  10083. * Forces the meshes to update their light related information in their rendering used effects
  10084. * @hidden Internal Use Only
  10085. */
  10086. _markMeshesAsLightDirty(): void;
  10087. /**
  10088. * Recomputes the cached photometric scale if needed.
  10089. */
  10090. private _computePhotometricScale;
  10091. /**
  10092. * Returns the Photometric Scale according to the light type and intensity mode.
  10093. */
  10094. private _getPhotometricScale;
  10095. /**
  10096. * Reorder the light in the scene according to their defined priority.
  10097. * @hidden Internal Use Only
  10098. */
  10099. _reorderLightsInScene(): void;
  10100. /**
  10101. * Prepares the list of defines specific to the light type.
  10102. * @param defines the list of defines
  10103. * @param lightIndex defines the index of the light for the effect
  10104. */
  10105. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10106. }
  10107. }
  10108. declare module "babylonjs/Actions/action" {
  10109. import { Observable } from "babylonjs/Misc/observable";
  10110. import { Condition } from "babylonjs/Actions/condition";
  10111. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10112. import { ActionManager } from "babylonjs/Actions/actionManager";
  10113. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10114. /**
  10115. * Interface used to define Action
  10116. */
  10117. export interface IAction {
  10118. /**
  10119. * Trigger for the action
  10120. */
  10121. trigger: number;
  10122. /** Options of the trigger */
  10123. triggerOptions: any;
  10124. /**
  10125. * Gets the trigger parameters
  10126. * @returns the trigger parameters
  10127. */
  10128. getTriggerParameter(): any;
  10129. /**
  10130. * Internal only - executes current action event
  10131. * @hidden
  10132. */
  10133. _executeCurrent(evt?: ActionEvent): void;
  10134. /**
  10135. * Serialize placeholder for child classes
  10136. * @param parent of child
  10137. * @returns the serialized object
  10138. */
  10139. serialize(parent: any): any;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _prepare(): void;
  10145. /**
  10146. * Internal only - manager for action
  10147. * @hidden
  10148. */
  10149. _actionManager: AbstractActionManager;
  10150. /**
  10151. * Adds action to chain of actions, may be a DoNothingAction
  10152. * @param action defines the next action to execute
  10153. * @returns The action passed in
  10154. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10155. */
  10156. then(action: IAction): IAction;
  10157. }
  10158. /**
  10159. * The action to be carried out following a trigger
  10160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10161. */
  10162. export class Action implements IAction {
  10163. /** the trigger, with or without parameters, for the action */
  10164. triggerOptions: any;
  10165. /**
  10166. * Trigger for the action
  10167. */
  10168. trigger: number;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: ActionManager;
  10174. private _nextActiveAction;
  10175. private _child;
  10176. private _condition?;
  10177. private _triggerParameter;
  10178. /**
  10179. * An event triggered prior to action being executed.
  10180. */
  10181. onBeforeExecuteObservable: Observable<Action>;
  10182. /**
  10183. * Creates a new Action
  10184. * @param triggerOptions the trigger, with or without parameters, for the action
  10185. * @param condition an optional determinant of action
  10186. */
  10187. constructor(
  10188. /** the trigger, with or without parameters, for the action */
  10189. triggerOptions: any, condition?: Condition);
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _prepare(): void;
  10195. /**
  10196. * Gets the trigger parameters
  10197. * @returns the trigger parameters
  10198. */
  10199. getTriggerParameter(): any;
  10200. /**
  10201. * Internal only - executes current action event
  10202. * @hidden
  10203. */
  10204. _executeCurrent(evt?: ActionEvent): void;
  10205. /**
  10206. * Execute placeholder for child classes
  10207. * @param evt optional action event
  10208. */
  10209. execute(evt?: ActionEvent): void;
  10210. /**
  10211. * Skips to next active action
  10212. */
  10213. skipToNextActiveAction(): void;
  10214. /**
  10215. * Adds action to chain of actions, may be a DoNothingAction
  10216. * @param action defines the next action to execute
  10217. * @returns The action passed in
  10218. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10219. */
  10220. then(action: Action): Action;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. _getProperty(propertyPath: string): string;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. _getEffectiveTarget(target: any, propertyPath: string): any;
  10231. /**
  10232. * Serialize placeholder for child classes
  10233. * @param parent of child
  10234. * @returns the serialized object
  10235. */
  10236. serialize(parent: any): any;
  10237. /**
  10238. * Internal only called by serialize
  10239. * @hidden
  10240. */
  10241. protected _serialize(serializedAction: any, parent?: any): any;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. static _SerializeValueAsString: (value: any) => string;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10252. name: string;
  10253. targetType: string;
  10254. value: string;
  10255. };
  10256. }
  10257. }
  10258. declare module "babylonjs/Actions/condition" {
  10259. import { ActionManager } from "babylonjs/Actions/actionManager";
  10260. /**
  10261. * A Condition applied to an Action
  10262. */
  10263. export class Condition {
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. /**
  10270. * Internal only
  10271. * @hidden
  10272. */
  10273. _evaluationId: number;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _currentResult: boolean;
  10279. /**
  10280. * Creates a new Condition
  10281. * @param actionManager the manager of the action the condition is applied to
  10282. */
  10283. constructor(actionManager: ActionManager);
  10284. /**
  10285. * Check if the current condition is valid
  10286. * @returns a boolean
  10287. */
  10288. isValid(): boolean;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getProperty(propertyPath: string): string;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _getEffectiveTarget(target: any, propertyPath: string): any;
  10299. /**
  10300. * Serialize placeholder for child classes
  10301. * @returns the serialized object
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. protected _serialize(serializedCondition: any): any;
  10309. }
  10310. /**
  10311. * Defines specific conditional operators as extensions of Condition
  10312. */
  10313. export class ValueCondition extends Condition {
  10314. /** path to specify the property of the target the conditional operator uses */
  10315. propertyPath: string;
  10316. /** the value compared by the conditional operator against the current value of the property */
  10317. value: any;
  10318. /** the conditional operator, default ValueCondition.IsEqual */
  10319. operator: number;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. private static _IsEqual;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. private static _IsDifferent;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. private static _IsGreater;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private static _IsLesser;
  10340. /**
  10341. * returns the number for IsEqual
  10342. */
  10343. static readonly IsEqual: number;
  10344. /**
  10345. * Returns the number for IsDifferent
  10346. */
  10347. static readonly IsDifferent: number;
  10348. /**
  10349. * Returns the number for IsGreater
  10350. */
  10351. static readonly IsGreater: number;
  10352. /**
  10353. * Returns the number for IsLesser
  10354. */
  10355. static readonly IsLesser: number;
  10356. /**
  10357. * Internal only The action manager for the condition
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. private _target;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _effectiveTarget;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private _property;
  10376. /**
  10377. * Creates a new ValueCondition
  10378. * @param actionManager manager for the action the condition applies to
  10379. * @param target for the action
  10380. * @param propertyPath path to specify the property of the target the conditional operator uses
  10381. * @param value the value compared by the conditional operator against the current value of the property
  10382. * @param operator the conditional operator, default ValueCondition.IsEqual
  10383. */
  10384. constructor(actionManager: ActionManager, target: any,
  10385. /** path to specify the property of the target the conditional operator uses */
  10386. propertyPath: string,
  10387. /** the value compared by the conditional operator against the current value of the property */
  10388. value: any,
  10389. /** the conditional operator, default ValueCondition.IsEqual */
  10390. operator?: number);
  10391. /**
  10392. * Compares the given value with the property value for the specified conditional operator
  10393. * @returns the result of the comparison
  10394. */
  10395. isValid(): boolean;
  10396. /**
  10397. * Serialize the ValueCondition into a JSON compatible object
  10398. * @returns serialization object
  10399. */
  10400. serialize(): any;
  10401. /**
  10402. * Gets the name of the conditional operator for the ValueCondition
  10403. * @param operator the conditional operator
  10404. * @returns the name
  10405. */
  10406. static GetOperatorName(operator: number): string;
  10407. }
  10408. /**
  10409. * Defines a predicate condition as an extension of Condition
  10410. */
  10411. export class PredicateCondition extends Condition {
  10412. /** defines the predicate function used to validate the condition */
  10413. predicate: () => boolean;
  10414. /**
  10415. * Internal only - manager for action
  10416. * @hidden
  10417. */
  10418. _actionManager: ActionManager;
  10419. /**
  10420. * Creates a new PredicateCondition
  10421. * @param actionManager manager for the action the condition applies to
  10422. * @param predicate defines the predicate function used to validate the condition
  10423. */
  10424. constructor(actionManager: ActionManager,
  10425. /** defines the predicate function used to validate the condition */
  10426. predicate: () => boolean);
  10427. /**
  10428. * @returns the validity of the predicate condition
  10429. */
  10430. isValid(): boolean;
  10431. }
  10432. /**
  10433. * Defines a state condition as an extension of Condition
  10434. */
  10435. export class StateCondition extends Condition {
  10436. /** Value to compare with target state */
  10437. value: string;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Internal only
  10445. * @hidden
  10446. */
  10447. private _target;
  10448. /**
  10449. * Creates a new StateCondition
  10450. * @param actionManager manager for the action the condition applies to
  10451. * @param target of the condition
  10452. * @param value to compare with target state
  10453. */
  10454. constructor(actionManager: ActionManager, target: any,
  10455. /** Value to compare with target state */
  10456. value: string);
  10457. /**
  10458. * Gets a boolean indicating if the current condition is met
  10459. * @returns the validity of the state
  10460. */
  10461. isValid(): boolean;
  10462. /**
  10463. * Serialize the StateCondition into a JSON compatible object
  10464. * @returns serialization object
  10465. */
  10466. serialize(): any;
  10467. }
  10468. }
  10469. declare module "babylonjs/Actions/directActions" {
  10470. import { Action } from "babylonjs/Actions/action";
  10471. import { Condition } from "babylonjs/Actions/condition";
  10472. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10473. /**
  10474. * This defines an action responsible to toggle a boolean once triggered.
  10475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10476. */
  10477. export class SwitchBooleanAction extends Action {
  10478. /**
  10479. * The path to the boolean property in the target object
  10480. */
  10481. propertyPath: string;
  10482. private _target;
  10483. private _effectiveTarget;
  10484. private _property;
  10485. /**
  10486. * Instantiate the action
  10487. * @param triggerOptions defines the trigger options
  10488. * @param target defines the object containing the boolean
  10489. * @param propertyPath defines the path to the boolean property in the target object
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action toggle the boolean value.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to set a the state field of the target
  10508. * to a desired value once triggered.
  10509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10510. */
  10511. export class SetStateAction extends Action {
  10512. /**
  10513. * The value to store in the state field.
  10514. */
  10515. value: string;
  10516. private _target;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the object containing the state property
  10521. * @param value defines the value to store in the state field
  10522. * @param condition defines the trigger related conditions
  10523. */
  10524. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10525. /**
  10526. * Execute the action and store the value on the target state property.
  10527. */
  10528. execute(): void;
  10529. /**
  10530. * Serializes the actions and its related information.
  10531. * @param parent defines the object to serialize in
  10532. * @returns the serialized object
  10533. */
  10534. serialize(parent: any): any;
  10535. }
  10536. /**
  10537. * This defines an action responsible to set a property of the target
  10538. * to a desired value once triggered.
  10539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10540. */
  10541. export class SetValueAction extends Action {
  10542. /**
  10543. * The path of the property to set in the target.
  10544. */
  10545. propertyPath: string;
  10546. /**
  10547. * The value to set in the property
  10548. */
  10549. value: any;
  10550. private _target;
  10551. private _effectiveTarget;
  10552. private _property;
  10553. /**
  10554. * Instantiate the action
  10555. * @param triggerOptions defines the trigger options
  10556. * @param target defines the object containing the property
  10557. * @param propertyPath defines the path of the property to set in the target
  10558. * @param value defines the value to set in the property
  10559. * @param condition defines the trigger related conditions
  10560. */
  10561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10562. /** @hidden */
  10563. _prepare(): void;
  10564. /**
  10565. * Execute the action and set the targetted property to the desired value.
  10566. */
  10567. execute(): void;
  10568. /**
  10569. * Serializes the actions and its related information.
  10570. * @param parent defines the object to serialize in
  10571. * @returns the serialized object
  10572. */
  10573. serialize(parent: any): any;
  10574. }
  10575. /**
  10576. * This defines an action responsible to increment the target value
  10577. * to a desired value once triggered.
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10579. */
  10580. export class IncrementValueAction extends Action {
  10581. /**
  10582. * The path of the property to increment in the target.
  10583. */
  10584. propertyPath: string;
  10585. /**
  10586. * The value we should increment the property by.
  10587. */
  10588. value: any;
  10589. private _target;
  10590. private _effectiveTarget;
  10591. private _property;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the object containing the property
  10596. * @param propertyPath defines the path of the property to increment in the target
  10597. * @param value defines the value value we should increment the property by
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and increment the target of the value amount.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible to start an animation once triggered.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class PlayAnimationAction extends Action {
  10619. /**
  10620. * Where the animation should start (animation frame)
  10621. */
  10622. from: number;
  10623. /**
  10624. * Where the animation should stop (animation frame)
  10625. */
  10626. to: number;
  10627. /**
  10628. * Define if the animation should loop or stop after the first play.
  10629. */
  10630. loop?: boolean;
  10631. private _target;
  10632. /**
  10633. * Instantiate the action
  10634. * @param triggerOptions defines the trigger options
  10635. * @param target defines the target animation or animation name
  10636. * @param from defines from where the animation should start (animation frame)
  10637. * @param end defines where the animation should stop (animation frame)
  10638. * @param loop defines if the animation should loop or stop after the first play
  10639. * @param condition defines the trigger related conditions
  10640. */
  10641. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10642. /** @hidden */
  10643. _prepare(): void;
  10644. /**
  10645. * Execute the action and play the animation.
  10646. */
  10647. execute(): void;
  10648. /**
  10649. * Serializes the actions and its related information.
  10650. * @param parent defines the object to serialize in
  10651. * @returns the serialized object
  10652. */
  10653. serialize(parent: any): any;
  10654. }
  10655. /**
  10656. * This defines an action responsible to stop an animation once triggered.
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10658. */
  10659. export class StopAnimationAction extends Action {
  10660. private _target;
  10661. /**
  10662. * Instantiate the action
  10663. * @param triggerOptions defines the trigger options
  10664. * @param target defines the target animation or animation name
  10665. * @param condition defines the trigger related conditions
  10666. */
  10667. constructor(triggerOptions: any, target: any, condition?: Condition);
  10668. /** @hidden */
  10669. _prepare(): void;
  10670. /**
  10671. * Execute the action and stop the animation.
  10672. */
  10673. execute(): void;
  10674. /**
  10675. * Serializes the actions and its related information.
  10676. * @param parent defines the object to serialize in
  10677. * @returns the serialized object
  10678. */
  10679. serialize(parent: any): any;
  10680. }
  10681. /**
  10682. * This defines an action responsible that does nothing once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class DoNothingAction extends Action {
  10686. /**
  10687. * Instantiate the action
  10688. * @param triggerOptions defines the trigger options
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions?: any, condition?: Condition);
  10692. /**
  10693. * Execute the action and do nothing.
  10694. */
  10695. execute(): void;
  10696. /**
  10697. * Serializes the actions and its related information.
  10698. * @param parent defines the object to serialize in
  10699. * @returns the serialized object
  10700. */
  10701. serialize(parent: any): any;
  10702. }
  10703. /**
  10704. * This defines an action responsible to trigger several actions once triggered.
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10706. */
  10707. export class CombineAction extends Action {
  10708. /**
  10709. * The list of aggregated animations to run.
  10710. */
  10711. children: Action[];
  10712. /**
  10713. * Instantiate the action
  10714. * @param triggerOptions defines the trigger options
  10715. * @param children defines the list of aggregated animations to run
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10719. /** @hidden */
  10720. _prepare(): void;
  10721. /**
  10722. * Execute the action and executes all the aggregated actions.
  10723. */
  10724. execute(evt: ActionEvent): void;
  10725. /**
  10726. * Serializes the actions and its related information.
  10727. * @param parent defines the object to serialize in
  10728. * @returns the serialized object
  10729. */
  10730. serialize(parent: any): any;
  10731. }
  10732. /**
  10733. * This defines an action responsible to run code (external event) once triggered.
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10735. */
  10736. export class ExecuteCodeAction extends Action {
  10737. /**
  10738. * The callback function to run.
  10739. */
  10740. func: (evt: ActionEvent) => void;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param func defines the callback function to run
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10748. /**
  10749. * Execute the action and run the attached code.
  10750. */
  10751. execute(evt: ActionEvent): void;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set the parent property of the target once triggered.
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10756. */
  10757. export class SetParentAction extends Action {
  10758. private _parent;
  10759. private _target;
  10760. /**
  10761. * Instantiate the action
  10762. * @param triggerOptions defines the trigger options
  10763. * @param target defines the target containing the parent property
  10764. * @param parent defines from where the animation should start (animation frame)
  10765. * @param condition defines the trigger related conditions
  10766. */
  10767. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10768. /** @hidden */
  10769. _prepare(): void;
  10770. /**
  10771. * Execute the action and set the parent property.
  10772. */
  10773. execute(): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. }
  10782. declare module "babylonjs/Actions/actionManager" {
  10783. import { Nullable } from "babylonjs/types";
  10784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10785. import { Scene } from "babylonjs/scene";
  10786. import { IAction } from "babylonjs/Actions/action";
  10787. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10789. /**
  10790. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10791. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10793. */
  10794. export class ActionManager extends AbstractActionManager {
  10795. /**
  10796. * Nothing
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly NothingTrigger: number;
  10800. /**
  10801. * On pick
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPickTrigger: number;
  10805. /**
  10806. * On left pick
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnLeftPickTrigger: number;
  10810. /**
  10811. * On right pick
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnRightPickTrigger: number;
  10815. /**
  10816. * On center pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnCenterPickTrigger: number;
  10820. /**
  10821. * On pick down
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnPickDownTrigger: number;
  10825. /**
  10826. * On double pick
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnDoublePickTrigger: number;
  10830. /**
  10831. * On pick up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnPickUpTrigger: number;
  10835. /**
  10836. * On pick out.
  10837. * This trigger will only be raised if you also declared a OnPickDown
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10839. */
  10840. static readonly OnPickOutTrigger: number;
  10841. /**
  10842. * On long press
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnLongPressTrigger: number;
  10846. /**
  10847. * On pointer over
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnPointerOverTrigger: number;
  10851. /**
  10852. * On pointer out
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPointerOutTrigger: number;
  10856. /**
  10857. * On every frame
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnEveryFrameTrigger: number;
  10861. /**
  10862. * On intersection enter
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnIntersectionEnterTrigger: number;
  10866. /**
  10867. * On intersection exit
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnIntersectionExitTrigger: number;
  10871. /**
  10872. * On key down
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnKeyDownTrigger: number;
  10876. /**
  10877. * On key up
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnKeyUpTrigger: number;
  10881. private _scene;
  10882. /**
  10883. * Creates a new action manager
  10884. * @param scene defines the hosting scene
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Releases all associated resources
  10889. */
  10890. dispose(): void;
  10891. /**
  10892. * Gets hosting scene
  10893. * @returns the hosting scene
  10894. */
  10895. getScene(): Scene;
  10896. /**
  10897. * Does this action manager handles actions of any of the given triggers
  10898. * @param triggers defines the triggers to be tested
  10899. * @return a boolean indicating whether one (or more) of the triggers is handled
  10900. */
  10901. hasSpecificTriggers(triggers: number[]): boolean;
  10902. /**
  10903. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10904. * speed.
  10905. * @param triggerA defines the trigger to be tested
  10906. * @param triggerB defines the trigger to be tested
  10907. * @return a boolean indicating whether one (or more) of the triggers is handled
  10908. */
  10909. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10910. /**
  10911. * Does this action manager handles actions of a given trigger
  10912. * @param trigger defines the trigger to be tested
  10913. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10914. * @return whether the trigger is handled
  10915. */
  10916. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10917. /**
  10918. * Does this action manager has pointer triggers
  10919. */
  10920. readonly hasPointerTriggers: boolean;
  10921. /**
  10922. * Does this action manager has pick triggers
  10923. */
  10924. readonly hasPickTriggers: boolean;
  10925. /**
  10926. * Registers an action to this action manager
  10927. * @param action defines the action to be registered
  10928. * @return the action amended (prepared) after registration
  10929. */
  10930. registerAction(action: IAction): Nullable<IAction>;
  10931. /**
  10932. * Unregisters an action to this action manager
  10933. * @param action defines the action to be unregistered
  10934. * @return a boolean indicating whether the action has been unregistered
  10935. */
  10936. unregisterAction(action: IAction): Boolean;
  10937. /**
  10938. * Process a specific trigger
  10939. * @param trigger defines the trigger to process
  10940. * @param evt defines the event details to be processed
  10941. */
  10942. processTrigger(trigger: number, evt?: IActionEvent): void;
  10943. /** @hidden */
  10944. _getEffectiveTarget(target: any, propertyPath: string): any;
  10945. /** @hidden */
  10946. _getProperty(propertyPath: string): string;
  10947. /**
  10948. * Serialize this manager to a JSON object
  10949. * @param name defines the property name to store this manager
  10950. * @returns a JSON representation of this manager
  10951. */
  10952. serialize(name: string): any;
  10953. /**
  10954. * Creates a new ActionManager from a JSON data
  10955. * @param parsedActions defines the JSON data to read from
  10956. * @param object defines the hosting mesh
  10957. * @param scene defines the hosting scene
  10958. */
  10959. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10960. /**
  10961. * Get a trigger name by index
  10962. * @param trigger defines the trigger index
  10963. * @returns a trigger name
  10964. */
  10965. static GetTriggerName(trigger: number): string;
  10966. }
  10967. }
  10968. declare module "babylonjs/Culling/ray" {
  10969. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10972. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10973. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10974. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10975. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10976. import { Plane } from "babylonjs/Maths/math.plane";
  10977. /**
  10978. * Class representing a ray with position and direction
  10979. */
  10980. export class Ray {
  10981. /** origin point */
  10982. origin: Vector3;
  10983. /** direction */
  10984. direction: Vector3;
  10985. /** length of the ray */
  10986. length: number;
  10987. private static readonly TmpVector3;
  10988. private _tmpRay;
  10989. /**
  10990. * Creates a new ray
  10991. * @param origin origin point
  10992. * @param direction direction
  10993. * @param length length of the ray
  10994. */
  10995. constructor(
  10996. /** origin point */
  10997. origin: Vector3,
  10998. /** direction */
  10999. direction: Vector3,
  11000. /** length of the ray */
  11001. length?: number);
  11002. /**
  11003. * Checks if the ray intersects a box
  11004. * @param minimum bound of the box
  11005. * @param maximum bound of the box
  11006. * @param intersectionTreshold extra extend to be added to the box in all direction
  11007. * @returns if the box was hit
  11008. */
  11009. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11010. /**
  11011. * Checks if the ray intersects a box
  11012. * @param box the bounding box to check
  11013. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11014. * @returns if the box was hit
  11015. */
  11016. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11017. /**
  11018. * If the ray hits a sphere
  11019. * @param sphere the bounding sphere to check
  11020. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11021. * @returns true if it hits the sphere
  11022. */
  11023. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11024. /**
  11025. * If the ray hits a triange
  11026. * @param vertex0 triangle vertex
  11027. * @param vertex1 triangle vertex
  11028. * @param vertex2 triangle vertex
  11029. * @returns intersection information if hit
  11030. */
  11031. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11032. /**
  11033. * Checks if ray intersects a plane
  11034. * @param plane the plane to check
  11035. * @returns the distance away it was hit
  11036. */
  11037. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11038. /**
  11039. * Calculate the intercept of a ray on a given axis
  11040. * @param axis to check 'x' | 'y' | 'z'
  11041. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11042. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11043. */
  11044. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11045. /**
  11046. * Checks if ray intersects a mesh
  11047. * @param mesh the mesh to check
  11048. * @param fastCheck if only the bounding box should checked
  11049. * @returns picking info of the intersecton
  11050. */
  11051. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11052. /**
  11053. * Checks if ray intersects a mesh
  11054. * @param meshes the meshes to check
  11055. * @param fastCheck if only the bounding box should checked
  11056. * @param results array to store result in
  11057. * @returns Array of picking infos
  11058. */
  11059. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11060. private _comparePickingInfo;
  11061. private static smallnum;
  11062. private static rayl;
  11063. /**
  11064. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11065. * @param sega the first point of the segment to test the intersection against
  11066. * @param segb the second point of the segment to test the intersection against
  11067. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11068. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11069. */
  11070. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11071. /**
  11072. * Update the ray from viewport position
  11073. * @param x position
  11074. * @param y y position
  11075. * @param viewportWidth viewport width
  11076. * @param viewportHeight viewport height
  11077. * @param world world matrix
  11078. * @param view view matrix
  11079. * @param projection projection matrix
  11080. * @returns this ray updated
  11081. */
  11082. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11083. /**
  11084. * Creates a ray with origin and direction of 0,0,0
  11085. * @returns the new ray
  11086. */
  11087. static Zero(): Ray;
  11088. /**
  11089. * Creates a new ray from screen space and viewport
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns new ray
  11098. */
  11099. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11102. * transformed to the given world matrix.
  11103. * @param origin The origin point
  11104. * @param end The end point
  11105. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11106. * @returns the new ray
  11107. */
  11108. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11109. /**
  11110. * Transforms a ray by a matrix
  11111. * @param ray ray to transform
  11112. * @param matrix matrix to apply
  11113. * @returns the resulting new ray
  11114. */
  11115. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11116. /**
  11117. * Transforms a ray by a matrix
  11118. * @param ray ray to transform
  11119. * @param matrix matrix to apply
  11120. * @param result ray to store result in
  11121. */
  11122. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11123. /**
  11124. * Unproject a ray from screen space to object space
  11125. * @param sourceX defines the screen space x coordinate to use
  11126. * @param sourceY defines the screen space y coordinate to use
  11127. * @param viewportWidth defines the current width of the viewport
  11128. * @param viewportHeight defines the current height of the viewport
  11129. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11130. * @param view defines the view matrix to use
  11131. * @param projection defines the projection matrix to use
  11132. */
  11133. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11134. }
  11135. /**
  11136. * Type used to define predicate used to select faces when a mesh intersection is detected
  11137. */
  11138. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11139. module "babylonjs/scene" {
  11140. interface Scene {
  11141. /** @hidden */
  11142. _tempPickingRay: Nullable<Ray>;
  11143. /** @hidden */
  11144. _cachedRayForTransform: Ray;
  11145. /** @hidden */
  11146. _pickWithRayInverseMatrix: Matrix;
  11147. /** @hidden */
  11148. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11149. /** @hidden */
  11150. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11151. }
  11152. }
  11153. }
  11154. declare module "babylonjs/sceneComponent" {
  11155. import { Scene } from "babylonjs/scene";
  11156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11158. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11159. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11160. import { Nullable } from "babylonjs/types";
  11161. import { Camera } from "babylonjs/Cameras/camera";
  11162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11163. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11164. import { AbstractScene } from "babylonjs/abstractScene";
  11165. /**
  11166. * Groups all the scene component constants in one place to ease maintenance.
  11167. * @hidden
  11168. */
  11169. export class SceneComponentConstants {
  11170. static readonly NAME_EFFECTLAYER: string;
  11171. static readonly NAME_LAYER: string;
  11172. static readonly NAME_LENSFLARESYSTEM: string;
  11173. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11174. static readonly NAME_PARTICLESYSTEM: string;
  11175. static readonly NAME_GAMEPAD: string;
  11176. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11177. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11178. static readonly NAME_DEPTHRENDERER: string;
  11179. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11180. static readonly NAME_SPRITE: string;
  11181. static readonly NAME_OUTLINERENDERER: string;
  11182. static readonly NAME_PROCEDURALTEXTURE: string;
  11183. static readonly NAME_SHADOWGENERATOR: string;
  11184. static readonly NAME_OCTREE: string;
  11185. static readonly NAME_PHYSICSENGINE: string;
  11186. static readonly NAME_AUDIO: string;
  11187. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11188. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11189. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11190. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11191. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11192. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11193. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11194. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11195. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11196. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11197. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11198. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11199. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11200. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11201. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11202. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11203. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11204. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11205. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11206. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11207. static readonly STEP_AFTERRENDER_AUDIO: number;
  11208. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11209. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11210. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11211. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11212. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11213. static readonly STEP_POINTERMOVE_SPRITE: number;
  11214. static readonly STEP_POINTERDOWN_SPRITE: number;
  11215. static readonly STEP_POINTERUP_SPRITE: number;
  11216. }
  11217. /**
  11218. * This represents a scene component.
  11219. *
  11220. * This is used to decouple the dependency the scene is having on the different workloads like
  11221. * layers, post processes...
  11222. */
  11223. export interface ISceneComponent {
  11224. /**
  11225. * The name of the component. Each component must have a unique name.
  11226. */
  11227. name: string;
  11228. /**
  11229. * The scene the component belongs to.
  11230. */
  11231. scene: Scene;
  11232. /**
  11233. * Register the component to one instance of a scene.
  11234. */
  11235. register(): void;
  11236. /**
  11237. * Rebuilds the elements related to this component in case of
  11238. * context lost for instance.
  11239. */
  11240. rebuild(): void;
  11241. /**
  11242. * Disposes the component and the associated ressources.
  11243. */
  11244. dispose(): void;
  11245. }
  11246. /**
  11247. * This represents a SERIALIZABLE scene component.
  11248. *
  11249. * This extends Scene Component to add Serialization methods on top.
  11250. */
  11251. export interface ISceneSerializableComponent extends ISceneComponent {
  11252. /**
  11253. * Adds all the elements from the container to the scene
  11254. * @param container the container holding the elements
  11255. */
  11256. addFromContainer(container: AbstractScene): void;
  11257. /**
  11258. * Removes all the elements in the container from the scene
  11259. * @param container contains the elements to remove
  11260. * @param dispose if the removed element should be disposed (default: false)
  11261. */
  11262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11263. /**
  11264. * Serializes the component data to the specified json object
  11265. * @param serializationObject The object to serialize to
  11266. */
  11267. serialize(serializationObject: any): void;
  11268. }
  11269. /**
  11270. * Strong typing of a Mesh related stage step action
  11271. */
  11272. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11273. /**
  11274. * Strong typing of a Evaluate Sub Mesh related stage step action
  11275. */
  11276. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11277. /**
  11278. * Strong typing of a Active Mesh related stage step action
  11279. */
  11280. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11281. /**
  11282. * Strong typing of a Camera related stage step action
  11283. */
  11284. export type CameraStageAction = (camera: Camera) => void;
  11285. /**
  11286. * Strong typing of a Camera Frame buffer related stage step action
  11287. */
  11288. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11289. /**
  11290. * Strong typing of a Render Target related stage step action
  11291. */
  11292. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11293. /**
  11294. * Strong typing of a RenderingGroup related stage step action
  11295. */
  11296. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11297. /**
  11298. * Strong typing of a Mesh Render related stage step action
  11299. */
  11300. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11301. /**
  11302. * Strong typing of a simple stage step action
  11303. */
  11304. export type SimpleStageAction = () => void;
  11305. /**
  11306. * Strong typing of a render target action.
  11307. */
  11308. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11309. /**
  11310. * Strong typing of a pointer move action.
  11311. */
  11312. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11313. /**
  11314. * Strong typing of a pointer up/down action.
  11315. */
  11316. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11317. /**
  11318. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11319. * @hidden
  11320. */
  11321. export class Stage<T extends Function> extends Array<{
  11322. index: number;
  11323. component: ISceneComponent;
  11324. action: T;
  11325. }> {
  11326. /**
  11327. * Hide ctor from the rest of the world.
  11328. * @param items The items to add.
  11329. */
  11330. private constructor();
  11331. /**
  11332. * Creates a new Stage.
  11333. * @returns A new instance of a Stage
  11334. */
  11335. static Create<T extends Function>(): Stage<T>;
  11336. /**
  11337. * Registers a step in an ordered way in the targeted stage.
  11338. * @param index Defines the position to register the step in
  11339. * @param component Defines the component attached to the step
  11340. * @param action Defines the action to launch during the step
  11341. */
  11342. registerStep(index: number, component: ISceneComponent, action: T): void;
  11343. /**
  11344. * Clears all the steps from the stage.
  11345. */
  11346. clear(): void;
  11347. }
  11348. }
  11349. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Observable } from "babylonjs/Misc/observable";
  11352. import { Scene } from "babylonjs/scene";
  11353. import { Sprite } from "babylonjs/Sprites/sprite";
  11354. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11355. import { Ray } from "babylonjs/Culling/ray";
  11356. import { Camera } from "babylonjs/Cameras/camera";
  11357. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11358. import { ISceneComponent } from "babylonjs/sceneComponent";
  11359. module "babylonjs/scene" {
  11360. interface Scene {
  11361. /** @hidden */
  11362. _pointerOverSprite: Nullable<Sprite>;
  11363. /** @hidden */
  11364. _pickedDownSprite: Nullable<Sprite>;
  11365. /** @hidden */
  11366. _tempSpritePickingRay: Nullable<Ray>;
  11367. /**
  11368. * All of the sprite managers added to this scene
  11369. * @see http://doc.babylonjs.com/babylon101/sprites
  11370. */
  11371. spriteManagers: Array<ISpriteManager>;
  11372. /**
  11373. * An event triggered when sprites rendering is about to start
  11374. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11375. */
  11376. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11377. /**
  11378. * An event triggered when sprites rendering is done
  11379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11380. */
  11381. onAfterSpritesRenderingObservable: Observable<Scene>;
  11382. /** @hidden */
  11383. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11384. /** Launch a ray to try to pick a sprite in the scene
  11385. * @param x position on screen
  11386. * @param y position on screen
  11387. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11388. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11389. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11390. * @returns a PickingInfo
  11391. */
  11392. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11393. /** Use the given ray to pick a sprite in the scene
  11394. * @param ray The ray (in world space) to use to pick meshes
  11395. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11396. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11397. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11398. * @returns a PickingInfo
  11399. */
  11400. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /**
  11402. * Force the sprite under the pointer
  11403. * @param sprite defines the sprite to use
  11404. */
  11405. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11406. /**
  11407. * Gets the sprite under the pointer
  11408. * @returns a Sprite or null if no sprite is under the pointer
  11409. */
  11410. getPointerOverSprite(): Nullable<Sprite>;
  11411. }
  11412. }
  11413. /**
  11414. * Defines the sprite scene component responsible to manage sprites
  11415. * in a given scene.
  11416. */
  11417. export class SpriteSceneComponent implements ISceneComponent {
  11418. /**
  11419. * The component name helpfull to identify the component in the list of scene components.
  11420. */
  11421. readonly name: string;
  11422. /**
  11423. * The scene the component belongs to.
  11424. */
  11425. scene: Scene;
  11426. /** @hidden */
  11427. private _spritePredicate;
  11428. /**
  11429. * Creates a new instance of the component for the given scene
  11430. * @param scene Defines the scene to register the component in
  11431. */
  11432. constructor(scene: Scene);
  11433. /**
  11434. * Registers the component in a given scene
  11435. */
  11436. register(): void;
  11437. /**
  11438. * Rebuilds the elements related to this component in case of
  11439. * context lost for instance.
  11440. */
  11441. rebuild(): void;
  11442. /**
  11443. * Disposes the component and the associated ressources.
  11444. */
  11445. dispose(): void;
  11446. private _pickSpriteButKeepRay;
  11447. private _pointerMove;
  11448. private _pointerDown;
  11449. private _pointerUp;
  11450. }
  11451. }
  11452. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11453. /** @hidden */
  11454. export var fogFragmentDeclaration: {
  11455. name: string;
  11456. shader: string;
  11457. };
  11458. }
  11459. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11460. /** @hidden */
  11461. export var fogFragment: {
  11462. name: string;
  11463. shader: string;
  11464. };
  11465. }
  11466. declare module "babylonjs/Shaders/sprites.fragment" {
  11467. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11468. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11469. /** @hidden */
  11470. export var spritesPixelShader: {
  11471. name: string;
  11472. shader: string;
  11473. };
  11474. }
  11475. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11476. /** @hidden */
  11477. export var fogVertexDeclaration: {
  11478. name: string;
  11479. shader: string;
  11480. };
  11481. }
  11482. declare module "babylonjs/Shaders/sprites.vertex" {
  11483. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11484. /** @hidden */
  11485. export var spritesVertexShader: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module "babylonjs/Sprites/spriteManager" {
  11491. import { IDisposable, Scene } from "babylonjs/scene";
  11492. import { Nullable } from "babylonjs/types";
  11493. import { Observable } from "babylonjs/Misc/observable";
  11494. import { Sprite } from "babylonjs/Sprites/sprite";
  11495. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11496. import { Camera } from "babylonjs/Cameras/camera";
  11497. import { Texture } from "babylonjs/Materials/Textures/texture";
  11498. import "babylonjs/Shaders/sprites.fragment";
  11499. import "babylonjs/Shaders/sprites.vertex";
  11500. import { Ray } from "babylonjs/Culling/ray";
  11501. /**
  11502. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11503. */
  11504. export interface ISpriteManager extends IDisposable {
  11505. /**
  11506. * Restricts the camera to viewing objects with the same layerMask.
  11507. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11508. */
  11509. layerMask: number;
  11510. /**
  11511. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11512. */
  11513. isPickable: boolean;
  11514. /**
  11515. * Specifies the rendering group id for this mesh (0 by default)
  11516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11517. */
  11518. renderingGroupId: number;
  11519. /**
  11520. * Defines the list of sprites managed by the manager.
  11521. */
  11522. sprites: Array<Sprite>;
  11523. /**
  11524. * Tests the intersection of a sprite with a specific ray.
  11525. * @param ray The ray we are sending to test the collision
  11526. * @param camera The camera space we are sending rays in
  11527. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11528. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11529. * @returns picking info or null.
  11530. */
  11531. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11532. /**
  11533. * Renders the list of sprites on screen.
  11534. */
  11535. render(): void;
  11536. }
  11537. /**
  11538. * Class used to manage multiple sprites on the same spritesheet
  11539. * @see http://doc.babylonjs.com/babylon101/sprites
  11540. */
  11541. export class SpriteManager implements ISpriteManager {
  11542. /** defines the manager's name */
  11543. name: string;
  11544. /** Gets the list of sprites */
  11545. sprites: Sprite[];
  11546. /** Gets or sets the rendering group id (0 by default) */
  11547. renderingGroupId: number;
  11548. /** Gets or sets camera layer mask */
  11549. layerMask: number;
  11550. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11551. fogEnabled: boolean;
  11552. /** Gets or sets a boolean indicating if the sprites are pickable */
  11553. isPickable: boolean;
  11554. /** Defines the default width of a cell in the spritesheet */
  11555. cellWidth: number;
  11556. /** Defines the default height of a cell in the spritesheet */
  11557. cellHeight: number;
  11558. /**
  11559. * An event triggered when the manager is disposed.
  11560. */
  11561. onDisposeObservable: Observable<SpriteManager>;
  11562. private _onDisposeObserver;
  11563. /**
  11564. * Callback called when the manager is disposed
  11565. */
  11566. onDispose: () => void;
  11567. private _capacity;
  11568. private _spriteTexture;
  11569. private _epsilon;
  11570. private _scene;
  11571. private _vertexData;
  11572. private _buffer;
  11573. private _vertexBuffers;
  11574. private _indexBuffer;
  11575. private _effectBase;
  11576. private _effectFog;
  11577. /**
  11578. * Gets or sets the spritesheet texture
  11579. */
  11580. texture: Texture;
  11581. /**
  11582. * Creates a new sprite manager
  11583. * @param name defines the manager's name
  11584. * @param imgUrl defines the sprite sheet url
  11585. * @param capacity defines the maximum allowed number of sprites
  11586. * @param cellSize defines the size of a sprite cell
  11587. * @param scene defines the hosting scene
  11588. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11589. * @param samplingMode defines the smapling mode to use with spritesheet
  11590. */
  11591. constructor(
  11592. /** defines the manager's name */
  11593. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11594. private _appendSpriteVertex;
  11595. /**
  11596. * Intersects the sprites with a ray
  11597. * @param ray defines the ray to intersect with
  11598. * @param camera defines the current active camera
  11599. * @param predicate defines a predicate used to select candidate sprites
  11600. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11601. * @returns null if no hit or a PickingInfo
  11602. */
  11603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11604. /**
  11605. * Render all child sprites
  11606. */
  11607. render(): void;
  11608. /**
  11609. * Release associated resources
  11610. */
  11611. dispose(): void;
  11612. }
  11613. }
  11614. declare module "babylonjs/Sprites/sprite" {
  11615. import { Vector3 } from "babylonjs/Maths/math.vector";
  11616. import { Nullable } from "babylonjs/types";
  11617. import { ActionManager } from "babylonjs/Actions/actionManager";
  11618. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11619. import { Color4 } from "babylonjs/Maths/math.color";
  11620. /**
  11621. * Class used to represent a sprite
  11622. * @see http://doc.babylonjs.com/babylon101/sprites
  11623. */
  11624. export class Sprite {
  11625. /** defines the name */
  11626. name: string;
  11627. /** Gets or sets the current world position */
  11628. position: Vector3;
  11629. /** Gets or sets the main color */
  11630. color: Color4;
  11631. /** Gets or sets the width */
  11632. width: number;
  11633. /** Gets or sets the height */
  11634. height: number;
  11635. /** Gets or sets rotation angle */
  11636. angle: number;
  11637. /** Gets or sets the cell index in the sprite sheet */
  11638. cellIndex: number;
  11639. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11640. invertU: number;
  11641. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11642. invertV: number;
  11643. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11644. disposeWhenFinishedAnimating: boolean;
  11645. /** Gets the list of attached animations */
  11646. animations: Animation[];
  11647. /** Gets or sets a boolean indicating if the sprite can be picked */
  11648. isPickable: boolean;
  11649. /**
  11650. * Gets or sets the associated action manager
  11651. */
  11652. actionManager: Nullable<ActionManager>;
  11653. private _animationStarted;
  11654. private _loopAnimation;
  11655. private _fromIndex;
  11656. private _toIndex;
  11657. private _delay;
  11658. private _direction;
  11659. private _manager;
  11660. private _time;
  11661. private _onAnimationEnd;
  11662. /**
  11663. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11664. */
  11665. isVisible: boolean;
  11666. /**
  11667. * Gets or sets the sprite size
  11668. */
  11669. size: number;
  11670. /**
  11671. * Creates a new Sprite
  11672. * @param name defines the name
  11673. * @param manager defines the manager
  11674. */
  11675. constructor(
  11676. /** defines the name */
  11677. name: string, manager: ISpriteManager);
  11678. /**
  11679. * Starts an animation
  11680. * @param from defines the initial key
  11681. * @param to defines the end key
  11682. * @param loop defines if the animation must loop
  11683. * @param delay defines the start delay (in ms)
  11684. * @param onAnimationEnd defines a callback to call when animation ends
  11685. */
  11686. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11687. /** Stops current animation (if any) */
  11688. stopAnimation(): void;
  11689. /** @hidden */
  11690. _animate(deltaTime: number): void;
  11691. /** Release associated resources */
  11692. dispose(): void;
  11693. }
  11694. }
  11695. declare module "babylonjs/Collisions/pickingInfo" {
  11696. import { Nullable } from "babylonjs/types";
  11697. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11699. import { Sprite } from "babylonjs/Sprites/sprite";
  11700. import { Ray } from "babylonjs/Culling/ray";
  11701. /**
  11702. * Information about the result of picking within a scene
  11703. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11704. */
  11705. export class PickingInfo {
  11706. /** @hidden */
  11707. _pickingUnavailable: boolean;
  11708. /**
  11709. * If the pick collided with an object
  11710. */
  11711. hit: boolean;
  11712. /**
  11713. * Distance away where the pick collided
  11714. */
  11715. distance: number;
  11716. /**
  11717. * The location of pick collision
  11718. */
  11719. pickedPoint: Nullable<Vector3>;
  11720. /**
  11721. * The mesh corresponding the the pick collision
  11722. */
  11723. pickedMesh: Nullable<AbstractMesh>;
  11724. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11725. bu: number;
  11726. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11727. bv: number;
  11728. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11729. faceId: number;
  11730. /** Id of the the submesh that was picked */
  11731. subMeshId: number;
  11732. /** If a sprite was picked, this will be the sprite the pick collided with */
  11733. pickedSprite: Nullable<Sprite>;
  11734. /**
  11735. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11736. */
  11737. originMesh: Nullable<AbstractMesh>;
  11738. /**
  11739. * The ray that was used to perform the picking.
  11740. */
  11741. ray: Nullable<Ray>;
  11742. /**
  11743. * Gets the normal correspodning to the face the pick collided with
  11744. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11745. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11746. * @returns The normal correspodning to the face the pick collided with
  11747. */
  11748. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11749. /**
  11750. * Gets the texture coordinates of where the pick occured
  11751. * @returns the vector containing the coordnates of the texture
  11752. */
  11753. getTextureCoordinates(): Nullable<Vector2>;
  11754. }
  11755. }
  11756. declare module "babylonjs/Events/pointerEvents" {
  11757. import { Nullable } from "babylonjs/types";
  11758. import { Vector2 } from "babylonjs/Maths/math.vector";
  11759. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11760. import { Ray } from "babylonjs/Culling/ray";
  11761. /**
  11762. * Gather the list of pointer event types as constants.
  11763. */
  11764. export class PointerEventTypes {
  11765. /**
  11766. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11767. */
  11768. static readonly POINTERDOWN: number;
  11769. /**
  11770. * The pointerup event is fired when a pointer is no longer active.
  11771. */
  11772. static readonly POINTERUP: number;
  11773. /**
  11774. * The pointermove event is fired when a pointer changes coordinates.
  11775. */
  11776. static readonly POINTERMOVE: number;
  11777. /**
  11778. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11779. */
  11780. static readonly POINTERWHEEL: number;
  11781. /**
  11782. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11783. */
  11784. static readonly POINTERPICK: number;
  11785. /**
  11786. * The pointertap event is fired when a the object has been touched and released without drag.
  11787. */
  11788. static readonly POINTERTAP: number;
  11789. /**
  11790. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11791. */
  11792. static readonly POINTERDOUBLETAP: number;
  11793. }
  11794. /**
  11795. * Base class of pointer info types.
  11796. */
  11797. export class PointerInfoBase {
  11798. /**
  11799. * Defines the type of event (PointerEventTypes)
  11800. */
  11801. type: number;
  11802. /**
  11803. * Defines the related dom event
  11804. */
  11805. event: PointerEvent | MouseWheelEvent;
  11806. /**
  11807. * Instantiates the base class of pointers info.
  11808. * @param type Defines the type of event (PointerEventTypes)
  11809. * @param event Defines the related dom event
  11810. */
  11811. constructor(
  11812. /**
  11813. * Defines the type of event (PointerEventTypes)
  11814. */
  11815. type: number,
  11816. /**
  11817. * Defines the related dom event
  11818. */
  11819. event: PointerEvent | MouseWheelEvent);
  11820. }
  11821. /**
  11822. * This class is used to store pointer related info for the onPrePointerObservable event.
  11823. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11824. */
  11825. export class PointerInfoPre extends PointerInfoBase {
  11826. /**
  11827. * Ray from a pointer if availible (eg. 6dof controller)
  11828. */
  11829. ray: Nullable<Ray>;
  11830. /**
  11831. * Defines the local position of the pointer on the canvas.
  11832. */
  11833. localPosition: Vector2;
  11834. /**
  11835. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11836. */
  11837. skipOnPointerObservable: boolean;
  11838. /**
  11839. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11840. * @param type Defines the type of event (PointerEventTypes)
  11841. * @param event Defines the related dom event
  11842. * @param localX Defines the local x coordinates of the pointer when the event occured
  11843. * @param localY Defines the local y coordinates of the pointer when the event occured
  11844. */
  11845. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11846. }
  11847. /**
  11848. * This type contains all the data related to a pointer event in Babylon.js.
  11849. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  11850. */
  11851. export class PointerInfo extends PointerInfoBase {
  11852. /**
  11853. * Defines the picking info associated to the info (if any)\
  11854. */
  11855. pickInfo: Nullable<PickingInfo>;
  11856. /**
  11857. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11858. * @param type Defines the type of event (PointerEventTypes)
  11859. * @param event Defines the related dom event
  11860. * @param pickInfo Defines the picking info associated to the info (if any)\
  11861. */
  11862. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11863. /**
  11864. * Defines the picking info associated to the info (if any)\
  11865. */
  11866. pickInfo: Nullable<PickingInfo>);
  11867. }
  11868. /**
  11869. * Data relating to a touch event on the screen.
  11870. */
  11871. export interface PointerTouch {
  11872. /**
  11873. * X coordinate of touch.
  11874. */
  11875. x: number;
  11876. /**
  11877. * Y coordinate of touch.
  11878. */
  11879. y: number;
  11880. /**
  11881. * Id of touch. Unique for each finger.
  11882. */
  11883. pointerId: number;
  11884. /**
  11885. * Event type passed from DOM.
  11886. */
  11887. type: any;
  11888. }
  11889. }
  11890. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11891. import { Observable } from "babylonjs/Misc/observable";
  11892. import { Nullable } from "babylonjs/types";
  11893. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11894. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11895. /**
  11896. * Manage the mouse inputs to control the movement of a free camera.
  11897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11898. */
  11899. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11900. /**
  11901. * Define if touch is enabled in the mouse input
  11902. */
  11903. touchEnabled: boolean;
  11904. /**
  11905. * Defines the camera the input is attached to.
  11906. */
  11907. camera: FreeCamera;
  11908. /**
  11909. * Defines the buttons associated with the input to handle camera move.
  11910. */
  11911. buttons: number[];
  11912. /**
  11913. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11914. */
  11915. angularSensibility: number;
  11916. private _pointerInput;
  11917. private _onMouseMove;
  11918. private _observer;
  11919. private previousPosition;
  11920. /**
  11921. * Observable for when a pointer move event occurs containing the move offset
  11922. */
  11923. onPointerMovedObservable: Observable<{
  11924. offsetX: number;
  11925. offsetY: number;
  11926. }>;
  11927. /**
  11928. * @hidden
  11929. * If the camera should be rotated automatically based on pointer movement
  11930. */
  11931. _allowCameraRotation: boolean;
  11932. /**
  11933. * Manage the mouse inputs to control the movement of a free camera.
  11934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11935. * @param touchEnabled Defines if touch is enabled or not
  11936. */
  11937. constructor(
  11938. /**
  11939. * Define if touch is enabled in the mouse input
  11940. */
  11941. touchEnabled?: boolean);
  11942. /**
  11943. * Attach the input controls to a specific dom element to get the input from.
  11944. * @param element Defines the element the controls should be listened from
  11945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11946. */
  11947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11948. /**
  11949. * Called on JS contextmenu event.
  11950. * Override this method to provide functionality.
  11951. */
  11952. protected onContextMenu(evt: PointerEvent): void;
  11953. /**
  11954. * Detach the current controls from the specified dom element.
  11955. * @param element Defines the element to stop listening the inputs from
  11956. */
  11957. detachControl(element: Nullable<HTMLElement>): void;
  11958. /**
  11959. * Gets the class name of the current intput.
  11960. * @returns the class name
  11961. */
  11962. getClassName(): string;
  11963. /**
  11964. * Get the friendly name associated with the input class.
  11965. * @returns the input friendly name
  11966. */
  11967. getSimpleName(): string;
  11968. }
  11969. }
  11970. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11971. import { Nullable } from "babylonjs/types";
  11972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11974. /**
  11975. * Manage the touch inputs to control the movement of a free camera.
  11976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11977. */
  11978. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11979. /**
  11980. * Defines the camera the input is attached to.
  11981. */
  11982. camera: FreeCamera;
  11983. /**
  11984. * Defines the touch sensibility for rotation.
  11985. * The higher the faster.
  11986. */
  11987. touchAngularSensibility: number;
  11988. /**
  11989. * Defines the touch sensibility for move.
  11990. * The higher the faster.
  11991. */
  11992. touchMoveSensibility: number;
  11993. private _offsetX;
  11994. private _offsetY;
  11995. private _pointerPressed;
  11996. private _pointerInput;
  11997. private _observer;
  11998. private _onLostFocus;
  11999. /**
  12000. * Attach the input controls to a specific dom element to get the input from.
  12001. * @param element Defines the element the controls should be listened from
  12002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12003. */
  12004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12005. /**
  12006. * Detach the current controls from the specified dom element.
  12007. * @param element Defines the element to stop listening the inputs from
  12008. */
  12009. detachControl(element: Nullable<HTMLElement>): void;
  12010. /**
  12011. * Update the current camera state depending on the inputs that have been used this frame.
  12012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12013. */
  12014. checkInputs(): void;
  12015. /**
  12016. * Gets the class name of the current intput.
  12017. * @returns the class name
  12018. */
  12019. getClassName(): string;
  12020. /**
  12021. * Get the friendly name associated with the input class.
  12022. * @returns the input friendly name
  12023. */
  12024. getSimpleName(): string;
  12025. }
  12026. }
  12027. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12029. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12030. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12031. import { Nullable } from "babylonjs/types";
  12032. /**
  12033. * Default Inputs manager for the FreeCamera.
  12034. * It groups all the default supported inputs for ease of use.
  12035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12036. */
  12037. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12038. /**
  12039. * @hidden
  12040. */
  12041. _mouseInput: Nullable<FreeCameraMouseInput>;
  12042. /**
  12043. * Instantiates a new FreeCameraInputsManager.
  12044. * @param camera Defines the camera the inputs belong to
  12045. */
  12046. constructor(camera: FreeCamera);
  12047. /**
  12048. * Add keyboard input support to the input manager.
  12049. * @returns the current input manager
  12050. */
  12051. addKeyboard(): FreeCameraInputsManager;
  12052. /**
  12053. * Add mouse input support to the input manager.
  12054. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12055. * @returns the current input manager
  12056. */
  12057. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12058. /**
  12059. * Removes the mouse input support from the manager
  12060. * @returns the current input manager
  12061. */
  12062. removeMouse(): FreeCameraInputsManager;
  12063. /**
  12064. * Add touch input support to the input manager.
  12065. * @returns the current input manager
  12066. */
  12067. addTouch(): FreeCameraInputsManager;
  12068. /**
  12069. * Remove all attached input methods from a camera
  12070. */
  12071. clear(): void;
  12072. }
  12073. }
  12074. declare module "babylonjs/Cameras/freeCamera" {
  12075. import { Vector3 } from "babylonjs/Maths/math.vector";
  12076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12077. import { Scene } from "babylonjs/scene";
  12078. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12079. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12080. /**
  12081. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12082. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12083. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12084. */
  12085. export class FreeCamera extends TargetCamera {
  12086. /**
  12087. * Define the collision ellipsoid of the camera.
  12088. * This is helpful to simulate a camera body like the player body around the camera
  12089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12090. */
  12091. ellipsoid: Vector3;
  12092. /**
  12093. * Define an offset for the position of the ellipsoid around the camera.
  12094. * This can be helpful to determine the center of the body near the gravity center of the body
  12095. * instead of its head.
  12096. */
  12097. ellipsoidOffset: Vector3;
  12098. /**
  12099. * Enable or disable collisions of the camera with the rest of the scene objects.
  12100. */
  12101. checkCollisions: boolean;
  12102. /**
  12103. * Enable or disable gravity on the camera.
  12104. */
  12105. applyGravity: boolean;
  12106. /**
  12107. * Define the input manager associated to the camera.
  12108. */
  12109. inputs: FreeCameraInputsManager;
  12110. /**
  12111. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12112. * Higher values reduce sensitivity.
  12113. */
  12114. /**
  12115. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12116. * Higher values reduce sensitivity.
  12117. */
  12118. angularSensibility: number;
  12119. /**
  12120. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12121. */
  12122. keysUp: number[];
  12123. /**
  12124. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12125. */
  12126. keysDown: number[];
  12127. /**
  12128. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12129. */
  12130. keysLeft: number[];
  12131. /**
  12132. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12133. */
  12134. keysRight: number[];
  12135. /**
  12136. * Event raised when the camera collide with a mesh in the scene.
  12137. */
  12138. onCollide: (collidedMesh: AbstractMesh) => void;
  12139. private _collider;
  12140. private _needMoveForGravity;
  12141. private _oldPosition;
  12142. private _diffPosition;
  12143. private _newPosition;
  12144. /** @hidden */
  12145. _localDirection: Vector3;
  12146. /** @hidden */
  12147. _transformedDirection: Vector3;
  12148. /**
  12149. * Instantiates a Free Camera.
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. * @param name Define the name of the camera in the scene
  12154. * @param position Define the start position of the camera in the scene
  12155. * @param scene Define the scene the camera belongs to
  12156. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12157. */
  12158. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12159. /**
  12160. * Attached controls to the current camera.
  12161. * @param element Defines the element the controls should be listened from
  12162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12163. */
  12164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12165. /**
  12166. * Detach the current controls from the camera.
  12167. * The camera will stop reacting to inputs.
  12168. * @param element Defines the element to stop listening the inputs from
  12169. */
  12170. detachControl(element: HTMLElement): void;
  12171. private _collisionMask;
  12172. /**
  12173. * Define a collision mask to limit the list of object the camera can collide with
  12174. */
  12175. collisionMask: number;
  12176. /** @hidden */
  12177. _collideWithWorld(displacement: Vector3): void;
  12178. private _onCollisionPositionChange;
  12179. /** @hidden */
  12180. _checkInputs(): void;
  12181. /** @hidden */
  12182. _decideIfNeedsToMove(): boolean;
  12183. /** @hidden */
  12184. _updatePosition(): void;
  12185. /**
  12186. * Destroy the camera and release the current resources hold by it.
  12187. */
  12188. dispose(): void;
  12189. /**
  12190. * Gets the current object class name.
  12191. * @return the class name
  12192. */
  12193. getClassName(): string;
  12194. }
  12195. }
  12196. declare module "babylonjs/Gamepads/gamepad" {
  12197. import { Observable } from "babylonjs/Misc/observable";
  12198. /**
  12199. * Represents a gamepad control stick position
  12200. */
  12201. export class StickValues {
  12202. /**
  12203. * The x component of the control stick
  12204. */
  12205. x: number;
  12206. /**
  12207. * The y component of the control stick
  12208. */
  12209. y: number;
  12210. /**
  12211. * Initializes the gamepad x and y control stick values
  12212. * @param x The x component of the gamepad control stick value
  12213. * @param y The y component of the gamepad control stick value
  12214. */
  12215. constructor(
  12216. /**
  12217. * The x component of the control stick
  12218. */
  12219. x: number,
  12220. /**
  12221. * The y component of the control stick
  12222. */
  12223. y: number);
  12224. }
  12225. /**
  12226. * An interface which manages callbacks for gamepad button changes
  12227. */
  12228. export interface GamepadButtonChanges {
  12229. /**
  12230. * Called when a gamepad has been changed
  12231. */
  12232. changed: boolean;
  12233. /**
  12234. * Called when a gamepad press event has been triggered
  12235. */
  12236. pressChanged: boolean;
  12237. /**
  12238. * Called when a touch event has been triggered
  12239. */
  12240. touchChanged: boolean;
  12241. /**
  12242. * Called when a value has changed
  12243. */
  12244. valueChanged: boolean;
  12245. }
  12246. /**
  12247. * Represents a gamepad
  12248. */
  12249. export class Gamepad {
  12250. /**
  12251. * The id of the gamepad
  12252. */
  12253. id: string;
  12254. /**
  12255. * The index of the gamepad
  12256. */
  12257. index: number;
  12258. /**
  12259. * The browser gamepad
  12260. */
  12261. browserGamepad: any;
  12262. /**
  12263. * Specifies what type of gamepad this represents
  12264. */
  12265. type: number;
  12266. private _leftStick;
  12267. private _rightStick;
  12268. /** @hidden */
  12269. _isConnected: boolean;
  12270. private _leftStickAxisX;
  12271. private _leftStickAxisY;
  12272. private _rightStickAxisX;
  12273. private _rightStickAxisY;
  12274. /**
  12275. * Triggered when the left control stick has been changed
  12276. */
  12277. private _onleftstickchanged;
  12278. /**
  12279. * Triggered when the right control stick has been changed
  12280. */
  12281. private _onrightstickchanged;
  12282. /**
  12283. * Represents a gamepad controller
  12284. */
  12285. static GAMEPAD: number;
  12286. /**
  12287. * Represents a generic controller
  12288. */
  12289. static GENERIC: number;
  12290. /**
  12291. * Represents an XBox controller
  12292. */
  12293. static XBOX: number;
  12294. /**
  12295. * Represents a pose-enabled controller
  12296. */
  12297. static POSE_ENABLED: number;
  12298. /**
  12299. * Specifies whether the left control stick should be Y-inverted
  12300. */
  12301. protected _invertLeftStickY: boolean;
  12302. /**
  12303. * Specifies if the gamepad has been connected
  12304. */
  12305. readonly isConnected: boolean;
  12306. /**
  12307. * Initializes the gamepad
  12308. * @param id The id of the gamepad
  12309. * @param index The index of the gamepad
  12310. * @param browserGamepad The browser gamepad
  12311. * @param leftStickX The x component of the left joystick
  12312. * @param leftStickY The y component of the left joystick
  12313. * @param rightStickX The x component of the right joystick
  12314. * @param rightStickY The y component of the right joystick
  12315. */
  12316. constructor(
  12317. /**
  12318. * The id of the gamepad
  12319. */
  12320. id: string,
  12321. /**
  12322. * The index of the gamepad
  12323. */
  12324. index: number,
  12325. /**
  12326. * The browser gamepad
  12327. */
  12328. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12329. /**
  12330. * Callback triggered when the left joystick has changed
  12331. * @param callback
  12332. */
  12333. onleftstickchanged(callback: (values: StickValues) => void): void;
  12334. /**
  12335. * Callback triggered when the right joystick has changed
  12336. * @param callback
  12337. */
  12338. onrightstickchanged(callback: (values: StickValues) => void): void;
  12339. /**
  12340. * Gets the left joystick
  12341. */
  12342. /**
  12343. * Sets the left joystick values
  12344. */
  12345. leftStick: StickValues;
  12346. /**
  12347. * Gets the right joystick
  12348. */
  12349. /**
  12350. * Sets the right joystick value
  12351. */
  12352. rightStick: StickValues;
  12353. /**
  12354. * Updates the gamepad joystick positions
  12355. */
  12356. update(): void;
  12357. /**
  12358. * Disposes the gamepad
  12359. */
  12360. dispose(): void;
  12361. }
  12362. /**
  12363. * Represents a generic gamepad
  12364. */
  12365. export class GenericPad extends Gamepad {
  12366. private _buttons;
  12367. private _onbuttondown;
  12368. private _onbuttonup;
  12369. /**
  12370. * Observable triggered when a button has been pressed
  12371. */
  12372. onButtonDownObservable: Observable<number>;
  12373. /**
  12374. * Observable triggered when a button has been released
  12375. */
  12376. onButtonUpObservable: Observable<number>;
  12377. /**
  12378. * Callback triggered when a button has been pressed
  12379. * @param callback Called when a button has been pressed
  12380. */
  12381. onbuttondown(callback: (buttonPressed: number) => void): void;
  12382. /**
  12383. * Callback triggered when a button has been released
  12384. * @param callback Called when a button has been released
  12385. */
  12386. onbuttonup(callback: (buttonReleased: number) => void): void;
  12387. /**
  12388. * Initializes the generic gamepad
  12389. * @param id The id of the generic gamepad
  12390. * @param index The index of the generic gamepad
  12391. * @param browserGamepad The browser gamepad
  12392. */
  12393. constructor(id: string, index: number, browserGamepad: any);
  12394. private _setButtonValue;
  12395. /**
  12396. * Updates the generic gamepad
  12397. */
  12398. update(): void;
  12399. /**
  12400. * Disposes the generic gamepad
  12401. */
  12402. dispose(): void;
  12403. }
  12404. }
  12405. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12406. import { Nullable } from "babylonjs/types";
  12407. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12408. import { Scene } from "babylonjs/scene";
  12409. module "babylonjs/Engines/engine" {
  12410. interface Engine {
  12411. /**
  12412. * Creates a raw texture
  12413. * @param data defines the data to store in the texture
  12414. * @param width defines the width of the texture
  12415. * @param height defines the height of the texture
  12416. * @param format defines the format of the data
  12417. * @param generateMipMaps defines if the engine should generate the mip levels
  12418. * @param invertY defines if data must be stored with Y axis inverted
  12419. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12420. * @param compression defines the compression used (null by default)
  12421. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12422. * @returns the raw texture inside an InternalTexture
  12423. */
  12424. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12425. /**
  12426. * Update a raw texture
  12427. * @param texture defines the texture to update
  12428. * @param data defines the data to store in the texture
  12429. * @param format defines the format of the data
  12430. * @param invertY defines if data must be stored with Y axis inverted
  12431. */
  12432. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12433. /**
  12434. * Update a raw texture
  12435. * @param texture defines the texture to update
  12436. * @param data defines the data to store in the texture
  12437. * @param format defines the format of the data
  12438. * @param invertY defines if data must be stored with Y axis inverted
  12439. * @param compression defines the compression used (null by default)
  12440. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12441. */
  12442. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12443. /**
  12444. * Creates a new raw cube texture
  12445. * @param data defines the array of data to use to create each face
  12446. * @param size defines the size of the textures
  12447. * @param format defines the format of the data
  12448. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12449. * @param generateMipMaps defines if the engine should generate the mip levels
  12450. * @param invertY defines if data must be stored with Y axis inverted
  12451. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12452. * @param compression defines the compression used (null by default)
  12453. * @returns the cube texture as an InternalTexture
  12454. */
  12455. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12456. /**
  12457. * Update a raw cube texture
  12458. * @param texture defines the texture to udpdate
  12459. * @param data defines the data to store
  12460. * @param format defines the data format
  12461. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12462. * @param invertY defines if data must be stored with Y axis inverted
  12463. */
  12464. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12465. /**
  12466. * Update a raw cube texture
  12467. * @param texture defines the texture to udpdate
  12468. * @param data defines the data to store
  12469. * @param format defines the data format
  12470. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12471. * @param invertY defines if data must be stored with Y axis inverted
  12472. * @param compression defines the compression used (null by default)
  12473. */
  12474. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12475. /**
  12476. * Update a raw cube texture
  12477. * @param texture defines the texture to udpdate
  12478. * @param data defines the data to store
  12479. * @param format defines the data format
  12480. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12481. * @param invertY defines if data must be stored with Y axis inverted
  12482. * @param compression defines the compression used (null by default)
  12483. * @param level defines which level of the texture to update
  12484. */
  12485. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12486. /**
  12487. * Creates a new raw cube texture from a specified url
  12488. * @param url defines the url where the data is located
  12489. * @param scene defines the current scene
  12490. * @param size defines the size of the textures
  12491. * @param format defines the format of the data
  12492. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12493. * @param noMipmap defines if the engine should avoid generating the mip levels
  12494. * @param callback defines a callback used to extract texture data from loaded data
  12495. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12496. * @param onLoad defines a callback called when texture is loaded
  12497. * @param onError defines a callback called if there is an error
  12498. * @returns the cube texture as an InternalTexture
  12499. */
  12500. 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;
  12501. /**
  12502. * Creates a new raw cube texture from a specified url
  12503. * @param url defines the url where the data is located
  12504. * @param scene defines the current scene
  12505. * @param size defines the size of the textures
  12506. * @param format defines the format of the data
  12507. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12508. * @param noMipmap defines if the engine should avoid generating the mip levels
  12509. * @param callback defines a callback used to extract texture data from loaded data
  12510. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12511. * @param onLoad defines a callback called when texture is loaded
  12512. * @param onError defines a callback called if there is an error
  12513. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12514. * @param invertY defines if data must be stored with Y axis inverted
  12515. * @returns the cube texture as an InternalTexture
  12516. */
  12517. 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;
  12518. /**
  12519. * Creates a new raw 3D texture
  12520. * @param data defines the data used to create the texture
  12521. * @param width defines the width of the texture
  12522. * @param height defines the height of the texture
  12523. * @param depth defines the depth of the texture
  12524. * @param format defines the format of the texture
  12525. * @param generateMipMaps defines if the engine must generate mip levels
  12526. * @param invertY defines if data must be stored with Y axis inverted
  12527. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12528. * @param compression defines the compressed used (can be null)
  12529. * @param textureType defines the compressed used (can be null)
  12530. * @returns a new raw 3D texture (stored in an InternalTexture)
  12531. */
  12532. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12533. /**
  12534. * Update a raw 3D texture
  12535. * @param texture defines the texture to update
  12536. * @param data defines the data to store
  12537. * @param format defines the data format
  12538. * @param invertY defines if data must be stored with Y axis inverted
  12539. */
  12540. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12541. /**
  12542. * Update a raw 3D texture
  12543. * @param texture defines the texture to update
  12544. * @param data defines the data to store
  12545. * @param format defines the data format
  12546. * @param invertY defines if data must be stored with Y axis inverted
  12547. * @param compression defines the used compression (can be null)
  12548. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12549. */
  12550. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12551. }
  12552. }
  12553. }
  12554. declare module "babylonjs/Materials/Textures/rawTexture" {
  12555. import { Scene } from "babylonjs/scene";
  12556. import { Texture } from "babylonjs/Materials/Textures/texture";
  12557. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12558. /**
  12559. * Raw texture can help creating a texture directly from an array of data.
  12560. * This can be super useful if you either get the data from an uncompressed source or
  12561. * if you wish to create your texture pixel by pixel.
  12562. */
  12563. export class RawTexture extends Texture {
  12564. /**
  12565. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12566. */
  12567. format: number;
  12568. private _engine;
  12569. /**
  12570. * Instantiates a new RawTexture.
  12571. * Raw texture can help creating a texture directly from an array of data.
  12572. * This can be super useful if you either get the data from an uncompressed source or
  12573. * if you wish to create your texture pixel by pixel.
  12574. * @param data define the array of data to use to create the texture
  12575. * @param width define the width of the texture
  12576. * @param height define the height of the texture
  12577. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12578. * @param scene define the scene the texture belongs to
  12579. * @param generateMipMaps define whether mip maps should be generated or not
  12580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12583. */
  12584. constructor(data: ArrayBufferView, width: number, height: number,
  12585. /**
  12586. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12587. */
  12588. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12589. /**
  12590. * Updates the texture underlying data.
  12591. * @param data Define the new data of the texture
  12592. */
  12593. update(data: ArrayBufferView): void;
  12594. /**
  12595. * Creates a luminance texture from some data.
  12596. * @param data Define the texture data
  12597. * @param width Define the width of the texture
  12598. * @param height Define the height of the texture
  12599. * @param scene Define the scene the texture belongs to
  12600. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12601. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12602. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12603. * @returns the luminance texture
  12604. */
  12605. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12606. /**
  12607. * Creates a luminance alpha texture from some data.
  12608. * @param data Define the texture data
  12609. * @param width Define the width of the texture
  12610. * @param height Define the height of the texture
  12611. * @param scene Define the scene the texture belongs to
  12612. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12613. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12614. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12615. * @returns the luminance alpha texture
  12616. */
  12617. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12618. /**
  12619. * Creates an alpha texture from some data.
  12620. * @param data Define the texture data
  12621. * @param width Define the width of the texture
  12622. * @param height Define the height of the texture
  12623. * @param scene Define the scene the texture belongs to
  12624. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12625. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12626. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12627. * @returns the alpha texture
  12628. */
  12629. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12630. /**
  12631. * Creates a RGB texture from some data.
  12632. * @param data Define the texture data
  12633. * @param width Define the width of the texture
  12634. * @param height Define the height of the texture
  12635. * @param scene Define the scene the texture belongs to
  12636. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12637. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12638. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12639. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12640. * @returns the RGB alpha texture
  12641. */
  12642. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12643. /**
  12644. * Creates a RGBA texture from some data.
  12645. * @param data Define the texture data
  12646. * @param width Define the width of the texture
  12647. * @param height Define the height of the texture
  12648. * @param scene Define the scene the texture belongs to
  12649. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12650. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12651. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12652. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12653. * @returns the RGBA texture
  12654. */
  12655. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12656. /**
  12657. * Creates a R texture from some data.
  12658. * @param data Define the texture data
  12659. * @param width Define the width of the texture
  12660. * @param height Define the height of the texture
  12661. * @param scene Define the scene the texture belongs to
  12662. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12663. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12664. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12665. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12666. * @returns the R texture
  12667. */
  12668. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12669. }
  12670. }
  12671. declare module "babylonjs/Maths/math.size" {
  12672. /**
  12673. * Interface for the size containing width and height
  12674. */
  12675. export interface ISize {
  12676. /**
  12677. * Width
  12678. */
  12679. width: number;
  12680. /**
  12681. * Heighht
  12682. */
  12683. height: number;
  12684. }
  12685. /**
  12686. * Size containing widht and height
  12687. */
  12688. export class Size implements ISize {
  12689. /**
  12690. * Width
  12691. */
  12692. width: number;
  12693. /**
  12694. * Height
  12695. */
  12696. height: number;
  12697. /**
  12698. * Creates a Size object from the given width and height (floats).
  12699. * @param width width of the new size
  12700. * @param height height of the new size
  12701. */
  12702. constructor(width: number, height: number);
  12703. /**
  12704. * Returns a string with the Size width and height
  12705. * @returns a string with the Size width and height
  12706. */
  12707. toString(): string;
  12708. /**
  12709. * "Size"
  12710. * @returns the string "Size"
  12711. */
  12712. getClassName(): string;
  12713. /**
  12714. * Returns the Size hash code.
  12715. * @returns a hash code for a unique width and height
  12716. */
  12717. getHashCode(): number;
  12718. /**
  12719. * Updates the current size from the given one.
  12720. * @param src the given size
  12721. */
  12722. copyFrom(src: Size): void;
  12723. /**
  12724. * Updates in place the current Size from the given floats.
  12725. * @param width width of the new size
  12726. * @param height height of the new size
  12727. * @returns the updated Size.
  12728. */
  12729. copyFromFloats(width: number, height: number): Size;
  12730. /**
  12731. * Updates in place the current Size from the given floats.
  12732. * @param width width to set
  12733. * @param height height to set
  12734. * @returns the updated Size.
  12735. */
  12736. set(width: number, height: number): Size;
  12737. /**
  12738. * Multiplies the width and height by numbers
  12739. * @param w factor to multiple the width by
  12740. * @param h factor to multiple the height by
  12741. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12742. */
  12743. multiplyByFloats(w: number, h: number): Size;
  12744. /**
  12745. * Clones the size
  12746. * @returns a new Size copied from the given one.
  12747. */
  12748. clone(): Size;
  12749. /**
  12750. * True if the current Size and the given one width and height are strictly equal.
  12751. * @param other the other size to compare against
  12752. * @returns True if the current Size and the given one width and height are strictly equal.
  12753. */
  12754. equals(other: Size): boolean;
  12755. /**
  12756. * The surface of the Size : width * height (float).
  12757. */
  12758. readonly surface: number;
  12759. /**
  12760. * Create a new size of zero
  12761. * @returns a new Size set to (0.0, 0.0)
  12762. */
  12763. static Zero(): Size;
  12764. /**
  12765. * Sums the width and height of two sizes
  12766. * @param otherSize size to add to this size
  12767. * @returns a new Size set as the addition result of the current Size and the given one.
  12768. */
  12769. add(otherSize: Size): Size;
  12770. /**
  12771. * Subtracts the width and height of two
  12772. * @param otherSize size to subtract to this size
  12773. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12774. */
  12775. subtract(otherSize: Size): Size;
  12776. /**
  12777. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12778. * @param start starting size to lerp between
  12779. * @param end end size to lerp between
  12780. * @param amount amount to lerp between the start and end values
  12781. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12782. */
  12783. static Lerp(start: Size, end: Size, amount: number): Size;
  12784. }
  12785. }
  12786. declare module "babylonjs/Animations/runtimeAnimation" {
  12787. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12788. import { Animatable } from "babylonjs/Animations/animatable";
  12789. import { Scene } from "babylonjs/scene";
  12790. /**
  12791. * Defines a runtime animation
  12792. */
  12793. export class RuntimeAnimation {
  12794. private _events;
  12795. /**
  12796. * The current frame of the runtime animation
  12797. */
  12798. private _currentFrame;
  12799. /**
  12800. * The animation used by the runtime animation
  12801. */
  12802. private _animation;
  12803. /**
  12804. * The target of the runtime animation
  12805. */
  12806. private _target;
  12807. /**
  12808. * The initiating animatable
  12809. */
  12810. private _host;
  12811. /**
  12812. * The original value of the runtime animation
  12813. */
  12814. private _originalValue;
  12815. /**
  12816. * The original blend value of the runtime animation
  12817. */
  12818. private _originalBlendValue;
  12819. /**
  12820. * The offsets cache of the runtime animation
  12821. */
  12822. private _offsetsCache;
  12823. /**
  12824. * The high limits cache of the runtime animation
  12825. */
  12826. private _highLimitsCache;
  12827. /**
  12828. * Specifies if the runtime animation has been stopped
  12829. */
  12830. private _stopped;
  12831. /**
  12832. * The blending factor of the runtime animation
  12833. */
  12834. private _blendingFactor;
  12835. /**
  12836. * The BabylonJS scene
  12837. */
  12838. private _scene;
  12839. /**
  12840. * The current value of the runtime animation
  12841. */
  12842. private _currentValue;
  12843. /** @hidden */
  12844. _animationState: _IAnimationState;
  12845. /**
  12846. * The active target of the runtime animation
  12847. */
  12848. private _activeTargets;
  12849. private _currentActiveTarget;
  12850. private _directTarget;
  12851. /**
  12852. * The target path of the runtime animation
  12853. */
  12854. private _targetPath;
  12855. /**
  12856. * The weight of the runtime animation
  12857. */
  12858. private _weight;
  12859. /**
  12860. * The ratio offset of the runtime animation
  12861. */
  12862. private _ratioOffset;
  12863. /**
  12864. * The previous delay of the runtime animation
  12865. */
  12866. private _previousDelay;
  12867. /**
  12868. * The previous ratio of the runtime animation
  12869. */
  12870. private _previousRatio;
  12871. private _enableBlending;
  12872. private _keys;
  12873. private _minFrame;
  12874. private _maxFrame;
  12875. private _minValue;
  12876. private _maxValue;
  12877. private _targetIsArray;
  12878. /**
  12879. * Gets the current frame of the runtime animation
  12880. */
  12881. readonly currentFrame: number;
  12882. /**
  12883. * Gets the weight of the runtime animation
  12884. */
  12885. readonly weight: number;
  12886. /**
  12887. * Gets the current value of the runtime animation
  12888. */
  12889. readonly currentValue: any;
  12890. /**
  12891. * Gets the target path of the runtime animation
  12892. */
  12893. readonly targetPath: string;
  12894. /**
  12895. * Gets the actual target of the runtime animation
  12896. */
  12897. readonly target: any;
  12898. /** @hidden */
  12899. _onLoop: () => void;
  12900. /**
  12901. * Create a new RuntimeAnimation object
  12902. * @param target defines the target of the animation
  12903. * @param animation defines the source animation object
  12904. * @param scene defines the hosting scene
  12905. * @param host defines the initiating Animatable
  12906. */
  12907. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12908. private _preparePath;
  12909. /**
  12910. * Gets the animation from the runtime animation
  12911. */
  12912. readonly animation: Animation;
  12913. /**
  12914. * Resets the runtime animation to the beginning
  12915. * @param restoreOriginal defines whether to restore the target property to the original value
  12916. */
  12917. reset(restoreOriginal?: boolean): void;
  12918. /**
  12919. * Specifies if the runtime animation is stopped
  12920. * @returns Boolean specifying if the runtime animation is stopped
  12921. */
  12922. isStopped(): boolean;
  12923. /**
  12924. * Disposes of the runtime animation
  12925. */
  12926. dispose(): void;
  12927. /**
  12928. * Apply the interpolated value to the target
  12929. * @param currentValue defines the value computed by the animation
  12930. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12931. */
  12932. setValue(currentValue: any, weight: number): void;
  12933. private _getOriginalValues;
  12934. private _setValue;
  12935. /**
  12936. * Gets the loop pmode of the runtime animation
  12937. * @returns Loop Mode
  12938. */
  12939. private _getCorrectLoopMode;
  12940. /**
  12941. * Move the current animation to a given frame
  12942. * @param frame defines the frame to move to
  12943. */
  12944. goToFrame(frame: number): void;
  12945. /**
  12946. * @hidden Internal use only
  12947. */
  12948. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12949. /**
  12950. * Execute the current animation
  12951. * @param delay defines the delay to add to the current frame
  12952. * @param from defines the lower bound of the animation range
  12953. * @param to defines the upper bound of the animation range
  12954. * @param loop defines if the current animation must loop
  12955. * @param speedRatio defines the current speed ratio
  12956. * @param weight defines the weight of the animation (default is -1 so no weight)
  12957. * @param onLoop optional callback called when animation loops
  12958. * @returns a boolean indicating if the animation is running
  12959. */
  12960. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12961. }
  12962. }
  12963. declare module "babylonjs/Animations/animatable" {
  12964. import { Animation } from "babylonjs/Animations/animation";
  12965. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  12966. import { Nullable } from "babylonjs/types";
  12967. import { Observable } from "babylonjs/Misc/observable";
  12968. import { Scene } from "babylonjs/scene";
  12969. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  12970. import { Node } from "babylonjs/node";
  12971. /**
  12972. * Class used to store an actual running animation
  12973. */
  12974. export class Animatable {
  12975. /** defines the target object */
  12976. target: any;
  12977. /** defines the starting frame number (default is 0) */
  12978. fromFrame: number;
  12979. /** defines the ending frame number (default is 100) */
  12980. toFrame: number;
  12981. /** defines if the animation must loop (default is false) */
  12982. loopAnimation: boolean;
  12983. /** defines a callback to call when animation ends if it is not looping */
  12984. onAnimationEnd?: (() => void) | null | undefined;
  12985. /** defines a callback to call when animation loops */
  12986. onAnimationLoop?: (() => void) | null | undefined;
  12987. private _localDelayOffset;
  12988. private _pausedDelay;
  12989. private _runtimeAnimations;
  12990. private _paused;
  12991. private _scene;
  12992. private _speedRatio;
  12993. private _weight;
  12994. private _syncRoot;
  12995. /**
  12996. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12997. * This will only apply for non looping animation (default is true)
  12998. */
  12999. disposeOnEnd: boolean;
  13000. /**
  13001. * Gets a boolean indicating if the animation has started
  13002. */
  13003. animationStarted: boolean;
  13004. /**
  13005. * Observer raised when the animation ends
  13006. */
  13007. onAnimationEndObservable: Observable<Animatable>;
  13008. /**
  13009. * Observer raised when the animation loops
  13010. */
  13011. onAnimationLoopObservable: Observable<Animatable>;
  13012. /**
  13013. * Gets the root Animatable used to synchronize and normalize animations
  13014. */
  13015. readonly syncRoot: Nullable<Animatable>;
  13016. /**
  13017. * Gets the current frame of the first RuntimeAnimation
  13018. * Used to synchronize Animatables
  13019. */
  13020. readonly masterFrame: number;
  13021. /**
  13022. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13023. */
  13024. weight: number;
  13025. /**
  13026. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13027. */
  13028. speedRatio: number;
  13029. /**
  13030. * Creates a new Animatable
  13031. * @param scene defines the hosting scene
  13032. * @param target defines the target object
  13033. * @param fromFrame defines the starting frame number (default is 0)
  13034. * @param toFrame defines the ending frame number (default is 100)
  13035. * @param loopAnimation defines if the animation must loop (default is false)
  13036. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13037. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13038. * @param animations defines a group of animation to add to the new Animatable
  13039. * @param onAnimationLoop defines a callback to call when animation loops
  13040. */
  13041. constructor(scene: Scene,
  13042. /** defines the target object */
  13043. target: any,
  13044. /** defines the starting frame number (default is 0) */
  13045. fromFrame?: number,
  13046. /** defines the ending frame number (default is 100) */
  13047. toFrame?: number,
  13048. /** defines if the animation must loop (default is false) */
  13049. loopAnimation?: boolean, speedRatio?: number,
  13050. /** defines a callback to call when animation ends if it is not looping */
  13051. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13052. /** defines a callback to call when animation loops */
  13053. onAnimationLoop?: (() => void) | null | undefined);
  13054. /**
  13055. * Synchronize and normalize current Animatable with a source Animatable
  13056. * This is useful when using animation weights and when animations are not of the same length
  13057. * @param root defines the root Animatable to synchronize with
  13058. * @returns the current Animatable
  13059. */
  13060. syncWith(root: Animatable): Animatable;
  13061. /**
  13062. * Gets the list of runtime animations
  13063. * @returns an array of RuntimeAnimation
  13064. */
  13065. getAnimations(): RuntimeAnimation[];
  13066. /**
  13067. * Adds more animations to the current animatable
  13068. * @param target defines the target of the animations
  13069. * @param animations defines the new animations to add
  13070. */
  13071. appendAnimations(target: any, animations: Animation[]): void;
  13072. /**
  13073. * Gets the source animation for a specific property
  13074. * @param property defines the propertyu to look for
  13075. * @returns null or the source animation for the given property
  13076. */
  13077. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13078. /**
  13079. * Gets the runtime animation for a specific property
  13080. * @param property defines the propertyu to look for
  13081. * @returns null or the runtime animation for the given property
  13082. */
  13083. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13084. /**
  13085. * Resets the animatable to its original state
  13086. */
  13087. reset(): void;
  13088. /**
  13089. * Allows the animatable to blend with current running animations
  13090. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13091. * @param blendingSpeed defines the blending speed to use
  13092. */
  13093. enableBlending(blendingSpeed: number): void;
  13094. /**
  13095. * Disable animation blending
  13096. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13097. */
  13098. disableBlending(): void;
  13099. /**
  13100. * Jump directly to a given frame
  13101. * @param frame defines the frame to jump to
  13102. */
  13103. goToFrame(frame: number): void;
  13104. /**
  13105. * Pause the animation
  13106. */
  13107. pause(): void;
  13108. /**
  13109. * Restart the animation
  13110. */
  13111. restart(): void;
  13112. private _raiseOnAnimationEnd;
  13113. /**
  13114. * Stop and delete the current animation
  13115. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13116. * @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)
  13117. */
  13118. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13119. /**
  13120. * Wait asynchronously for the animation to end
  13121. * @returns a promise which will be fullfilled when the animation ends
  13122. */
  13123. waitAsync(): Promise<Animatable>;
  13124. /** @hidden */
  13125. _animate(delay: number): boolean;
  13126. }
  13127. module "babylonjs/scene" {
  13128. interface Scene {
  13129. /** @hidden */
  13130. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13131. /** @hidden */
  13132. _processLateAnimationBindingsForMatrices(holder: {
  13133. totalWeight: number;
  13134. animations: RuntimeAnimation[];
  13135. originalValue: Matrix;
  13136. }): any;
  13137. /** @hidden */
  13138. _processLateAnimationBindingsForQuaternions(holder: {
  13139. totalWeight: number;
  13140. animations: RuntimeAnimation[];
  13141. originalValue: Quaternion;
  13142. }, refQuaternion: Quaternion): Quaternion;
  13143. /** @hidden */
  13144. _processLateAnimationBindings(): void;
  13145. /**
  13146. * Will start the animation sequence of a given target
  13147. * @param target defines the target
  13148. * @param from defines from which frame should animation start
  13149. * @param to defines until which frame should animation run.
  13150. * @param weight defines the weight to apply to the animation (1.0 by default)
  13151. * @param loop defines if the animation loops
  13152. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13153. * @param onAnimationEnd defines the function to be executed when the animation ends
  13154. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13155. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13156. * @param onAnimationLoop defines the callback to call when an animation loops
  13157. * @returns the animatable object created for this animation
  13158. */
  13159. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13160. /**
  13161. * Will start the animation sequence of a given target
  13162. * @param target defines the target
  13163. * @param from defines from which frame should animation start
  13164. * @param to defines until which frame should animation run.
  13165. * @param loop defines if the animation loops
  13166. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13167. * @param onAnimationEnd defines the function to be executed when the animation ends
  13168. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13169. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13170. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13171. * @param onAnimationLoop defines the callback to call when an animation loops
  13172. * @returns the animatable object created for this animation
  13173. */
  13174. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13175. /**
  13176. * Will start the animation sequence of a given target and its hierarchy
  13177. * @param target defines the target
  13178. * @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.
  13179. * @param from defines from which frame should animation start
  13180. * @param to defines until which frame should animation run.
  13181. * @param loop defines if the animation loops
  13182. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13183. * @param onAnimationEnd defines the function to be executed when the animation ends
  13184. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13185. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13186. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13187. * @param onAnimationLoop defines the callback to call when an animation loops
  13188. * @returns the list of created animatables
  13189. */
  13190. 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[];
  13191. /**
  13192. * Begin a new animation on a given node
  13193. * @param target defines the target where the animation will take place
  13194. * @param animations defines the list of animations to start
  13195. * @param from defines the initial value
  13196. * @param to defines the final value
  13197. * @param loop defines if you want animation to loop (off by default)
  13198. * @param speedRatio defines the speed ratio to apply to all animations
  13199. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13200. * @param onAnimationLoop defines the callback to call when an animation loops
  13201. * @returns the list of created animatables
  13202. */
  13203. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13204. /**
  13205. * Begin a new animation on a given node and its hierarchy
  13206. * @param target defines the root node where the animation will take place
  13207. * @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.
  13208. * @param animations defines the list of animations to start
  13209. * @param from defines the initial value
  13210. * @param to defines the final value
  13211. * @param loop defines if you want animation to loop (off by default)
  13212. * @param speedRatio defines the speed ratio to apply to all animations
  13213. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13214. * @param onAnimationLoop defines the callback to call when an animation loops
  13215. * @returns the list of animatables created for all nodes
  13216. */
  13217. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13218. /**
  13219. * Gets the animatable associated with a specific target
  13220. * @param target defines the target of the animatable
  13221. * @returns the required animatable if found
  13222. */
  13223. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13224. /**
  13225. * Gets all animatables associated with a given target
  13226. * @param target defines the target to look animatables for
  13227. * @returns an array of Animatables
  13228. */
  13229. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13230. /**
  13231. * Stops and removes all animations that have been applied to the scene
  13232. */
  13233. stopAllAnimations(): void;
  13234. }
  13235. }
  13236. module "babylonjs/Bones/bone" {
  13237. interface Bone {
  13238. /**
  13239. * Copy an animation range from another bone
  13240. * @param source defines the source bone
  13241. * @param rangeName defines the range name to copy
  13242. * @param frameOffset defines the frame offset
  13243. * @param rescaleAsRequired defines if rescaling must be applied if required
  13244. * @param skelDimensionsRatio defines the scaling ratio
  13245. * @returns true if operation was successful
  13246. */
  13247. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13248. }
  13249. }
  13250. }
  13251. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13252. /**
  13253. * Class used to override all child animations of a given target
  13254. */
  13255. export class AnimationPropertiesOverride {
  13256. /**
  13257. * Gets or sets a value indicating if animation blending must be used
  13258. */
  13259. enableBlending: boolean;
  13260. /**
  13261. * Gets or sets the blending speed to use when enableBlending is true
  13262. */
  13263. blendingSpeed: number;
  13264. /**
  13265. * Gets or sets the default loop mode to use
  13266. */
  13267. loopMode: number;
  13268. }
  13269. }
  13270. declare module "babylonjs/Bones/skeleton" {
  13271. import { Bone } from "babylonjs/Bones/bone";
  13272. import { Observable } from "babylonjs/Misc/observable";
  13273. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13274. import { Scene } from "babylonjs/scene";
  13275. import { Nullable } from "babylonjs/types";
  13276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13277. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13278. import { Animatable } from "babylonjs/Animations/animatable";
  13279. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13280. import { Animation } from "babylonjs/Animations/animation";
  13281. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13282. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13283. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13284. /**
  13285. * Class used to handle skinning animations
  13286. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13287. */
  13288. export class Skeleton implements IAnimatable {
  13289. /** defines the skeleton name */
  13290. name: string;
  13291. /** defines the skeleton Id */
  13292. id: string;
  13293. /**
  13294. * Defines the list of child bones
  13295. */
  13296. bones: Bone[];
  13297. /**
  13298. * Defines an estimate of the dimension of the skeleton at rest
  13299. */
  13300. dimensionsAtRest: Vector3;
  13301. /**
  13302. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13303. */
  13304. needInitialSkinMatrix: boolean;
  13305. /**
  13306. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13307. */
  13308. overrideMesh: Nullable<AbstractMesh>;
  13309. /**
  13310. * Gets the list of animations attached to this skeleton
  13311. */
  13312. animations: Array<Animation>;
  13313. private _scene;
  13314. private _isDirty;
  13315. private _transformMatrices;
  13316. private _transformMatrixTexture;
  13317. private _meshesWithPoseMatrix;
  13318. private _animatables;
  13319. private _identity;
  13320. private _synchronizedWithMesh;
  13321. private _ranges;
  13322. private _lastAbsoluteTransformsUpdateId;
  13323. private _canUseTextureForBones;
  13324. private _uniqueId;
  13325. /** @hidden */
  13326. _numBonesWithLinkedTransformNode: number;
  13327. /** @hidden */
  13328. _hasWaitingData: Nullable<boolean>;
  13329. /**
  13330. * Specifies if the skeleton should be serialized
  13331. */
  13332. doNotSerialize: boolean;
  13333. private _useTextureToStoreBoneMatrices;
  13334. /**
  13335. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13336. * Please note that this option is not available if the hardware does not support it
  13337. */
  13338. useTextureToStoreBoneMatrices: boolean;
  13339. private _animationPropertiesOverride;
  13340. /**
  13341. * Gets or sets the animation properties override
  13342. */
  13343. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13344. /**
  13345. * List of inspectable custom properties (used by the Inspector)
  13346. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13347. */
  13348. inspectableCustomProperties: IInspectable[];
  13349. /**
  13350. * An observable triggered before computing the skeleton's matrices
  13351. */
  13352. onBeforeComputeObservable: Observable<Skeleton>;
  13353. /**
  13354. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13355. */
  13356. readonly isUsingTextureForMatrices: boolean;
  13357. /**
  13358. * Gets the unique ID of this skeleton
  13359. */
  13360. readonly uniqueId: number;
  13361. /**
  13362. * Creates a new skeleton
  13363. * @param name defines the skeleton name
  13364. * @param id defines the skeleton Id
  13365. * @param scene defines the hosting scene
  13366. */
  13367. constructor(
  13368. /** defines the skeleton name */
  13369. name: string,
  13370. /** defines the skeleton Id */
  13371. id: string, scene: Scene);
  13372. /**
  13373. * Gets the current object class name.
  13374. * @return the class name
  13375. */
  13376. getClassName(): string;
  13377. /**
  13378. * Returns an array containing the root bones
  13379. * @returns an array containing the root bones
  13380. */
  13381. getChildren(): Array<Bone>;
  13382. /**
  13383. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13384. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13385. * @returns a Float32Array containing matrices data
  13386. */
  13387. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13388. /**
  13389. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13390. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13391. * @returns a raw texture containing the data
  13392. */
  13393. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13394. /**
  13395. * Gets the current hosting scene
  13396. * @returns a scene object
  13397. */
  13398. getScene(): Scene;
  13399. /**
  13400. * Gets a string representing the current skeleton data
  13401. * @param fullDetails defines a boolean indicating if we want a verbose version
  13402. * @returns a string representing the current skeleton data
  13403. */
  13404. toString(fullDetails?: boolean): string;
  13405. /**
  13406. * Get bone's index searching by name
  13407. * @param name defines bone's name to search for
  13408. * @return the indice of the bone. Returns -1 if not found
  13409. */
  13410. getBoneIndexByName(name: string): number;
  13411. /**
  13412. * Creater a new animation range
  13413. * @param name defines the name of the range
  13414. * @param from defines the start key
  13415. * @param to defines the end key
  13416. */
  13417. createAnimationRange(name: string, from: number, to: number): void;
  13418. /**
  13419. * Delete a specific animation range
  13420. * @param name defines the name of the range
  13421. * @param deleteFrames defines if frames must be removed as well
  13422. */
  13423. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13424. /**
  13425. * Gets a specific animation range
  13426. * @param name defines the name of the range to look for
  13427. * @returns the requested animation range or null if not found
  13428. */
  13429. getAnimationRange(name: string): Nullable<AnimationRange>;
  13430. /**
  13431. * Gets the list of all animation ranges defined on this skeleton
  13432. * @returns an array
  13433. */
  13434. getAnimationRanges(): Nullable<AnimationRange>[];
  13435. /**
  13436. * Copy animation range from a source skeleton.
  13437. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13438. * @param source defines the source skeleton
  13439. * @param name defines the name of the range to copy
  13440. * @param rescaleAsRequired defines if rescaling must be applied if required
  13441. * @returns true if operation was successful
  13442. */
  13443. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13444. /**
  13445. * Forces the skeleton to go to rest pose
  13446. */
  13447. returnToRest(): void;
  13448. private _getHighestAnimationFrame;
  13449. /**
  13450. * Begin a specific animation range
  13451. * @param name defines the name of the range to start
  13452. * @param loop defines if looping must be turned on (false by default)
  13453. * @param speedRatio defines the speed ratio to apply (1 by default)
  13454. * @param onAnimationEnd defines a callback which will be called when animation will end
  13455. * @returns a new animatable
  13456. */
  13457. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13458. /** @hidden */
  13459. _markAsDirty(): void;
  13460. /** @hidden */
  13461. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13462. /** @hidden */
  13463. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13464. private _computeTransformMatrices;
  13465. /**
  13466. * Build all resources required to render a skeleton
  13467. */
  13468. prepare(): void;
  13469. /**
  13470. * Gets the list of animatables currently running for this skeleton
  13471. * @returns an array of animatables
  13472. */
  13473. getAnimatables(): IAnimatable[];
  13474. /**
  13475. * Clone the current skeleton
  13476. * @param name defines the name of the new skeleton
  13477. * @param id defines the id of the new skeleton
  13478. * @returns the new skeleton
  13479. */
  13480. clone(name: string, id: string): Skeleton;
  13481. /**
  13482. * Enable animation blending for this skeleton
  13483. * @param blendingSpeed defines the blending speed to apply
  13484. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13485. */
  13486. enableBlending(blendingSpeed?: number): void;
  13487. /**
  13488. * Releases all resources associated with the current skeleton
  13489. */
  13490. dispose(): void;
  13491. /**
  13492. * Serialize the skeleton in a JSON object
  13493. * @returns a JSON object
  13494. */
  13495. serialize(): any;
  13496. /**
  13497. * Creates a new skeleton from serialized data
  13498. * @param parsedSkeleton defines the serialized data
  13499. * @param scene defines the hosting scene
  13500. * @returns a new skeleton
  13501. */
  13502. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13503. /**
  13504. * Compute all node absolute transforms
  13505. * @param forceUpdate defines if computation must be done even if cache is up to date
  13506. */
  13507. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13508. /**
  13509. * Gets the root pose matrix
  13510. * @returns a matrix
  13511. */
  13512. getPoseMatrix(): Nullable<Matrix>;
  13513. /**
  13514. * Sorts bones per internal index
  13515. */
  13516. sortBones(): void;
  13517. private _sortBones;
  13518. }
  13519. }
  13520. declare module "babylonjs/Bones/bone" {
  13521. import { Skeleton } from "babylonjs/Bones/skeleton";
  13522. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13523. import { Nullable } from "babylonjs/types";
  13524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13526. import { Node } from "babylonjs/node";
  13527. import { Space } from "babylonjs/Maths/math.axis";
  13528. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13529. /**
  13530. * Class used to store bone information
  13531. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13532. */
  13533. export class Bone extends Node {
  13534. /**
  13535. * defines the bone name
  13536. */
  13537. name: string;
  13538. private static _tmpVecs;
  13539. private static _tmpQuat;
  13540. private static _tmpMats;
  13541. /**
  13542. * Gets the list of child bones
  13543. */
  13544. children: Bone[];
  13545. /** Gets the animations associated with this bone */
  13546. animations: import("babylonjs/Animations/animation").Animation[];
  13547. /**
  13548. * Gets or sets bone length
  13549. */
  13550. length: number;
  13551. /**
  13552. * @hidden Internal only
  13553. * Set this value to map this bone to a different index in the transform matrices
  13554. * Set this value to -1 to exclude the bone from the transform matrices
  13555. */
  13556. _index: Nullable<number>;
  13557. private _skeleton;
  13558. private _localMatrix;
  13559. private _restPose;
  13560. private _baseMatrix;
  13561. private _absoluteTransform;
  13562. private _invertedAbsoluteTransform;
  13563. private _parent;
  13564. private _scalingDeterminant;
  13565. private _worldTransform;
  13566. private _localScaling;
  13567. private _localRotation;
  13568. private _localPosition;
  13569. private _needToDecompose;
  13570. private _needToCompose;
  13571. /** @hidden */
  13572. _linkedTransformNode: Nullable<TransformNode>;
  13573. /** @hidden */
  13574. _waitingTransformNodeId: Nullable<string>;
  13575. /** @hidden */
  13576. /** @hidden */
  13577. _matrix: Matrix;
  13578. /**
  13579. * Create a new bone
  13580. * @param name defines the bone name
  13581. * @param skeleton defines the parent skeleton
  13582. * @param parentBone defines the parent (can be null if the bone is the root)
  13583. * @param localMatrix defines the local matrix
  13584. * @param restPose defines the rest pose matrix
  13585. * @param baseMatrix defines the base matrix
  13586. * @param index defines index of the bone in the hiearchy
  13587. */
  13588. constructor(
  13589. /**
  13590. * defines the bone name
  13591. */
  13592. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13593. /**
  13594. * Gets the current object class name.
  13595. * @return the class name
  13596. */
  13597. getClassName(): string;
  13598. /**
  13599. * Gets the parent skeleton
  13600. * @returns a skeleton
  13601. */
  13602. getSkeleton(): Skeleton;
  13603. /**
  13604. * Gets parent bone
  13605. * @returns a bone or null if the bone is the root of the bone hierarchy
  13606. */
  13607. getParent(): Nullable<Bone>;
  13608. /**
  13609. * Returns an array containing the root bones
  13610. * @returns an array containing the root bones
  13611. */
  13612. getChildren(): Array<Bone>;
  13613. /**
  13614. * Sets the parent bone
  13615. * @param parent defines the parent (can be null if the bone is the root)
  13616. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13617. */
  13618. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13619. /**
  13620. * Gets the local matrix
  13621. * @returns a matrix
  13622. */
  13623. getLocalMatrix(): Matrix;
  13624. /**
  13625. * Gets the base matrix (initial matrix which remains unchanged)
  13626. * @returns a matrix
  13627. */
  13628. getBaseMatrix(): Matrix;
  13629. /**
  13630. * Gets the rest pose matrix
  13631. * @returns a matrix
  13632. */
  13633. getRestPose(): Matrix;
  13634. /**
  13635. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13636. */
  13637. getWorldMatrix(): Matrix;
  13638. /**
  13639. * Sets the local matrix to rest pose matrix
  13640. */
  13641. returnToRest(): void;
  13642. /**
  13643. * Gets the inverse of the absolute transform matrix.
  13644. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13645. * @returns a matrix
  13646. */
  13647. getInvertedAbsoluteTransform(): Matrix;
  13648. /**
  13649. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13650. * @returns a matrix
  13651. */
  13652. getAbsoluteTransform(): Matrix;
  13653. /**
  13654. * Links with the given transform node.
  13655. * The local matrix of this bone is copied from the transform node every frame.
  13656. * @param transformNode defines the transform node to link to
  13657. */
  13658. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13659. /**
  13660. * Gets the node used to drive the bone's transformation
  13661. * @returns a transform node or null
  13662. */
  13663. getTransformNode(): Nullable<TransformNode>;
  13664. /** Gets or sets current position (in local space) */
  13665. position: Vector3;
  13666. /** Gets or sets current rotation (in local space) */
  13667. rotation: Vector3;
  13668. /** Gets or sets current rotation quaternion (in local space) */
  13669. rotationQuaternion: Quaternion;
  13670. /** Gets or sets current scaling (in local space) */
  13671. scaling: Vector3;
  13672. /**
  13673. * Gets the animation properties override
  13674. */
  13675. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13676. private _decompose;
  13677. private _compose;
  13678. /**
  13679. * Update the base and local matrices
  13680. * @param matrix defines the new base or local matrix
  13681. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13682. * @param updateLocalMatrix defines if the local matrix should be updated
  13683. */
  13684. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13685. /** @hidden */
  13686. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13687. /**
  13688. * Flag the bone as dirty (Forcing it to update everything)
  13689. */
  13690. markAsDirty(): void;
  13691. /** @hidden */
  13692. _markAsDirtyAndCompose(): void;
  13693. private _markAsDirtyAndDecompose;
  13694. /**
  13695. * Translate the bone in local or world space
  13696. * @param vec The amount to translate the bone
  13697. * @param space The space that the translation is in
  13698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13699. */
  13700. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13701. /**
  13702. * Set the postion of the bone in local or world space
  13703. * @param position The position to set the bone
  13704. * @param space The space that the position is in
  13705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13706. */
  13707. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13708. /**
  13709. * Set the absolute position of the bone (world space)
  13710. * @param position The position to set the bone
  13711. * @param mesh The mesh that this bone is attached to
  13712. */
  13713. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13714. /**
  13715. * Scale the bone on the x, y and z axes (in local space)
  13716. * @param x The amount to scale the bone on the x axis
  13717. * @param y The amount to scale the bone on the y axis
  13718. * @param z The amount to scale the bone on the z axis
  13719. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13720. */
  13721. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13722. /**
  13723. * Set the bone scaling in local space
  13724. * @param scale defines the scaling vector
  13725. */
  13726. setScale(scale: Vector3): void;
  13727. /**
  13728. * Gets the current scaling in local space
  13729. * @returns the current scaling vector
  13730. */
  13731. getScale(): Vector3;
  13732. /**
  13733. * Gets the current scaling in local space and stores it in a target vector
  13734. * @param result defines the target vector
  13735. */
  13736. getScaleToRef(result: Vector3): void;
  13737. /**
  13738. * Set the yaw, pitch, and roll of the bone in local or world space
  13739. * @param yaw The rotation of the bone on the y axis
  13740. * @param pitch The rotation of the bone on the x axis
  13741. * @param roll The rotation of the bone on the z axis
  13742. * @param space The space that the axes of rotation are in
  13743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13744. */
  13745. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13746. /**
  13747. * Add a rotation to the bone on an axis in local or world space
  13748. * @param axis The axis to rotate the bone on
  13749. * @param amount The amount to rotate the bone
  13750. * @param space The space that the axis is in
  13751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13752. */
  13753. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13754. /**
  13755. * Set the rotation of the bone to a particular axis angle in local or world space
  13756. * @param axis The axis to rotate the bone on
  13757. * @param angle The angle that the bone should be rotated to
  13758. * @param space The space that the axis is in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. */
  13761. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13762. /**
  13763. * Set the euler rotation of the bone in local of world space
  13764. * @param rotation The euler rotation that the bone should be set to
  13765. * @param space The space that the rotation is in
  13766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13767. */
  13768. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13769. /**
  13770. * Set the quaternion rotation of the bone in local of world space
  13771. * @param quat The quaternion rotation that the bone should be set to
  13772. * @param space The space that the rotation is in
  13773. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13774. */
  13775. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13776. /**
  13777. * Set the rotation matrix of the bone in local of world space
  13778. * @param rotMat The rotation matrix that the bone should be set to
  13779. * @param space The space that the rotation is in
  13780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13781. */
  13782. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13783. private _rotateWithMatrix;
  13784. private _getNegativeRotationToRef;
  13785. /**
  13786. * Get the position of the bone in local or world space
  13787. * @param space The space that the returned position is in
  13788. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13789. * @returns The position of the bone
  13790. */
  13791. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13792. /**
  13793. * Copy the position of the bone to a vector3 in local or world space
  13794. * @param space The space that the returned position is in
  13795. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13796. * @param result The vector3 to copy the position to
  13797. */
  13798. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13799. /**
  13800. * Get the absolute position of the bone (world space)
  13801. * @param mesh The mesh that this bone is attached to
  13802. * @returns The absolute position of the bone
  13803. */
  13804. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13805. /**
  13806. * Copy the absolute position of the bone (world space) to the result param
  13807. * @param mesh The mesh that this bone is attached to
  13808. * @param result The vector3 to copy the absolute position to
  13809. */
  13810. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13811. /**
  13812. * Compute the absolute transforms of this bone and its children
  13813. */
  13814. computeAbsoluteTransforms(): void;
  13815. /**
  13816. * Get the world direction from an axis that is in the local space of the bone
  13817. * @param localAxis The local direction that is used to compute the world direction
  13818. * @param mesh The mesh that this bone is attached to
  13819. * @returns The world direction
  13820. */
  13821. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13822. /**
  13823. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13824. * @param localAxis The local direction that is used to compute the world direction
  13825. * @param mesh The mesh that this bone is attached to
  13826. * @param result The vector3 that the world direction will be copied to
  13827. */
  13828. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13829. /**
  13830. * Get the euler rotation of the bone in local or world space
  13831. * @param space The space that the rotation should be in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. * @returns The euler rotation
  13834. */
  13835. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13836. /**
  13837. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13838. * @param space The space that the rotation should be in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. * @param result The vector3 that the rotation should be copied to
  13841. */
  13842. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13843. /**
  13844. * Get the quaternion rotation of the bone in either local or world space
  13845. * @param space The space that the rotation should be in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. * @returns The quaternion rotation
  13848. */
  13849. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13850. /**
  13851. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13852. * @param space The space that the rotation should be in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. * @param result The quaternion that the rotation should be copied to
  13855. */
  13856. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13857. /**
  13858. * Get the rotation matrix of the bone in local or world space
  13859. * @param space The space that the rotation should be in
  13860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13861. * @returns The rotation matrix
  13862. */
  13863. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13864. /**
  13865. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13866. * @param space The space that the rotation should be in
  13867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13868. * @param result The quaternion that the rotation should be copied to
  13869. */
  13870. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13871. /**
  13872. * Get the world position of a point that is in the local space of the bone
  13873. * @param position The local position
  13874. * @param mesh The mesh that this bone is attached to
  13875. * @returns The world position
  13876. */
  13877. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13878. /**
  13879. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13880. * @param position The local position
  13881. * @param mesh The mesh that this bone is attached to
  13882. * @param result The vector3 that the world position should be copied to
  13883. */
  13884. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13885. /**
  13886. * Get the local position of a point that is in world space
  13887. * @param position The world position
  13888. * @param mesh The mesh that this bone is attached to
  13889. * @returns The local position
  13890. */
  13891. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13892. /**
  13893. * Get the local position of a point that is in world space and copy it to the result param
  13894. * @param position The world position
  13895. * @param mesh The mesh that this bone is attached to
  13896. * @param result The vector3 that the local position should be copied to
  13897. */
  13898. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13899. }
  13900. }
  13901. declare module "babylonjs/Meshes/transformNode" {
  13902. import { DeepImmutable } from "babylonjs/types";
  13903. import { Observable } from "babylonjs/Misc/observable";
  13904. import { Nullable } from "babylonjs/types";
  13905. import { Camera } from "babylonjs/Cameras/camera";
  13906. import { Scene } from "babylonjs/scene";
  13907. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13908. import { Node } from "babylonjs/node";
  13909. import { Bone } from "babylonjs/Bones/bone";
  13910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13911. import { Space } from "babylonjs/Maths/math.axis";
  13912. /**
  13913. * 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.
  13914. * @see https://doc.babylonjs.com/how_to/transformnode
  13915. */
  13916. export class TransformNode extends Node {
  13917. /**
  13918. * Object will not rotate to face the camera
  13919. */
  13920. static BILLBOARDMODE_NONE: number;
  13921. /**
  13922. * Object will rotate to face the camera but only on the x axis
  13923. */
  13924. static BILLBOARDMODE_X: number;
  13925. /**
  13926. * Object will rotate to face the camera but only on the y axis
  13927. */
  13928. static BILLBOARDMODE_Y: number;
  13929. /**
  13930. * Object will rotate to face the camera but only on the z axis
  13931. */
  13932. static BILLBOARDMODE_Z: number;
  13933. /**
  13934. * Object will rotate to face the camera
  13935. */
  13936. static BILLBOARDMODE_ALL: number;
  13937. private _forward;
  13938. private _forwardInverted;
  13939. private _up;
  13940. private _right;
  13941. private _rightInverted;
  13942. private _position;
  13943. private _rotation;
  13944. private _rotationQuaternion;
  13945. protected _scaling: Vector3;
  13946. protected _isDirty: boolean;
  13947. private _transformToBoneReferal;
  13948. private _isAbsoluteSynced;
  13949. private _billboardMode;
  13950. /**
  13951. * Gets or sets the billboard mode. Default is 0.
  13952. *
  13953. * | Value | Type | Description |
  13954. * | --- | --- | --- |
  13955. * | 0 | BILLBOARDMODE_NONE | |
  13956. * | 1 | BILLBOARDMODE_X | |
  13957. * | 2 | BILLBOARDMODE_Y | |
  13958. * | 4 | BILLBOARDMODE_Z | |
  13959. * | 7 | BILLBOARDMODE_ALL | |
  13960. *
  13961. */
  13962. billboardMode: number;
  13963. private _preserveParentRotationForBillboard;
  13964. /**
  13965. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13966. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13967. */
  13968. preserveParentRotationForBillboard: boolean;
  13969. /**
  13970. * 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
  13971. */
  13972. scalingDeterminant: number;
  13973. private _infiniteDistance;
  13974. /**
  13975. * Gets or sets the distance of the object to max, often used by skybox
  13976. */
  13977. infiniteDistance: boolean;
  13978. /**
  13979. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13980. * By default the system will update normals to compensate
  13981. */
  13982. ignoreNonUniformScaling: boolean;
  13983. /**
  13984. * 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
  13985. */
  13986. reIntegrateRotationIntoRotationQuaternion: boolean;
  13987. /** @hidden */
  13988. _poseMatrix: Nullable<Matrix>;
  13989. /** @hidden */
  13990. _localMatrix: Matrix;
  13991. private _usePivotMatrix;
  13992. private _absolutePosition;
  13993. private _absoluteScaling;
  13994. private _absoluteRotationQuaternion;
  13995. private _pivotMatrix;
  13996. private _pivotMatrixInverse;
  13997. protected _postMultiplyPivotMatrix: boolean;
  13998. protected _isWorldMatrixFrozen: boolean;
  13999. /** @hidden */
  14000. _indexInSceneTransformNodesArray: number;
  14001. /**
  14002. * An event triggered after the world matrix is updated
  14003. */
  14004. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14005. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14006. /**
  14007. * Gets a string identifying the name of the class
  14008. * @returns "TransformNode" string
  14009. */
  14010. getClassName(): string;
  14011. /**
  14012. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14013. */
  14014. position: Vector3;
  14015. /**
  14016. * 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)).
  14017. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14018. */
  14019. rotation: Vector3;
  14020. /**
  14021. * 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)).
  14022. */
  14023. scaling: Vector3;
  14024. /**
  14025. * 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).
  14026. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14027. */
  14028. rotationQuaternion: Nullable<Quaternion>;
  14029. /**
  14030. * The forward direction of that transform in world space.
  14031. */
  14032. readonly forward: Vector3;
  14033. /**
  14034. * The up direction of that transform in world space.
  14035. */
  14036. readonly up: Vector3;
  14037. /**
  14038. * The right direction of that transform in world space.
  14039. */
  14040. readonly right: Vector3;
  14041. /**
  14042. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14043. * @param matrix the matrix to copy the pose from
  14044. * @returns this TransformNode.
  14045. */
  14046. updatePoseMatrix(matrix: Matrix): TransformNode;
  14047. /**
  14048. * Returns the mesh Pose matrix.
  14049. * @returns the pose matrix
  14050. */
  14051. getPoseMatrix(): Matrix;
  14052. /** @hidden */
  14053. _isSynchronized(): boolean;
  14054. /** @hidden */
  14055. _initCache(): void;
  14056. /**
  14057. * Flag the transform node as dirty (Forcing it to update everything)
  14058. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14059. * @returns this transform node
  14060. */
  14061. markAsDirty(property: string): TransformNode;
  14062. /**
  14063. * Returns the current mesh absolute position.
  14064. * Returns a Vector3.
  14065. */
  14066. readonly absolutePosition: Vector3;
  14067. /**
  14068. * Returns the current mesh absolute scaling.
  14069. * Returns a Vector3.
  14070. */
  14071. readonly absoluteScaling: Vector3;
  14072. /**
  14073. * Returns the current mesh absolute rotation.
  14074. * Returns a Quaternion.
  14075. */
  14076. readonly absoluteRotationQuaternion: Quaternion;
  14077. /**
  14078. * Sets a new matrix to apply before all other transformation
  14079. * @param matrix defines the transform matrix
  14080. * @returns the current TransformNode
  14081. */
  14082. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14083. /**
  14084. * Sets a new pivot matrix to the current node
  14085. * @param matrix defines the new pivot matrix to use
  14086. * @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
  14087. * @returns the current TransformNode
  14088. */
  14089. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14090. /**
  14091. * Returns the mesh pivot matrix.
  14092. * Default : Identity.
  14093. * @returns the matrix
  14094. */
  14095. getPivotMatrix(): Matrix;
  14096. /**
  14097. * Prevents the World matrix to be computed any longer.
  14098. * @returns the TransformNode.
  14099. */
  14100. freezeWorldMatrix(): TransformNode;
  14101. /**
  14102. * Allows back the World matrix computation.
  14103. * @returns the TransformNode.
  14104. */
  14105. unfreezeWorldMatrix(): this;
  14106. /**
  14107. * True if the World matrix has been frozen.
  14108. */
  14109. readonly isWorldMatrixFrozen: boolean;
  14110. /**
  14111. * Retuns the mesh absolute position in the World.
  14112. * @returns a Vector3.
  14113. */
  14114. getAbsolutePosition(): Vector3;
  14115. /**
  14116. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14117. * @param absolutePosition the absolute position to set
  14118. * @returns the TransformNode.
  14119. */
  14120. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14121. /**
  14122. * Sets the mesh position in its local space.
  14123. * @param vector3 the position to set in localspace
  14124. * @returns the TransformNode.
  14125. */
  14126. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14127. /**
  14128. * Returns the mesh position in the local space from the current World matrix values.
  14129. * @returns a new Vector3.
  14130. */
  14131. getPositionExpressedInLocalSpace(): Vector3;
  14132. /**
  14133. * Translates the mesh along the passed Vector3 in its local space.
  14134. * @param vector3 the distance to translate in localspace
  14135. * @returns the TransformNode.
  14136. */
  14137. locallyTranslate(vector3: Vector3): TransformNode;
  14138. private static _lookAtVectorCache;
  14139. /**
  14140. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14141. * @param targetPoint the position (must be in same space as current mesh) to look at
  14142. * @param yawCor optional yaw (y-axis) correction in radians
  14143. * @param pitchCor optional pitch (x-axis) correction in radians
  14144. * @param rollCor optional roll (z-axis) correction in radians
  14145. * @param space the choosen space of the target
  14146. * @returns the TransformNode.
  14147. */
  14148. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14149. /**
  14150. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14151. * This Vector3 is expressed in the World space.
  14152. * @param localAxis axis to rotate
  14153. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14154. */
  14155. getDirection(localAxis: Vector3): Vector3;
  14156. /**
  14157. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14158. * localAxis is expressed in the mesh local space.
  14159. * result is computed in the Wordl space from the mesh World matrix.
  14160. * @param localAxis axis to rotate
  14161. * @param result the resulting transformnode
  14162. * @returns this TransformNode.
  14163. */
  14164. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14165. /**
  14166. * Sets this transform node rotation to the given local axis.
  14167. * @param localAxis the axis in local space
  14168. * @param yawCor optional yaw (y-axis) correction in radians
  14169. * @param pitchCor optional pitch (x-axis) correction in radians
  14170. * @param rollCor optional roll (z-axis) correction in radians
  14171. * @returns this TransformNode
  14172. */
  14173. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14174. /**
  14175. * Sets a new pivot point to the current node
  14176. * @param point defines the new pivot point to use
  14177. * @param space defines if the point is in world or local space (local by default)
  14178. * @returns the current TransformNode
  14179. */
  14180. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14181. /**
  14182. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14183. * @returns the pivot point
  14184. */
  14185. getPivotPoint(): Vector3;
  14186. /**
  14187. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14188. * @param result the vector3 to store the result
  14189. * @returns this TransformNode.
  14190. */
  14191. getPivotPointToRef(result: Vector3): TransformNode;
  14192. /**
  14193. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14194. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14195. */
  14196. getAbsolutePivotPoint(): Vector3;
  14197. /**
  14198. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14199. * @param result vector3 to store the result
  14200. * @returns this TransformNode.
  14201. */
  14202. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14203. /**
  14204. * Defines the passed node as the parent of the current node.
  14205. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14206. * @see https://doc.babylonjs.com/how_to/parenting
  14207. * @param node the node ot set as the parent
  14208. * @returns this TransformNode.
  14209. */
  14210. setParent(node: Nullable<Node>): TransformNode;
  14211. private _nonUniformScaling;
  14212. /**
  14213. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14214. */
  14215. readonly nonUniformScaling: boolean;
  14216. /** @hidden */
  14217. _updateNonUniformScalingState(value: boolean): boolean;
  14218. /**
  14219. * Attach the current TransformNode to another TransformNode associated with a bone
  14220. * @param bone Bone affecting the TransformNode
  14221. * @param affectedTransformNode TransformNode associated with the bone
  14222. * @returns this object
  14223. */
  14224. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14225. /**
  14226. * Detach the transform node if its associated with a bone
  14227. * @returns this object
  14228. */
  14229. detachFromBone(): TransformNode;
  14230. private static _rotationAxisCache;
  14231. /**
  14232. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14233. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14234. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14235. * The passed axis is also normalized.
  14236. * @param axis the axis to rotate around
  14237. * @param amount the amount to rotate in radians
  14238. * @param space Space to rotate in (Default: local)
  14239. * @returns the TransformNode.
  14240. */
  14241. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14242. /**
  14243. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14244. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14245. * The passed axis is also normalized. .
  14246. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14247. * @param point the point to rotate around
  14248. * @param axis the axis to rotate around
  14249. * @param amount the amount to rotate in radians
  14250. * @returns the TransformNode
  14251. */
  14252. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14253. /**
  14254. * Translates the mesh along the axis vector for the passed distance in the given space.
  14255. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14256. * @param axis the axis to translate in
  14257. * @param distance the distance to translate
  14258. * @param space Space to rotate in (Default: local)
  14259. * @returns the TransformNode.
  14260. */
  14261. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14262. /**
  14263. * Adds a rotation step to the mesh current rotation.
  14264. * x, y, z are Euler angles expressed in radians.
  14265. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14266. * This means this rotation is made in the mesh local space only.
  14267. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14268. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14269. * ```javascript
  14270. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14271. * ```
  14272. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14273. * 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.
  14274. * @param x Rotation to add
  14275. * @param y Rotation to add
  14276. * @param z Rotation to add
  14277. * @returns the TransformNode.
  14278. */
  14279. addRotation(x: number, y: number, z: number): TransformNode;
  14280. /**
  14281. * @hidden
  14282. */
  14283. protected _getEffectiveParent(): Nullable<Node>;
  14284. /**
  14285. * Computes the world matrix of the node
  14286. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14287. * @returns the world matrix
  14288. */
  14289. computeWorldMatrix(force?: boolean): Matrix;
  14290. protected _afterComputeWorldMatrix(): void;
  14291. /**
  14292. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14293. * @param func callback function to add
  14294. *
  14295. * @returns the TransformNode.
  14296. */
  14297. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14298. /**
  14299. * Removes a registered callback function.
  14300. * @param func callback function to remove
  14301. * @returns the TransformNode.
  14302. */
  14303. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14304. /**
  14305. * Gets the position of the current mesh in camera space
  14306. * @param camera defines the camera to use
  14307. * @returns a position
  14308. */
  14309. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14310. /**
  14311. * Returns the distance from the mesh to the active camera
  14312. * @param camera defines the camera to use
  14313. * @returns the distance
  14314. */
  14315. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14316. /**
  14317. * Clone the current transform node
  14318. * @param name Name of the new clone
  14319. * @param newParent New parent for the clone
  14320. * @param doNotCloneChildren Do not clone children hierarchy
  14321. * @returns the new transform node
  14322. */
  14323. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14324. /**
  14325. * Serializes the objects information.
  14326. * @param currentSerializationObject defines the object to serialize in
  14327. * @returns the serialized object
  14328. */
  14329. serialize(currentSerializationObject?: any): any;
  14330. /**
  14331. * Returns a new TransformNode object parsed from the source provided.
  14332. * @param parsedTransformNode is the source.
  14333. * @param scene the scne the object belongs to
  14334. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14335. * @returns a new TransformNode object parsed from the source provided.
  14336. */
  14337. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14338. /**
  14339. * Get all child-transformNodes of this node
  14340. * @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
  14341. * @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
  14342. * @returns an array of TransformNode
  14343. */
  14344. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14345. /**
  14346. * Releases resources associated with this transform node.
  14347. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14348. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14349. */
  14350. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14351. /**
  14352. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14353. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14354. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14355. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14356. * @returns the current mesh
  14357. */
  14358. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14359. private _syncAbsoluteScalingAndRotation;
  14360. }
  14361. }
  14362. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14363. import { Observable } from "babylonjs/Misc/observable";
  14364. import { Nullable } from "babylonjs/types";
  14365. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14366. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14368. import { Ray } from "babylonjs/Culling/ray";
  14369. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14370. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14371. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14372. /**
  14373. * Defines the types of pose enabled controllers that are supported
  14374. */
  14375. export enum PoseEnabledControllerType {
  14376. /**
  14377. * HTC Vive
  14378. */
  14379. VIVE = 0,
  14380. /**
  14381. * Oculus Rift
  14382. */
  14383. OCULUS = 1,
  14384. /**
  14385. * Windows mixed reality
  14386. */
  14387. WINDOWS = 2,
  14388. /**
  14389. * Samsung gear VR
  14390. */
  14391. GEAR_VR = 3,
  14392. /**
  14393. * Google Daydream
  14394. */
  14395. DAYDREAM = 4,
  14396. /**
  14397. * Generic
  14398. */
  14399. GENERIC = 5
  14400. }
  14401. /**
  14402. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14403. */
  14404. export interface MutableGamepadButton {
  14405. /**
  14406. * Value of the button/trigger
  14407. */
  14408. value: number;
  14409. /**
  14410. * If the button/trigger is currently touched
  14411. */
  14412. touched: boolean;
  14413. /**
  14414. * If the button/trigger is currently pressed
  14415. */
  14416. pressed: boolean;
  14417. }
  14418. /**
  14419. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14420. * @hidden
  14421. */
  14422. export interface ExtendedGamepadButton extends GamepadButton {
  14423. /**
  14424. * If the button/trigger is currently pressed
  14425. */
  14426. readonly pressed: boolean;
  14427. /**
  14428. * If the button/trigger is currently touched
  14429. */
  14430. readonly touched: boolean;
  14431. /**
  14432. * Value of the button/trigger
  14433. */
  14434. readonly value: number;
  14435. }
  14436. /** @hidden */
  14437. export interface _GamePadFactory {
  14438. /**
  14439. * Returns wether or not the current gamepad can be created for this type of controller.
  14440. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14441. * @returns true if it can be created, otherwise false
  14442. */
  14443. canCreate(gamepadInfo: any): boolean;
  14444. /**
  14445. * Creates a new instance of the Gamepad.
  14446. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14447. * @returns the new gamepad instance
  14448. */
  14449. create(gamepadInfo: any): Gamepad;
  14450. }
  14451. /**
  14452. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14453. */
  14454. export class PoseEnabledControllerHelper {
  14455. /** @hidden */
  14456. static _ControllerFactories: _GamePadFactory[];
  14457. /** @hidden */
  14458. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14459. /**
  14460. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14461. * @param vrGamepad the gamepad to initialized
  14462. * @returns a vr controller of the type the gamepad identified as
  14463. */
  14464. static InitiateController(vrGamepad: any): Gamepad;
  14465. }
  14466. /**
  14467. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14468. */
  14469. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14470. /**
  14471. * If the controller is used in a webXR session
  14472. */
  14473. isXR: boolean;
  14474. private _deviceRoomPosition;
  14475. private _deviceRoomRotationQuaternion;
  14476. /**
  14477. * The device position in babylon space
  14478. */
  14479. devicePosition: Vector3;
  14480. /**
  14481. * The device rotation in babylon space
  14482. */
  14483. deviceRotationQuaternion: Quaternion;
  14484. /**
  14485. * The scale factor of the device in babylon space
  14486. */
  14487. deviceScaleFactor: number;
  14488. /**
  14489. * (Likely devicePosition should be used instead) The device position in its room space
  14490. */
  14491. position: Vector3;
  14492. /**
  14493. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14494. */
  14495. rotationQuaternion: Quaternion;
  14496. /**
  14497. * The type of controller (Eg. Windows mixed reality)
  14498. */
  14499. controllerType: PoseEnabledControllerType;
  14500. protected _calculatedPosition: Vector3;
  14501. private _calculatedRotation;
  14502. /**
  14503. * The raw pose from the device
  14504. */
  14505. rawPose: DevicePose;
  14506. private _trackPosition;
  14507. private _maxRotationDistFromHeadset;
  14508. private _draggedRoomRotation;
  14509. /**
  14510. * @hidden
  14511. */
  14512. _disableTrackPosition(fixedPosition: Vector3): void;
  14513. /**
  14514. * Internal, the mesh attached to the controller
  14515. * @hidden
  14516. */
  14517. _mesh: Nullable<AbstractMesh>;
  14518. private _poseControlledCamera;
  14519. private _leftHandSystemQuaternion;
  14520. /**
  14521. * Internal, matrix used to convert room space to babylon space
  14522. * @hidden
  14523. */
  14524. _deviceToWorld: Matrix;
  14525. /**
  14526. * Node to be used when casting a ray from the controller
  14527. * @hidden
  14528. */
  14529. _pointingPoseNode: Nullable<TransformNode>;
  14530. /**
  14531. * Name of the child mesh that can be used to cast a ray from the controller
  14532. */
  14533. static readonly POINTING_POSE: string;
  14534. /**
  14535. * Creates a new PoseEnabledController from a gamepad
  14536. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14537. */
  14538. constructor(browserGamepad: any);
  14539. private _workingMatrix;
  14540. /**
  14541. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14542. */
  14543. update(): void;
  14544. /**
  14545. * Updates only the pose device and mesh without doing any button event checking
  14546. */
  14547. protected _updatePoseAndMesh(): void;
  14548. /**
  14549. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14550. * @param poseData raw pose fromthe device
  14551. */
  14552. updateFromDevice(poseData: DevicePose): void;
  14553. /**
  14554. * @hidden
  14555. */
  14556. _meshAttachedObservable: Observable<AbstractMesh>;
  14557. /**
  14558. * Attaches a mesh to the controller
  14559. * @param mesh the mesh to be attached
  14560. */
  14561. attachToMesh(mesh: AbstractMesh): void;
  14562. /**
  14563. * Attaches the controllers mesh to a camera
  14564. * @param camera the camera the mesh should be attached to
  14565. */
  14566. attachToPoseControlledCamera(camera: TargetCamera): void;
  14567. /**
  14568. * Disposes of the controller
  14569. */
  14570. dispose(): void;
  14571. /**
  14572. * The mesh that is attached to the controller
  14573. */
  14574. readonly mesh: Nullable<AbstractMesh>;
  14575. /**
  14576. * Gets the ray of the controller in the direction the controller is pointing
  14577. * @param length the length the resulting ray should be
  14578. * @returns a ray in the direction the controller is pointing
  14579. */
  14580. getForwardRay(length?: number): Ray;
  14581. }
  14582. }
  14583. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14584. import { Observable } from "babylonjs/Misc/observable";
  14585. import { Scene } from "babylonjs/scene";
  14586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14587. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14588. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14589. /**
  14590. * Defines the WebVRController object that represents controllers tracked in 3D space
  14591. */
  14592. export abstract class WebVRController extends PoseEnabledController {
  14593. /**
  14594. * Internal, the default controller model for the controller
  14595. */
  14596. protected _defaultModel: AbstractMesh;
  14597. /**
  14598. * Fired when the trigger state has changed
  14599. */
  14600. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14601. /**
  14602. * Fired when the main button state has changed
  14603. */
  14604. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14605. /**
  14606. * Fired when the secondary button state has changed
  14607. */
  14608. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14609. /**
  14610. * Fired when the pad state has changed
  14611. */
  14612. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14613. /**
  14614. * Fired when controllers stick values have changed
  14615. */
  14616. onPadValuesChangedObservable: Observable<StickValues>;
  14617. /**
  14618. * Array of button availible on the controller
  14619. */
  14620. protected _buttons: Array<MutableGamepadButton>;
  14621. private _onButtonStateChange;
  14622. /**
  14623. * Fired when a controller button's state has changed
  14624. * @param callback the callback containing the button that was modified
  14625. */
  14626. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14627. /**
  14628. * X and Y axis corresponding to the controllers joystick
  14629. */
  14630. pad: StickValues;
  14631. /**
  14632. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14633. */
  14634. hand: string;
  14635. /**
  14636. * The default controller model for the controller
  14637. */
  14638. readonly defaultModel: AbstractMesh;
  14639. /**
  14640. * Creates a new WebVRController from a gamepad
  14641. * @param vrGamepad the gamepad that the WebVRController should be created from
  14642. */
  14643. constructor(vrGamepad: any);
  14644. /**
  14645. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14646. */
  14647. update(): void;
  14648. /**
  14649. * Function to be called when a button is modified
  14650. */
  14651. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14652. /**
  14653. * Loads a mesh and attaches it to the controller
  14654. * @param scene the scene the mesh should be added to
  14655. * @param meshLoaded callback for when the mesh has been loaded
  14656. */
  14657. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14658. private _setButtonValue;
  14659. private _changes;
  14660. private _checkChanges;
  14661. /**
  14662. * Disposes of th webVRCOntroller
  14663. */
  14664. dispose(): void;
  14665. }
  14666. }
  14667. declare module "babylonjs/Lights/hemisphericLight" {
  14668. import { Nullable } from "babylonjs/types";
  14669. import { Scene } from "babylonjs/scene";
  14670. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14671. import { Color3 } from "babylonjs/Maths/math.color";
  14672. import { Effect } from "babylonjs/Materials/effect";
  14673. import { Light } from "babylonjs/Lights/light";
  14674. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14675. /**
  14676. * The HemisphericLight simulates the ambient environment light,
  14677. * so the passed direction is the light reflection direction, not the incoming direction.
  14678. */
  14679. export class HemisphericLight extends Light {
  14680. /**
  14681. * The groundColor is the light in the opposite direction to the one specified during creation.
  14682. * 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.
  14683. */
  14684. groundColor: Color3;
  14685. /**
  14686. * The light reflection direction, not the incoming direction.
  14687. */
  14688. direction: Vector3;
  14689. /**
  14690. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14691. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14692. * The HemisphericLight can't cast shadows.
  14693. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14694. * @param name The friendly name of the light
  14695. * @param direction The direction of the light reflection
  14696. * @param scene The scene the light belongs to
  14697. */
  14698. constructor(name: string, direction: Vector3, scene: Scene);
  14699. protected _buildUniformLayout(): void;
  14700. /**
  14701. * Returns the string "HemisphericLight".
  14702. * @return The class name
  14703. */
  14704. getClassName(): string;
  14705. /**
  14706. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14707. * Returns the updated direction.
  14708. * @param target The target the direction should point to
  14709. * @return The computed direction
  14710. */
  14711. setDirectionToTarget(target: Vector3): Vector3;
  14712. /**
  14713. * Returns the shadow generator associated to the light.
  14714. * @returns Always null for hemispheric lights because it does not support shadows.
  14715. */
  14716. getShadowGenerator(): Nullable<IShadowGenerator>;
  14717. /**
  14718. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14719. * @param effect The effect to update
  14720. * @param lightIndex The index of the light in the effect to update
  14721. * @returns The hemispheric light
  14722. */
  14723. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14724. /**
  14725. * Computes the world matrix of the node
  14726. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14727. * @param useWasUpdatedFlag defines a reserved property
  14728. * @returns the world matrix
  14729. */
  14730. computeWorldMatrix(): Matrix;
  14731. /**
  14732. * Returns the integer 3.
  14733. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14734. */
  14735. getTypeID(): number;
  14736. /**
  14737. * Prepares the list of defines specific to the light type.
  14738. * @param defines the list of defines
  14739. * @param lightIndex defines the index of the light for the effect
  14740. */
  14741. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14742. }
  14743. }
  14744. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14745. /** @hidden */
  14746. export var vrMultiviewToSingleviewPixelShader: {
  14747. name: string;
  14748. shader: string;
  14749. };
  14750. }
  14751. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14752. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14753. import { Scene } from "babylonjs/scene";
  14754. /**
  14755. * Renders to multiple views with a single draw call
  14756. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14757. */
  14758. export class MultiviewRenderTarget extends RenderTargetTexture {
  14759. /**
  14760. * Creates a multiview render target
  14761. * @param scene scene used with the render target
  14762. * @param size the size of the render target (used for each view)
  14763. */
  14764. constructor(scene: Scene, size?: number | {
  14765. width: number;
  14766. height: number;
  14767. } | {
  14768. ratio: number;
  14769. });
  14770. /**
  14771. * @hidden
  14772. * @param faceIndex the face index, if its a cube texture
  14773. */
  14774. _bindFrameBuffer(faceIndex?: number): void;
  14775. /**
  14776. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14777. * @returns the view count
  14778. */
  14779. getViewCount(): number;
  14780. }
  14781. }
  14782. declare module "babylonjs/Maths/math.frustum" {
  14783. import { Matrix } from "babylonjs/Maths/math.vector";
  14784. import { DeepImmutable } from "babylonjs/types";
  14785. import { Plane } from "babylonjs/Maths/math.plane";
  14786. /**
  14787. * Reprasents a camera frustum
  14788. */
  14789. export class Frustum {
  14790. /**
  14791. * Gets the planes representing the frustum
  14792. * @param transform matrix to be applied to the returned planes
  14793. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14794. */
  14795. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14796. /**
  14797. * Gets the near frustum plane transformed by the transform matrix
  14798. * @param transform transformation matrix to be applied to the resulting frustum plane
  14799. * @param frustumPlane the resuling frustum plane
  14800. */
  14801. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14802. /**
  14803. * Gets the far frustum plane transformed by the transform matrix
  14804. * @param transform transformation matrix to be applied to the resulting frustum plane
  14805. * @param frustumPlane the resuling frustum plane
  14806. */
  14807. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14808. /**
  14809. * Gets the left frustum plane transformed by the transform matrix
  14810. * @param transform transformation matrix to be applied to the resulting frustum plane
  14811. * @param frustumPlane the resuling frustum plane
  14812. */
  14813. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14814. /**
  14815. * Gets the right frustum plane transformed by the transform matrix
  14816. * @param transform transformation matrix to be applied to the resulting frustum plane
  14817. * @param frustumPlane the resuling frustum plane
  14818. */
  14819. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14820. /**
  14821. * Gets the top frustum plane transformed by the transform matrix
  14822. * @param transform transformation matrix to be applied to the resulting frustum plane
  14823. * @param frustumPlane the resuling frustum plane
  14824. */
  14825. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14826. /**
  14827. * Gets the bottom frustum plane transformed by the transform matrix
  14828. * @param transform transformation matrix to be applied to the resulting frustum plane
  14829. * @param frustumPlane the resuling frustum plane
  14830. */
  14831. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14832. /**
  14833. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14834. * @param transform transformation matrix to be applied to the resulting frustum planes
  14835. * @param frustumPlanes the resuling frustum planes
  14836. */
  14837. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14838. }
  14839. }
  14840. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14841. import { Camera } from "babylonjs/Cameras/camera";
  14842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14843. import { Nullable } from "babylonjs/types";
  14844. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14845. import { Matrix } from "babylonjs/Maths/math.vector";
  14846. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14847. module "babylonjs/Engines/engine" {
  14848. interface Engine {
  14849. /**
  14850. * Creates a new multiview render target
  14851. * @param width defines the width of the texture
  14852. * @param height defines the height of the texture
  14853. * @returns the created multiview texture
  14854. */
  14855. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14856. /**
  14857. * Binds a multiview framebuffer to be drawn to
  14858. * @param multiviewTexture texture to bind
  14859. */
  14860. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14861. }
  14862. }
  14863. module "babylonjs/Cameras/camera" {
  14864. interface Camera {
  14865. /**
  14866. * @hidden
  14867. * 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)
  14868. */
  14869. _useMultiviewToSingleView: boolean;
  14870. /**
  14871. * @hidden
  14872. * 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)
  14873. */
  14874. _multiviewTexture: Nullable<RenderTargetTexture>;
  14875. /**
  14876. * @hidden
  14877. * ensures the multiview texture of the camera exists and has the specified width/height
  14878. * @param width height to set on the multiview texture
  14879. * @param height width to set on the multiview texture
  14880. */
  14881. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14882. }
  14883. }
  14884. module "babylonjs/scene" {
  14885. interface Scene {
  14886. /** @hidden */
  14887. _transformMatrixR: Matrix;
  14888. /** @hidden */
  14889. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14890. /** @hidden */
  14891. _createMultiviewUbo(): void;
  14892. /** @hidden */
  14893. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14894. /** @hidden */
  14895. _renderMultiviewToSingleView(camera: Camera): void;
  14896. }
  14897. }
  14898. }
  14899. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14900. import { Camera } from "babylonjs/Cameras/camera";
  14901. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14902. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14903. import "babylonjs/Engines/Extensions/engine.multiview";
  14904. /**
  14905. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14906. * This will not be used for webXR as it supports displaying texture arrays directly
  14907. */
  14908. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14909. /**
  14910. * Initializes a VRMultiviewToSingleview
  14911. * @param name name of the post process
  14912. * @param camera camera to be applied to
  14913. * @param scaleFactor scaling factor to the size of the output texture
  14914. */
  14915. constructor(name: string, camera: Camera, scaleFactor: number);
  14916. }
  14917. }
  14918. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14919. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14920. import { Nullable } from "babylonjs/types";
  14921. import { Size } from "babylonjs/Maths/math.size";
  14922. import { Observable } from "babylonjs/Misc/observable";
  14923. module "babylonjs/Engines/engine" {
  14924. interface Engine {
  14925. /** @hidden */
  14926. _vrDisplay: any;
  14927. /** @hidden */
  14928. _vrSupported: boolean;
  14929. /** @hidden */
  14930. _oldSize: Size;
  14931. /** @hidden */
  14932. _oldHardwareScaleFactor: number;
  14933. /** @hidden */
  14934. _vrExclusivePointerMode: boolean;
  14935. /** @hidden */
  14936. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14937. /** @hidden */
  14938. _onVRDisplayPointerRestricted: () => void;
  14939. /** @hidden */
  14940. _onVRDisplayPointerUnrestricted: () => void;
  14941. /** @hidden */
  14942. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14943. /** @hidden */
  14944. _onVrDisplayDisconnect: Nullable<() => void>;
  14945. /** @hidden */
  14946. _onVrDisplayPresentChange: Nullable<() => void>;
  14947. /**
  14948. * Observable signaled when VR display mode changes
  14949. */
  14950. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14951. /**
  14952. * Observable signaled when VR request present is complete
  14953. */
  14954. onVRRequestPresentComplete: Observable<boolean>;
  14955. /**
  14956. * Observable signaled when VR request present starts
  14957. */
  14958. onVRRequestPresentStart: Observable<Engine>;
  14959. /**
  14960. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14961. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14962. */
  14963. isInVRExclusivePointerMode: boolean;
  14964. /**
  14965. * Gets a boolean indicating if a webVR device was detected
  14966. * @returns true if a webVR device was detected
  14967. */
  14968. isVRDevicePresent(): boolean;
  14969. /**
  14970. * Gets the current webVR device
  14971. * @returns the current webVR device (or null)
  14972. */
  14973. getVRDevice(): any;
  14974. /**
  14975. * Initializes a webVR display and starts listening to display change events
  14976. * The onVRDisplayChangedObservable will be notified upon these changes
  14977. * @returns A promise containing a VRDisplay and if vr is supported
  14978. */
  14979. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14980. /** @hidden */
  14981. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14982. /**
  14983. * Call this function to switch to webVR mode
  14984. * Will do nothing if webVR is not supported or if there is no webVR device
  14985. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14986. */
  14987. enableVR(): void;
  14988. /** @hidden */
  14989. _onVRFullScreenTriggered(): void;
  14990. }
  14991. }
  14992. }
  14993. declare module "babylonjs/Cameras/VR/webVRCamera" {
  14994. import { Nullable } from "babylonjs/types";
  14995. import { Observable } from "babylonjs/Misc/observable";
  14996. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  14997. import { Scene } from "babylonjs/scene";
  14998. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14999. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15000. import { Node } from "babylonjs/node";
  15001. import { Ray } from "babylonjs/Culling/ray";
  15002. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15003. import "babylonjs/Engines/Extensions/engine.webVR";
  15004. /**
  15005. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15006. * IMPORTANT!! The data is right-hand data.
  15007. * @export
  15008. * @interface DevicePose
  15009. */
  15010. export interface DevicePose {
  15011. /**
  15012. * The position of the device, values in array are [x,y,z].
  15013. */
  15014. readonly position: Nullable<Float32Array>;
  15015. /**
  15016. * The linearVelocity of the device, values in array are [x,y,z].
  15017. */
  15018. readonly linearVelocity: Nullable<Float32Array>;
  15019. /**
  15020. * The linearAcceleration of the device, values in array are [x,y,z].
  15021. */
  15022. readonly linearAcceleration: Nullable<Float32Array>;
  15023. /**
  15024. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15025. */
  15026. readonly orientation: Nullable<Float32Array>;
  15027. /**
  15028. * The angularVelocity of the device, values in array are [x,y,z].
  15029. */
  15030. readonly angularVelocity: Nullable<Float32Array>;
  15031. /**
  15032. * The angularAcceleration of the device, values in array are [x,y,z].
  15033. */
  15034. readonly angularAcceleration: Nullable<Float32Array>;
  15035. }
  15036. /**
  15037. * Interface representing a pose controlled object in Babylon.
  15038. * A pose controlled object has both regular pose values as well as pose values
  15039. * from an external device such as a VR head mounted display
  15040. */
  15041. export interface PoseControlled {
  15042. /**
  15043. * The position of the object in babylon space.
  15044. */
  15045. position: Vector3;
  15046. /**
  15047. * The rotation quaternion of the object in babylon space.
  15048. */
  15049. rotationQuaternion: Quaternion;
  15050. /**
  15051. * The position of the device in babylon space.
  15052. */
  15053. devicePosition?: Vector3;
  15054. /**
  15055. * The rotation quaternion of the device in babylon space.
  15056. */
  15057. deviceRotationQuaternion: Quaternion;
  15058. /**
  15059. * The raw pose coming from the device.
  15060. */
  15061. rawPose: Nullable<DevicePose>;
  15062. /**
  15063. * The scale of the device to be used when translating from device space to babylon space.
  15064. */
  15065. deviceScaleFactor: number;
  15066. /**
  15067. * Updates the poseControlled values based on the input device pose.
  15068. * @param poseData the pose data to update the object with
  15069. */
  15070. updateFromDevice(poseData: DevicePose): void;
  15071. }
  15072. /**
  15073. * Set of options to customize the webVRCamera
  15074. */
  15075. export interface WebVROptions {
  15076. /**
  15077. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15078. */
  15079. trackPosition?: boolean;
  15080. /**
  15081. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15082. */
  15083. positionScale?: number;
  15084. /**
  15085. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15086. */
  15087. displayName?: string;
  15088. /**
  15089. * Should the native controller meshes be initialized. (default: true)
  15090. */
  15091. controllerMeshes?: boolean;
  15092. /**
  15093. * Creating a default HemiLight only on controllers. (default: true)
  15094. */
  15095. defaultLightingOnControllers?: boolean;
  15096. /**
  15097. * If you don't want to use the default VR button of the helper. (default: false)
  15098. */
  15099. useCustomVRButton?: boolean;
  15100. /**
  15101. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15102. */
  15103. customVRButton?: HTMLButtonElement;
  15104. /**
  15105. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15106. */
  15107. rayLength?: number;
  15108. /**
  15109. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15110. */
  15111. defaultHeight?: number;
  15112. /**
  15113. * If multiview should be used if availible (default: false)
  15114. */
  15115. useMultiview?: boolean;
  15116. }
  15117. /**
  15118. * This represents a WebVR camera.
  15119. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15120. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15121. */
  15122. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15123. private webVROptions;
  15124. /**
  15125. * @hidden
  15126. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15127. */
  15128. _vrDevice: any;
  15129. /**
  15130. * The rawPose of the vrDevice.
  15131. */
  15132. rawPose: Nullable<DevicePose>;
  15133. private _onVREnabled;
  15134. private _specsVersion;
  15135. private _attached;
  15136. private _frameData;
  15137. protected _descendants: Array<Node>;
  15138. private _deviceRoomPosition;
  15139. /** @hidden */
  15140. _deviceRoomRotationQuaternion: Quaternion;
  15141. private _standingMatrix;
  15142. /**
  15143. * Represents device position in babylon space.
  15144. */
  15145. devicePosition: Vector3;
  15146. /**
  15147. * Represents device rotation in babylon space.
  15148. */
  15149. deviceRotationQuaternion: Quaternion;
  15150. /**
  15151. * The scale of the device to be used when translating from device space to babylon space.
  15152. */
  15153. deviceScaleFactor: number;
  15154. private _deviceToWorld;
  15155. private _worldToDevice;
  15156. /**
  15157. * References to the webVR controllers for the vrDevice.
  15158. */
  15159. controllers: Array<WebVRController>;
  15160. /**
  15161. * Emits an event when a controller is attached.
  15162. */
  15163. onControllersAttachedObservable: Observable<WebVRController[]>;
  15164. /**
  15165. * Emits an event when a controller's mesh has been loaded;
  15166. */
  15167. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15168. /**
  15169. * Emits an event when the HMD's pose has been updated.
  15170. */
  15171. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15172. private _poseSet;
  15173. /**
  15174. * If the rig cameras be used as parent instead of this camera.
  15175. */
  15176. rigParenting: boolean;
  15177. private _lightOnControllers;
  15178. private _defaultHeight?;
  15179. /**
  15180. * Instantiates a WebVRFreeCamera.
  15181. * @param name The name of the WebVRFreeCamera
  15182. * @param position The starting anchor position for the camera
  15183. * @param scene The scene the camera belongs to
  15184. * @param webVROptions a set of customizable options for the webVRCamera
  15185. */
  15186. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15187. /**
  15188. * Gets the device distance from the ground in meters.
  15189. * @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.
  15190. */
  15191. deviceDistanceToRoomGround(): number;
  15192. /**
  15193. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15194. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15195. */
  15196. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15197. /**
  15198. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15199. * @returns A promise with a boolean set to if the standing matrix is supported.
  15200. */
  15201. useStandingMatrixAsync(): Promise<boolean>;
  15202. /**
  15203. * Disposes the camera
  15204. */
  15205. dispose(): void;
  15206. /**
  15207. * Gets a vrController by name.
  15208. * @param name The name of the controller to retreive
  15209. * @returns the controller matching the name specified or null if not found
  15210. */
  15211. getControllerByName(name: string): Nullable<WebVRController>;
  15212. private _leftController;
  15213. /**
  15214. * The controller corresponding to the users left hand.
  15215. */
  15216. readonly leftController: Nullable<WebVRController>;
  15217. private _rightController;
  15218. /**
  15219. * The controller corresponding to the users right hand.
  15220. */
  15221. readonly rightController: Nullable<WebVRController>;
  15222. /**
  15223. * Casts a ray forward from the vrCamera's gaze.
  15224. * @param length Length of the ray (default: 100)
  15225. * @returns the ray corresponding to the gaze
  15226. */
  15227. getForwardRay(length?: number): Ray;
  15228. /**
  15229. * @hidden
  15230. * Updates the camera based on device's frame data
  15231. */
  15232. _checkInputs(): void;
  15233. /**
  15234. * Updates the poseControlled values based on the input device pose.
  15235. * @param poseData Pose coming from the device
  15236. */
  15237. updateFromDevice(poseData: DevicePose): void;
  15238. private _htmlElementAttached;
  15239. private _detachIfAttached;
  15240. /**
  15241. * WebVR's attach control will start broadcasting frames to the device.
  15242. * Note that in certain browsers (chrome for example) this function must be called
  15243. * within a user-interaction callback. Example:
  15244. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15245. *
  15246. * @param element html element to attach the vrDevice to
  15247. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15248. */
  15249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15250. /**
  15251. * Detaches the camera from the html element and disables VR
  15252. *
  15253. * @param element html element to detach from
  15254. */
  15255. detachControl(element: HTMLElement): void;
  15256. /**
  15257. * @returns the name of this class
  15258. */
  15259. getClassName(): string;
  15260. /**
  15261. * Calls resetPose on the vrDisplay
  15262. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15263. */
  15264. resetToCurrentRotation(): void;
  15265. /**
  15266. * @hidden
  15267. * Updates the rig cameras (left and right eye)
  15268. */
  15269. _updateRigCameras(): void;
  15270. private _workingVector;
  15271. private _oneVector;
  15272. private _workingMatrix;
  15273. private updateCacheCalled;
  15274. private _correctPositionIfNotTrackPosition;
  15275. /**
  15276. * @hidden
  15277. * Updates the cached values of the camera
  15278. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15279. */
  15280. _updateCache(ignoreParentClass?: boolean): void;
  15281. /**
  15282. * @hidden
  15283. * Get current device position in babylon world
  15284. */
  15285. _computeDevicePosition(): void;
  15286. /**
  15287. * Updates the current device position and rotation in the babylon world
  15288. */
  15289. update(): void;
  15290. /**
  15291. * @hidden
  15292. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15293. * @returns an identity matrix
  15294. */
  15295. _getViewMatrix(): Matrix;
  15296. private _tmpMatrix;
  15297. /**
  15298. * This function is called by the two RIG cameras.
  15299. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15300. * @hidden
  15301. */
  15302. _getWebVRViewMatrix(): Matrix;
  15303. /** @hidden */
  15304. _getWebVRProjectionMatrix(): Matrix;
  15305. private _onGamepadConnectedObserver;
  15306. private _onGamepadDisconnectedObserver;
  15307. private _updateCacheWhenTrackingDisabledObserver;
  15308. /**
  15309. * Initializes the controllers and their meshes
  15310. */
  15311. initControllers(): void;
  15312. }
  15313. }
  15314. declare module "babylonjs/PostProcesses/postProcess" {
  15315. import { Nullable } from "babylonjs/types";
  15316. import { SmartArray } from "babylonjs/Misc/smartArray";
  15317. import { Observable } from "babylonjs/Misc/observable";
  15318. import { Vector2 } from "babylonjs/Maths/math.vector";
  15319. import { Camera } from "babylonjs/Cameras/camera";
  15320. import { Effect } from "babylonjs/Materials/effect";
  15321. import "babylonjs/Shaders/postprocess.vertex";
  15322. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15323. import { Engine } from "babylonjs/Engines/engine";
  15324. import { Color4 } from "babylonjs/Maths/math.color";
  15325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15326. /**
  15327. * Size options for a post process
  15328. */
  15329. export type PostProcessOptions = {
  15330. width: number;
  15331. height: number;
  15332. };
  15333. /**
  15334. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15335. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15336. */
  15337. export class PostProcess {
  15338. /** Name of the PostProcess. */
  15339. name: string;
  15340. /**
  15341. * Gets or sets the unique id of the post process
  15342. */
  15343. uniqueId: number;
  15344. /**
  15345. * Width of the texture to apply the post process on
  15346. */
  15347. width: number;
  15348. /**
  15349. * Height of the texture to apply the post process on
  15350. */
  15351. height: number;
  15352. /**
  15353. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15354. * @hidden
  15355. */
  15356. _outputTexture: Nullable<InternalTexture>;
  15357. /**
  15358. * Sampling mode used by the shader
  15359. * See https://doc.babylonjs.com/classes/3.1/texture
  15360. */
  15361. renderTargetSamplingMode: number;
  15362. /**
  15363. * Clear color to use when screen clearing
  15364. */
  15365. clearColor: Color4;
  15366. /**
  15367. * If the buffer needs to be cleared before applying the post process. (default: true)
  15368. * Should be set to false if shader will overwrite all previous pixels.
  15369. */
  15370. autoClear: boolean;
  15371. /**
  15372. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15373. */
  15374. alphaMode: number;
  15375. /**
  15376. * Sets the setAlphaBlendConstants of the babylon engine
  15377. */
  15378. alphaConstants: Color4;
  15379. /**
  15380. * Animations to be used for the post processing
  15381. */
  15382. animations: import("babylonjs/Animations/animation").Animation[];
  15383. /**
  15384. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15385. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15386. */
  15387. enablePixelPerfectMode: boolean;
  15388. /**
  15389. * Force the postprocess to be applied without taking in account viewport
  15390. */
  15391. forceFullscreenViewport: boolean;
  15392. /**
  15393. * List of inspectable custom properties (used by the Inspector)
  15394. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15395. */
  15396. inspectableCustomProperties: IInspectable[];
  15397. /**
  15398. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15399. *
  15400. * | Value | Type | Description |
  15401. * | ----- | ----------------------------------- | ----------- |
  15402. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15403. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15404. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15405. *
  15406. */
  15407. scaleMode: number;
  15408. /**
  15409. * Force textures to be a power of two (default: false)
  15410. */
  15411. alwaysForcePOT: boolean;
  15412. private _samples;
  15413. /**
  15414. * Number of sample textures (default: 1)
  15415. */
  15416. samples: number;
  15417. /**
  15418. * Modify the scale of the post process to be the same as the viewport (default: false)
  15419. */
  15420. adaptScaleToCurrentViewport: boolean;
  15421. private _camera;
  15422. private _scene;
  15423. private _engine;
  15424. private _options;
  15425. private _reusable;
  15426. private _textureType;
  15427. /**
  15428. * Smart array of input and output textures for the post process.
  15429. * @hidden
  15430. */
  15431. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15432. /**
  15433. * The index in _textures that corresponds to the output texture.
  15434. * @hidden
  15435. */
  15436. _currentRenderTextureInd: number;
  15437. private _effect;
  15438. private _samplers;
  15439. private _fragmentUrl;
  15440. private _vertexUrl;
  15441. private _parameters;
  15442. private _scaleRatio;
  15443. protected _indexParameters: any;
  15444. private _shareOutputWithPostProcess;
  15445. private _texelSize;
  15446. private _forcedOutputTexture;
  15447. /**
  15448. * Returns the fragment url or shader name used in the post process.
  15449. * @returns the fragment url or name in the shader store.
  15450. */
  15451. getEffectName(): string;
  15452. /**
  15453. * An event triggered when the postprocess is activated.
  15454. */
  15455. onActivateObservable: Observable<Camera>;
  15456. private _onActivateObserver;
  15457. /**
  15458. * A function that is added to the onActivateObservable
  15459. */
  15460. onActivate: Nullable<(camera: Camera) => void>;
  15461. /**
  15462. * An event triggered when the postprocess changes its size.
  15463. */
  15464. onSizeChangedObservable: Observable<PostProcess>;
  15465. private _onSizeChangedObserver;
  15466. /**
  15467. * A function that is added to the onSizeChangedObservable
  15468. */
  15469. onSizeChanged: (postProcess: PostProcess) => void;
  15470. /**
  15471. * An event triggered when the postprocess applies its effect.
  15472. */
  15473. onApplyObservable: Observable<Effect>;
  15474. private _onApplyObserver;
  15475. /**
  15476. * A function that is added to the onApplyObservable
  15477. */
  15478. onApply: (effect: Effect) => void;
  15479. /**
  15480. * An event triggered before rendering the postprocess
  15481. */
  15482. onBeforeRenderObservable: Observable<Effect>;
  15483. private _onBeforeRenderObserver;
  15484. /**
  15485. * A function that is added to the onBeforeRenderObservable
  15486. */
  15487. onBeforeRender: (effect: Effect) => void;
  15488. /**
  15489. * An event triggered after rendering the postprocess
  15490. */
  15491. onAfterRenderObservable: Observable<Effect>;
  15492. private _onAfterRenderObserver;
  15493. /**
  15494. * A function that is added to the onAfterRenderObservable
  15495. */
  15496. onAfterRender: (efect: Effect) => void;
  15497. /**
  15498. * 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
  15499. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15500. */
  15501. inputTexture: InternalTexture;
  15502. /**
  15503. * Gets the camera which post process is applied to.
  15504. * @returns The camera the post process is applied to.
  15505. */
  15506. getCamera(): Camera;
  15507. /**
  15508. * Gets the texel size of the postprocess.
  15509. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15510. */
  15511. readonly texelSize: Vector2;
  15512. /**
  15513. * Creates a new instance PostProcess
  15514. * @param name The name of the PostProcess.
  15515. * @param fragmentUrl The url of the fragment shader to be used.
  15516. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15517. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15518. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15519. * @param camera The camera to apply the render pass to.
  15520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15521. * @param engine The engine which the post process will be applied. (default: current engine)
  15522. * @param reusable If the post process can be reused on the same frame. (default: false)
  15523. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15524. * @param textureType Type of textures used when performing the post process. (default: 0)
  15525. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15526. * @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
  15527. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15528. */
  15529. constructor(
  15530. /** Name of the PostProcess. */
  15531. 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);
  15532. /**
  15533. * Gets a string idenfifying the name of the class
  15534. * @returns "PostProcess" string
  15535. */
  15536. getClassName(): string;
  15537. /**
  15538. * Gets the engine which this post process belongs to.
  15539. * @returns The engine the post process was enabled with.
  15540. */
  15541. getEngine(): Engine;
  15542. /**
  15543. * The effect that is created when initializing the post process.
  15544. * @returns The created effect corresponding the the postprocess.
  15545. */
  15546. getEffect(): Effect;
  15547. /**
  15548. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15549. * @param postProcess The post process to share the output with.
  15550. * @returns This post process.
  15551. */
  15552. shareOutputWith(postProcess: PostProcess): PostProcess;
  15553. /**
  15554. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15555. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15556. */
  15557. useOwnOutput(): void;
  15558. /**
  15559. * Updates the effect with the current post process compile time values and recompiles the shader.
  15560. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15561. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15562. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15563. * @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
  15564. * @param onCompiled Called when the shader has been compiled.
  15565. * @param onError Called if there is an error when compiling a shader.
  15566. */
  15567. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15568. /**
  15569. * The post process is reusable if it can be used multiple times within one frame.
  15570. * @returns If the post process is reusable
  15571. */
  15572. isReusable(): boolean;
  15573. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15574. markTextureDirty(): void;
  15575. /**
  15576. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15577. * 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.
  15578. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15579. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15580. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15581. * @returns The target texture that was bound to be written to.
  15582. */
  15583. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15584. /**
  15585. * If the post process is supported.
  15586. */
  15587. readonly isSupported: boolean;
  15588. /**
  15589. * The aspect ratio of the output texture.
  15590. */
  15591. readonly aspectRatio: number;
  15592. /**
  15593. * Get a value indicating if the post-process is ready to be used
  15594. * @returns true if the post-process is ready (shader is compiled)
  15595. */
  15596. isReady(): boolean;
  15597. /**
  15598. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15599. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15600. */
  15601. apply(): Nullable<Effect>;
  15602. private _disposeTextures;
  15603. /**
  15604. * Disposes the post process.
  15605. * @param camera The camera to dispose the post process on.
  15606. */
  15607. dispose(camera?: Camera): void;
  15608. }
  15609. }
  15610. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15611. /** @hidden */
  15612. export var kernelBlurVaryingDeclaration: {
  15613. name: string;
  15614. shader: string;
  15615. };
  15616. }
  15617. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15618. /** @hidden */
  15619. export var kernelBlurFragment: {
  15620. name: string;
  15621. shader: string;
  15622. };
  15623. }
  15624. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15625. /** @hidden */
  15626. export var kernelBlurFragment2: {
  15627. name: string;
  15628. shader: string;
  15629. };
  15630. }
  15631. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15632. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15633. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15634. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15635. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15636. /** @hidden */
  15637. export var kernelBlurPixelShader: {
  15638. name: string;
  15639. shader: string;
  15640. };
  15641. }
  15642. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15643. /** @hidden */
  15644. export var kernelBlurVertex: {
  15645. name: string;
  15646. shader: string;
  15647. };
  15648. }
  15649. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15650. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15651. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15652. /** @hidden */
  15653. export var kernelBlurVertexShader: {
  15654. name: string;
  15655. shader: string;
  15656. };
  15657. }
  15658. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15659. import { Vector2 } from "babylonjs/Maths/math.vector";
  15660. import { Nullable } from "babylonjs/types";
  15661. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15662. import { Camera } from "babylonjs/Cameras/camera";
  15663. import { Effect } from "babylonjs/Materials/effect";
  15664. import { Engine } from "babylonjs/Engines/engine";
  15665. import "babylonjs/Shaders/kernelBlur.fragment";
  15666. import "babylonjs/Shaders/kernelBlur.vertex";
  15667. /**
  15668. * The Blur Post Process which blurs an image based on a kernel and direction.
  15669. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15670. */
  15671. export class BlurPostProcess extends PostProcess {
  15672. /** The direction in which to blur the image. */
  15673. direction: Vector2;
  15674. private blockCompilation;
  15675. protected _kernel: number;
  15676. protected _idealKernel: number;
  15677. protected _packedFloat: boolean;
  15678. private _staticDefines;
  15679. /**
  15680. * Sets the length in pixels of the blur sample region
  15681. */
  15682. /**
  15683. * Gets the length in pixels of the blur sample region
  15684. */
  15685. kernel: number;
  15686. /**
  15687. * Sets wether or not the blur needs to unpack/repack floats
  15688. */
  15689. /**
  15690. * Gets wether or not the blur is unpacking/repacking floats
  15691. */
  15692. packedFloat: boolean;
  15693. /**
  15694. * Creates a new instance BlurPostProcess
  15695. * @param name The name of the effect.
  15696. * @param direction The direction in which to blur the image.
  15697. * @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.
  15698. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15699. * @param camera The camera to apply the render pass to.
  15700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15701. * @param engine The engine which the post process will be applied. (default: current engine)
  15702. * @param reusable If the post process can be reused on the same frame. (default: false)
  15703. * @param textureType Type of textures used when performing the post process. (default: 0)
  15704. * @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)
  15705. */
  15706. constructor(name: string,
  15707. /** The direction in which to blur the image. */
  15708. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15709. /**
  15710. * Updates the effect with the current post process compile time values and recompiles the shader.
  15711. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15712. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15713. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15714. * @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
  15715. * @param onCompiled Called when the shader has been compiled.
  15716. * @param onError Called if there is an error when compiling a shader.
  15717. */
  15718. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15719. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15720. /**
  15721. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15722. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15723. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15724. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15725. * The gaps between physical kernels are compensated for in the weighting of the samples
  15726. * @param idealKernel Ideal blur kernel.
  15727. * @return Nearest best kernel.
  15728. */
  15729. protected _nearestBestKernel(idealKernel: number): number;
  15730. /**
  15731. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15732. * @param x The point on the Gaussian distribution to sample.
  15733. * @return the value of the Gaussian function at x.
  15734. */
  15735. protected _gaussianWeight(x: number): number;
  15736. /**
  15737. * Generates a string that can be used as a floating point number in GLSL.
  15738. * @param x Value to print.
  15739. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15740. * @return GLSL float string.
  15741. */
  15742. protected _glslFloat(x: number, decimalFigures?: number): string;
  15743. }
  15744. }
  15745. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15746. import { Scene } from "babylonjs/scene";
  15747. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15748. import { Plane } from "babylonjs/Maths/math.plane";
  15749. /**
  15750. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15751. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15752. * You can then easily use it as a reflectionTexture on a flat surface.
  15753. * In case the surface is not a plane, please consider relying on reflection probes.
  15754. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15755. */
  15756. export class MirrorTexture extends RenderTargetTexture {
  15757. private scene;
  15758. /**
  15759. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15760. * 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.
  15761. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15762. */
  15763. mirrorPlane: Plane;
  15764. /**
  15765. * Define the blur ratio used to blur the reflection if needed.
  15766. */
  15767. blurRatio: number;
  15768. /**
  15769. * Define the adaptive blur kernel used to blur the reflection if needed.
  15770. * This will autocompute the closest best match for the `blurKernel`
  15771. */
  15772. adaptiveBlurKernel: number;
  15773. /**
  15774. * Define the blur kernel used to blur the reflection if needed.
  15775. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15776. */
  15777. blurKernel: number;
  15778. /**
  15779. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15780. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15781. */
  15782. blurKernelX: number;
  15783. /**
  15784. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15785. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15786. */
  15787. blurKernelY: number;
  15788. private _autoComputeBlurKernel;
  15789. protected _onRatioRescale(): void;
  15790. private _updateGammaSpace;
  15791. private _imageProcessingConfigChangeObserver;
  15792. private _transformMatrix;
  15793. private _mirrorMatrix;
  15794. private _savedViewMatrix;
  15795. private _blurX;
  15796. private _blurY;
  15797. private _adaptiveBlurKernel;
  15798. private _blurKernelX;
  15799. private _blurKernelY;
  15800. private _blurRatio;
  15801. /**
  15802. * Instantiates a Mirror Texture.
  15803. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15804. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15805. * You can then easily use it as a reflectionTexture on a flat surface.
  15806. * In case the surface is not a plane, please consider relying on reflection probes.
  15807. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15808. * @param name
  15809. * @param size
  15810. * @param scene
  15811. * @param generateMipMaps
  15812. * @param type
  15813. * @param samplingMode
  15814. * @param generateDepthBuffer
  15815. */
  15816. constructor(name: string, size: number | {
  15817. width: number;
  15818. height: number;
  15819. } | {
  15820. ratio: number;
  15821. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15822. private _preparePostProcesses;
  15823. /**
  15824. * Clone the mirror texture.
  15825. * @returns the cloned texture
  15826. */
  15827. clone(): MirrorTexture;
  15828. /**
  15829. * Serialize the texture to a JSON representation you could use in Parse later on
  15830. * @returns the serialized JSON representation
  15831. */
  15832. serialize(): any;
  15833. /**
  15834. * Dispose the texture and release its associated resources.
  15835. */
  15836. dispose(): void;
  15837. }
  15838. }
  15839. declare module "babylonjs/Materials/Textures/texture" {
  15840. import { Observable } from "babylonjs/Misc/observable";
  15841. import { Nullable } from "babylonjs/types";
  15842. import { Scene } from "babylonjs/scene";
  15843. import { Matrix } from "babylonjs/Maths/math.vector";
  15844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15845. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15846. import { Engine } from "babylonjs/Engines/engine";
  15847. /**
  15848. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15849. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15850. */
  15851. export class Texture extends BaseTexture {
  15852. /** @hidden */
  15853. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15854. /** @hidden */
  15855. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15856. /** @hidden */
  15857. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15858. /** nearest is mag = nearest and min = nearest and mip = linear */
  15859. static readonly NEAREST_SAMPLINGMODE: number;
  15860. /** nearest is mag = nearest and min = nearest and mip = linear */
  15861. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15862. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15863. static readonly BILINEAR_SAMPLINGMODE: number;
  15864. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15865. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15866. /** Trilinear is mag = linear and min = linear and mip = linear */
  15867. static readonly TRILINEAR_SAMPLINGMODE: number;
  15868. /** Trilinear is mag = linear and min = linear and mip = linear */
  15869. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15870. /** mag = nearest and min = nearest and mip = nearest */
  15871. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15872. /** mag = nearest and min = linear and mip = nearest */
  15873. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15874. /** mag = nearest and min = linear and mip = linear */
  15875. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15876. /** mag = nearest and min = linear and mip = none */
  15877. static readonly NEAREST_LINEAR: number;
  15878. /** mag = nearest and min = nearest and mip = none */
  15879. static readonly NEAREST_NEAREST: number;
  15880. /** mag = linear and min = nearest and mip = nearest */
  15881. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15882. /** mag = linear and min = nearest and mip = linear */
  15883. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15884. /** mag = linear and min = linear and mip = none */
  15885. static readonly LINEAR_LINEAR: number;
  15886. /** mag = linear and min = nearest and mip = none */
  15887. static readonly LINEAR_NEAREST: number;
  15888. /** Explicit coordinates mode */
  15889. static readonly EXPLICIT_MODE: number;
  15890. /** Spherical coordinates mode */
  15891. static readonly SPHERICAL_MODE: number;
  15892. /** Planar coordinates mode */
  15893. static readonly PLANAR_MODE: number;
  15894. /** Cubic coordinates mode */
  15895. static readonly CUBIC_MODE: number;
  15896. /** Projection coordinates mode */
  15897. static readonly PROJECTION_MODE: number;
  15898. /** Inverse Cubic coordinates mode */
  15899. static readonly SKYBOX_MODE: number;
  15900. /** Inverse Cubic coordinates mode */
  15901. static readonly INVCUBIC_MODE: number;
  15902. /** Equirectangular coordinates mode */
  15903. static readonly EQUIRECTANGULAR_MODE: number;
  15904. /** Equirectangular Fixed coordinates mode */
  15905. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15906. /** Equirectangular Fixed Mirrored coordinates mode */
  15907. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15908. /** Texture is not repeating outside of 0..1 UVs */
  15909. static readonly CLAMP_ADDRESSMODE: number;
  15910. /** Texture is repeating outside of 0..1 UVs */
  15911. static readonly WRAP_ADDRESSMODE: number;
  15912. /** Texture is repeating and mirrored */
  15913. static readonly MIRROR_ADDRESSMODE: number;
  15914. /**
  15915. * 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
  15916. */
  15917. static UseSerializedUrlIfAny: boolean;
  15918. /**
  15919. * Define the url of the texture.
  15920. */
  15921. url: Nullable<string>;
  15922. /**
  15923. * Define an offset on the texture to offset the u coordinates of the UVs
  15924. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15925. */
  15926. uOffset: number;
  15927. /**
  15928. * Define an offset on the texture to offset the v coordinates of the UVs
  15929. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15930. */
  15931. vOffset: number;
  15932. /**
  15933. * Define an offset on the texture to scale the u coordinates of the UVs
  15934. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15935. */
  15936. uScale: number;
  15937. /**
  15938. * Define an offset on the texture to scale the v coordinates of the UVs
  15939. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15940. */
  15941. vScale: number;
  15942. /**
  15943. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15944. * @see http://doc.babylonjs.com/how_to/more_materials
  15945. */
  15946. uAng: number;
  15947. /**
  15948. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15949. * @see http://doc.babylonjs.com/how_to/more_materials
  15950. */
  15951. vAng: number;
  15952. /**
  15953. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15954. * @see http://doc.babylonjs.com/how_to/more_materials
  15955. */
  15956. wAng: number;
  15957. /**
  15958. * Defines the center of rotation (U)
  15959. */
  15960. uRotationCenter: number;
  15961. /**
  15962. * Defines the center of rotation (V)
  15963. */
  15964. vRotationCenter: number;
  15965. /**
  15966. * Defines the center of rotation (W)
  15967. */
  15968. wRotationCenter: number;
  15969. /**
  15970. * Are mip maps generated for this texture or not.
  15971. */
  15972. readonly noMipmap: boolean;
  15973. /**
  15974. * List of inspectable custom properties (used by the Inspector)
  15975. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15976. */
  15977. inspectableCustomProperties: Nullable<IInspectable[]>;
  15978. private _noMipmap;
  15979. /** @hidden */
  15980. _invertY: boolean;
  15981. private _rowGenerationMatrix;
  15982. private _cachedTextureMatrix;
  15983. private _projectionModeMatrix;
  15984. private _t0;
  15985. private _t1;
  15986. private _t2;
  15987. private _cachedUOffset;
  15988. private _cachedVOffset;
  15989. private _cachedUScale;
  15990. private _cachedVScale;
  15991. private _cachedUAng;
  15992. private _cachedVAng;
  15993. private _cachedWAng;
  15994. private _cachedProjectionMatrixId;
  15995. private _cachedCoordinatesMode;
  15996. /** @hidden */
  15997. protected _initialSamplingMode: number;
  15998. /** @hidden */
  15999. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16000. private _deleteBuffer;
  16001. protected _format: Nullable<number>;
  16002. private _delayedOnLoad;
  16003. private _delayedOnError;
  16004. /**
  16005. * Observable triggered once the texture has been loaded.
  16006. */
  16007. onLoadObservable: Observable<Texture>;
  16008. protected _isBlocking: boolean;
  16009. /**
  16010. * Is the texture preventing material to render while loading.
  16011. * If false, a default texture will be used instead of the loading one during the preparation step.
  16012. */
  16013. isBlocking: boolean;
  16014. /**
  16015. * Get the current sampling mode associated with the texture.
  16016. */
  16017. readonly samplingMode: number;
  16018. /**
  16019. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16020. */
  16021. readonly invertY: boolean;
  16022. /**
  16023. * Instantiates a new texture.
  16024. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16025. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16026. * @param url define the url of the picture to load as a texture
  16027. * @param scene define the scene or engine the texture will belong to
  16028. * @param noMipmap define if the texture will require mip maps or not
  16029. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16030. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16031. * @param onLoad define a callback triggered when the texture has been loaded
  16032. * @param onError define a callback triggered when an error occurred during the loading session
  16033. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16034. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16035. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16036. */
  16037. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16038. /**
  16039. * Update the url (and optional buffer) of this texture if url was null during construction.
  16040. * @param url the url of the texture
  16041. * @param buffer the buffer of the texture (defaults to null)
  16042. * @param onLoad callback called when the texture is loaded (defaults to null)
  16043. */
  16044. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16045. /**
  16046. * Finish the loading sequence of a texture flagged as delayed load.
  16047. * @hidden
  16048. */
  16049. delayLoad(): void;
  16050. private _prepareRowForTextureGeneration;
  16051. /**
  16052. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16053. * @returns the transform matrix of the texture.
  16054. */
  16055. getTextureMatrix(): Matrix;
  16056. /**
  16057. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16058. * @returns The reflection texture transform
  16059. */
  16060. getReflectionTextureMatrix(): Matrix;
  16061. /**
  16062. * Clones the texture.
  16063. * @returns the cloned texture
  16064. */
  16065. clone(): Texture;
  16066. /**
  16067. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16068. * @returns The JSON representation of the texture
  16069. */
  16070. serialize(): any;
  16071. /**
  16072. * Get the current class name of the texture useful for serialization or dynamic coding.
  16073. * @returns "Texture"
  16074. */
  16075. getClassName(): string;
  16076. /**
  16077. * Dispose the texture and release its associated resources.
  16078. */
  16079. dispose(): void;
  16080. /**
  16081. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16082. * @param parsedTexture Define the JSON representation of the texture
  16083. * @param scene Define the scene the parsed texture should be instantiated in
  16084. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16085. * @returns The parsed texture if successful
  16086. */
  16087. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16088. /**
  16089. * Creates a texture from its base 64 representation.
  16090. * @param data Define the base64 payload without the data: prefix
  16091. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16092. * @param scene Define the scene the texture should belong to
  16093. * @param noMipmap Forces the texture to not create mip map information if true
  16094. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16095. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16096. * @param onLoad define a callback triggered when the texture has been loaded
  16097. * @param onError define a callback triggered when an error occurred during the loading session
  16098. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16099. * @returns the created texture
  16100. */
  16101. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16102. /**
  16103. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16104. * @param data Define the base64 payload without the data: prefix
  16105. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16106. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16107. * @param scene Define the scene the texture should belong to
  16108. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16109. * @param noMipmap Forces the texture to not create mip map information if true
  16110. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16111. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16112. * @param onLoad define a callback triggered when the texture has been loaded
  16113. * @param onError define a callback triggered when an error occurred during the loading session
  16114. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16115. * @returns the created texture
  16116. */
  16117. 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;
  16118. }
  16119. }
  16120. declare module "babylonjs/PostProcesses/postProcessManager" {
  16121. import { Nullable } from "babylonjs/types";
  16122. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16123. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16124. import { Scene } from "babylonjs/scene";
  16125. /**
  16126. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16127. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16128. */
  16129. export class PostProcessManager {
  16130. private _scene;
  16131. private _indexBuffer;
  16132. private _vertexBuffers;
  16133. /**
  16134. * Creates a new instance PostProcess
  16135. * @param scene The scene that the post process is associated with.
  16136. */
  16137. constructor(scene: Scene);
  16138. private _prepareBuffers;
  16139. private _buildIndexBuffer;
  16140. /**
  16141. * Rebuilds the vertex buffers of the manager.
  16142. * @hidden
  16143. */
  16144. _rebuild(): void;
  16145. /**
  16146. * Prepares a frame to be run through a post process.
  16147. * @param sourceTexture The input texture to the post procesess. (default: null)
  16148. * @param postProcesses An array of post processes to be run. (default: null)
  16149. * @returns True if the post processes were able to be run.
  16150. * @hidden
  16151. */
  16152. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16153. /**
  16154. * Manually render a set of post processes to a texture.
  16155. * @param postProcesses An array of post processes to be run.
  16156. * @param targetTexture The target texture to render to.
  16157. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16158. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16159. * @param lodLevel defines which lod of the texture to render to
  16160. */
  16161. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16162. /**
  16163. * Finalize the result of the output of the postprocesses.
  16164. * @param doNotPresent If true the result will not be displayed to the screen.
  16165. * @param targetTexture The target texture to render to.
  16166. * @param faceIndex The index of the face to bind the target texture to.
  16167. * @param postProcesses The array of post processes to render.
  16168. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16169. * @hidden
  16170. */
  16171. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16172. /**
  16173. * Disposes of the post process manager.
  16174. */
  16175. dispose(): void;
  16176. }
  16177. }
  16178. declare module "babylonjs/Misc/gradients" {
  16179. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16180. /** Interface used by value gradients (color, factor, ...) */
  16181. export interface IValueGradient {
  16182. /**
  16183. * Gets or sets the gradient value (between 0 and 1)
  16184. */
  16185. gradient: number;
  16186. }
  16187. /** Class used to store color4 gradient */
  16188. export class ColorGradient implements IValueGradient {
  16189. /**
  16190. * Gets or sets the gradient value (between 0 and 1)
  16191. */
  16192. gradient: number;
  16193. /**
  16194. * Gets or sets first associated color
  16195. */
  16196. color1: Color4;
  16197. /**
  16198. * Gets or sets second associated color
  16199. */
  16200. color2?: Color4;
  16201. /**
  16202. * Will get a color picked randomly between color1 and color2.
  16203. * If color2 is undefined then color1 will be used
  16204. * @param result defines the target Color4 to store the result in
  16205. */
  16206. getColorToRef(result: Color4): void;
  16207. }
  16208. /** Class used to store color 3 gradient */
  16209. export class Color3Gradient implements IValueGradient {
  16210. /**
  16211. * Gets or sets the gradient value (between 0 and 1)
  16212. */
  16213. gradient: number;
  16214. /**
  16215. * Gets or sets the associated color
  16216. */
  16217. color: Color3;
  16218. }
  16219. /** Class used to store factor gradient */
  16220. export class FactorGradient implements IValueGradient {
  16221. /**
  16222. * Gets or sets the gradient value (between 0 and 1)
  16223. */
  16224. gradient: number;
  16225. /**
  16226. * Gets or sets first associated factor
  16227. */
  16228. factor1: number;
  16229. /**
  16230. * Gets or sets second associated factor
  16231. */
  16232. factor2?: number;
  16233. /**
  16234. * Will get a number picked randomly between factor1 and factor2.
  16235. * If factor2 is undefined then factor1 will be used
  16236. * @returns the picked number
  16237. */
  16238. getFactor(): number;
  16239. }
  16240. /**
  16241. * Helper used to simplify some generic gradient tasks
  16242. */
  16243. export class GradientHelper {
  16244. /**
  16245. * Gets the current gradient from an array of IValueGradient
  16246. * @param ratio defines the current ratio to get
  16247. * @param gradients defines the array of IValueGradient
  16248. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16249. */
  16250. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16251. }
  16252. }
  16253. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16254. import { Scene } from "babylonjs/scene";
  16255. import { ISceneComponent } from "babylonjs/sceneComponent";
  16256. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16257. module "babylonjs/abstractScene" {
  16258. interface AbstractScene {
  16259. /**
  16260. * The list of procedural textures added to the scene
  16261. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16262. */
  16263. proceduralTextures: Array<ProceduralTexture>;
  16264. }
  16265. }
  16266. /**
  16267. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16268. * in a given scene.
  16269. */
  16270. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16271. /**
  16272. * The component name helpfull to identify the component in the list of scene components.
  16273. */
  16274. readonly name: string;
  16275. /**
  16276. * The scene the component belongs to.
  16277. */
  16278. scene: Scene;
  16279. /**
  16280. * Creates a new instance of the component for the given scene
  16281. * @param scene Defines the scene to register the component in
  16282. */
  16283. constructor(scene: Scene);
  16284. /**
  16285. * Registers the component in a given scene
  16286. */
  16287. register(): void;
  16288. /**
  16289. * Rebuilds the elements related to this component in case of
  16290. * context lost for instance.
  16291. */
  16292. rebuild(): void;
  16293. /**
  16294. * Disposes the component and the associated ressources.
  16295. */
  16296. dispose(): void;
  16297. private _beforeClear;
  16298. }
  16299. }
  16300. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16301. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16302. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16303. module "babylonjs/Engines/engine" {
  16304. interface Engine {
  16305. /**
  16306. * Creates a new render target cube texture
  16307. * @param size defines the size of the texture
  16308. * @param options defines the options used to create the texture
  16309. * @returns a new render target cube texture stored in an InternalTexture
  16310. */
  16311. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16312. }
  16313. }
  16314. }
  16315. declare module "babylonjs/Shaders/procedural.vertex" {
  16316. /** @hidden */
  16317. export var proceduralVertexShader: {
  16318. name: string;
  16319. shader: string;
  16320. };
  16321. }
  16322. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16323. import { Observable } from "babylonjs/Misc/observable";
  16324. import { Nullable } from "babylonjs/types";
  16325. import { Scene } from "babylonjs/scene";
  16326. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16327. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16328. import { Effect } from "babylonjs/Materials/effect";
  16329. import { Texture } from "babylonjs/Materials/Textures/texture";
  16330. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16331. import "babylonjs/Shaders/procedural.vertex";
  16332. /**
  16333. * 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.
  16334. * This is the base class of any Procedural texture and contains most of the shareable code.
  16335. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16336. */
  16337. export class ProceduralTexture extends Texture {
  16338. isCube: boolean;
  16339. /**
  16340. * Define if the texture is enabled or not (disabled texture will not render)
  16341. */
  16342. isEnabled: boolean;
  16343. /**
  16344. * Define if the texture must be cleared before rendering (default is true)
  16345. */
  16346. autoClear: boolean;
  16347. /**
  16348. * Callback called when the texture is generated
  16349. */
  16350. onGenerated: () => void;
  16351. /**
  16352. * Event raised when the texture is generated
  16353. */
  16354. onGeneratedObservable: Observable<ProceduralTexture>;
  16355. /** @hidden */
  16356. _generateMipMaps: boolean;
  16357. /** @hidden **/
  16358. _effect: Effect;
  16359. /** @hidden */
  16360. _textures: {
  16361. [key: string]: Texture;
  16362. };
  16363. private _size;
  16364. private _currentRefreshId;
  16365. private _refreshRate;
  16366. private _vertexBuffers;
  16367. private _indexBuffer;
  16368. private _uniforms;
  16369. private _samplers;
  16370. private _fragment;
  16371. private _floats;
  16372. private _ints;
  16373. private _floatsArrays;
  16374. private _colors3;
  16375. private _colors4;
  16376. private _vectors2;
  16377. private _vectors3;
  16378. private _matrices;
  16379. private _fallbackTexture;
  16380. private _fallbackTextureUsed;
  16381. private _engine;
  16382. private _cachedDefines;
  16383. private _contentUpdateId;
  16384. private _contentData;
  16385. /**
  16386. * Instantiates a new procedural texture.
  16387. * 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.
  16388. * This is the base class of any Procedural texture and contains most of the shareable code.
  16389. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16390. * @param name Define the name of the texture
  16391. * @param size Define the size of the texture to create
  16392. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16393. * @param scene Define the scene the texture belongs to
  16394. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16395. * @param generateMipMaps Define if the texture should creates mip maps or not
  16396. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16397. */
  16398. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16399. /**
  16400. * The effect that is created when initializing the post process.
  16401. * @returns The created effect corresponding the the postprocess.
  16402. */
  16403. getEffect(): Effect;
  16404. /**
  16405. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16406. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16407. */
  16408. getContent(): Nullable<ArrayBufferView>;
  16409. private _createIndexBuffer;
  16410. /** @hidden */
  16411. _rebuild(): void;
  16412. /**
  16413. * Resets the texture in order to recreate its associated resources.
  16414. * This can be called in case of context loss
  16415. */
  16416. reset(): void;
  16417. protected _getDefines(): string;
  16418. /**
  16419. * Is the texture ready to be used ? (rendered at least once)
  16420. * @returns true if ready, otherwise, false.
  16421. */
  16422. isReady(): boolean;
  16423. /**
  16424. * Resets the refresh counter of the texture and start bak from scratch.
  16425. * Could be useful to regenerate the texture if it is setup to render only once.
  16426. */
  16427. resetRefreshCounter(): void;
  16428. /**
  16429. * Set the fragment shader to use in order to render the texture.
  16430. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16431. */
  16432. setFragment(fragment: any): void;
  16433. /**
  16434. * Define the refresh rate of the texture or the rendering frequency.
  16435. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16436. */
  16437. refreshRate: number;
  16438. /** @hidden */
  16439. _shouldRender(): boolean;
  16440. /**
  16441. * Get the size the texture is rendering at.
  16442. * @returns the size (texture is always squared)
  16443. */
  16444. getRenderSize(): number;
  16445. /**
  16446. * Resize the texture to new value.
  16447. * @param size Define the new size the texture should have
  16448. * @param generateMipMaps Define whether the new texture should create mip maps
  16449. */
  16450. resize(size: number, generateMipMaps: boolean): void;
  16451. private _checkUniform;
  16452. /**
  16453. * Set a texture in the shader program used to render.
  16454. * @param name Define the name of the uniform samplers as defined in the shader
  16455. * @param texture Define the texture to bind to this sampler
  16456. * @return the texture itself allowing "fluent" like uniform updates
  16457. */
  16458. setTexture(name: string, texture: Texture): ProceduralTexture;
  16459. /**
  16460. * Set a float in the shader.
  16461. * @param name Define the name of the uniform as defined in the shader
  16462. * @param value Define the value to give to the uniform
  16463. * @return the texture itself allowing "fluent" like uniform updates
  16464. */
  16465. setFloat(name: string, value: number): ProceduralTexture;
  16466. /**
  16467. * Set a int in the shader.
  16468. * @param name Define the name of the uniform as defined in the shader
  16469. * @param value Define the value to give to the uniform
  16470. * @return the texture itself allowing "fluent" like uniform updates
  16471. */
  16472. setInt(name: string, value: number): ProceduralTexture;
  16473. /**
  16474. * Set an array of floats in the shader.
  16475. * @param name Define the name of the uniform as defined in the shader
  16476. * @param value Define the value to give to the uniform
  16477. * @return the texture itself allowing "fluent" like uniform updates
  16478. */
  16479. setFloats(name: string, value: number[]): ProceduralTexture;
  16480. /**
  16481. * Set a vec3 in the shader from a Color3.
  16482. * @param name Define the name of the uniform as defined in the shader
  16483. * @param value Define the value to give to the uniform
  16484. * @return the texture itself allowing "fluent" like uniform updates
  16485. */
  16486. setColor3(name: string, value: Color3): ProceduralTexture;
  16487. /**
  16488. * Set a vec4 in the shader from a Color4.
  16489. * @param name Define the name of the uniform as defined in the shader
  16490. * @param value Define the value to give to the uniform
  16491. * @return the texture itself allowing "fluent" like uniform updates
  16492. */
  16493. setColor4(name: string, value: Color4): ProceduralTexture;
  16494. /**
  16495. * Set a vec2 in the shader from a Vector2.
  16496. * @param name Define the name of the uniform as defined in the shader
  16497. * @param value Define the value to give to the uniform
  16498. * @return the texture itself allowing "fluent" like uniform updates
  16499. */
  16500. setVector2(name: string, value: Vector2): ProceduralTexture;
  16501. /**
  16502. * Set a vec3 in the shader from a Vector3.
  16503. * @param name Define the name of the uniform as defined in the shader
  16504. * @param value Define the value to give to the uniform
  16505. * @return the texture itself allowing "fluent" like uniform updates
  16506. */
  16507. setVector3(name: string, value: Vector3): ProceduralTexture;
  16508. /**
  16509. * Set a mat4 in the shader from a MAtrix.
  16510. * @param name Define the name of the uniform as defined in the shader
  16511. * @param value Define the value to give to the uniform
  16512. * @return the texture itself allowing "fluent" like uniform updates
  16513. */
  16514. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16515. /**
  16516. * Render the texture to its associated render target.
  16517. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16518. */
  16519. render(useCameraPostProcess?: boolean): void;
  16520. /**
  16521. * Clone the texture.
  16522. * @returns the cloned texture
  16523. */
  16524. clone(): ProceduralTexture;
  16525. /**
  16526. * Dispose the texture and release its asoociated resources.
  16527. */
  16528. dispose(): void;
  16529. }
  16530. }
  16531. declare module "babylonjs/Particles/baseParticleSystem" {
  16532. import { Nullable } from "babylonjs/types";
  16533. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16535. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16536. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16537. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16538. import { Scene } from "babylonjs/scene";
  16539. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16540. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16541. import { Texture } from "babylonjs/Materials/Textures/texture";
  16542. import { Color4 } from "babylonjs/Maths/math.color";
  16543. import { Animation } from "babylonjs/Animations/animation";
  16544. /**
  16545. * This represents the base class for particle system in Babylon.
  16546. * 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.
  16547. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16548. * @example https://doc.babylonjs.com/babylon101/particles
  16549. */
  16550. export class BaseParticleSystem {
  16551. /**
  16552. * Source color is added to the destination color without alpha affecting the result
  16553. */
  16554. static BLENDMODE_ONEONE: number;
  16555. /**
  16556. * Blend current color and particle color using particle’s alpha
  16557. */
  16558. static BLENDMODE_STANDARD: number;
  16559. /**
  16560. * Add current color and particle color multiplied by particle’s alpha
  16561. */
  16562. static BLENDMODE_ADD: number;
  16563. /**
  16564. * Multiply current color with particle color
  16565. */
  16566. static BLENDMODE_MULTIPLY: number;
  16567. /**
  16568. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16569. */
  16570. static BLENDMODE_MULTIPLYADD: number;
  16571. /**
  16572. * List of animations used by the particle system.
  16573. */
  16574. animations: Animation[];
  16575. /**
  16576. * The id of the Particle system.
  16577. */
  16578. id: string;
  16579. /**
  16580. * The friendly name of the Particle system.
  16581. */
  16582. name: string;
  16583. /**
  16584. * The rendering group used by the Particle system to chose when to render.
  16585. */
  16586. renderingGroupId: number;
  16587. /**
  16588. * The emitter represents the Mesh or position we are attaching the particle system to.
  16589. */
  16590. emitter: Nullable<AbstractMesh | Vector3>;
  16591. /**
  16592. * The maximum number of particles to emit per frame
  16593. */
  16594. emitRate: number;
  16595. /**
  16596. * If you want to launch only a few particles at once, that can be done, as well.
  16597. */
  16598. manualEmitCount: number;
  16599. /**
  16600. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16601. */
  16602. updateSpeed: number;
  16603. /**
  16604. * The amount of time the particle system is running (depends of the overall update speed).
  16605. */
  16606. targetStopDuration: number;
  16607. /**
  16608. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16609. */
  16610. disposeOnStop: boolean;
  16611. /**
  16612. * Minimum power of emitting particles.
  16613. */
  16614. minEmitPower: number;
  16615. /**
  16616. * Maximum power of emitting particles.
  16617. */
  16618. maxEmitPower: number;
  16619. /**
  16620. * Minimum life time of emitting particles.
  16621. */
  16622. minLifeTime: number;
  16623. /**
  16624. * Maximum life time of emitting particles.
  16625. */
  16626. maxLifeTime: number;
  16627. /**
  16628. * Minimum Size of emitting particles.
  16629. */
  16630. minSize: number;
  16631. /**
  16632. * Maximum Size of emitting particles.
  16633. */
  16634. maxSize: number;
  16635. /**
  16636. * Minimum scale of emitting particles on X axis.
  16637. */
  16638. minScaleX: number;
  16639. /**
  16640. * Maximum scale of emitting particles on X axis.
  16641. */
  16642. maxScaleX: number;
  16643. /**
  16644. * Minimum scale of emitting particles on Y axis.
  16645. */
  16646. minScaleY: number;
  16647. /**
  16648. * Maximum scale of emitting particles on Y axis.
  16649. */
  16650. maxScaleY: number;
  16651. /**
  16652. * Gets or sets the minimal initial rotation in radians.
  16653. */
  16654. minInitialRotation: number;
  16655. /**
  16656. * Gets or sets the maximal initial rotation in radians.
  16657. */
  16658. maxInitialRotation: number;
  16659. /**
  16660. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16661. */
  16662. minAngularSpeed: number;
  16663. /**
  16664. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16665. */
  16666. maxAngularSpeed: number;
  16667. /**
  16668. * The texture used to render each particle. (this can be a spritesheet)
  16669. */
  16670. particleTexture: Nullable<Texture>;
  16671. /**
  16672. * The layer mask we are rendering the particles through.
  16673. */
  16674. layerMask: number;
  16675. /**
  16676. * This can help using your own shader to render the particle system.
  16677. * The according effect will be created
  16678. */
  16679. customShader: any;
  16680. /**
  16681. * By default particle system starts as soon as they are created. This prevents the
  16682. * automatic start to happen and let you decide when to start emitting particles.
  16683. */
  16684. preventAutoStart: boolean;
  16685. private _noiseTexture;
  16686. /**
  16687. * Gets or sets a texture used to add random noise to particle positions
  16688. */
  16689. noiseTexture: Nullable<ProceduralTexture>;
  16690. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16691. noiseStrength: Vector3;
  16692. /**
  16693. * Callback triggered when the particle animation is ending.
  16694. */
  16695. onAnimationEnd: Nullable<() => void>;
  16696. /**
  16697. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16698. */
  16699. blendMode: number;
  16700. /**
  16701. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16702. * to override the particles.
  16703. */
  16704. forceDepthWrite: boolean;
  16705. /** 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 */
  16706. preWarmCycles: number;
  16707. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16708. preWarmStepOffset: number;
  16709. /**
  16710. * 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)
  16711. */
  16712. spriteCellChangeSpeed: number;
  16713. /**
  16714. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16715. */
  16716. startSpriteCellID: number;
  16717. /**
  16718. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16719. */
  16720. endSpriteCellID: number;
  16721. /**
  16722. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16723. */
  16724. spriteCellWidth: number;
  16725. /**
  16726. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16727. */
  16728. spriteCellHeight: number;
  16729. /**
  16730. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16731. */
  16732. spriteRandomStartCell: boolean;
  16733. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16734. translationPivot: Vector2;
  16735. /** @hidden */
  16736. protected _isAnimationSheetEnabled: boolean;
  16737. /**
  16738. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16739. */
  16740. beginAnimationOnStart: boolean;
  16741. /**
  16742. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16743. */
  16744. beginAnimationFrom: number;
  16745. /**
  16746. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16747. */
  16748. beginAnimationTo: number;
  16749. /**
  16750. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16751. */
  16752. beginAnimationLoop: boolean;
  16753. /**
  16754. * Gets or sets a world offset applied to all particles
  16755. */
  16756. worldOffset: Vector3;
  16757. /**
  16758. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16759. */
  16760. isAnimationSheetEnabled: boolean;
  16761. /**
  16762. * Get hosting scene
  16763. * @returns the scene
  16764. */
  16765. getScene(): Scene;
  16766. /**
  16767. * You can use gravity if you want to give an orientation to your particles.
  16768. */
  16769. gravity: Vector3;
  16770. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16771. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16772. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16773. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16774. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16775. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16776. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16777. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16778. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16779. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16780. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16781. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16782. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16783. /**
  16784. * Defines the delay in milliseconds before starting the system (0 by default)
  16785. */
  16786. startDelay: number;
  16787. /**
  16788. * Gets the current list of drag gradients.
  16789. * You must use addDragGradient and removeDragGradient to udpate this list
  16790. * @returns the list of drag gradients
  16791. */
  16792. getDragGradients(): Nullable<Array<FactorGradient>>;
  16793. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16794. limitVelocityDamping: number;
  16795. /**
  16796. * Gets the current list of limit velocity gradients.
  16797. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16798. * @returns the list of limit velocity gradients
  16799. */
  16800. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16801. /**
  16802. * Gets the current list of color gradients.
  16803. * You must use addColorGradient and removeColorGradient to udpate this list
  16804. * @returns the list of color gradients
  16805. */
  16806. getColorGradients(): Nullable<Array<ColorGradient>>;
  16807. /**
  16808. * Gets the current list of size gradients.
  16809. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16810. * @returns the list of size gradients
  16811. */
  16812. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16813. /**
  16814. * Gets the current list of color remap gradients.
  16815. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16816. * @returns the list of color remap gradients
  16817. */
  16818. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16819. /**
  16820. * Gets the current list of alpha remap gradients.
  16821. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16822. * @returns the list of alpha remap gradients
  16823. */
  16824. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16825. /**
  16826. * Gets the current list of life time gradients.
  16827. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16828. * @returns the list of life time gradients
  16829. */
  16830. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16831. /**
  16832. * Gets the current list of angular speed gradients.
  16833. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16834. * @returns the list of angular speed gradients
  16835. */
  16836. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16837. /**
  16838. * Gets the current list of velocity gradients.
  16839. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16840. * @returns the list of velocity gradients
  16841. */
  16842. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16843. /**
  16844. * Gets the current list of start size gradients.
  16845. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16846. * @returns the list of start size gradients
  16847. */
  16848. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16849. /**
  16850. * Gets the current list of emit rate gradients.
  16851. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16852. * @returns the list of emit rate gradients
  16853. */
  16854. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16855. /**
  16856. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16857. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16858. */
  16859. direction1: Vector3;
  16860. /**
  16861. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16862. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16863. */
  16864. direction2: Vector3;
  16865. /**
  16866. * 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.
  16867. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16868. */
  16869. minEmitBox: Vector3;
  16870. /**
  16871. * 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.
  16872. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16873. */
  16874. maxEmitBox: Vector3;
  16875. /**
  16876. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16877. */
  16878. color1: Color4;
  16879. /**
  16880. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16881. */
  16882. color2: Color4;
  16883. /**
  16884. * Color the particle will have at the end of its lifetime
  16885. */
  16886. colorDead: Color4;
  16887. /**
  16888. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16889. */
  16890. textureMask: Color4;
  16891. /**
  16892. * The particle emitter type defines the emitter used by the particle system.
  16893. * It can be for example box, sphere, or cone...
  16894. */
  16895. particleEmitterType: IParticleEmitterType;
  16896. /** @hidden */
  16897. _isSubEmitter: boolean;
  16898. /**
  16899. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16900. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16901. */
  16902. billboardMode: number;
  16903. protected _isBillboardBased: boolean;
  16904. /**
  16905. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16906. */
  16907. isBillboardBased: boolean;
  16908. /**
  16909. * The scene the particle system belongs to.
  16910. */
  16911. protected _scene: Scene;
  16912. /**
  16913. * Local cache of defines for image processing.
  16914. */
  16915. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16916. /**
  16917. * Default configuration related to image processing available in the standard Material.
  16918. */
  16919. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16920. /**
  16921. * Gets the image processing configuration used either in this material.
  16922. */
  16923. /**
  16924. * Sets the Default image processing configuration used either in the this material.
  16925. *
  16926. * If sets to null, the scene one is in use.
  16927. */
  16928. imageProcessingConfiguration: ImageProcessingConfiguration;
  16929. /**
  16930. * Attaches a new image processing configuration to the Standard Material.
  16931. * @param configuration
  16932. */
  16933. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16934. /** @hidden */
  16935. protected _reset(): void;
  16936. /** @hidden */
  16937. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16938. /**
  16939. * Instantiates a particle system.
  16940. * 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.
  16941. * @param name The name of the particle system
  16942. */
  16943. constructor(name: string);
  16944. /**
  16945. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16946. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16947. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16948. * @returns the emitter
  16949. */
  16950. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16951. /**
  16952. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16953. * @param radius The radius of the hemisphere to emit from
  16954. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16955. * @returns the emitter
  16956. */
  16957. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16958. /**
  16959. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16960. * @param radius The radius of the sphere to emit from
  16961. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16962. * @returns the emitter
  16963. */
  16964. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16965. /**
  16966. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16967. * @param radius The radius of the sphere to emit from
  16968. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16969. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16970. * @returns the emitter
  16971. */
  16972. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16973. /**
  16974. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16975. * @param radius The radius of the emission cylinder
  16976. * @param height The height of the emission cylinder
  16977. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16978. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16979. * @returns the emitter
  16980. */
  16981. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16982. /**
  16983. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16984. * @param radius The radius of the cylinder to emit from
  16985. * @param height The height of the emission cylinder
  16986. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16987. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16988. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16989. * @returns the emitter
  16990. */
  16991. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16992. /**
  16993. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16994. * @param radius The radius of the cone to emit from
  16995. * @param angle The base angle of the cone
  16996. * @returns the emitter
  16997. */
  16998. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16999. /**
  17000. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17001. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17002. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17003. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17004. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17005. * @returns the emitter
  17006. */
  17007. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17008. }
  17009. }
  17010. declare module "babylonjs/Particles/subEmitter" {
  17011. import { Scene } from "babylonjs/scene";
  17012. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17013. /**
  17014. * Type of sub emitter
  17015. */
  17016. export enum SubEmitterType {
  17017. /**
  17018. * Attached to the particle over it's lifetime
  17019. */
  17020. ATTACHED = 0,
  17021. /**
  17022. * Created when the particle dies
  17023. */
  17024. END = 1
  17025. }
  17026. /**
  17027. * Sub emitter class used to emit particles from an existing particle
  17028. */
  17029. export class SubEmitter {
  17030. /**
  17031. * the particle system to be used by the sub emitter
  17032. */
  17033. particleSystem: ParticleSystem;
  17034. /**
  17035. * Type of the submitter (Default: END)
  17036. */
  17037. type: SubEmitterType;
  17038. /**
  17039. * 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)
  17040. * Note: This only is supported when using an emitter of type Mesh
  17041. */
  17042. inheritDirection: boolean;
  17043. /**
  17044. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17045. */
  17046. inheritedVelocityAmount: number;
  17047. /**
  17048. * Creates a sub emitter
  17049. * @param particleSystem the particle system to be used by the sub emitter
  17050. */
  17051. constructor(
  17052. /**
  17053. * the particle system to be used by the sub emitter
  17054. */
  17055. particleSystem: ParticleSystem);
  17056. /**
  17057. * Clones the sub emitter
  17058. * @returns the cloned sub emitter
  17059. */
  17060. clone(): SubEmitter;
  17061. /**
  17062. * Serialize current object to a JSON object
  17063. * @returns the serialized object
  17064. */
  17065. serialize(): any;
  17066. /** @hidden */
  17067. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17068. /**
  17069. * Creates a new SubEmitter from a serialized JSON version
  17070. * @param serializationObject defines the JSON object to read from
  17071. * @param scene defines the hosting scene
  17072. * @param rootUrl defines the rootUrl for data loading
  17073. * @returns a new SubEmitter
  17074. */
  17075. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17076. /** Release associated resources */
  17077. dispose(): void;
  17078. }
  17079. }
  17080. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17081. /** @hidden */
  17082. export var clipPlaneFragmentDeclaration: {
  17083. name: string;
  17084. shader: string;
  17085. };
  17086. }
  17087. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17088. /** @hidden */
  17089. export var imageProcessingDeclaration: {
  17090. name: string;
  17091. shader: string;
  17092. };
  17093. }
  17094. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17095. /** @hidden */
  17096. export var imageProcessingFunctions: {
  17097. name: string;
  17098. shader: string;
  17099. };
  17100. }
  17101. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17102. /** @hidden */
  17103. export var clipPlaneFragment: {
  17104. name: string;
  17105. shader: string;
  17106. };
  17107. }
  17108. declare module "babylonjs/Shaders/particles.fragment" {
  17109. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17110. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17111. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17112. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17113. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17114. /** @hidden */
  17115. export var particlesPixelShader: {
  17116. name: string;
  17117. shader: string;
  17118. };
  17119. }
  17120. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17121. /** @hidden */
  17122. export var clipPlaneVertexDeclaration: {
  17123. name: string;
  17124. shader: string;
  17125. };
  17126. }
  17127. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17128. /** @hidden */
  17129. export var clipPlaneVertex: {
  17130. name: string;
  17131. shader: string;
  17132. };
  17133. }
  17134. declare module "babylonjs/Shaders/particles.vertex" {
  17135. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17136. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17137. /** @hidden */
  17138. export var particlesVertexShader: {
  17139. name: string;
  17140. shader: string;
  17141. };
  17142. }
  17143. declare module "babylonjs/Particles/particleSystem" {
  17144. import { Nullable } from "babylonjs/types";
  17145. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17146. import { Observable } from "babylonjs/Misc/observable";
  17147. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17148. import { Effect } from "babylonjs/Materials/effect";
  17149. import { Scene, IDisposable } from "babylonjs/scene";
  17150. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17151. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17152. import { Particle } from "babylonjs/Particles/particle";
  17153. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17154. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17155. import "babylonjs/Shaders/particles.fragment";
  17156. import "babylonjs/Shaders/particles.vertex";
  17157. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17158. /**
  17159. * This represents a particle system in Babylon.
  17160. * 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.
  17161. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17162. * @example https://doc.babylonjs.com/babylon101/particles
  17163. */
  17164. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17165. /**
  17166. * Billboard mode will only apply to Y axis
  17167. */
  17168. static readonly BILLBOARDMODE_Y: number;
  17169. /**
  17170. * Billboard mode will apply to all axes
  17171. */
  17172. static readonly BILLBOARDMODE_ALL: number;
  17173. /**
  17174. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17175. */
  17176. static readonly BILLBOARDMODE_STRETCHED: number;
  17177. /**
  17178. * This function can be defined to provide custom update for active particles.
  17179. * This function will be called instead of regular update (age, position, color, etc.).
  17180. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17181. */
  17182. updateFunction: (particles: Particle[]) => void;
  17183. private _emitterWorldMatrix;
  17184. /**
  17185. * This function can be defined to specify initial direction for every new particle.
  17186. * It by default use the emitterType defined function
  17187. */
  17188. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17189. /**
  17190. * This function can be defined to specify initial position for every new particle.
  17191. * It by default use the emitterType defined function
  17192. */
  17193. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17194. /**
  17195. * @hidden
  17196. */
  17197. _inheritedVelocityOffset: Vector3;
  17198. /**
  17199. * An event triggered when the system is disposed
  17200. */
  17201. onDisposeObservable: Observable<ParticleSystem>;
  17202. private _onDisposeObserver;
  17203. /**
  17204. * Sets a callback that will be triggered when the system is disposed
  17205. */
  17206. onDispose: () => void;
  17207. private _particles;
  17208. private _epsilon;
  17209. private _capacity;
  17210. private _stockParticles;
  17211. private _newPartsExcess;
  17212. private _vertexData;
  17213. private _vertexBuffer;
  17214. private _vertexBuffers;
  17215. private _spriteBuffer;
  17216. private _indexBuffer;
  17217. private _effect;
  17218. private _customEffect;
  17219. private _cachedDefines;
  17220. private _scaledColorStep;
  17221. private _colorDiff;
  17222. private _scaledDirection;
  17223. private _scaledGravity;
  17224. private _currentRenderId;
  17225. private _alive;
  17226. private _useInstancing;
  17227. private _started;
  17228. private _stopped;
  17229. private _actualFrame;
  17230. private _scaledUpdateSpeed;
  17231. private _vertexBufferSize;
  17232. /** @hidden */
  17233. _currentEmitRateGradient: Nullable<FactorGradient>;
  17234. /** @hidden */
  17235. _currentEmitRate1: number;
  17236. /** @hidden */
  17237. _currentEmitRate2: number;
  17238. /** @hidden */
  17239. _currentStartSizeGradient: Nullable<FactorGradient>;
  17240. /** @hidden */
  17241. _currentStartSize1: number;
  17242. /** @hidden */
  17243. _currentStartSize2: number;
  17244. private readonly _rawTextureWidth;
  17245. private _rampGradientsTexture;
  17246. private _useRampGradients;
  17247. /** Gets or sets a boolean indicating that ramp gradients must be used
  17248. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17249. */
  17250. useRampGradients: boolean;
  17251. /**
  17252. * 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.
  17253. * 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: [])
  17254. */
  17255. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17256. private _subEmitters;
  17257. /**
  17258. * @hidden
  17259. * If the particle systems emitter should be disposed when the particle system is disposed
  17260. */
  17261. _disposeEmitterOnDispose: boolean;
  17262. /**
  17263. * The current active Sub-systems, this property is used by the root particle system only.
  17264. */
  17265. activeSubSystems: Array<ParticleSystem>;
  17266. private _rootParticleSystem;
  17267. /**
  17268. * Gets the current list of active particles
  17269. */
  17270. readonly particles: Particle[];
  17271. /**
  17272. * Returns the string "ParticleSystem"
  17273. * @returns a string containing the class name
  17274. */
  17275. getClassName(): string;
  17276. /**
  17277. * Instantiates a particle system.
  17278. * 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.
  17279. * @param name The name of the particle system
  17280. * @param capacity The max number of particles alive at the same time
  17281. * @param scene The scene the particle system belongs to
  17282. * @param customEffect a custom effect used to change the way particles are rendered by default
  17283. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17284. * @param epsilon Offset used to render the particles
  17285. */
  17286. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17287. private _addFactorGradient;
  17288. private _removeFactorGradient;
  17289. /**
  17290. * Adds a new life time gradient
  17291. * @param gradient defines the gradient to use (between 0 and 1)
  17292. * @param factor defines the life time factor to affect to the specified gradient
  17293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17294. * @returns the current particle system
  17295. */
  17296. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17297. /**
  17298. * Remove a specific life time gradient
  17299. * @param gradient defines the gradient to remove
  17300. * @returns the current particle system
  17301. */
  17302. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17303. /**
  17304. * Adds a new size gradient
  17305. * @param gradient defines the gradient to use (between 0 and 1)
  17306. * @param factor defines the size factor to affect to the specified gradient
  17307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17308. * @returns the current particle system
  17309. */
  17310. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17311. /**
  17312. * Remove a specific size gradient
  17313. * @param gradient defines the gradient to remove
  17314. * @returns the current particle system
  17315. */
  17316. removeSizeGradient(gradient: number): IParticleSystem;
  17317. /**
  17318. * Adds a new color remap gradient
  17319. * @param gradient defines the gradient to use (between 0 and 1)
  17320. * @param min defines the color remap minimal range
  17321. * @param max defines the color remap maximal range
  17322. * @returns the current particle system
  17323. */
  17324. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17325. /**
  17326. * Remove a specific color remap gradient
  17327. * @param gradient defines the gradient to remove
  17328. * @returns the current particle system
  17329. */
  17330. removeColorRemapGradient(gradient: number): IParticleSystem;
  17331. /**
  17332. * Adds a new alpha remap gradient
  17333. * @param gradient defines the gradient to use (between 0 and 1)
  17334. * @param min defines the alpha remap minimal range
  17335. * @param max defines the alpha remap maximal range
  17336. * @returns the current particle system
  17337. */
  17338. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17339. /**
  17340. * Remove a specific alpha remap gradient
  17341. * @param gradient defines the gradient to remove
  17342. * @returns the current particle system
  17343. */
  17344. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17345. /**
  17346. * Adds a new angular speed gradient
  17347. * @param gradient defines the gradient to use (between 0 and 1)
  17348. * @param factor defines the angular speed to affect to the specified gradient
  17349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17350. * @returns the current particle system
  17351. */
  17352. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17353. /**
  17354. * Remove a specific angular speed gradient
  17355. * @param gradient defines the gradient to remove
  17356. * @returns the current particle system
  17357. */
  17358. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17359. /**
  17360. * Adds a new velocity gradient
  17361. * @param gradient defines the gradient to use (between 0 and 1)
  17362. * @param factor defines the velocity to affect to the specified gradient
  17363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17364. * @returns the current particle system
  17365. */
  17366. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17367. /**
  17368. * Remove a specific velocity gradient
  17369. * @param gradient defines the gradient to remove
  17370. * @returns the current particle system
  17371. */
  17372. removeVelocityGradient(gradient: number): IParticleSystem;
  17373. /**
  17374. * Adds a new limit velocity gradient
  17375. * @param gradient defines the gradient to use (between 0 and 1)
  17376. * @param factor defines the limit velocity value to affect to the specified gradient
  17377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17378. * @returns the current particle system
  17379. */
  17380. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17381. /**
  17382. * Remove a specific limit velocity gradient
  17383. * @param gradient defines the gradient to remove
  17384. * @returns the current particle system
  17385. */
  17386. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17387. /**
  17388. * Adds a new drag gradient
  17389. * @param gradient defines the gradient to use (between 0 and 1)
  17390. * @param factor defines the drag value to affect to the specified gradient
  17391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17392. * @returns the current particle system
  17393. */
  17394. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17395. /**
  17396. * Remove a specific drag gradient
  17397. * @param gradient defines the gradient to remove
  17398. * @returns the current particle system
  17399. */
  17400. removeDragGradient(gradient: number): IParticleSystem;
  17401. /**
  17402. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17403. * @param gradient defines the gradient to use (between 0 and 1)
  17404. * @param factor defines the emit rate value to affect to the specified gradient
  17405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17406. * @returns the current particle system
  17407. */
  17408. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17409. /**
  17410. * Remove a specific emit rate gradient
  17411. * @param gradient defines the gradient to remove
  17412. * @returns the current particle system
  17413. */
  17414. removeEmitRateGradient(gradient: number): IParticleSystem;
  17415. /**
  17416. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17417. * @param gradient defines the gradient to use (between 0 and 1)
  17418. * @param factor defines the start size value to affect to the specified gradient
  17419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17420. * @returns the current particle system
  17421. */
  17422. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17423. /**
  17424. * Remove a specific start size gradient
  17425. * @param gradient defines the gradient to remove
  17426. * @returns the current particle system
  17427. */
  17428. removeStartSizeGradient(gradient: number): IParticleSystem;
  17429. private _createRampGradientTexture;
  17430. /**
  17431. * Gets the current list of ramp gradients.
  17432. * You must use addRampGradient and removeRampGradient to udpate this list
  17433. * @returns the list of ramp gradients
  17434. */
  17435. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17436. /**
  17437. * Adds a new ramp gradient used to remap particle colors
  17438. * @param gradient defines the gradient to use (between 0 and 1)
  17439. * @param color defines the color to affect to the specified gradient
  17440. * @returns the current particle system
  17441. */
  17442. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17443. /**
  17444. * Remove a specific ramp gradient
  17445. * @param gradient defines the gradient to remove
  17446. * @returns the current particle system
  17447. */
  17448. removeRampGradient(gradient: number): ParticleSystem;
  17449. /**
  17450. * Adds a new color gradient
  17451. * @param gradient defines the gradient to use (between 0 and 1)
  17452. * @param color1 defines the color to affect to the specified gradient
  17453. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17454. * @returns this particle system
  17455. */
  17456. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17457. /**
  17458. * Remove a specific color gradient
  17459. * @param gradient defines the gradient to remove
  17460. * @returns this particle system
  17461. */
  17462. removeColorGradient(gradient: number): IParticleSystem;
  17463. private _fetchR;
  17464. protected _reset(): void;
  17465. private _resetEffect;
  17466. private _createVertexBuffers;
  17467. private _createIndexBuffer;
  17468. /**
  17469. * Gets the maximum number of particles active at the same time.
  17470. * @returns The max number of active particles.
  17471. */
  17472. getCapacity(): number;
  17473. /**
  17474. * Gets whether there are still active particles in the system.
  17475. * @returns True if it is alive, otherwise false.
  17476. */
  17477. isAlive(): boolean;
  17478. /**
  17479. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17480. * @returns True if it has been started, otherwise false.
  17481. */
  17482. isStarted(): boolean;
  17483. private _prepareSubEmitterInternalArray;
  17484. /**
  17485. * Starts the particle system and begins to emit
  17486. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17487. */
  17488. start(delay?: number): void;
  17489. /**
  17490. * Stops the particle system.
  17491. * @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.
  17492. */
  17493. stop(stopSubEmitters?: boolean): void;
  17494. /**
  17495. * Remove all active particles
  17496. */
  17497. reset(): void;
  17498. /**
  17499. * @hidden (for internal use only)
  17500. */
  17501. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17502. /**
  17503. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17504. * Its lifetime will start back at 0.
  17505. */
  17506. recycleParticle: (particle: Particle) => void;
  17507. private _stopSubEmitters;
  17508. private _createParticle;
  17509. private _removeFromRoot;
  17510. private _emitFromParticle;
  17511. private _update;
  17512. /** @hidden */
  17513. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17514. /** @hidden */
  17515. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17516. /** @hidden */
  17517. private _getEffect;
  17518. /**
  17519. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17520. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17521. */
  17522. animate(preWarmOnly?: boolean): void;
  17523. private _appendParticleVertices;
  17524. /**
  17525. * Rebuilds the particle system.
  17526. */
  17527. rebuild(): void;
  17528. /**
  17529. * Is this system ready to be used/rendered
  17530. * @return true if the system is ready
  17531. */
  17532. isReady(): boolean;
  17533. private _render;
  17534. /**
  17535. * Renders the particle system in its current state.
  17536. * @returns the current number of particles
  17537. */
  17538. render(): number;
  17539. /**
  17540. * Disposes the particle system and free the associated resources
  17541. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17542. */
  17543. dispose(disposeTexture?: boolean): void;
  17544. /**
  17545. * Clones the particle system.
  17546. * @param name The name of the cloned object
  17547. * @param newEmitter The new emitter to use
  17548. * @returns the cloned particle system
  17549. */
  17550. clone(name: string, newEmitter: any): ParticleSystem;
  17551. /**
  17552. * Serializes the particle system to a JSON object.
  17553. * @returns the JSON object
  17554. */
  17555. serialize(): any;
  17556. /** @hidden */
  17557. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17558. /** @hidden */
  17559. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17560. /**
  17561. * Parses a JSON object to create a particle system.
  17562. * @param parsedParticleSystem The JSON object to parse
  17563. * @param scene The scene to create the particle system in
  17564. * @param rootUrl The root url to use to load external dependencies like texture
  17565. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17566. * @returns the Parsed particle system
  17567. */
  17568. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17569. }
  17570. }
  17571. declare module "babylonjs/Particles/particle" {
  17572. import { Nullable } from "babylonjs/types";
  17573. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17574. import { Color4 } from "babylonjs/Maths/math.color";
  17575. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17576. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17577. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17578. /**
  17579. * A particle represents one of the element emitted by a particle system.
  17580. * This is mainly define by its coordinates, direction, velocity and age.
  17581. */
  17582. export class Particle {
  17583. /**
  17584. * The particle system the particle belongs to.
  17585. */
  17586. particleSystem: ParticleSystem;
  17587. private static _Count;
  17588. /**
  17589. * Unique ID of the particle
  17590. */
  17591. id: number;
  17592. /**
  17593. * The world position of the particle in the scene.
  17594. */
  17595. position: Vector3;
  17596. /**
  17597. * The world direction of the particle in the scene.
  17598. */
  17599. direction: Vector3;
  17600. /**
  17601. * The color of the particle.
  17602. */
  17603. color: Color4;
  17604. /**
  17605. * The color change of the particle per step.
  17606. */
  17607. colorStep: Color4;
  17608. /**
  17609. * Defines how long will the life of the particle be.
  17610. */
  17611. lifeTime: number;
  17612. /**
  17613. * The current age of the particle.
  17614. */
  17615. age: number;
  17616. /**
  17617. * The current size of the particle.
  17618. */
  17619. size: number;
  17620. /**
  17621. * The current scale of the particle.
  17622. */
  17623. scale: Vector2;
  17624. /**
  17625. * The current angle of the particle.
  17626. */
  17627. angle: number;
  17628. /**
  17629. * Defines how fast is the angle changing.
  17630. */
  17631. angularSpeed: number;
  17632. /**
  17633. * Defines the cell index used by the particle to be rendered from a sprite.
  17634. */
  17635. cellIndex: number;
  17636. /**
  17637. * The information required to support color remapping
  17638. */
  17639. remapData: Vector4;
  17640. /** @hidden */
  17641. _randomCellOffset?: number;
  17642. /** @hidden */
  17643. _initialDirection: Nullable<Vector3>;
  17644. /** @hidden */
  17645. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17646. /** @hidden */
  17647. _initialStartSpriteCellID: number;
  17648. /** @hidden */
  17649. _initialEndSpriteCellID: number;
  17650. /** @hidden */
  17651. _currentColorGradient: Nullable<ColorGradient>;
  17652. /** @hidden */
  17653. _currentColor1: Color4;
  17654. /** @hidden */
  17655. _currentColor2: Color4;
  17656. /** @hidden */
  17657. _currentSizeGradient: Nullable<FactorGradient>;
  17658. /** @hidden */
  17659. _currentSize1: number;
  17660. /** @hidden */
  17661. _currentSize2: number;
  17662. /** @hidden */
  17663. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17664. /** @hidden */
  17665. _currentAngularSpeed1: number;
  17666. /** @hidden */
  17667. _currentAngularSpeed2: number;
  17668. /** @hidden */
  17669. _currentVelocityGradient: Nullable<FactorGradient>;
  17670. /** @hidden */
  17671. _currentVelocity1: number;
  17672. /** @hidden */
  17673. _currentVelocity2: number;
  17674. /** @hidden */
  17675. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17676. /** @hidden */
  17677. _currentLimitVelocity1: number;
  17678. /** @hidden */
  17679. _currentLimitVelocity2: number;
  17680. /** @hidden */
  17681. _currentDragGradient: Nullable<FactorGradient>;
  17682. /** @hidden */
  17683. _currentDrag1: number;
  17684. /** @hidden */
  17685. _currentDrag2: number;
  17686. /** @hidden */
  17687. _randomNoiseCoordinates1: Vector3;
  17688. /** @hidden */
  17689. _randomNoiseCoordinates2: Vector3;
  17690. /**
  17691. * Creates a new instance Particle
  17692. * @param particleSystem the particle system the particle belongs to
  17693. */
  17694. constructor(
  17695. /**
  17696. * The particle system the particle belongs to.
  17697. */
  17698. particleSystem: ParticleSystem);
  17699. private updateCellInfoFromSystem;
  17700. /**
  17701. * Defines how the sprite cell index is updated for the particle
  17702. */
  17703. updateCellIndex(): void;
  17704. /** @hidden */
  17705. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17706. /** @hidden */
  17707. _inheritParticleInfoToSubEmitters(): void;
  17708. /** @hidden */
  17709. _reset(): void;
  17710. /**
  17711. * Copy the properties of particle to another one.
  17712. * @param other the particle to copy the information to.
  17713. */
  17714. copyTo(other: Particle): void;
  17715. }
  17716. }
  17717. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17718. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17719. import { Effect } from "babylonjs/Materials/effect";
  17720. import { Particle } from "babylonjs/Particles/particle";
  17721. /**
  17722. * Particle emitter represents a volume emitting particles.
  17723. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17724. */
  17725. export interface IParticleEmitterType {
  17726. /**
  17727. * Called by the particle System when the direction is computed for the created particle.
  17728. * @param worldMatrix is the world matrix of the particle system
  17729. * @param directionToUpdate is the direction vector to update with the result
  17730. * @param particle is the particle we are computed the direction for
  17731. */
  17732. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17733. /**
  17734. * Called by the particle System when the position is computed for the created particle.
  17735. * @param worldMatrix is the world matrix of the particle system
  17736. * @param positionToUpdate is the position vector to update with the result
  17737. * @param particle is the particle we are computed the position for
  17738. */
  17739. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17740. /**
  17741. * Clones the current emitter and returns a copy of it
  17742. * @returns the new emitter
  17743. */
  17744. clone(): IParticleEmitterType;
  17745. /**
  17746. * Called by the GPUParticleSystem to setup the update shader
  17747. * @param effect defines the update shader
  17748. */
  17749. applyToShader(effect: Effect): void;
  17750. /**
  17751. * Returns a string to use to update the GPU particles update shader
  17752. * @returns the effect defines string
  17753. */
  17754. getEffectDefines(): string;
  17755. /**
  17756. * Returns a string representing the class name
  17757. * @returns a string containing the class name
  17758. */
  17759. getClassName(): string;
  17760. /**
  17761. * Serializes the particle system to a JSON object.
  17762. * @returns the JSON object
  17763. */
  17764. serialize(): any;
  17765. /**
  17766. * Parse properties from a JSON object
  17767. * @param serializationObject defines the JSON object
  17768. */
  17769. parse(serializationObject: any): void;
  17770. }
  17771. }
  17772. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17773. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17774. import { Effect } from "babylonjs/Materials/effect";
  17775. import { Particle } from "babylonjs/Particles/particle";
  17776. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17777. /**
  17778. * Particle emitter emitting particles from the inside of a box.
  17779. * It emits the particles randomly between 2 given directions.
  17780. */
  17781. export class BoxParticleEmitter implements IParticleEmitterType {
  17782. /**
  17783. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17784. */
  17785. direction1: Vector3;
  17786. /**
  17787. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17788. */
  17789. direction2: Vector3;
  17790. /**
  17791. * 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.
  17792. */
  17793. minEmitBox: Vector3;
  17794. /**
  17795. * 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.
  17796. */
  17797. maxEmitBox: Vector3;
  17798. /**
  17799. * Creates a new instance BoxParticleEmitter
  17800. */
  17801. constructor();
  17802. /**
  17803. * Called by the particle System when the direction is computed for the created particle.
  17804. * @param worldMatrix is the world matrix of the particle system
  17805. * @param directionToUpdate is the direction vector to update with the result
  17806. * @param particle is the particle we are computed the direction for
  17807. */
  17808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17809. /**
  17810. * Called by the particle System when the position is computed for the created particle.
  17811. * @param worldMatrix is the world matrix of the particle system
  17812. * @param positionToUpdate is the position vector to update with the result
  17813. * @param particle is the particle we are computed the position for
  17814. */
  17815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17816. /**
  17817. * Clones the current emitter and returns a copy of it
  17818. * @returns the new emitter
  17819. */
  17820. clone(): BoxParticleEmitter;
  17821. /**
  17822. * Called by the GPUParticleSystem to setup the update shader
  17823. * @param effect defines the update shader
  17824. */
  17825. applyToShader(effect: Effect): void;
  17826. /**
  17827. * Returns a string to use to update the GPU particles update shader
  17828. * @returns a string containng the defines string
  17829. */
  17830. getEffectDefines(): string;
  17831. /**
  17832. * Returns the string "BoxParticleEmitter"
  17833. * @returns a string containing the class name
  17834. */
  17835. getClassName(): string;
  17836. /**
  17837. * Serializes the particle system to a JSON object.
  17838. * @returns the JSON object
  17839. */
  17840. serialize(): any;
  17841. /**
  17842. * Parse properties from a JSON object
  17843. * @param serializationObject defines the JSON object
  17844. */
  17845. parse(serializationObject: any): void;
  17846. }
  17847. }
  17848. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17849. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17850. import { Effect } from "babylonjs/Materials/effect";
  17851. import { Particle } from "babylonjs/Particles/particle";
  17852. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17853. /**
  17854. * Particle emitter emitting particles from the inside of a cone.
  17855. * It emits the particles alongside the cone volume from the base to the particle.
  17856. * The emission direction might be randomized.
  17857. */
  17858. export class ConeParticleEmitter implements IParticleEmitterType {
  17859. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17860. directionRandomizer: number;
  17861. private _radius;
  17862. private _angle;
  17863. private _height;
  17864. /**
  17865. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17866. */
  17867. radiusRange: number;
  17868. /**
  17869. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17870. */
  17871. heightRange: number;
  17872. /**
  17873. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17874. */
  17875. emitFromSpawnPointOnly: boolean;
  17876. /**
  17877. * Gets or sets the radius of the emission cone
  17878. */
  17879. radius: number;
  17880. /**
  17881. * Gets or sets the angle of the emission cone
  17882. */
  17883. angle: number;
  17884. private _buildHeight;
  17885. /**
  17886. * Creates a new instance ConeParticleEmitter
  17887. * @param radius the radius of the emission cone (1 by default)
  17888. * @param angle the cone base angle (PI by default)
  17889. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17890. */
  17891. constructor(radius?: number, angle?: number,
  17892. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17893. directionRandomizer?: number);
  17894. /**
  17895. * Called by the particle System when the direction is computed for the created particle.
  17896. * @param worldMatrix is the world matrix of the particle system
  17897. * @param directionToUpdate is the direction vector to update with the result
  17898. * @param particle is the particle we are computed the direction for
  17899. */
  17900. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17901. /**
  17902. * Called by the particle System when the position is computed for the created particle.
  17903. * @param worldMatrix is the world matrix of the particle system
  17904. * @param positionToUpdate is the position vector to update with the result
  17905. * @param particle is the particle we are computed the position for
  17906. */
  17907. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17908. /**
  17909. * Clones the current emitter and returns a copy of it
  17910. * @returns the new emitter
  17911. */
  17912. clone(): ConeParticleEmitter;
  17913. /**
  17914. * Called by the GPUParticleSystem to setup the update shader
  17915. * @param effect defines the update shader
  17916. */
  17917. applyToShader(effect: Effect): void;
  17918. /**
  17919. * Returns a string to use to update the GPU particles update shader
  17920. * @returns a string containng the defines string
  17921. */
  17922. getEffectDefines(): string;
  17923. /**
  17924. * Returns the string "ConeParticleEmitter"
  17925. * @returns a string containing the class name
  17926. */
  17927. getClassName(): string;
  17928. /**
  17929. * Serializes the particle system to a JSON object.
  17930. * @returns the JSON object
  17931. */
  17932. serialize(): any;
  17933. /**
  17934. * Parse properties from a JSON object
  17935. * @param serializationObject defines the JSON object
  17936. */
  17937. parse(serializationObject: any): void;
  17938. }
  17939. }
  17940. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17941. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17942. import { Effect } from "babylonjs/Materials/effect";
  17943. import { Particle } from "babylonjs/Particles/particle";
  17944. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17945. /**
  17946. * Particle emitter emitting particles from the inside of a cylinder.
  17947. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17948. */
  17949. export class CylinderParticleEmitter implements IParticleEmitterType {
  17950. /**
  17951. * The radius of the emission cylinder.
  17952. */
  17953. radius: number;
  17954. /**
  17955. * The height of the emission cylinder.
  17956. */
  17957. height: number;
  17958. /**
  17959. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17960. */
  17961. radiusRange: number;
  17962. /**
  17963. * How much to randomize the particle direction [0-1].
  17964. */
  17965. directionRandomizer: number;
  17966. /**
  17967. * Creates a new instance CylinderParticleEmitter
  17968. * @param radius the radius of the emission cylinder (1 by default)
  17969. * @param height the height of the emission cylinder (1 by default)
  17970. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17971. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17972. */
  17973. constructor(
  17974. /**
  17975. * The radius of the emission cylinder.
  17976. */
  17977. radius?: number,
  17978. /**
  17979. * The height of the emission cylinder.
  17980. */
  17981. height?: number,
  17982. /**
  17983. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17984. */
  17985. radiusRange?: number,
  17986. /**
  17987. * How much to randomize the particle direction [0-1].
  17988. */
  17989. directionRandomizer?: number);
  17990. /**
  17991. * Called by the particle System when the direction is computed for the created particle.
  17992. * @param worldMatrix is the world matrix of the particle system
  17993. * @param directionToUpdate is the direction vector to update with the result
  17994. * @param particle is the particle we are computed the direction for
  17995. */
  17996. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17997. /**
  17998. * Called by the particle System when the position is computed for the created particle.
  17999. * @param worldMatrix is the world matrix of the particle system
  18000. * @param positionToUpdate is the position vector to update with the result
  18001. * @param particle is the particle we are computed the position for
  18002. */
  18003. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18004. /**
  18005. * Clones the current emitter and returns a copy of it
  18006. * @returns the new emitter
  18007. */
  18008. clone(): CylinderParticleEmitter;
  18009. /**
  18010. * Called by the GPUParticleSystem to setup the update shader
  18011. * @param effect defines the update shader
  18012. */
  18013. applyToShader(effect: Effect): void;
  18014. /**
  18015. * Returns a string to use to update the GPU particles update shader
  18016. * @returns a string containng the defines string
  18017. */
  18018. getEffectDefines(): string;
  18019. /**
  18020. * Returns the string "CylinderParticleEmitter"
  18021. * @returns a string containing the class name
  18022. */
  18023. getClassName(): string;
  18024. /**
  18025. * Serializes the particle system to a JSON object.
  18026. * @returns the JSON object
  18027. */
  18028. serialize(): any;
  18029. /**
  18030. * Parse properties from a JSON object
  18031. * @param serializationObject defines the JSON object
  18032. */
  18033. parse(serializationObject: any): void;
  18034. }
  18035. /**
  18036. * Particle emitter emitting particles from the inside of a cylinder.
  18037. * It emits the particles randomly between two vectors.
  18038. */
  18039. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18040. /**
  18041. * The min limit of the emission direction.
  18042. */
  18043. direction1: Vector3;
  18044. /**
  18045. * The max limit of the emission direction.
  18046. */
  18047. direction2: Vector3;
  18048. /**
  18049. * Creates a new instance CylinderDirectedParticleEmitter
  18050. * @param radius the radius of the emission cylinder (1 by default)
  18051. * @param height the height of the emission cylinder (1 by default)
  18052. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18053. * @param direction1 the min limit of the emission direction (up vector by default)
  18054. * @param direction2 the max limit of the emission direction (up vector by default)
  18055. */
  18056. constructor(radius?: number, height?: number, radiusRange?: number,
  18057. /**
  18058. * The min limit of the emission direction.
  18059. */
  18060. direction1?: Vector3,
  18061. /**
  18062. * The max limit of the emission direction.
  18063. */
  18064. direction2?: Vector3);
  18065. /**
  18066. * Called by the particle System when the direction is computed for the created particle.
  18067. * @param worldMatrix is the world matrix of the particle system
  18068. * @param directionToUpdate is the direction vector to update with the result
  18069. * @param particle is the particle we are computed the direction for
  18070. */
  18071. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18072. /**
  18073. * Clones the current emitter and returns a copy of it
  18074. * @returns the new emitter
  18075. */
  18076. clone(): CylinderDirectedParticleEmitter;
  18077. /**
  18078. * Called by the GPUParticleSystem to setup the update shader
  18079. * @param effect defines the update shader
  18080. */
  18081. applyToShader(effect: Effect): void;
  18082. /**
  18083. * Returns a string to use to update the GPU particles update shader
  18084. * @returns a string containng the defines string
  18085. */
  18086. getEffectDefines(): string;
  18087. /**
  18088. * Returns the string "CylinderDirectedParticleEmitter"
  18089. * @returns a string containing the class name
  18090. */
  18091. getClassName(): string;
  18092. /**
  18093. * Serializes the particle system to a JSON object.
  18094. * @returns the JSON object
  18095. */
  18096. serialize(): any;
  18097. /**
  18098. * Parse properties from a JSON object
  18099. * @param serializationObject defines the JSON object
  18100. */
  18101. parse(serializationObject: any): void;
  18102. }
  18103. }
  18104. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18105. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18106. import { Effect } from "babylonjs/Materials/effect";
  18107. import { Particle } from "babylonjs/Particles/particle";
  18108. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18109. /**
  18110. * Particle emitter emitting particles from the inside of a hemisphere.
  18111. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18112. */
  18113. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18114. /**
  18115. * The radius of the emission hemisphere.
  18116. */
  18117. radius: number;
  18118. /**
  18119. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18120. */
  18121. radiusRange: number;
  18122. /**
  18123. * How much to randomize the particle direction [0-1].
  18124. */
  18125. directionRandomizer: number;
  18126. /**
  18127. * Creates a new instance HemisphericParticleEmitter
  18128. * @param radius the radius of the emission hemisphere (1 by default)
  18129. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18130. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18131. */
  18132. constructor(
  18133. /**
  18134. * The radius of the emission hemisphere.
  18135. */
  18136. radius?: number,
  18137. /**
  18138. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18139. */
  18140. radiusRange?: number,
  18141. /**
  18142. * How much to randomize the particle direction [0-1].
  18143. */
  18144. directionRandomizer?: number);
  18145. /**
  18146. * Called by the particle System when the direction is computed for the created particle.
  18147. * @param worldMatrix is the world matrix of the particle system
  18148. * @param directionToUpdate is the direction vector to update with the result
  18149. * @param particle is the particle we are computed the direction for
  18150. */
  18151. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18152. /**
  18153. * Called by the particle System when the position is computed for the created particle.
  18154. * @param worldMatrix is the world matrix of the particle system
  18155. * @param positionToUpdate is the position vector to update with the result
  18156. * @param particle is the particle we are computed the position for
  18157. */
  18158. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18159. /**
  18160. * Clones the current emitter and returns a copy of it
  18161. * @returns the new emitter
  18162. */
  18163. clone(): HemisphericParticleEmitter;
  18164. /**
  18165. * Called by the GPUParticleSystem to setup the update shader
  18166. * @param effect defines the update shader
  18167. */
  18168. applyToShader(effect: Effect): void;
  18169. /**
  18170. * Returns a string to use to update the GPU particles update shader
  18171. * @returns a string containng the defines string
  18172. */
  18173. getEffectDefines(): string;
  18174. /**
  18175. * Returns the string "HemisphericParticleEmitter"
  18176. * @returns a string containing the class name
  18177. */
  18178. getClassName(): string;
  18179. /**
  18180. * Serializes the particle system to a JSON object.
  18181. * @returns the JSON object
  18182. */
  18183. serialize(): any;
  18184. /**
  18185. * Parse properties from a JSON object
  18186. * @param serializationObject defines the JSON object
  18187. */
  18188. parse(serializationObject: any): void;
  18189. }
  18190. }
  18191. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18192. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18193. import { Effect } from "babylonjs/Materials/effect";
  18194. import { Particle } from "babylonjs/Particles/particle";
  18195. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18196. /**
  18197. * Particle emitter emitting particles from a point.
  18198. * It emits the particles randomly between 2 given directions.
  18199. */
  18200. export class PointParticleEmitter implements IParticleEmitterType {
  18201. /**
  18202. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18203. */
  18204. direction1: Vector3;
  18205. /**
  18206. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18207. */
  18208. direction2: Vector3;
  18209. /**
  18210. * Creates a new instance PointParticleEmitter
  18211. */
  18212. constructor();
  18213. /**
  18214. * Called by the particle System when the direction is computed for the created particle.
  18215. * @param worldMatrix is the world matrix of the particle system
  18216. * @param directionToUpdate is the direction vector to update with the result
  18217. * @param particle is the particle we are computed the direction for
  18218. */
  18219. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18220. /**
  18221. * Called by the particle System when the position is computed for the created particle.
  18222. * @param worldMatrix is the world matrix of the particle system
  18223. * @param positionToUpdate is the position vector to update with the result
  18224. * @param particle is the particle we are computed the position for
  18225. */
  18226. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18227. /**
  18228. * Clones the current emitter and returns a copy of it
  18229. * @returns the new emitter
  18230. */
  18231. clone(): PointParticleEmitter;
  18232. /**
  18233. * Called by the GPUParticleSystem to setup the update shader
  18234. * @param effect defines the update shader
  18235. */
  18236. applyToShader(effect: Effect): void;
  18237. /**
  18238. * Returns a string to use to update the GPU particles update shader
  18239. * @returns a string containng the defines string
  18240. */
  18241. getEffectDefines(): string;
  18242. /**
  18243. * Returns the string "PointParticleEmitter"
  18244. * @returns a string containing the class name
  18245. */
  18246. getClassName(): string;
  18247. /**
  18248. * Serializes the particle system to a JSON object.
  18249. * @returns the JSON object
  18250. */
  18251. serialize(): any;
  18252. /**
  18253. * Parse properties from a JSON object
  18254. * @param serializationObject defines the JSON object
  18255. */
  18256. parse(serializationObject: any): void;
  18257. }
  18258. }
  18259. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18260. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18261. import { Effect } from "babylonjs/Materials/effect";
  18262. import { Particle } from "babylonjs/Particles/particle";
  18263. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18264. /**
  18265. * Particle emitter emitting particles from the inside of a sphere.
  18266. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18267. */
  18268. export class SphereParticleEmitter implements IParticleEmitterType {
  18269. /**
  18270. * The radius of the emission sphere.
  18271. */
  18272. radius: number;
  18273. /**
  18274. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18275. */
  18276. radiusRange: number;
  18277. /**
  18278. * How much to randomize the particle direction [0-1].
  18279. */
  18280. directionRandomizer: number;
  18281. /**
  18282. * Creates a new instance SphereParticleEmitter
  18283. * @param radius the radius of the emission sphere (1 by default)
  18284. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18285. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18286. */
  18287. constructor(
  18288. /**
  18289. * The radius of the emission sphere.
  18290. */
  18291. radius?: number,
  18292. /**
  18293. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18294. */
  18295. radiusRange?: number,
  18296. /**
  18297. * How much to randomize the particle direction [0-1].
  18298. */
  18299. directionRandomizer?: number);
  18300. /**
  18301. * Called by the particle System when the direction is computed for the created particle.
  18302. * @param worldMatrix is the world matrix of the particle system
  18303. * @param directionToUpdate is the direction vector to update with the result
  18304. * @param particle is the particle we are computed the direction for
  18305. */
  18306. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18307. /**
  18308. * Called by the particle System when the position is computed for the created particle.
  18309. * @param worldMatrix is the world matrix of the particle system
  18310. * @param positionToUpdate is the position vector to update with the result
  18311. * @param particle is the particle we are computed the position for
  18312. */
  18313. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18314. /**
  18315. * Clones the current emitter and returns a copy of it
  18316. * @returns the new emitter
  18317. */
  18318. clone(): SphereParticleEmitter;
  18319. /**
  18320. * Called by the GPUParticleSystem to setup the update shader
  18321. * @param effect defines the update shader
  18322. */
  18323. applyToShader(effect: Effect): void;
  18324. /**
  18325. * Returns a string to use to update the GPU particles update shader
  18326. * @returns a string containng the defines string
  18327. */
  18328. getEffectDefines(): string;
  18329. /**
  18330. * Returns the string "SphereParticleEmitter"
  18331. * @returns a string containing the class name
  18332. */
  18333. getClassName(): string;
  18334. /**
  18335. * Serializes the particle system to a JSON object.
  18336. * @returns the JSON object
  18337. */
  18338. serialize(): any;
  18339. /**
  18340. * Parse properties from a JSON object
  18341. * @param serializationObject defines the JSON object
  18342. */
  18343. parse(serializationObject: any): void;
  18344. }
  18345. /**
  18346. * Particle emitter emitting particles from the inside of a sphere.
  18347. * It emits the particles randomly between two vectors.
  18348. */
  18349. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18350. /**
  18351. * The min limit of the emission direction.
  18352. */
  18353. direction1: Vector3;
  18354. /**
  18355. * The max limit of the emission direction.
  18356. */
  18357. direction2: Vector3;
  18358. /**
  18359. * Creates a new instance SphereDirectedParticleEmitter
  18360. * @param radius the radius of the emission sphere (1 by default)
  18361. * @param direction1 the min limit of the emission direction (up vector by default)
  18362. * @param direction2 the max limit of the emission direction (up vector by default)
  18363. */
  18364. constructor(radius?: number,
  18365. /**
  18366. * The min limit of the emission direction.
  18367. */
  18368. direction1?: Vector3,
  18369. /**
  18370. * The max limit of the emission direction.
  18371. */
  18372. direction2?: Vector3);
  18373. /**
  18374. * Called by the particle System when the direction is computed for the created particle.
  18375. * @param worldMatrix is the world matrix of the particle system
  18376. * @param directionToUpdate is the direction vector to update with the result
  18377. * @param particle is the particle we are computed the direction for
  18378. */
  18379. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18380. /**
  18381. * Clones the current emitter and returns a copy of it
  18382. * @returns the new emitter
  18383. */
  18384. clone(): SphereDirectedParticleEmitter;
  18385. /**
  18386. * Called by the GPUParticleSystem to setup the update shader
  18387. * @param effect defines the update shader
  18388. */
  18389. applyToShader(effect: Effect): void;
  18390. /**
  18391. * Returns a string to use to update the GPU particles update shader
  18392. * @returns a string containng the defines string
  18393. */
  18394. getEffectDefines(): string;
  18395. /**
  18396. * Returns the string "SphereDirectedParticleEmitter"
  18397. * @returns a string containing the class name
  18398. */
  18399. getClassName(): string;
  18400. /**
  18401. * Serializes the particle system to a JSON object.
  18402. * @returns the JSON object
  18403. */
  18404. serialize(): any;
  18405. /**
  18406. * Parse properties from a JSON object
  18407. * @param serializationObject defines the JSON object
  18408. */
  18409. parse(serializationObject: any): void;
  18410. }
  18411. }
  18412. declare module "babylonjs/Particles/EmitterTypes/index" {
  18413. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18414. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18415. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18416. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18417. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18418. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18419. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18420. }
  18421. declare module "babylonjs/Particles/IParticleSystem" {
  18422. import { Nullable } from "babylonjs/types";
  18423. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18424. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18427. import { Texture } from "babylonjs/Materials/Textures/texture";
  18428. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18429. import { Scene } from "babylonjs/scene";
  18430. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18431. import { Animation } from "babylonjs/Animations/animation";
  18432. /**
  18433. * Interface representing a particle system in Babylon.js.
  18434. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18435. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18436. */
  18437. export interface IParticleSystem {
  18438. /**
  18439. * List of animations used by the particle system.
  18440. */
  18441. animations: Animation[];
  18442. /**
  18443. * The id of the Particle system.
  18444. */
  18445. id: string;
  18446. /**
  18447. * The name of the Particle system.
  18448. */
  18449. name: string;
  18450. /**
  18451. * The emitter represents the Mesh or position we are attaching the particle system to.
  18452. */
  18453. emitter: Nullable<AbstractMesh | Vector3>;
  18454. /**
  18455. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18456. */
  18457. isBillboardBased: boolean;
  18458. /**
  18459. * The rendering group used by the Particle system to chose when to render.
  18460. */
  18461. renderingGroupId: number;
  18462. /**
  18463. * The layer mask we are rendering the particles through.
  18464. */
  18465. layerMask: number;
  18466. /**
  18467. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18468. */
  18469. updateSpeed: number;
  18470. /**
  18471. * The amount of time the particle system is running (depends of the overall update speed).
  18472. */
  18473. targetStopDuration: number;
  18474. /**
  18475. * The texture used to render each particle. (this can be a spritesheet)
  18476. */
  18477. particleTexture: Nullable<Texture>;
  18478. /**
  18479. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18480. */
  18481. blendMode: number;
  18482. /**
  18483. * Minimum life time of emitting particles.
  18484. */
  18485. minLifeTime: number;
  18486. /**
  18487. * Maximum life time of emitting particles.
  18488. */
  18489. maxLifeTime: number;
  18490. /**
  18491. * Minimum Size of emitting particles.
  18492. */
  18493. minSize: number;
  18494. /**
  18495. * Maximum Size of emitting particles.
  18496. */
  18497. maxSize: number;
  18498. /**
  18499. * Minimum scale of emitting particles on X axis.
  18500. */
  18501. minScaleX: number;
  18502. /**
  18503. * Maximum scale of emitting particles on X axis.
  18504. */
  18505. maxScaleX: number;
  18506. /**
  18507. * Minimum scale of emitting particles on Y axis.
  18508. */
  18509. minScaleY: number;
  18510. /**
  18511. * Maximum scale of emitting particles on Y axis.
  18512. */
  18513. maxScaleY: number;
  18514. /**
  18515. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18516. */
  18517. color1: Color4;
  18518. /**
  18519. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18520. */
  18521. color2: Color4;
  18522. /**
  18523. * Color the particle will have at the end of its lifetime.
  18524. */
  18525. colorDead: Color4;
  18526. /**
  18527. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18528. */
  18529. emitRate: number;
  18530. /**
  18531. * You can use gravity if you want to give an orientation to your particles.
  18532. */
  18533. gravity: Vector3;
  18534. /**
  18535. * Minimum power of emitting particles.
  18536. */
  18537. minEmitPower: number;
  18538. /**
  18539. * Maximum power of emitting particles.
  18540. */
  18541. maxEmitPower: number;
  18542. /**
  18543. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18544. */
  18545. minAngularSpeed: number;
  18546. /**
  18547. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18548. */
  18549. maxAngularSpeed: number;
  18550. /**
  18551. * Gets or sets the minimal initial rotation in radians.
  18552. */
  18553. minInitialRotation: number;
  18554. /**
  18555. * Gets or sets the maximal initial rotation in radians.
  18556. */
  18557. maxInitialRotation: number;
  18558. /**
  18559. * The particle emitter type defines the emitter used by the particle system.
  18560. * It can be for example box, sphere, or cone...
  18561. */
  18562. particleEmitterType: Nullable<IParticleEmitterType>;
  18563. /**
  18564. * Defines the delay in milliseconds before starting the system (0 by default)
  18565. */
  18566. startDelay: number;
  18567. /**
  18568. * 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
  18569. */
  18570. preWarmCycles: number;
  18571. /**
  18572. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18573. */
  18574. preWarmStepOffset: number;
  18575. /**
  18576. * 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)
  18577. */
  18578. spriteCellChangeSpeed: number;
  18579. /**
  18580. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18581. */
  18582. startSpriteCellID: number;
  18583. /**
  18584. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18585. */
  18586. endSpriteCellID: number;
  18587. /**
  18588. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18589. */
  18590. spriteCellWidth: number;
  18591. /**
  18592. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18593. */
  18594. spriteCellHeight: number;
  18595. /**
  18596. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18597. */
  18598. spriteRandomStartCell: boolean;
  18599. /**
  18600. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18601. */
  18602. isAnimationSheetEnabled: boolean;
  18603. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18604. translationPivot: Vector2;
  18605. /**
  18606. * Gets or sets a texture used to add random noise to particle positions
  18607. */
  18608. noiseTexture: Nullable<BaseTexture>;
  18609. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18610. noiseStrength: Vector3;
  18611. /**
  18612. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18613. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18614. */
  18615. billboardMode: number;
  18616. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18617. limitVelocityDamping: number;
  18618. /**
  18619. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18620. */
  18621. beginAnimationOnStart: boolean;
  18622. /**
  18623. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18624. */
  18625. beginAnimationFrom: number;
  18626. /**
  18627. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18628. */
  18629. beginAnimationTo: number;
  18630. /**
  18631. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18632. */
  18633. beginAnimationLoop: boolean;
  18634. /**
  18635. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18636. */
  18637. disposeOnStop: boolean;
  18638. /**
  18639. * Gets the maximum number of particles active at the same time.
  18640. * @returns The max number of active particles.
  18641. */
  18642. getCapacity(): number;
  18643. /**
  18644. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18645. * @returns True if it has been started, otherwise false.
  18646. */
  18647. isStarted(): boolean;
  18648. /**
  18649. * Animates the particle system for this frame.
  18650. */
  18651. animate(): void;
  18652. /**
  18653. * Renders the particle system in its current state.
  18654. * @returns the current number of particles
  18655. */
  18656. render(): number;
  18657. /**
  18658. * Dispose the particle system and frees its associated resources.
  18659. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18660. */
  18661. dispose(disposeTexture?: boolean): void;
  18662. /**
  18663. * Clones the particle system.
  18664. * @param name The name of the cloned object
  18665. * @param newEmitter The new emitter to use
  18666. * @returns the cloned particle system
  18667. */
  18668. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18669. /**
  18670. * Serializes the particle system to a JSON object.
  18671. * @returns the JSON object
  18672. */
  18673. serialize(): any;
  18674. /**
  18675. * Rebuild the particle system
  18676. */
  18677. rebuild(): void;
  18678. /**
  18679. * Starts the particle system and begins to emit
  18680. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18681. */
  18682. start(delay?: number): void;
  18683. /**
  18684. * Stops the particle system.
  18685. */
  18686. stop(): void;
  18687. /**
  18688. * Remove all active particles
  18689. */
  18690. reset(): void;
  18691. /**
  18692. * Is this system ready to be used/rendered
  18693. * @return true if the system is ready
  18694. */
  18695. isReady(): boolean;
  18696. /**
  18697. * Adds a new color gradient
  18698. * @param gradient defines the gradient to use (between 0 and 1)
  18699. * @param color1 defines the color to affect to the specified gradient
  18700. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18701. * @returns the current particle system
  18702. */
  18703. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18704. /**
  18705. * Remove a specific color gradient
  18706. * @param gradient defines the gradient to remove
  18707. * @returns the current particle system
  18708. */
  18709. removeColorGradient(gradient: number): IParticleSystem;
  18710. /**
  18711. * Adds a new size gradient
  18712. * @param gradient defines the gradient to use (between 0 and 1)
  18713. * @param factor defines the size factor to affect to the specified gradient
  18714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18715. * @returns the current particle system
  18716. */
  18717. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18718. /**
  18719. * Remove a specific size gradient
  18720. * @param gradient defines the gradient to remove
  18721. * @returns the current particle system
  18722. */
  18723. removeSizeGradient(gradient: number): IParticleSystem;
  18724. /**
  18725. * Gets the current list of color gradients.
  18726. * You must use addColorGradient and removeColorGradient to udpate this list
  18727. * @returns the list of color gradients
  18728. */
  18729. getColorGradients(): Nullable<Array<ColorGradient>>;
  18730. /**
  18731. * Gets the current list of size gradients.
  18732. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18733. * @returns the list of size gradients
  18734. */
  18735. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18736. /**
  18737. * Gets the current list of angular speed gradients.
  18738. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18739. * @returns the list of angular speed gradients
  18740. */
  18741. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18742. /**
  18743. * Adds a new angular speed gradient
  18744. * @param gradient defines the gradient to use (between 0 and 1)
  18745. * @param factor defines the angular speed to affect to the specified gradient
  18746. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18747. * @returns the current particle system
  18748. */
  18749. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18750. /**
  18751. * Remove a specific angular speed gradient
  18752. * @param gradient defines the gradient to remove
  18753. * @returns the current particle system
  18754. */
  18755. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18756. /**
  18757. * Gets the current list of velocity gradients.
  18758. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18759. * @returns the list of velocity gradients
  18760. */
  18761. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18762. /**
  18763. * Adds a new velocity gradient
  18764. * @param gradient defines the gradient to use (between 0 and 1)
  18765. * @param factor defines the velocity to affect to the specified gradient
  18766. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18767. * @returns the current particle system
  18768. */
  18769. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18770. /**
  18771. * Remove a specific velocity gradient
  18772. * @param gradient defines the gradient to remove
  18773. * @returns the current particle system
  18774. */
  18775. removeVelocityGradient(gradient: number): IParticleSystem;
  18776. /**
  18777. * Gets the current list of limit velocity gradients.
  18778. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18779. * @returns the list of limit velocity gradients
  18780. */
  18781. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18782. /**
  18783. * Adds a new limit velocity gradient
  18784. * @param gradient defines the gradient to use (between 0 and 1)
  18785. * @param factor defines the limit velocity to affect to the specified gradient
  18786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18787. * @returns the current particle system
  18788. */
  18789. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18790. /**
  18791. * Remove a specific limit velocity gradient
  18792. * @param gradient defines the gradient to remove
  18793. * @returns the current particle system
  18794. */
  18795. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18796. /**
  18797. * Adds a new drag gradient
  18798. * @param gradient defines the gradient to use (between 0 and 1)
  18799. * @param factor defines the drag to affect to the specified gradient
  18800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18801. * @returns the current particle system
  18802. */
  18803. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18804. /**
  18805. * Remove a specific drag gradient
  18806. * @param gradient defines the gradient to remove
  18807. * @returns the current particle system
  18808. */
  18809. removeDragGradient(gradient: number): IParticleSystem;
  18810. /**
  18811. * Gets the current list of drag gradients.
  18812. * You must use addDragGradient and removeDragGradient to udpate this list
  18813. * @returns the list of drag gradients
  18814. */
  18815. getDragGradients(): Nullable<Array<FactorGradient>>;
  18816. /**
  18817. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18818. * @param gradient defines the gradient to use (between 0 and 1)
  18819. * @param factor defines the emit rate to affect to the specified gradient
  18820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18821. * @returns the current particle system
  18822. */
  18823. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18824. /**
  18825. * Remove a specific emit rate gradient
  18826. * @param gradient defines the gradient to remove
  18827. * @returns the current particle system
  18828. */
  18829. removeEmitRateGradient(gradient: number): IParticleSystem;
  18830. /**
  18831. * Gets the current list of emit rate gradients.
  18832. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18833. * @returns the list of emit rate gradients
  18834. */
  18835. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18836. /**
  18837. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18838. * @param gradient defines the gradient to use (between 0 and 1)
  18839. * @param factor defines the start size to affect to the specified gradient
  18840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18841. * @returns the current particle system
  18842. */
  18843. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18844. /**
  18845. * Remove a specific start size gradient
  18846. * @param gradient defines the gradient to remove
  18847. * @returns the current particle system
  18848. */
  18849. removeStartSizeGradient(gradient: number): IParticleSystem;
  18850. /**
  18851. * Gets the current list of start size gradients.
  18852. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18853. * @returns the list of start size gradients
  18854. */
  18855. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18856. /**
  18857. * Adds a new life time gradient
  18858. * @param gradient defines the gradient to use (between 0 and 1)
  18859. * @param factor defines the life time factor to affect to the specified gradient
  18860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18861. * @returns the current particle system
  18862. */
  18863. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18864. /**
  18865. * Remove a specific life time gradient
  18866. * @param gradient defines the gradient to remove
  18867. * @returns the current particle system
  18868. */
  18869. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18870. /**
  18871. * Gets the current list of life time gradients.
  18872. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18873. * @returns the list of life time gradients
  18874. */
  18875. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18876. /**
  18877. * Gets the current list of color gradients.
  18878. * You must use addColorGradient and removeColorGradient to udpate this list
  18879. * @returns the list of color gradients
  18880. */
  18881. getColorGradients(): Nullable<Array<ColorGradient>>;
  18882. /**
  18883. * Adds a new ramp gradient used to remap particle colors
  18884. * @param gradient defines the gradient to use (between 0 and 1)
  18885. * @param color defines the color to affect to the specified gradient
  18886. * @returns the current particle system
  18887. */
  18888. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18889. /**
  18890. * Gets the current list of ramp gradients.
  18891. * You must use addRampGradient and removeRampGradient to udpate this list
  18892. * @returns the list of ramp gradients
  18893. */
  18894. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18895. /** Gets or sets a boolean indicating that ramp gradients must be used
  18896. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18897. */
  18898. useRampGradients: boolean;
  18899. /**
  18900. * Adds a new color remap gradient
  18901. * @param gradient defines the gradient to use (between 0 and 1)
  18902. * @param min defines the color remap minimal range
  18903. * @param max defines the color remap maximal range
  18904. * @returns the current particle system
  18905. */
  18906. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18907. /**
  18908. * Gets the current list of color remap gradients.
  18909. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18910. * @returns the list of color remap gradients
  18911. */
  18912. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18913. /**
  18914. * Adds a new alpha remap gradient
  18915. * @param gradient defines the gradient to use (between 0 and 1)
  18916. * @param min defines the alpha remap minimal range
  18917. * @param max defines the alpha remap maximal range
  18918. * @returns the current particle system
  18919. */
  18920. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18921. /**
  18922. * Gets the current list of alpha remap gradients.
  18923. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18924. * @returns the list of alpha remap gradients
  18925. */
  18926. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18927. /**
  18928. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18929. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18930. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18931. * @returns the emitter
  18932. */
  18933. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18934. /**
  18935. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18936. * @param radius The radius of the hemisphere to emit from
  18937. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18938. * @returns the emitter
  18939. */
  18940. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18941. /**
  18942. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18943. * @param radius The radius of the sphere to emit from
  18944. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18945. * @returns the emitter
  18946. */
  18947. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18948. /**
  18949. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18950. * @param radius The radius of the sphere to emit from
  18951. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18952. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18953. * @returns the emitter
  18954. */
  18955. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18956. /**
  18957. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18958. * @param radius The radius of the emission cylinder
  18959. * @param height The height of the emission cylinder
  18960. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18961. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18962. * @returns the emitter
  18963. */
  18964. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18965. /**
  18966. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18967. * @param radius The radius of the cylinder to emit from
  18968. * @param height The height of the emission cylinder
  18969. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18970. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18971. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18972. * @returns the emitter
  18973. */
  18974. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18975. /**
  18976. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18977. * @param radius The radius of the cone to emit from
  18978. * @param angle The base angle of the cone
  18979. * @returns the emitter
  18980. */
  18981. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18982. /**
  18983. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18984. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18985. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18986. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18987. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18988. * @returns the emitter
  18989. */
  18990. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18991. /**
  18992. * Get hosting scene
  18993. * @returns the scene
  18994. */
  18995. getScene(): Scene;
  18996. }
  18997. }
  18998. declare module "babylonjs/Meshes/instancedMesh" {
  18999. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19000. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19001. import { Camera } from "babylonjs/Cameras/camera";
  19002. import { Node } from "babylonjs/node";
  19003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19004. import { Mesh } from "babylonjs/Meshes/mesh";
  19005. import { Material } from "babylonjs/Materials/material";
  19006. import { Skeleton } from "babylonjs/Bones/skeleton";
  19007. import { Light } from "babylonjs/Lights/light";
  19008. /**
  19009. * Creates an instance based on a source mesh.
  19010. */
  19011. export class InstancedMesh extends AbstractMesh {
  19012. private _sourceMesh;
  19013. private _currentLOD;
  19014. /** @hidden */
  19015. _indexInSourceMeshInstanceArray: number;
  19016. constructor(name: string, source: Mesh);
  19017. /**
  19018. * Returns the string "InstancedMesh".
  19019. */
  19020. getClassName(): string;
  19021. /** Gets the list of lights affecting that mesh */
  19022. readonly lightSources: Light[];
  19023. _resyncLightSources(): void;
  19024. _resyncLighSource(light: Light): void;
  19025. _removeLightSource(light: Light): void;
  19026. /**
  19027. * If the source mesh receives shadows
  19028. */
  19029. readonly receiveShadows: boolean;
  19030. /**
  19031. * The material of the source mesh
  19032. */
  19033. readonly material: Nullable<Material>;
  19034. /**
  19035. * Visibility of the source mesh
  19036. */
  19037. readonly visibility: number;
  19038. /**
  19039. * Skeleton of the source mesh
  19040. */
  19041. readonly skeleton: Nullable<Skeleton>;
  19042. /**
  19043. * Rendering ground id of the source mesh
  19044. */
  19045. renderingGroupId: number;
  19046. /**
  19047. * Returns the total number of vertices (integer).
  19048. */
  19049. getTotalVertices(): number;
  19050. /**
  19051. * Returns a positive integer : the total number of indices in this mesh geometry.
  19052. * @returns the numner of indices or zero if the mesh has no geometry.
  19053. */
  19054. getTotalIndices(): number;
  19055. /**
  19056. * The source mesh of the instance
  19057. */
  19058. readonly sourceMesh: Mesh;
  19059. /**
  19060. * Is this node ready to be used/rendered
  19061. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19062. * @return {boolean} is it ready
  19063. */
  19064. isReady(completeCheck?: boolean): boolean;
  19065. /**
  19066. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19067. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19068. * @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.
  19069. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19070. */
  19071. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19072. /**
  19073. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19074. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19075. * The `data` are either a numeric array either a Float32Array.
  19076. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19077. * 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).
  19078. * Note that a new underlying VertexBuffer object is created each call.
  19079. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19080. *
  19081. * Possible `kind` values :
  19082. * - VertexBuffer.PositionKind
  19083. * - VertexBuffer.UVKind
  19084. * - VertexBuffer.UV2Kind
  19085. * - VertexBuffer.UV3Kind
  19086. * - VertexBuffer.UV4Kind
  19087. * - VertexBuffer.UV5Kind
  19088. * - VertexBuffer.UV6Kind
  19089. * - VertexBuffer.ColorKind
  19090. * - VertexBuffer.MatricesIndicesKind
  19091. * - VertexBuffer.MatricesIndicesExtraKind
  19092. * - VertexBuffer.MatricesWeightsKind
  19093. * - VertexBuffer.MatricesWeightsExtraKind
  19094. *
  19095. * Returns the Mesh.
  19096. */
  19097. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19098. /**
  19099. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19100. * If the mesh has no geometry, it is simply returned as it is.
  19101. * The `data` are either a numeric array either a Float32Array.
  19102. * No new underlying VertexBuffer object is created.
  19103. * 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.
  19104. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19105. *
  19106. * Possible `kind` values :
  19107. * - VertexBuffer.PositionKind
  19108. * - VertexBuffer.UVKind
  19109. * - VertexBuffer.UV2Kind
  19110. * - VertexBuffer.UV3Kind
  19111. * - VertexBuffer.UV4Kind
  19112. * - VertexBuffer.UV5Kind
  19113. * - VertexBuffer.UV6Kind
  19114. * - VertexBuffer.ColorKind
  19115. * - VertexBuffer.MatricesIndicesKind
  19116. * - VertexBuffer.MatricesIndicesExtraKind
  19117. * - VertexBuffer.MatricesWeightsKind
  19118. * - VertexBuffer.MatricesWeightsExtraKind
  19119. *
  19120. * Returns the Mesh.
  19121. */
  19122. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19123. /**
  19124. * Sets the mesh indices.
  19125. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19126. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19127. * This method creates a new index buffer each call.
  19128. * Returns the Mesh.
  19129. */
  19130. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19131. /**
  19132. * Boolean : True if the mesh owns the requested kind of data.
  19133. */
  19134. isVerticesDataPresent(kind: string): boolean;
  19135. /**
  19136. * Returns an array of indices (IndicesArray).
  19137. */
  19138. getIndices(): Nullable<IndicesArray>;
  19139. readonly _positions: Nullable<Vector3[]>;
  19140. /**
  19141. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19142. * This means the mesh underlying bounding box and sphere are recomputed.
  19143. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19144. * @returns the current mesh
  19145. */
  19146. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19147. /** @hidden */
  19148. _preActivate(): InstancedMesh;
  19149. /** @hidden */
  19150. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19151. /** @hidden */
  19152. _postActivate(): void;
  19153. getWorldMatrix(): Matrix;
  19154. readonly isAnInstance: boolean;
  19155. /**
  19156. * Returns the current associated LOD AbstractMesh.
  19157. */
  19158. getLOD(camera: Camera): AbstractMesh;
  19159. /** @hidden */
  19160. _syncSubMeshes(): InstancedMesh;
  19161. /** @hidden */
  19162. _generatePointsArray(): boolean;
  19163. /**
  19164. * Creates a new InstancedMesh from the current mesh.
  19165. * - name (string) : the cloned mesh name
  19166. * - newParent (optional Node) : the optional Node to parent the clone to.
  19167. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19168. *
  19169. * Returns the clone.
  19170. */
  19171. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19172. /**
  19173. * Disposes the InstancedMesh.
  19174. * Returns nothing.
  19175. */
  19176. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19177. }
  19178. }
  19179. declare module "babylonjs/Materials/shaderMaterial" {
  19180. import { Scene } from "babylonjs/scene";
  19181. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19183. import { Mesh } from "babylonjs/Meshes/mesh";
  19184. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19185. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19186. import { Texture } from "babylonjs/Materials/Textures/texture";
  19187. import { Material } from "babylonjs/Materials/material";
  19188. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19189. /**
  19190. * Defines the options associated with the creation of a shader material.
  19191. */
  19192. export interface IShaderMaterialOptions {
  19193. /**
  19194. * Does the material work in alpha blend mode
  19195. */
  19196. needAlphaBlending: boolean;
  19197. /**
  19198. * Does the material work in alpha test mode
  19199. */
  19200. needAlphaTesting: boolean;
  19201. /**
  19202. * The list of attribute names used in the shader
  19203. */
  19204. attributes: string[];
  19205. /**
  19206. * The list of unifrom names used in the shader
  19207. */
  19208. uniforms: string[];
  19209. /**
  19210. * The list of UBO names used in the shader
  19211. */
  19212. uniformBuffers: string[];
  19213. /**
  19214. * The list of sampler names used in the shader
  19215. */
  19216. samplers: string[];
  19217. /**
  19218. * The list of defines used in the shader
  19219. */
  19220. defines: string[];
  19221. }
  19222. /**
  19223. * 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.
  19224. *
  19225. * This returned material effects how the mesh will look based on the code in the shaders.
  19226. *
  19227. * @see http://doc.babylonjs.com/how_to/shader_material
  19228. */
  19229. export class ShaderMaterial extends Material {
  19230. private _shaderPath;
  19231. private _options;
  19232. private _textures;
  19233. private _textureArrays;
  19234. private _floats;
  19235. private _ints;
  19236. private _floatsArrays;
  19237. private _colors3;
  19238. private _colors3Arrays;
  19239. private _colors4;
  19240. private _colors4Arrays;
  19241. private _vectors2;
  19242. private _vectors3;
  19243. private _vectors4;
  19244. private _matrices;
  19245. private _matrices3x3;
  19246. private _matrices2x2;
  19247. private _vectors2Arrays;
  19248. private _vectors3Arrays;
  19249. private _vectors4Arrays;
  19250. private _cachedWorldViewMatrix;
  19251. private _cachedWorldViewProjectionMatrix;
  19252. private _renderId;
  19253. /**
  19254. * Instantiate a new shader material.
  19255. * 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.
  19256. * This returned material effects how the mesh will look based on the code in the shaders.
  19257. * @see http://doc.babylonjs.com/how_to/shader_material
  19258. * @param name Define the name of the material in the scene
  19259. * @param scene Define the scene the material belongs to
  19260. * @param shaderPath Defines the route to the shader code in one of three ways:
  19261. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19262. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19263. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19264. * @param options Define the options used to create the shader
  19265. */
  19266. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19267. /**
  19268. * Gets the options used to compile the shader.
  19269. * They can be modified to trigger a new compilation
  19270. */
  19271. readonly options: IShaderMaterialOptions;
  19272. /**
  19273. * Gets the current class name of the material e.g. "ShaderMaterial"
  19274. * Mainly use in serialization.
  19275. * @returns the class name
  19276. */
  19277. getClassName(): string;
  19278. /**
  19279. * Specifies if the material will require alpha blending
  19280. * @returns a boolean specifying if alpha blending is needed
  19281. */
  19282. needAlphaBlending(): boolean;
  19283. /**
  19284. * Specifies if this material should be rendered in alpha test mode
  19285. * @returns a boolean specifying if an alpha test is needed.
  19286. */
  19287. needAlphaTesting(): boolean;
  19288. private _checkUniform;
  19289. /**
  19290. * Set a texture in the shader.
  19291. * @param name Define the name of the uniform samplers as defined in the shader
  19292. * @param texture Define the texture to bind to this sampler
  19293. * @return the material itself allowing "fluent" like uniform updates
  19294. */
  19295. setTexture(name: string, texture: Texture): ShaderMaterial;
  19296. /**
  19297. * Set a texture array in the shader.
  19298. * @param name Define the name of the uniform sampler array as defined in the shader
  19299. * @param textures Define the list of textures to bind to this sampler
  19300. * @return the material itself allowing "fluent" like uniform updates
  19301. */
  19302. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19303. /**
  19304. * Set a float in the shader.
  19305. * @param name Define the name of the uniform as defined in the shader
  19306. * @param value Define the value to give to the uniform
  19307. * @return the material itself allowing "fluent" like uniform updates
  19308. */
  19309. setFloat(name: string, value: number): ShaderMaterial;
  19310. /**
  19311. * Set a int in the shader.
  19312. * @param name Define the name of the uniform as defined in the shader
  19313. * @param value Define the value to give to the uniform
  19314. * @return the material itself allowing "fluent" like uniform updates
  19315. */
  19316. setInt(name: string, value: number): ShaderMaterial;
  19317. /**
  19318. * Set an array of floats in the shader.
  19319. * @param name Define the name of the uniform as defined in the shader
  19320. * @param value Define the value to give to the uniform
  19321. * @return the material itself allowing "fluent" like uniform updates
  19322. */
  19323. setFloats(name: string, value: number[]): ShaderMaterial;
  19324. /**
  19325. * Set a vec3 in the shader from a Color3.
  19326. * @param name Define the name of the uniform as defined in the shader
  19327. * @param value Define the value to give to the uniform
  19328. * @return the material itself allowing "fluent" like uniform updates
  19329. */
  19330. setColor3(name: string, value: Color3): ShaderMaterial;
  19331. /**
  19332. * Set a vec3 array in the shader from a Color3 array.
  19333. * @param name Define the name of the uniform as defined in the shader
  19334. * @param value Define the value to give to the uniform
  19335. * @return the material itself allowing "fluent" like uniform updates
  19336. */
  19337. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19338. /**
  19339. * Set a vec4 in the shader from a Color4.
  19340. * @param name Define the name of the uniform as defined in the shader
  19341. * @param value Define the value to give to the uniform
  19342. * @return the material itself allowing "fluent" like uniform updates
  19343. */
  19344. setColor4(name: string, value: Color4): ShaderMaterial;
  19345. /**
  19346. * Set a vec4 array in the shader from a Color4 array.
  19347. * @param name Define the name of the uniform as defined in the shader
  19348. * @param value Define the value to give to the uniform
  19349. * @return the material itself allowing "fluent" like uniform updates
  19350. */
  19351. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19352. /**
  19353. * Set a vec2 in the shader from a Vector2.
  19354. * @param name Define the name of the uniform as defined in the shader
  19355. * @param value Define the value to give to the uniform
  19356. * @return the material itself allowing "fluent" like uniform updates
  19357. */
  19358. setVector2(name: string, value: Vector2): ShaderMaterial;
  19359. /**
  19360. * Set a vec3 in the shader from a Vector3.
  19361. * @param name Define the name of the uniform as defined in the shader
  19362. * @param value Define the value to give to the uniform
  19363. * @return the material itself allowing "fluent" like uniform updates
  19364. */
  19365. setVector3(name: string, value: Vector3): ShaderMaterial;
  19366. /**
  19367. * Set a vec4 in the shader from a Vector4.
  19368. * @param name Define the name of the uniform as defined in the shader
  19369. * @param value Define the value to give to the uniform
  19370. * @return the material itself allowing "fluent" like uniform updates
  19371. */
  19372. setVector4(name: string, value: Vector4): ShaderMaterial;
  19373. /**
  19374. * Set a mat4 in the shader from a Matrix.
  19375. * @param name Define the name of the uniform as defined in the shader
  19376. * @param value Define the value to give to the uniform
  19377. * @return the material itself allowing "fluent" like uniform updates
  19378. */
  19379. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19380. /**
  19381. * Set a mat3 in the shader from a Float32Array.
  19382. * @param name Define the name of the uniform as defined in the shader
  19383. * @param value Define the value to give to the uniform
  19384. * @return the material itself allowing "fluent" like uniform updates
  19385. */
  19386. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19387. /**
  19388. * Set a mat2 in the shader from a Float32Array.
  19389. * @param name Define the name of the uniform as defined in the shader
  19390. * @param value Define the value to give to the uniform
  19391. * @return the material itself allowing "fluent" like uniform updates
  19392. */
  19393. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19394. /**
  19395. * Set a vec2 array in the shader from a number array.
  19396. * @param name Define the name of the uniform as defined in the shader
  19397. * @param value Define the value to give to the uniform
  19398. * @return the material itself allowing "fluent" like uniform updates
  19399. */
  19400. setArray2(name: string, value: number[]): ShaderMaterial;
  19401. /**
  19402. * Set a vec3 array in the shader from a number array.
  19403. * @param name Define the name of the uniform as defined in the shader
  19404. * @param value Define the value to give to the uniform
  19405. * @return the material itself allowing "fluent" like uniform updates
  19406. */
  19407. setArray3(name: string, value: number[]): ShaderMaterial;
  19408. /**
  19409. * Set a vec4 array in the shader from a number array.
  19410. * @param name Define the name of the uniform as defined in the shader
  19411. * @param value Define the value to give to the uniform
  19412. * @return the material itself allowing "fluent" like uniform updates
  19413. */
  19414. setArray4(name: string, value: number[]): ShaderMaterial;
  19415. private _checkCache;
  19416. /**
  19417. * Specifies that the submesh is ready to be used
  19418. * @param mesh defines the mesh to check
  19419. * @param subMesh defines which submesh to check
  19420. * @param useInstances specifies that instances should be used
  19421. * @returns a boolean indicating that the submesh is ready or not
  19422. */
  19423. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19424. /**
  19425. * Checks if the material is ready to render the requested mesh
  19426. * @param mesh Define the mesh to render
  19427. * @param useInstances Define whether or not the material is used with instances
  19428. * @returns true if ready, otherwise false
  19429. */
  19430. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19431. /**
  19432. * Binds the world matrix to the material
  19433. * @param world defines the world transformation matrix
  19434. */
  19435. bindOnlyWorldMatrix(world: Matrix): void;
  19436. /**
  19437. * Binds the material to the mesh
  19438. * @param world defines the world transformation matrix
  19439. * @param mesh defines the mesh to bind the material to
  19440. */
  19441. bind(world: Matrix, mesh?: Mesh): void;
  19442. /**
  19443. * Gets the active textures from the material
  19444. * @returns an array of textures
  19445. */
  19446. getActiveTextures(): BaseTexture[];
  19447. /**
  19448. * Specifies if the material uses a texture
  19449. * @param texture defines the texture to check against the material
  19450. * @returns a boolean specifying if the material uses the texture
  19451. */
  19452. hasTexture(texture: BaseTexture): boolean;
  19453. /**
  19454. * Makes a duplicate of the material, and gives it a new name
  19455. * @param name defines the new name for the duplicated material
  19456. * @returns the cloned material
  19457. */
  19458. clone(name: string): ShaderMaterial;
  19459. /**
  19460. * Disposes the material
  19461. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19462. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19463. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19464. */
  19465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19466. /**
  19467. * Serializes this material in a JSON representation
  19468. * @returns the serialized material object
  19469. */
  19470. serialize(): any;
  19471. /**
  19472. * Creates a shader material from parsed shader material data
  19473. * @param source defines the JSON represnetation of the material
  19474. * @param scene defines the hosting scene
  19475. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19476. * @returns a new material
  19477. */
  19478. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19479. }
  19480. }
  19481. declare module "babylonjs/Shaders/color.fragment" {
  19482. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19483. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19484. /** @hidden */
  19485. export var colorPixelShader: {
  19486. name: string;
  19487. shader: string;
  19488. };
  19489. }
  19490. declare module "babylonjs/Shaders/color.vertex" {
  19491. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19492. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19493. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19494. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19495. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19496. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19497. /** @hidden */
  19498. export var colorVertexShader: {
  19499. name: string;
  19500. shader: string;
  19501. };
  19502. }
  19503. declare module "babylonjs/Meshes/linesMesh" {
  19504. import { Nullable } from "babylonjs/types";
  19505. import { Scene } from "babylonjs/scene";
  19506. import { Color3 } from "babylonjs/Maths/math.color";
  19507. import { Node } from "babylonjs/node";
  19508. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19509. import { Mesh } from "babylonjs/Meshes/mesh";
  19510. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19511. import { Effect } from "babylonjs/Materials/effect";
  19512. import { Material } from "babylonjs/Materials/material";
  19513. import "babylonjs/Shaders/color.fragment";
  19514. import "babylonjs/Shaders/color.vertex";
  19515. /**
  19516. * Line mesh
  19517. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19518. */
  19519. export class LinesMesh extends Mesh {
  19520. /**
  19521. * If vertex color should be applied to the mesh
  19522. */
  19523. readonly useVertexColor?: boolean | undefined;
  19524. /**
  19525. * If vertex alpha should be applied to the mesh
  19526. */
  19527. readonly useVertexAlpha?: boolean | undefined;
  19528. /**
  19529. * Color of the line (Default: White)
  19530. */
  19531. color: Color3;
  19532. /**
  19533. * Alpha of the line (Default: 1)
  19534. */
  19535. alpha: number;
  19536. /**
  19537. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19538. * This margin is expressed in world space coordinates, so its value may vary.
  19539. * Default value is 0.1
  19540. */
  19541. intersectionThreshold: number;
  19542. private _colorShader;
  19543. private color4;
  19544. /**
  19545. * Creates a new LinesMesh
  19546. * @param name defines the name
  19547. * @param scene defines the hosting scene
  19548. * @param parent defines the parent mesh if any
  19549. * @param source defines the optional source LinesMesh used to clone data from
  19550. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19551. * When false, achieved by calling a clone(), also passing False.
  19552. * This will make creation of children, recursive.
  19553. * @param useVertexColor defines if this LinesMesh supports vertex color
  19554. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19555. */
  19556. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19557. /**
  19558. * If vertex color should be applied to the mesh
  19559. */
  19560. useVertexColor?: boolean | undefined,
  19561. /**
  19562. * If vertex alpha should be applied to the mesh
  19563. */
  19564. useVertexAlpha?: boolean | undefined);
  19565. private _addClipPlaneDefine;
  19566. private _removeClipPlaneDefine;
  19567. isReady(): boolean;
  19568. /**
  19569. * Returns the string "LineMesh"
  19570. */
  19571. getClassName(): string;
  19572. /**
  19573. * @hidden
  19574. */
  19575. /**
  19576. * @hidden
  19577. */
  19578. material: Material;
  19579. /**
  19580. * @hidden
  19581. */
  19582. readonly checkCollisions: boolean;
  19583. /** @hidden */
  19584. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19585. /** @hidden */
  19586. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19587. /**
  19588. * Disposes of the line mesh
  19589. * @param doNotRecurse If children should be disposed
  19590. */
  19591. dispose(doNotRecurse?: boolean): void;
  19592. /**
  19593. * Returns a new LineMesh object cloned from the current one.
  19594. */
  19595. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19596. /**
  19597. * Creates a new InstancedLinesMesh object from the mesh model.
  19598. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19599. * @param name defines the name of the new instance
  19600. * @returns a new InstancedLinesMesh
  19601. */
  19602. createInstance(name: string): InstancedLinesMesh;
  19603. }
  19604. /**
  19605. * Creates an instance based on a source LinesMesh
  19606. */
  19607. export class InstancedLinesMesh extends InstancedMesh {
  19608. /**
  19609. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19610. * This margin is expressed in world space coordinates, so its value may vary.
  19611. * Initilized with the intersectionThreshold value of the source LinesMesh
  19612. */
  19613. intersectionThreshold: number;
  19614. constructor(name: string, source: LinesMesh);
  19615. /**
  19616. * Returns the string "InstancedLinesMesh".
  19617. */
  19618. getClassName(): string;
  19619. }
  19620. }
  19621. declare module "babylonjs/Shaders/line.fragment" {
  19622. /** @hidden */
  19623. export var linePixelShader: {
  19624. name: string;
  19625. shader: string;
  19626. };
  19627. }
  19628. declare module "babylonjs/Shaders/line.vertex" {
  19629. /** @hidden */
  19630. export var lineVertexShader: {
  19631. name: string;
  19632. shader: string;
  19633. };
  19634. }
  19635. declare module "babylonjs/Rendering/edgesRenderer" {
  19636. import { Nullable } from "babylonjs/types";
  19637. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19639. import { Vector3 } from "babylonjs/Maths/math.vector";
  19640. import { IDisposable } from "babylonjs/scene";
  19641. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19642. import "babylonjs/Shaders/line.fragment";
  19643. import "babylonjs/Shaders/line.vertex";
  19644. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19645. module "babylonjs/Meshes/abstractMesh" {
  19646. interface AbstractMesh {
  19647. /**
  19648. * Gets the edgesRenderer associated with the mesh
  19649. */
  19650. edgesRenderer: Nullable<EdgesRenderer>;
  19651. }
  19652. }
  19653. module "babylonjs/Meshes/linesMesh" {
  19654. interface LinesMesh {
  19655. /**
  19656. * Enables the edge rendering mode on the mesh.
  19657. * This mode makes the mesh edges visible
  19658. * @param epsilon defines the maximal distance between two angles to detect a face
  19659. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19660. * @returns the currentAbstractMesh
  19661. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19662. */
  19663. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19664. }
  19665. }
  19666. module "babylonjs/Meshes/linesMesh" {
  19667. interface InstancedLinesMesh {
  19668. /**
  19669. * Enables the edge rendering mode on the mesh.
  19670. * This mode makes the mesh edges visible
  19671. * @param epsilon defines the maximal distance between two angles to detect a face
  19672. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19673. * @returns the current InstancedLinesMesh
  19674. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19675. */
  19676. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19677. }
  19678. }
  19679. /**
  19680. * Defines the minimum contract an Edges renderer should follow.
  19681. */
  19682. export interface IEdgesRenderer extends IDisposable {
  19683. /**
  19684. * Gets or sets a boolean indicating if the edgesRenderer is active
  19685. */
  19686. isEnabled: boolean;
  19687. /**
  19688. * Renders the edges of the attached mesh,
  19689. */
  19690. render(): void;
  19691. /**
  19692. * Checks wether or not the edges renderer is ready to render.
  19693. * @return true if ready, otherwise false.
  19694. */
  19695. isReady(): boolean;
  19696. }
  19697. /**
  19698. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19699. */
  19700. export class EdgesRenderer implements IEdgesRenderer {
  19701. /**
  19702. * Define the size of the edges with an orthographic camera
  19703. */
  19704. edgesWidthScalerForOrthographic: number;
  19705. /**
  19706. * Define the size of the edges with a perspective camera
  19707. */
  19708. edgesWidthScalerForPerspective: number;
  19709. protected _source: AbstractMesh;
  19710. protected _linesPositions: number[];
  19711. protected _linesNormals: number[];
  19712. protected _linesIndices: number[];
  19713. protected _epsilon: number;
  19714. protected _indicesCount: number;
  19715. protected _lineShader: ShaderMaterial;
  19716. protected _ib: DataBuffer;
  19717. protected _buffers: {
  19718. [key: string]: Nullable<VertexBuffer>;
  19719. };
  19720. protected _checkVerticesInsteadOfIndices: boolean;
  19721. private _meshRebuildObserver;
  19722. private _meshDisposeObserver;
  19723. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19724. isEnabled: boolean;
  19725. /**
  19726. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19727. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19728. * @param source Mesh used to create edges
  19729. * @param epsilon sum of angles in adjacency to check for edge
  19730. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19731. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19732. */
  19733. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19734. protected _prepareRessources(): void;
  19735. /** @hidden */
  19736. _rebuild(): void;
  19737. /**
  19738. * Releases the required resources for the edges renderer
  19739. */
  19740. dispose(): void;
  19741. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19742. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19743. /**
  19744. * Checks if the pair of p0 and p1 is en edge
  19745. * @param faceIndex
  19746. * @param edge
  19747. * @param faceNormals
  19748. * @param p0
  19749. * @param p1
  19750. * @private
  19751. */
  19752. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19753. /**
  19754. * push line into the position, normal and index buffer
  19755. * @protected
  19756. */
  19757. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19758. /**
  19759. * Generates lines edges from adjacencjes
  19760. * @private
  19761. */
  19762. _generateEdgesLines(): void;
  19763. /**
  19764. * Checks wether or not the edges renderer is ready to render.
  19765. * @return true if ready, otherwise false.
  19766. */
  19767. isReady(): boolean;
  19768. /**
  19769. * Renders the edges of the attached mesh,
  19770. */
  19771. render(): void;
  19772. }
  19773. /**
  19774. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19775. */
  19776. export class LineEdgesRenderer extends EdgesRenderer {
  19777. /**
  19778. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19779. * @param source LineMesh used to generate edges
  19780. * @param epsilon not important (specified angle for edge detection)
  19781. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19782. */
  19783. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19784. /**
  19785. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19786. */
  19787. _generateEdgesLines(): void;
  19788. }
  19789. }
  19790. declare module "babylonjs/Rendering/renderingGroup" {
  19791. import { SmartArray } from "babylonjs/Misc/smartArray";
  19792. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19794. import { Nullable } from "babylonjs/types";
  19795. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19796. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19797. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19798. import { Material } from "babylonjs/Materials/material";
  19799. import { Scene } from "babylonjs/scene";
  19800. /**
  19801. * This represents the object necessary to create a rendering group.
  19802. * This is exclusively used and created by the rendering manager.
  19803. * To modify the behavior, you use the available helpers in your scene or meshes.
  19804. * @hidden
  19805. */
  19806. export class RenderingGroup {
  19807. index: number;
  19808. private static _zeroVector;
  19809. private _scene;
  19810. private _opaqueSubMeshes;
  19811. private _transparentSubMeshes;
  19812. private _alphaTestSubMeshes;
  19813. private _depthOnlySubMeshes;
  19814. private _particleSystems;
  19815. private _spriteManagers;
  19816. private _opaqueSortCompareFn;
  19817. private _alphaTestSortCompareFn;
  19818. private _transparentSortCompareFn;
  19819. private _renderOpaque;
  19820. private _renderAlphaTest;
  19821. private _renderTransparent;
  19822. /** @hidden */
  19823. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19824. onBeforeTransparentRendering: () => void;
  19825. /**
  19826. * Set the opaque sort comparison function.
  19827. * If null the sub meshes will be render in the order they were created
  19828. */
  19829. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19830. /**
  19831. * Set the alpha test sort comparison function.
  19832. * If null the sub meshes will be render in the order they were created
  19833. */
  19834. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19835. /**
  19836. * Set the transparent sort comparison function.
  19837. * If null the sub meshes will be render in the order they were created
  19838. */
  19839. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19840. /**
  19841. * Creates a new rendering group.
  19842. * @param index The rendering group index
  19843. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19844. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19845. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19846. */
  19847. 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>);
  19848. /**
  19849. * Render all the sub meshes contained in the group.
  19850. * @param customRenderFunction Used to override the default render behaviour of the group.
  19851. * @returns true if rendered some submeshes.
  19852. */
  19853. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19854. /**
  19855. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19856. * @param subMeshes The submeshes to render
  19857. */
  19858. private renderOpaqueSorted;
  19859. /**
  19860. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19861. * @param subMeshes The submeshes to render
  19862. */
  19863. private renderAlphaTestSorted;
  19864. /**
  19865. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19866. * @param subMeshes The submeshes to render
  19867. */
  19868. private renderTransparentSorted;
  19869. /**
  19870. * Renders the submeshes in a specified order.
  19871. * @param subMeshes The submeshes to sort before render
  19872. * @param sortCompareFn The comparison function use to sort
  19873. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19874. * @param transparent Specifies to activate blending if true
  19875. */
  19876. private static renderSorted;
  19877. /**
  19878. * Renders the submeshes in the order they were dispatched (no sort applied).
  19879. * @param subMeshes The submeshes to render
  19880. */
  19881. private static renderUnsorted;
  19882. /**
  19883. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19884. * are rendered back to front if in the same alpha index.
  19885. *
  19886. * @param a The first submesh
  19887. * @param b The second submesh
  19888. * @returns The result of the comparison
  19889. */
  19890. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19891. /**
  19892. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19893. * are rendered back to front.
  19894. *
  19895. * @param a The first submesh
  19896. * @param b The second submesh
  19897. * @returns The result of the comparison
  19898. */
  19899. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19900. /**
  19901. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19902. * are rendered front to back (prevent overdraw).
  19903. *
  19904. * @param a The first submesh
  19905. * @param b The second submesh
  19906. * @returns The result of the comparison
  19907. */
  19908. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19909. /**
  19910. * Resets the different lists of submeshes to prepare a new frame.
  19911. */
  19912. prepare(): void;
  19913. dispose(): void;
  19914. /**
  19915. * Inserts the submesh in its correct queue depending on its material.
  19916. * @param subMesh The submesh to dispatch
  19917. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19918. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19919. */
  19920. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19921. dispatchSprites(spriteManager: ISpriteManager): void;
  19922. dispatchParticles(particleSystem: IParticleSystem): void;
  19923. private _renderParticles;
  19924. private _renderSprites;
  19925. }
  19926. }
  19927. declare module "babylonjs/Rendering/renderingManager" {
  19928. import { Nullable } from "babylonjs/types";
  19929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19931. import { SmartArray } from "babylonjs/Misc/smartArray";
  19932. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19933. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19934. import { Material } from "babylonjs/Materials/material";
  19935. import { Scene } from "babylonjs/scene";
  19936. import { Camera } from "babylonjs/Cameras/camera";
  19937. /**
  19938. * Interface describing the different options available in the rendering manager
  19939. * regarding Auto Clear between groups.
  19940. */
  19941. export interface IRenderingManagerAutoClearSetup {
  19942. /**
  19943. * Defines whether or not autoclear is enable.
  19944. */
  19945. autoClear: boolean;
  19946. /**
  19947. * Defines whether or not to autoclear the depth buffer.
  19948. */
  19949. depth: boolean;
  19950. /**
  19951. * Defines whether or not to autoclear the stencil buffer.
  19952. */
  19953. stencil: boolean;
  19954. }
  19955. /**
  19956. * This class is used by the onRenderingGroupObservable
  19957. */
  19958. export class RenderingGroupInfo {
  19959. /**
  19960. * The Scene that being rendered
  19961. */
  19962. scene: Scene;
  19963. /**
  19964. * The camera currently used for the rendering pass
  19965. */
  19966. camera: Nullable<Camera>;
  19967. /**
  19968. * The ID of the renderingGroup being processed
  19969. */
  19970. renderingGroupId: number;
  19971. }
  19972. /**
  19973. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19974. * It is enable to manage the different groups as well as the different necessary sort functions.
  19975. * This should not be used directly aside of the few static configurations
  19976. */
  19977. export class RenderingManager {
  19978. /**
  19979. * The max id used for rendering groups (not included)
  19980. */
  19981. static MAX_RENDERINGGROUPS: number;
  19982. /**
  19983. * The min id used for rendering groups (included)
  19984. */
  19985. static MIN_RENDERINGGROUPS: number;
  19986. /**
  19987. * Used to globally prevent autoclearing scenes.
  19988. */
  19989. static AUTOCLEAR: boolean;
  19990. /**
  19991. * @hidden
  19992. */
  19993. _useSceneAutoClearSetup: boolean;
  19994. private _scene;
  19995. private _renderingGroups;
  19996. private _depthStencilBufferAlreadyCleaned;
  19997. private _autoClearDepthStencil;
  19998. private _customOpaqueSortCompareFn;
  19999. private _customAlphaTestSortCompareFn;
  20000. private _customTransparentSortCompareFn;
  20001. private _renderingGroupInfo;
  20002. /**
  20003. * Instantiates a new rendering group for a particular scene
  20004. * @param scene Defines the scene the groups belongs to
  20005. */
  20006. constructor(scene: Scene);
  20007. private _clearDepthStencilBuffer;
  20008. /**
  20009. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20010. * @hidden
  20011. */
  20012. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20013. /**
  20014. * Resets the different information of the group to prepare a new frame
  20015. * @hidden
  20016. */
  20017. reset(): void;
  20018. /**
  20019. * Dispose and release the group and its associated resources.
  20020. * @hidden
  20021. */
  20022. dispose(): void;
  20023. /**
  20024. * Clear the info related to rendering groups preventing retention points during dispose.
  20025. */
  20026. freeRenderingGroups(): void;
  20027. private _prepareRenderingGroup;
  20028. /**
  20029. * Add a sprite manager to the rendering manager in order to render it this frame.
  20030. * @param spriteManager Define the sprite manager to render
  20031. */
  20032. dispatchSprites(spriteManager: ISpriteManager): void;
  20033. /**
  20034. * Add a particle system to the rendering manager in order to render it this frame.
  20035. * @param particleSystem Define the particle system to render
  20036. */
  20037. dispatchParticles(particleSystem: IParticleSystem): void;
  20038. /**
  20039. * Add a submesh to the manager in order to render it this frame
  20040. * @param subMesh The submesh to dispatch
  20041. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20042. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20043. */
  20044. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20045. /**
  20046. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20047. * This allowed control for front to back rendering or reversly depending of the special needs.
  20048. *
  20049. * @param renderingGroupId The rendering group id corresponding to its index
  20050. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20051. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20052. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20053. */
  20054. 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;
  20055. /**
  20056. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20057. *
  20058. * @param renderingGroupId The rendering group id corresponding to its index
  20059. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20060. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20061. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20062. */
  20063. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20064. /**
  20065. * Gets the current auto clear configuration for one rendering group of the rendering
  20066. * manager.
  20067. * @param index the rendering group index to get the information for
  20068. * @returns The auto clear setup for the requested rendering group
  20069. */
  20070. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20071. }
  20072. }
  20073. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20074. import { Observable } from "babylonjs/Misc/observable";
  20075. import { SmartArray } from "babylonjs/Misc/smartArray";
  20076. import { Nullable } from "babylonjs/types";
  20077. import { Camera } from "babylonjs/Cameras/camera";
  20078. import { Scene } from "babylonjs/scene";
  20079. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20080. import { Color4 } from "babylonjs/Maths/math.color";
  20081. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20084. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20085. import { Texture } from "babylonjs/Materials/Textures/texture";
  20086. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20087. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20088. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20089. import { Engine } from "babylonjs/Engines/engine";
  20090. /**
  20091. * This Helps creating a texture that will be created from a camera in your scene.
  20092. * It is basically a dynamic texture that could be used to create special effects for instance.
  20093. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20094. */
  20095. export class RenderTargetTexture extends Texture {
  20096. isCube: boolean;
  20097. /**
  20098. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20099. */
  20100. static readonly REFRESHRATE_RENDER_ONCE: number;
  20101. /**
  20102. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20103. */
  20104. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20105. /**
  20106. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20107. * the central point of your effect and can save a lot of performances.
  20108. */
  20109. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20110. /**
  20111. * Use this predicate to dynamically define the list of mesh you want to render.
  20112. * If set, the renderList property will be overwritten.
  20113. */
  20114. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20115. private _renderList;
  20116. /**
  20117. * Use this list to define the list of mesh you want to render.
  20118. */
  20119. renderList: Nullable<Array<AbstractMesh>>;
  20120. private _hookArray;
  20121. /**
  20122. * Define if particles should be rendered in your texture.
  20123. */
  20124. renderParticles: boolean;
  20125. /**
  20126. * Define if sprites should be rendered in your texture.
  20127. */
  20128. renderSprites: boolean;
  20129. /**
  20130. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20131. */
  20132. coordinatesMode: number;
  20133. /**
  20134. * Define the camera used to render the texture.
  20135. */
  20136. activeCamera: Nullable<Camera>;
  20137. /**
  20138. * Override the render function of the texture with your own one.
  20139. */
  20140. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20141. /**
  20142. * Define if camera post processes should be use while rendering the texture.
  20143. */
  20144. useCameraPostProcesses: boolean;
  20145. /**
  20146. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20147. */
  20148. ignoreCameraViewport: boolean;
  20149. private _postProcessManager;
  20150. private _postProcesses;
  20151. private _resizeObserver;
  20152. /**
  20153. * An event triggered when the texture is unbind.
  20154. */
  20155. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20156. /**
  20157. * An event triggered when the texture is unbind.
  20158. */
  20159. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20160. private _onAfterUnbindObserver;
  20161. /**
  20162. * Set a after unbind callback in the texture.
  20163. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20164. */
  20165. onAfterUnbind: () => void;
  20166. /**
  20167. * An event triggered before rendering the texture
  20168. */
  20169. onBeforeRenderObservable: Observable<number>;
  20170. private _onBeforeRenderObserver;
  20171. /**
  20172. * Set a before render callback in the texture.
  20173. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20174. */
  20175. onBeforeRender: (faceIndex: number) => void;
  20176. /**
  20177. * An event triggered after rendering the texture
  20178. */
  20179. onAfterRenderObservable: Observable<number>;
  20180. private _onAfterRenderObserver;
  20181. /**
  20182. * Set a after render callback in the texture.
  20183. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20184. */
  20185. onAfterRender: (faceIndex: number) => void;
  20186. /**
  20187. * An event triggered after the texture clear
  20188. */
  20189. onClearObservable: Observable<Engine>;
  20190. private _onClearObserver;
  20191. /**
  20192. * Set a clear callback in the texture.
  20193. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20194. */
  20195. onClear: (Engine: Engine) => void;
  20196. /**
  20197. * An event triggered when the texture is resized.
  20198. */
  20199. onResizeObservable: Observable<RenderTargetTexture>;
  20200. /**
  20201. * Define the clear color of the Render Target if it should be different from the scene.
  20202. */
  20203. clearColor: Color4;
  20204. protected _size: number | {
  20205. width: number;
  20206. height: number;
  20207. };
  20208. protected _initialSizeParameter: number | {
  20209. width: number;
  20210. height: number;
  20211. } | {
  20212. ratio: number;
  20213. };
  20214. protected _sizeRatio: Nullable<number>;
  20215. /** @hidden */
  20216. _generateMipMaps: boolean;
  20217. protected _renderingManager: RenderingManager;
  20218. /** @hidden */
  20219. _waitingRenderList: string[];
  20220. protected _doNotChangeAspectRatio: boolean;
  20221. protected _currentRefreshId: number;
  20222. protected _refreshRate: number;
  20223. protected _textureMatrix: Matrix;
  20224. protected _samples: number;
  20225. protected _renderTargetOptions: RenderTargetCreationOptions;
  20226. /**
  20227. * Gets render target creation options that were used.
  20228. */
  20229. readonly renderTargetOptions: RenderTargetCreationOptions;
  20230. protected _engine: Engine;
  20231. protected _onRatioRescale(): void;
  20232. /**
  20233. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20234. * It must define where the camera used to render the texture is set
  20235. */
  20236. boundingBoxPosition: Vector3;
  20237. private _boundingBoxSize;
  20238. /**
  20239. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20240. * When defined, the cubemap will switch to local mode
  20241. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20242. * @example https://www.babylonjs-playground.com/#RNASML
  20243. */
  20244. boundingBoxSize: Vector3;
  20245. /**
  20246. * In case the RTT has been created with a depth texture, get the associated
  20247. * depth texture.
  20248. * Otherwise, return null.
  20249. */
  20250. depthStencilTexture: Nullable<InternalTexture>;
  20251. /**
  20252. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20253. * or used a shadow, depth texture...
  20254. * @param name The friendly name of the texture
  20255. * @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)
  20256. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20257. * @param generateMipMaps True if mip maps need to be generated after render.
  20258. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20259. * @param type The type of the buffer in the RTT (int, half float, float...)
  20260. * @param isCube True if a cube texture needs to be created
  20261. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20262. * @param generateDepthBuffer True to generate a depth buffer
  20263. * @param generateStencilBuffer True to generate a stencil buffer
  20264. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20265. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20266. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20267. */
  20268. constructor(name: string, size: number | {
  20269. width: number;
  20270. height: number;
  20271. } | {
  20272. ratio: number;
  20273. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20274. /**
  20275. * Creates a depth stencil texture.
  20276. * This is only available in WebGL 2 or with the depth texture extension available.
  20277. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20278. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20279. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20280. */
  20281. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20282. private _processSizeParameter;
  20283. /**
  20284. * Define the number of samples to use in case of MSAA.
  20285. * It defaults to one meaning no MSAA has been enabled.
  20286. */
  20287. samples: number;
  20288. /**
  20289. * Resets the refresh counter of the texture and start bak from scratch.
  20290. * Could be useful to regenerate the texture if it is setup to render only once.
  20291. */
  20292. resetRefreshCounter(): void;
  20293. /**
  20294. * Define the refresh rate of the texture or the rendering frequency.
  20295. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20296. */
  20297. refreshRate: number;
  20298. /**
  20299. * Adds a post process to the render target rendering passes.
  20300. * @param postProcess define the post process to add
  20301. */
  20302. addPostProcess(postProcess: PostProcess): void;
  20303. /**
  20304. * Clear all the post processes attached to the render target
  20305. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20306. */
  20307. clearPostProcesses(dispose?: boolean): void;
  20308. /**
  20309. * Remove one of the post process from the list of attached post processes to the texture
  20310. * @param postProcess define the post process to remove from the list
  20311. */
  20312. removePostProcess(postProcess: PostProcess): void;
  20313. /** @hidden */
  20314. _shouldRender(): boolean;
  20315. /**
  20316. * Gets the actual render size of the texture.
  20317. * @returns the width of the render size
  20318. */
  20319. getRenderSize(): number;
  20320. /**
  20321. * Gets the actual render width of the texture.
  20322. * @returns the width of the render size
  20323. */
  20324. getRenderWidth(): number;
  20325. /**
  20326. * Gets the actual render height of the texture.
  20327. * @returns the height of the render size
  20328. */
  20329. getRenderHeight(): number;
  20330. /**
  20331. * Get if the texture can be rescaled or not.
  20332. */
  20333. readonly canRescale: boolean;
  20334. /**
  20335. * Resize the texture using a ratio.
  20336. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20337. */
  20338. scale(ratio: number): void;
  20339. /**
  20340. * Get the texture reflection matrix used to rotate/transform the reflection.
  20341. * @returns the reflection matrix
  20342. */
  20343. getReflectionTextureMatrix(): Matrix;
  20344. /**
  20345. * Resize the texture to a new desired size.
  20346. * Be carrefull as it will recreate all the data in the new texture.
  20347. * @param size Define the new size. It can be:
  20348. * - a number for squared texture,
  20349. * - an object containing { width: number, height: number }
  20350. * - or an object containing a ratio { ratio: number }
  20351. */
  20352. resize(size: number | {
  20353. width: number;
  20354. height: number;
  20355. } | {
  20356. ratio: number;
  20357. }): void;
  20358. /**
  20359. * Renders all the objects from the render list into the texture.
  20360. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20361. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20362. */
  20363. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20364. private _bestReflectionRenderTargetDimension;
  20365. /**
  20366. * @hidden
  20367. * @param faceIndex face index to bind to if this is a cubetexture
  20368. */
  20369. _bindFrameBuffer(faceIndex?: number): void;
  20370. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20371. private renderToTarget;
  20372. /**
  20373. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20374. * This allowed control for front to back rendering or reversly depending of the special needs.
  20375. *
  20376. * @param renderingGroupId The rendering group id corresponding to its index
  20377. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20378. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20379. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20380. */
  20381. 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;
  20382. /**
  20383. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20384. *
  20385. * @param renderingGroupId The rendering group id corresponding to its index
  20386. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20387. */
  20388. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20389. /**
  20390. * Clones the texture.
  20391. * @returns the cloned texture
  20392. */
  20393. clone(): RenderTargetTexture;
  20394. /**
  20395. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20396. * @returns The JSON representation of the texture
  20397. */
  20398. serialize(): any;
  20399. /**
  20400. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20401. */
  20402. disposeFramebufferObjects(): void;
  20403. /**
  20404. * Dispose the texture and release its associated resources.
  20405. */
  20406. dispose(): void;
  20407. /** @hidden */
  20408. _rebuild(): void;
  20409. /**
  20410. * Clear the info related to rendering groups preventing retention point in material dispose.
  20411. */
  20412. freeRenderingGroups(): void;
  20413. /**
  20414. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20415. * @returns the view count
  20416. */
  20417. getViewCount(): number;
  20418. }
  20419. }
  20420. declare module "babylonjs/Materials/material" {
  20421. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20422. import { SmartArray } from "babylonjs/Misc/smartArray";
  20423. import { Observable } from "babylonjs/Misc/observable";
  20424. import { Nullable } from "babylonjs/types";
  20425. import { Scene } from "babylonjs/scene";
  20426. import { Matrix } from "babylonjs/Maths/math.vector";
  20427. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20429. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20430. import { Effect } from "babylonjs/Materials/effect";
  20431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20432. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20433. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20434. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20435. import { Mesh } from "babylonjs/Meshes/mesh";
  20436. import { Animation } from "babylonjs/Animations/animation";
  20437. /**
  20438. * Base class for the main features of a material in Babylon.js
  20439. */
  20440. export class Material implements IAnimatable {
  20441. /**
  20442. * Returns the triangle fill mode
  20443. */
  20444. static readonly TriangleFillMode: number;
  20445. /**
  20446. * Returns the wireframe mode
  20447. */
  20448. static readonly WireFrameFillMode: number;
  20449. /**
  20450. * Returns the point fill mode
  20451. */
  20452. static readonly PointFillMode: number;
  20453. /**
  20454. * Returns the point list draw mode
  20455. */
  20456. static readonly PointListDrawMode: number;
  20457. /**
  20458. * Returns the line list draw mode
  20459. */
  20460. static readonly LineListDrawMode: number;
  20461. /**
  20462. * Returns the line loop draw mode
  20463. */
  20464. static readonly LineLoopDrawMode: number;
  20465. /**
  20466. * Returns the line strip draw mode
  20467. */
  20468. static readonly LineStripDrawMode: number;
  20469. /**
  20470. * Returns the triangle strip draw mode
  20471. */
  20472. static readonly TriangleStripDrawMode: number;
  20473. /**
  20474. * Returns the triangle fan draw mode
  20475. */
  20476. static readonly TriangleFanDrawMode: number;
  20477. /**
  20478. * Stores the clock-wise side orientation
  20479. */
  20480. static readonly ClockWiseSideOrientation: number;
  20481. /**
  20482. * Stores the counter clock-wise side orientation
  20483. */
  20484. static readonly CounterClockWiseSideOrientation: number;
  20485. /**
  20486. * The dirty texture flag value
  20487. */
  20488. static readonly TextureDirtyFlag: number;
  20489. /**
  20490. * The dirty light flag value
  20491. */
  20492. static readonly LightDirtyFlag: number;
  20493. /**
  20494. * The dirty fresnel flag value
  20495. */
  20496. static readonly FresnelDirtyFlag: number;
  20497. /**
  20498. * The dirty attribute flag value
  20499. */
  20500. static readonly AttributesDirtyFlag: number;
  20501. /**
  20502. * The dirty misc flag value
  20503. */
  20504. static readonly MiscDirtyFlag: number;
  20505. /**
  20506. * The all dirty flag value
  20507. */
  20508. static readonly AllDirtyFlag: number;
  20509. /**
  20510. * The ID of the material
  20511. */
  20512. id: string;
  20513. /**
  20514. * Gets or sets the unique id of the material
  20515. */
  20516. uniqueId: number;
  20517. /**
  20518. * The name of the material
  20519. */
  20520. name: string;
  20521. /**
  20522. * Gets or sets user defined metadata
  20523. */
  20524. metadata: any;
  20525. /**
  20526. * For internal use only. Please do not use.
  20527. */
  20528. reservedDataStore: any;
  20529. /**
  20530. * Specifies if the ready state should be checked on each call
  20531. */
  20532. checkReadyOnEveryCall: boolean;
  20533. /**
  20534. * Specifies if the ready state should be checked once
  20535. */
  20536. checkReadyOnlyOnce: boolean;
  20537. /**
  20538. * The state of the material
  20539. */
  20540. state: string;
  20541. /**
  20542. * The alpha value of the material
  20543. */
  20544. protected _alpha: number;
  20545. /**
  20546. * List of inspectable custom properties (used by the Inspector)
  20547. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20548. */
  20549. inspectableCustomProperties: IInspectable[];
  20550. /**
  20551. * Sets the alpha value of the material
  20552. */
  20553. /**
  20554. * Gets the alpha value of the material
  20555. */
  20556. alpha: number;
  20557. /**
  20558. * Specifies if back face culling is enabled
  20559. */
  20560. protected _backFaceCulling: boolean;
  20561. /**
  20562. * Sets the back-face culling state
  20563. */
  20564. /**
  20565. * Gets the back-face culling state
  20566. */
  20567. backFaceCulling: boolean;
  20568. /**
  20569. * Stores the value for side orientation
  20570. */
  20571. sideOrientation: number;
  20572. /**
  20573. * Callback triggered when the material is compiled
  20574. */
  20575. onCompiled: Nullable<(effect: Effect) => void>;
  20576. /**
  20577. * Callback triggered when an error occurs
  20578. */
  20579. onError: Nullable<(effect: Effect, errors: string) => void>;
  20580. /**
  20581. * Callback triggered to get the render target textures
  20582. */
  20583. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20584. /**
  20585. * Gets a boolean indicating that current material needs to register RTT
  20586. */
  20587. readonly hasRenderTargetTextures: boolean;
  20588. /**
  20589. * Specifies if the material should be serialized
  20590. */
  20591. doNotSerialize: boolean;
  20592. /**
  20593. * @hidden
  20594. */
  20595. _storeEffectOnSubMeshes: boolean;
  20596. /**
  20597. * Stores the animations for the material
  20598. */
  20599. animations: Nullable<Array<Animation>>;
  20600. /**
  20601. * An event triggered when the material is disposed
  20602. */
  20603. onDisposeObservable: Observable<Material>;
  20604. /**
  20605. * An observer which watches for dispose events
  20606. */
  20607. private _onDisposeObserver;
  20608. private _onUnBindObservable;
  20609. /**
  20610. * Called during a dispose event
  20611. */
  20612. onDispose: () => void;
  20613. private _onBindObservable;
  20614. /**
  20615. * An event triggered when the material is bound
  20616. */
  20617. readonly onBindObservable: Observable<AbstractMesh>;
  20618. /**
  20619. * An observer which watches for bind events
  20620. */
  20621. private _onBindObserver;
  20622. /**
  20623. * Called during a bind event
  20624. */
  20625. onBind: (Mesh: AbstractMesh) => void;
  20626. /**
  20627. * An event triggered when the material is unbound
  20628. */
  20629. readonly onUnBindObservable: Observable<Material>;
  20630. /**
  20631. * Stores the value of the alpha mode
  20632. */
  20633. private _alphaMode;
  20634. /**
  20635. * Sets the value of the alpha mode.
  20636. *
  20637. * | Value | Type | Description |
  20638. * | --- | --- | --- |
  20639. * | 0 | ALPHA_DISABLE | |
  20640. * | 1 | ALPHA_ADD | |
  20641. * | 2 | ALPHA_COMBINE | |
  20642. * | 3 | ALPHA_SUBTRACT | |
  20643. * | 4 | ALPHA_MULTIPLY | |
  20644. * | 5 | ALPHA_MAXIMIZED | |
  20645. * | 6 | ALPHA_ONEONE | |
  20646. * | 7 | ALPHA_PREMULTIPLIED | |
  20647. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20648. * | 9 | ALPHA_INTERPOLATE | |
  20649. * | 10 | ALPHA_SCREENMODE | |
  20650. *
  20651. */
  20652. /**
  20653. * Gets the value of the alpha mode
  20654. */
  20655. alphaMode: number;
  20656. /**
  20657. * Stores the state of the need depth pre-pass value
  20658. */
  20659. private _needDepthPrePass;
  20660. /**
  20661. * Sets the need depth pre-pass value
  20662. */
  20663. /**
  20664. * Gets the depth pre-pass value
  20665. */
  20666. needDepthPrePass: boolean;
  20667. /**
  20668. * Specifies if depth writing should be disabled
  20669. */
  20670. disableDepthWrite: boolean;
  20671. /**
  20672. * Specifies if depth writing should be forced
  20673. */
  20674. forceDepthWrite: boolean;
  20675. /**
  20676. * Specifies if there should be a separate pass for culling
  20677. */
  20678. separateCullingPass: boolean;
  20679. /**
  20680. * Stores the state specifing if fog should be enabled
  20681. */
  20682. private _fogEnabled;
  20683. /**
  20684. * Sets the state for enabling fog
  20685. */
  20686. /**
  20687. * Gets the value of the fog enabled state
  20688. */
  20689. fogEnabled: boolean;
  20690. /**
  20691. * Stores the size of points
  20692. */
  20693. pointSize: number;
  20694. /**
  20695. * Stores the z offset value
  20696. */
  20697. zOffset: number;
  20698. /**
  20699. * Gets a value specifying if wireframe mode is enabled
  20700. */
  20701. /**
  20702. * Sets the state of wireframe mode
  20703. */
  20704. wireframe: boolean;
  20705. /**
  20706. * Gets the value specifying if point clouds are enabled
  20707. */
  20708. /**
  20709. * Sets the state of point cloud mode
  20710. */
  20711. pointsCloud: boolean;
  20712. /**
  20713. * Gets the material fill mode
  20714. */
  20715. /**
  20716. * Sets the material fill mode
  20717. */
  20718. fillMode: number;
  20719. /**
  20720. * @hidden
  20721. * Stores the effects for the material
  20722. */
  20723. _effect: Nullable<Effect>;
  20724. /**
  20725. * @hidden
  20726. * Specifies if the material was previously ready
  20727. */
  20728. _wasPreviouslyReady: boolean;
  20729. /**
  20730. * Specifies if uniform buffers should be used
  20731. */
  20732. private _useUBO;
  20733. /**
  20734. * Stores a reference to the scene
  20735. */
  20736. private _scene;
  20737. /**
  20738. * Stores the fill mode state
  20739. */
  20740. private _fillMode;
  20741. /**
  20742. * Specifies if the depth write state should be cached
  20743. */
  20744. private _cachedDepthWriteState;
  20745. /**
  20746. * Stores the uniform buffer
  20747. */
  20748. protected _uniformBuffer: UniformBuffer;
  20749. /** @hidden */
  20750. _indexInSceneMaterialArray: number;
  20751. /** @hidden */
  20752. meshMap: Nullable<{
  20753. [id: string]: AbstractMesh | undefined;
  20754. }>;
  20755. /**
  20756. * Creates a material instance
  20757. * @param name defines the name of the material
  20758. * @param scene defines the scene to reference
  20759. * @param doNotAdd specifies if the material should be added to the scene
  20760. */
  20761. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20762. /**
  20763. * Returns a string representation of the current material
  20764. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20765. * @returns a string with material information
  20766. */
  20767. toString(fullDetails?: boolean): string;
  20768. /**
  20769. * Gets the class name of the material
  20770. * @returns a string with the class name of the material
  20771. */
  20772. getClassName(): string;
  20773. /**
  20774. * Specifies if updates for the material been locked
  20775. */
  20776. readonly isFrozen: boolean;
  20777. /**
  20778. * Locks updates for the material
  20779. */
  20780. freeze(): void;
  20781. /**
  20782. * Unlocks updates for the material
  20783. */
  20784. unfreeze(): void;
  20785. /**
  20786. * Specifies if the material is ready to be used
  20787. * @param mesh defines the mesh to check
  20788. * @param useInstances specifies if instances should be used
  20789. * @returns a boolean indicating if the material is ready to be used
  20790. */
  20791. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20792. /**
  20793. * Specifies that the submesh is ready to be used
  20794. * @param mesh defines the mesh to check
  20795. * @param subMesh defines which submesh to check
  20796. * @param useInstances specifies that instances should be used
  20797. * @returns a boolean indicating that the submesh is ready or not
  20798. */
  20799. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20800. /**
  20801. * Returns the material effect
  20802. * @returns the effect associated with the material
  20803. */
  20804. getEffect(): Nullable<Effect>;
  20805. /**
  20806. * Returns the current scene
  20807. * @returns a Scene
  20808. */
  20809. getScene(): Scene;
  20810. /**
  20811. * Specifies if the material will require alpha blending
  20812. * @returns a boolean specifying if alpha blending is needed
  20813. */
  20814. needAlphaBlending(): boolean;
  20815. /**
  20816. * Specifies if the mesh will require alpha blending
  20817. * @param mesh defines the mesh to check
  20818. * @returns a boolean specifying if alpha blending is needed for the mesh
  20819. */
  20820. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20821. /**
  20822. * Specifies if this material should be rendered in alpha test mode
  20823. * @returns a boolean specifying if an alpha test is needed.
  20824. */
  20825. needAlphaTesting(): boolean;
  20826. /**
  20827. * Gets the texture used for the alpha test
  20828. * @returns the texture to use for alpha testing
  20829. */
  20830. getAlphaTestTexture(): Nullable<BaseTexture>;
  20831. /**
  20832. * Marks the material to indicate that it needs to be re-calculated
  20833. */
  20834. markDirty(): void;
  20835. /** @hidden */
  20836. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20837. /**
  20838. * Binds the material to the mesh
  20839. * @param world defines the world transformation matrix
  20840. * @param mesh defines the mesh to bind the material to
  20841. */
  20842. bind(world: Matrix, mesh?: Mesh): void;
  20843. /**
  20844. * Binds the submesh to the material
  20845. * @param world defines the world transformation matrix
  20846. * @param mesh defines the mesh containing the submesh
  20847. * @param subMesh defines the submesh to bind the material to
  20848. */
  20849. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20850. /**
  20851. * Binds the world matrix to the material
  20852. * @param world defines the world transformation matrix
  20853. */
  20854. bindOnlyWorldMatrix(world: Matrix): void;
  20855. /**
  20856. * Binds the scene's uniform buffer to the effect.
  20857. * @param effect defines the effect to bind to the scene uniform buffer
  20858. * @param sceneUbo defines the uniform buffer storing scene data
  20859. */
  20860. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20861. /**
  20862. * Binds the view matrix to the effect
  20863. * @param effect defines the effect to bind the view matrix to
  20864. */
  20865. bindView(effect: Effect): void;
  20866. /**
  20867. * Binds the view projection matrix to the effect
  20868. * @param effect defines the effect to bind the view projection matrix to
  20869. */
  20870. bindViewProjection(effect: Effect): void;
  20871. /**
  20872. * Specifies if material alpha testing should be turned on for the mesh
  20873. * @param mesh defines the mesh to check
  20874. */
  20875. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20876. /**
  20877. * Processes to execute after binding the material to a mesh
  20878. * @param mesh defines the rendered mesh
  20879. */
  20880. protected _afterBind(mesh?: Mesh): void;
  20881. /**
  20882. * Unbinds the material from the mesh
  20883. */
  20884. unbind(): void;
  20885. /**
  20886. * Gets the active textures from the material
  20887. * @returns an array of textures
  20888. */
  20889. getActiveTextures(): BaseTexture[];
  20890. /**
  20891. * Specifies if the material uses a texture
  20892. * @param texture defines the texture to check against the material
  20893. * @returns a boolean specifying if the material uses the texture
  20894. */
  20895. hasTexture(texture: BaseTexture): boolean;
  20896. /**
  20897. * Makes a duplicate of the material, and gives it a new name
  20898. * @param name defines the new name for the duplicated material
  20899. * @returns the cloned material
  20900. */
  20901. clone(name: string): Nullable<Material>;
  20902. /**
  20903. * Gets the meshes bound to the material
  20904. * @returns an array of meshes bound to the material
  20905. */
  20906. getBindedMeshes(): AbstractMesh[];
  20907. /**
  20908. * Force shader compilation
  20909. * @param mesh defines the mesh associated with this material
  20910. * @param onCompiled defines a function to execute once the material is compiled
  20911. * @param options defines the options to configure the compilation
  20912. */
  20913. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20914. clipPlane: boolean;
  20915. }>): void;
  20916. /**
  20917. * Force shader compilation
  20918. * @param mesh defines the mesh that will use this material
  20919. * @param options defines additional options for compiling the shaders
  20920. * @returns a promise that resolves when the compilation completes
  20921. */
  20922. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20923. clipPlane: boolean;
  20924. }>): Promise<void>;
  20925. private static readonly _AllDirtyCallBack;
  20926. private static readonly _ImageProcessingDirtyCallBack;
  20927. private static readonly _TextureDirtyCallBack;
  20928. private static readonly _FresnelDirtyCallBack;
  20929. private static readonly _MiscDirtyCallBack;
  20930. private static readonly _LightsDirtyCallBack;
  20931. private static readonly _AttributeDirtyCallBack;
  20932. private static _FresnelAndMiscDirtyCallBack;
  20933. private static _TextureAndMiscDirtyCallBack;
  20934. private static readonly _DirtyCallbackArray;
  20935. private static readonly _RunDirtyCallBacks;
  20936. /**
  20937. * Marks a define in the material to indicate that it needs to be re-computed
  20938. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20939. */
  20940. markAsDirty(flag: number): void;
  20941. /**
  20942. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20943. * @param func defines a function which checks material defines against the submeshes
  20944. */
  20945. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20946. /**
  20947. * Indicates that we need to re-calculated for all submeshes
  20948. */
  20949. protected _markAllSubMeshesAsAllDirty(): void;
  20950. /**
  20951. * Indicates that image processing needs to be re-calculated for all submeshes
  20952. */
  20953. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20954. /**
  20955. * Indicates that textures need to be re-calculated for all submeshes
  20956. */
  20957. protected _markAllSubMeshesAsTexturesDirty(): void;
  20958. /**
  20959. * Indicates that fresnel needs to be re-calculated for all submeshes
  20960. */
  20961. protected _markAllSubMeshesAsFresnelDirty(): void;
  20962. /**
  20963. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20964. */
  20965. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20966. /**
  20967. * Indicates that lights need to be re-calculated for all submeshes
  20968. */
  20969. protected _markAllSubMeshesAsLightsDirty(): void;
  20970. /**
  20971. * Indicates that attributes need to be re-calculated for all submeshes
  20972. */
  20973. protected _markAllSubMeshesAsAttributesDirty(): void;
  20974. /**
  20975. * Indicates that misc needs to be re-calculated for all submeshes
  20976. */
  20977. protected _markAllSubMeshesAsMiscDirty(): void;
  20978. /**
  20979. * Indicates that textures and misc need to be re-calculated for all submeshes
  20980. */
  20981. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20982. /**
  20983. * Disposes the material
  20984. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20985. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20986. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20987. */
  20988. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20989. /** @hidden */
  20990. private releaseVertexArrayObject;
  20991. /**
  20992. * Serializes this material
  20993. * @returns the serialized material object
  20994. */
  20995. serialize(): any;
  20996. /**
  20997. * Creates a material from parsed material data
  20998. * @param parsedMaterial defines parsed material data
  20999. * @param scene defines the hosting scene
  21000. * @param rootUrl defines the root URL to use to load textures
  21001. * @returns a new material
  21002. */
  21003. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21004. }
  21005. }
  21006. declare module "babylonjs/Materials/multiMaterial" {
  21007. import { Nullable } from "babylonjs/types";
  21008. import { Scene } from "babylonjs/scene";
  21009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21010. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21012. import { Material } from "babylonjs/Materials/material";
  21013. /**
  21014. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21015. * separate meshes. This can be use to improve performances.
  21016. * @see http://doc.babylonjs.com/how_to/multi_materials
  21017. */
  21018. export class MultiMaterial extends Material {
  21019. private _subMaterials;
  21020. /**
  21021. * Gets or Sets the list of Materials used within the multi material.
  21022. * They need to be ordered according to the submeshes order in the associated mesh
  21023. */
  21024. subMaterials: Nullable<Material>[];
  21025. /**
  21026. * Function used to align with Node.getChildren()
  21027. * @returns the list of Materials used within the multi material
  21028. */
  21029. getChildren(): Nullable<Material>[];
  21030. /**
  21031. * Instantiates a new Multi Material
  21032. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21033. * separate meshes. This can be use to improve performances.
  21034. * @see http://doc.babylonjs.com/how_to/multi_materials
  21035. * @param name Define the name in the scene
  21036. * @param scene Define the scene the material belongs to
  21037. */
  21038. constructor(name: string, scene: Scene);
  21039. private _hookArray;
  21040. /**
  21041. * Get one of the submaterial by its index in the submaterials array
  21042. * @param index The index to look the sub material at
  21043. * @returns The Material if the index has been defined
  21044. */
  21045. getSubMaterial(index: number): Nullable<Material>;
  21046. /**
  21047. * Get the list of active textures for the whole sub materials list.
  21048. * @returns All the textures that will be used during the rendering
  21049. */
  21050. getActiveTextures(): BaseTexture[];
  21051. /**
  21052. * Gets the current class name of the material e.g. "MultiMaterial"
  21053. * Mainly use in serialization.
  21054. * @returns the class name
  21055. */
  21056. getClassName(): string;
  21057. /**
  21058. * Checks if the material is ready to render the requested sub mesh
  21059. * @param mesh Define the mesh the submesh belongs to
  21060. * @param subMesh Define the sub mesh to look readyness for
  21061. * @param useInstances Define whether or not the material is used with instances
  21062. * @returns true if ready, otherwise false
  21063. */
  21064. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21065. /**
  21066. * Clones the current material and its related sub materials
  21067. * @param name Define the name of the newly cloned material
  21068. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21069. * @returns the cloned material
  21070. */
  21071. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21072. /**
  21073. * Serializes the materials into a JSON representation.
  21074. * @returns the JSON representation
  21075. */
  21076. serialize(): any;
  21077. /**
  21078. * Dispose the material and release its associated resources
  21079. * @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)
  21080. * @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)
  21081. * @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)
  21082. */
  21083. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21084. /**
  21085. * Creates a MultiMaterial from parsed MultiMaterial data.
  21086. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21087. * @param scene defines the hosting scene
  21088. * @returns a new MultiMaterial
  21089. */
  21090. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21091. }
  21092. }
  21093. declare module "babylonjs/Meshes/subMesh" {
  21094. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21095. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21096. import { Engine } from "babylonjs/Engines/engine";
  21097. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21098. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21099. import { Effect } from "babylonjs/Materials/effect";
  21100. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21101. import { Plane } from "babylonjs/Maths/math.plane";
  21102. import { Collider } from "babylonjs/Collisions/collider";
  21103. import { Material } from "babylonjs/Materials/material";
  21104. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21106. import { Mesh } from "babylonjs/Meshes/mesh";
  21107. import { Ray } from "babylonjs/Culling/ray";
  21108. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21109. /**
  21110. * Base class for submeshes
  21111. */
  21112. export class BaseSubMesh {
  21113. /** @hidden */
  21114. _materialDefines: Nullable<MaterialDefines>;
  21115. /** @hidden */
  21116. _materialEffect: Nullable<Effect>;
  21117. /**
  21118. * Gets associated effect
  21119. */
  21120. readonly effect: Nullable<Effect>;
  21121. /**
  21122. * Sets associated effect (effect used to render this submesh)
  21123. * @param effect defines the effect to associate with
  21124. * @param defines defines the set of defines used to compile this effect
  21125. */
  21126. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21127. }
  21128. /**
  21129. * Defines a subdivision inside a mesh
  21130. */
  21131. export class SubMesh extends BaseSubMesh implements ICullable {
  21132. /** the material index to use */
  21133. materialIndex: number;
  21134. /** vertex index start */
  21135. verticesStart: number;
  21136. /** vertices count */
  21137. verticesCount: number;
  21138. /** index start */
  21139. indexStart: number;
  21140. /** indices count */
  21141. indexCount: number;
  21142. /** @hidden */
  21143. _linesIndexCount: number;
  21144. private _mesh;
  21145. private _renderingMesh;
  21146. private _boundingInfo;
  21147. private _linesIndexBuffer;
  21148. /** @hidden */
  21149. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21150. /** @hidden */
  21151. _trianglePlanes: Plane[];
  21152. /** @hidden */
  21153. _lastColliderTransformMatrix: Nullable<Matrix>;
  21154. /** @hidden */
  21155. _renderId: number;
  21156. /** @hidden */
  21157. _alphaIndex: number;
  21158. /** @hidden */
  21159. _distanceToCamera: number;
  21160. /** @hidden */
  21161. _id: number;
  21162. private _currentMaterial;
  21163. /**
  21164. * Add a new submesh to a mesh
  21165. * @param materialIndex defines the material index to use
  21166. * @param verticesStart defines vertex index start
  21167. * @param verticesCount defines vertices count
  21168. * @param indexStart defines index start
  21169. * @param indexCount defines indices count
  21170. * @param mesh defines the parent mesh
  21171. * @param renderingMesh defines an optional rendering mesh
  21172. * @param createBoundingBox defines if bounding box should be created for this submesh
  21173. * @returns the new submesh
  21174. */
  21175. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21176. /**
  21177. * Creates a new submesh
  21178. * @param materialIndex defines the material index to use
  21179. * @param verticesStart defines vertex index start
  21180. * @param verticesCount defines vertices count
  21181. * @param indexStart defines index start
  21182. * @param indexCount defines indices count
  21183. * @param mesh defines the parent mesh
  21184. * @param renderingMesh defines an optional rendering mesh
  21185. * @param createBoundingBox defines if bounding box should be created for this submesh
  21186. */
  21187. constructor(
  21188. /** the material index to use */
  21189. materialIndex: number,
  21190. /** vertex index start */
  21191. verticesStart: number,
  21192. /** vertices count */
  21193. verticesCount: number,
  21194. /** index start */
  21195. indexStart: number,
  21196. /** indices count */
  21197. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21198. /**
  21199. * Returns true if this submesh covers the entire parent mesh
  21200. * @ignorenaming
  21201. */
  21202. readonly IsGlobal: boolean;
  21203. /**
  21204. * Returns the submesh BoudingInfo object
  21205. * @returns current bounding info (or mesh's one if the submesh is global)
  21206. */
  21207. getBoundingInfo(): BoundingInfo;
  21208. /**
  21209. * Sets the submesh BoundingInfo
  21210. * @param boundingInfo defines the new bounding info to use
  21211. * @returns the SubMesh
  21212. */
  21213. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21214. /**
  21215. * Returns the mesh of the current submesh
  21216. * @return the parent mesh
  21217. */
  21218. getMesh(): AbstractMesh;
  21219. /**
  21220. * Returns the rendering mesh of the submesh
  21221. * @returns the rendering mesh (could be different from parent mesh)
  21222. */
  21223. getRenderingMesh(): Mesh;
  21224. /**
  21225. * Returns the submesh material
  21226. * @returns null or the current material
  21227. */
  21228. getMaterial(): Nullable<Material>;
  21229. /**
  21230. * Sets a new updated BoundingInfo object to the submesh
  21231. * @param data defines an optional position array to use to determine the bounding info
  21232. * @returns the SubMesh
  21233. */
  21234. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21235. /** @hidden */
  21236. _checkCollision(collider: Collider): boolean;
  21237. /**
  21238. * Updates the submesh BoundingInfo
  21239. * @param world defines the world matrix to use to update the bounding info
  21240. * @returns the submesh
  21241. */
  21242. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21243. /**
  21244. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21245. * @param frustumPlanes defines the frustum planes
  21246. * @returns true if the submesh is intersecting with the frustum
  21247. */
  21248. isInFrustum(frustumPlanes: Plane[]): boolean;
  21249. /**
  21250. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21251. * @param frustumPlanes defines the frustum planes
  21252. * @returns true if the submesh is inside the frustum
  21253. */
  21254. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21255. /**
  21256. * Renders the submesh
  21257. * @param enableAlphaMode defines if alpha needs to be used
  21258. * @returns the submesh
  21259. */
  21260. render(enableAlphaMode: boolean): SubMesh;
  21261. /**
  21262. * @hidden
  21263. */
  21264. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21265. /**
  21266. * Checks if the submesh intersects with a ray
  21267. * @param ray defines the ray to test
  21268. * @returns true is the passed ray intersects the submesh bounding box
  21269. */
  21270. canIntersects(ray: Ray): boolean;
  21271. /**
  21272. * Intersects current submesh with a ray
  21273. * @param ray defines the ray to test
  21274. * @param positions defines mesh's positions array
  21275. * @param indices defines mesh's indices array
  21276. * @param fastCheck defines if only bounding info should be used
  21277. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21278. * @returns intersection info or null if no intersection
  21279. */
  21280. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21281. /** @hidden */
  21282. private _intersectLines;
  21283. /** @hidden */
  21284. private _intersectUnIndexedLines;
  21285. /** @hidden */
  21286. private _intersectTriangles;
  21287. /** @hidden */
  21288. private _intersectUnIndexedTriangles;
  21289. /** @hidden */
  21290. _rebuild(): void;
  21291. /**
  21292. * Creates a new submesh from the passed mesh
  21293. * @param newMesh defines the new hosting mesh
  21294. * @param newRenderingMesh defines an optional rendering mesh
  21295. * @returns the new submesh
  21296. */
  21297. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21298. /**
  21299. * Release associated resources
  21300. */
  21301. dispose(): void;
  21302. /**
  21303. * Gets the class name
  21304. * @returns the string "SubMesh".
  21305. */
  21306. getClassName(): string;
  21307. /**
  21308. * Creates a new submesh from indices data
  21309. * @param materialIndex the index of the main mesh material
  21310. * @param startIndex the index where to start the copy in the mesh indices array
  21311. * @param indexCount the number of indices to copy then from the startIndex
  21312. * @param mesh the main mesh to create the submesh from
  21313. * @param renderingMesh the optional rendering mesh
  21314. * @returns a new submesh
  21315. */
  21316. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21317. }
  21318. }
  21319. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21320. /**
  21321. * Class used to represent data loading progression
  21322. */
  21323. export class SceneLoaderFlags {
  21324. private static _ForceFullSceneLoadingForIncremental;
  21325. private static _ShowLoadingScreen;
  21326. private static _CleanBoneMatrixWeights;
  21327. private static _loggingLevel;
  21328. /**
  21329. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21330. */
  21331. static ForceFullSceneLoadingForIncremental: boolean;
  21332. /**
  21333. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21334. */
  21335. static ShowLoadingScreen: boolean;
  21336. /**
  21337. * Defines the current logging level (while loading the scene)
  21338. * @ignorenaming
  21339. */
  21340. static loggingLevel: number;
  21341. /**
  21342. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21343. */
  21344. static CleanBoneMatrixWeights: boolean;
  21345. }
  21346. }
  21347. declare module "babylonjs/Meshes/geometry" {
  21348. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21349. import { Scene } from "babylonjs/scene";
  21350. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21351. import { Engine } from "babylonjs/Engines/engine";
  21352. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21353. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21354. import { Effect } from "babylonjs/Materials/effect";
  21355. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21356. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21357. import { Mesh } from "babylonjs/Meshes/mesh";
  21358. /**
  21359. * Class used to store geometry data (vertex buffers + index buffer)
  21360. */
  21361. export class Geometry implements IGetSetVerticesData {
  21362. /**
  21363. * Gets or sets the ID of the geometry
  21364. */
  21365. id: string;
  21366. /**
  21367. * Gets or sets the unique ID of the geometry
  21368. */
  21369. uniqueId: number;
  21370. /**
  21371. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21372. */
  21373. delayLoadState: number;
  21374. /**
  21375. * Gets the file containing the data to load when running in delay load state
  21376. */
  21377. delayLoadingFile: Nullable<string>;
  21378. /**
  21379. * Callback called when the geometry is updated
  21380. */
  21381. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21382. private _scene;
  21383. private _engine;
  21384. private _meshes;
  21385. private _totalVertices;
  21386. /** @hidden */
  21387. _indices: IndicesArray;
  21388. /** @hidden */
  21389. _vertexBuffers: {
  21390. [key: string]: VertexBuffer;
  21391. };
  21392. private _isDisposed;
  21393. private _extend;
  21394. private _boundingBias;
  21395. /** @hidden */
  21396. _delayInfo: Array<string>;
  21397. private _indexBuffer;
  21398. private _indexBufferIsUpdatable;
  21399. /** @hidden */
  21400. _boundingInfo: Nullable<BoundingInfo>;
  21401. /** @hidden */
  21402. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21403. /** @hidden */
  21404. _softwareSkinningFrameId: number;
  21405. private _vertexArrayObjects;
  21406. private _updatable;
  21407. /** @hidden */
  21408. _positions: Nullable<Vector3[]>;
  21409. /**
  21410. * 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
  21411. */
  21412. /**
  21413. * 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
  21414. */
  21415. boundingBias: Vector2;
  21416. /**
  21417. * Static function used to attach a new empty geometry to a mesh
  21418. * @param mesh defines the mesh to attach the geometry to
  21419. * @returns the new Geometry
  21420. */
  21421. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21422. /**
  21423. * Creates a new geometry
  21424. * @param id defines the unique ID
  21425. * @param scene defines the hosting scene
  21426. * @param vertexData defines the VertexData used to get geometry data
  21427. * @param updatable defines if geometry must be updatable (false by default)
  21428. * @param mesh defines the mesh that will be associated with the geometry
  21429. */
  21430. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21431. /**
  21432. * Gets the current extend of the geometry
  21433. */
  21434. readonly extend: {
  21435. minimum: Vector3;
  21436. maximum: Vector3;
  21437. };
  21438. /**
  21439. * Gets the hosting scene
  21440. * @returns the hosting Scene
  21441. */
  21442. getScene(): Scene;
  21443. /**
  21444. * Gets the hosting engine
  21445. * @returns the hosting Engine
  21446. */
  21447. getEngine(): Engine;
  21448. /**
  21449. * Defines if the geometry is ready to use
  21450. * @returns true if the geometry is ready to be used
  21451. */
  21452. isReady(): boolean;
  21453. /**
  21454. * Gets a value indicating that the geometry should not be serialized
  21455. */
  21456. readonly doNotSerialize: boolean;
  21457. /** @hidden */
  21458. _rebuild(): void;
  21459. /**
  21460. * Affects all geometry data in one call
  21461. * @param vertexData defines the geometry data
  21462. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21463. */
  21464. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21465. /**
  21466. * Set specific vertex data
  21467. * @param kind defines the data kind (Position, normal, etc...)
  21468. * @param data defines the vertex data to use
  21469. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21470. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21471. */
  21472. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21473. /**
  21474. * Removes a specific vertex data
  21475. * @param kind defines the data kind (Position, normal, etc...)
  21476. */
  21477. removeVerticesData(kind: string): void;
  21478. /**
  21479. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21480. * @param buffer defines the vertex buffer to use
  21481. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21482. */
  21483. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21484. /**
  21485. * Update a specific vertex buffer
  21486. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21487. * It will do nothing if the buffer is not updatable
  21488. * @param kind defines the data kind (Position, normal, etc...)
  21489. * @param data defines the data to use
  21490. * @param offset defines the offset in the target buffer where to store the data
  21491. * @param useBytes set to true if the offset is in bytes
  21492. */
  21493. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21494. /**
  21495. * Update a specific vertex buffer
  21496. * This function will create a new buffer if the current one is not updatable
  21497. * @param kind defines the data kind (Position, normal, etc...)
  21498. * @param data defines the data to use
  21499. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21500. */
  21501. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21502. private _updateBoundingInfo;
  21503. /** @hidden */
  21504. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21505. /**
  21506. * Gets total number of vertices
  21507. * @returns the total number of vertices
  21508. */
  21509. getTotalVertices(): number;
  21510. /**
  21511. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21512. * @param kind defines the data kind (Position, normal, etc...)
  21513. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21514. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21515. * @returns a float array containing vertex data
  21516. */
  21517. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21518. /**
  21519. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21520. * @param kind defines the data kind (Position, normal, etc...)
  21521. * @returns true if the vertex buffer with the specified kind is updatable
  21522. */
  21523. isVertexBufferUpdatable(kind: string): boolean;
  21524. /**
  21525. * Gets a specific vertex buffer
  21526. * @param kind defines the data kind (Position, normal, etc...)
  21527. * @returns a VertexBuffer
  21528. */
  21529. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21530. /**
  21531. * Returns all vertex buffers
  21532. * @return an object holding all vertex buffers indexed by kind
  21533. */
  21534. getVertexBuffers(): Nullable<{
  21535. [key: string]: VertexBuffer;
  21536. }>;
  21537. /**
  21538. * Gets a boolean indicating if specific vertex buffer is present
  21539. * @param kind defines the data kind (Position, normal, etc...)
  21540. * @returns true if data is present
  21541. */
  21542. isVerticesDataPresent(kind: string): boolean;
  21543. /**
  21544. * Gets a list of all attached data kinds (Position, normal, etc...)
  21545. * @returns a list of string containing all kinds
  21546. */
  21547. getVerticesDataKinds(): string[];
  21548. /**
  21549. * Update index buffer
  21550. * @param indices defines the indices to store in the index buffer
  21551. * @param offset defines the offset in the target buffer where to store the data
  21552. * @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)
  21553. */
  21554. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21555. /**
  21556. * Creates a new index buffer
  21557. * @param indices defines the indices to store in the index buffer
  21558. * @param totalVertices defines the total number of vertices (could be null)
  21559. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21560. */
  21561. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21562. /**
  21563. * Return the total number of indices
  21564. * @returns the total number of indices
  21565. */
  21566. getTotalIndices(): number;
  21567. /**
  21568. * Gets the index buffer array
  21569. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21570. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21571. * @returns the index buffer array
  21572. */
  21573. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21574. /**
  21575. * Gets the index buffer
  21576. * @return the index buffer
  21577. */
  21578. getIndexBuffer(): Nullable<DataBuffer>;
  21579. /** @hidden */
  21580. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21581. /**
  21582. * Release the associated resources for a specific mesh
  21583. * @param mesh defines the source mesh
  21584. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21585. */
  21586. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21587. /**
  21588. * Apply current geometry to a given mesh
  21589. * @param mesh defines the mesh to apply geometry to
  21590. */
  21591. applyToMesh(mesh: Mesh): void;
  21592. private _updateExtend;
  21593. private _applyToMesh;
  21594. private notifyUpdate;
  21595. /**
  21596. * Load the geometry if it was flagged as delay loaded
  21597. * @param scene defines the hosting scene
  21598. * @param onLoaded defines a callback called when the geometry is loaded
  21599. */
  21600. load(scene: Scene, onLoaded?: () => void): void;
  21601. private _queueLoad;
  21602. /**
  21603. * Invert the geometry to move from a right handed system to a left handed one.
  21604. */
  21605. toLeftHanded(): void;
  21606. /** @hidden */
  21607. _resetPointsArrayCache(): void;
  21608. /** @hidden */
  21609. _generatePointsArray(): boolean;
  21610. /**
  21611. * Gets a value indicating if the geometry is disposed
  21612. * @returns true if the geometry was disposed
  21613. */
  21614. isDisposed(): boolean;
  21615. private _disposeVertexArrayObjects;
  21616. /**
  21617. * Free all associated resources
  21618. */
  21619. dispose(): void;
  21620. /**
  21621. * Clone the current geometry into a new geometry
  21622. * @param id defines the unique ID of the new geometry
  21623. * @returns a new geometry object
  21624. */
  21625. copy(id: string): Geometry;
  21626. /**
  21627. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21628. * @return a JSON representation of the current geometry data (without the vertices data)
  21629. */
  21630. serialize(): any;
  21631. private toNumberArray;
  21632. /**
  21633. * Serialize all vertices data into a JSON oject
  21634. * @returns a JSON representation of the current geometry data
  21635. */
  21636. serializeVerticeData(): any;
  21637. /**
  21638. * Extracts a clone of a mesh geometry
  21639. * @param mesh defines the source mesh
  21640. * @param id defines the unique ID of the new geometry object
  21641. * @returns the new geometry object
  21642. */
  21643. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21644. /**
  21645. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21646. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21647. * Be aware Math.random() could cause collisions, but:
  21648. * "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"
  21649. * @returns a string containing a new GUID
  21650. */
  21651. static RandomId(): string;
  21652. /** @hidden */
  21653. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21654. private static _CleanMatricesWeights;
  21655. /**
  21656. * Create a new geometry from persisted data (Using .babylon file format)
  21657. * @param parsedVertexData defines the persisted data
  21658. * @param scene defines the hosting scene
  21659. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21660. * @returns the new geometry object
  21661. */
  21662. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21663. }
  21664. }
  21665. declare module "babylonjs/Meshes/mesh.vertexData" {
  21666. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21667. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21668. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21669. import { Geometry } from "babylonjs/Meshes/geometry";
  21670. import { Mesh } from "babylonjs/Meshes/mesh";
  21671. /**
  21672. * Define an interface for all classes that will get and set the data on vertices
  21673. */
  21674. export interface IGetSetVerticesData {
  21675. /**
  21676. * Gets a boolean indicating if specific vertex data is present
  21677. * @param kind defines the vertex data kind to use
  21678. * @returns true is data kind is present
  21679. */
  21680. isVerticesDataPresent(kind: string): boolean;
  21681. /**
  21682. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21683. * @param kind defines the data kind (Position, normal, etc...)
  21684. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21685. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21686. * @returns a float array containing vertex data
  21687. */
  21688. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21689. /**
  21690. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21691. * @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.
  21692. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21693. * @returns the indices array or an empty array if the mesh has no geometry
  21694. */
  21695. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21696. /**
  21697. * Set specific vertex data
  21698. * @param kind defines the data kind (Position, normal, etc...)
  21699. * @param data defines the vertex data to use
  21700. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21701. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21702. */
  21703. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21704. /**
  21705. * Update a specific associated vertex buffer
  21706. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21707. * - VertexBuffer.PositionKind
  21708. * - VertexBuffer.UVKind
  21709. * - VertexBuffer.UV2Kind
  21710. * - VertexBuffer.UV3Kind
  21711. * - VertexBuffer.UV4Kind
  21712. * - VertexBuffer.UV5Kind
  21713. * - VertexBuffer.UV6Kind
  21714. * - VertexBuffer.ColorKind
  21715. * - VertexBuffer.MatricesIndicesKind
  21716. * - VertexBuffer.MatricesIndicesExtraKind
  21717. * - VertexBuffer.MatricesWeightsKind
  21718. * - VertexBuffer.MatricesWeightsExtraKind
  21719. * @param data defines the data source
  21720. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21721. * @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)
  21722. */
  21723. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21724. /**
  21725. * Creates a new index buffer
  21726. * @param indices defines the indices to store in the index buffer
  21727. * @param totalVertices defines the total number of vertices (could be null)
  21728. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21729. */
  21730. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21731. }
  21732. /**
  21733. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21734. */
  21735. export class VertexData {
  21736. /**
  21737. * Mesh side orientation : usually the external or front surface
  21738. */
  21739. static readonly FRONTSIDE: number;
  21740. /**
  21741. * Mesh side orientation : usually the internal or back surface
  21742. */
  21743. static readonly BACKSIDE: number;
  21744. /**
  21745. * Mesh side orientation : both internal and external or front and back surfaces
  21746. */
  21747. static readonly DOUBLESIDE: number;
  21748. /**
  21749. * Mesh side orientation : by default, `FRONTSIDE`
  21750. */
  21751. static readonly DEFAULTSIDE: number;
  21752. /**
  21753. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21754. */
  21755. positions: Nullable<FloatArray>;
  21756. /**
  21757. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21758. */
  21759. normals: Nullable<FloatArray>;
  21760. /**
  21761. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21762. */
  21763. tangents: Nullable<FloatArray>;
  21764. /**
  21765. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21766. */
  21767. uvs: Nullable<FloatArray>;
  21768. /**
  21769. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21770. */
  21771. uvs2: Nullable<FloatArray>;
  21772. /**
  21773. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21774. */
  21775. uvs3: Nullable<FloatArray>;
  21776. /**
  21777. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21778. */
  21779. uvs4: Nullable<FloatArray>;
  21780. /**
  21781. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21782. */
  21783. uvs5: Nullable<FloatArray>;
  21784. /**
  21785. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21786. */
  21787. uvs6: Nullable<FloatArray>;
  21788. /**
  21789. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21790. */
  21791. colors: Nullable<FloatArray>;
  21792. /**
  21793. * 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).
  21794. */
  21795. matricesIndices: Nullable<FloatArray>;
  21796. /**
  21797. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21798. */
  21799. matricesWeights: Nullable<FloatArray>;
  21800. /**
  21801. * An array extending the number of possible indices
  21802. */
  21803. matricesIndicesExtra: Nullable<FloatArray>;
  21804. /**
  21805. * An array extending the number of possible weights when the number of indices is extended
  21806. */
  21807. matricesWeightsExtra: Nullable<FloatArray>;
  21808. /**
  21809. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21810. */
  21811. indices: Nullable<IndicesArray>;
  21812. /**
  21813. * Uses the passed data array to set the set the values for the specified kind of data
  21814. * @param data a linear array of floating numbers
  21815. * @param kind the type of data that is being set, eg positions, colors etc
  21816. */
  21817. set(data: FloatArray, kind: string): void;
  21818. /**
  21819. * Associates the vertexData to the passed Mesh.
  21820. * Sets it as updatable or not (default `false`)
  21821. * @param mesh the mesh the vertexData is applied to
  21822. * @param updatable when used and having the value true allows new data to update the vertexData
  21823. * @returns the VertexData
  21824. */
  21825. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21826. /**
  21827. * Associates the vertexData to the passed Geometry.
  21828. * Sets it as updatable or not (default `false`)
  21829. * @param geometry the geometry the vertexData is applied to
  21830. * @param updatable when used and having the value true allows new data to update the vertexData
  21831. * @returns VertexData
  21832. */
  21833. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21834. /**
  21835. * Updates the associated mesh
  21836. * @param mesh the mesh to be updated
  21837. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21838. * @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
  21839. * @returns VertexData
  21840. */
  21841. updateMesh(mesh: Mesh): VertexData;
  21842. /**
  21843. * Updates the associated geometry
  21844. * @param geometry the geometry to be updated
  21845. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21846. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21847. * @returns VertexData.
  21848. */
  21849. updateGeometry(geometry: Geometry): VertexData;
  21850. private _applyTo;
  21851. private _update;
  21852. /**
  21853. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21854. * @param matrix the transforming matrix
  21855. * @returns the VertexData
  21856. */
  21857. transform(matrix: Matrix): VertexData;
  21858. /**
  21859. * Merges the passed VertexData into the current one
  21860. * @param other the VertexData to be merged into the current one
  21861. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21862. * @returns the modified VertexData
  21863. */
  21864. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21865. private _mergeElement;
  21866. private _validate;
  21867. /**
  21868. * Serializes the VertexData
  21869. * @returns a serialized object
  21870. */
  21871. serialize(): any;
  21872. /**
  21873. * Extracts the vertexData from a mesh
  21874. * @param mesh the mesh from which to extract the VertexData
  21875. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21876. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21877. * @returns the object VertexData associated to the passed mesh
  21878. */
  21879. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21880. /**
  21881. * Extracts the vertexData from the geometry
  21882. * @param geometry the geometry from which to extract the VertexData
  21883. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21884. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21885. * @returns the object VertexData associated to the passed mesh
  21886. */
  21887. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21888. private static _ExtractFrom;
  21889. /**
  21890. * Creates the VertexData for a Ribbon
  21891. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21892. * * pathArray array of paths, each of which an array of successive Vector3
  21893. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21894. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21895. * * 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
  21896. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21897. * * 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)
  21898. * * 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)
  21899. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21900. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21901. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21902. * @returns the VertexData of the ribbon
  21903. */
  21904. static CreateRibbon(options: {
  21905. pathArray: Vector3[][];
  21906. closeArray?: boolean;
  21907. closePath?: boolean;
  21908. offset?: number;
  21909. sideOrientation?: number;
  21910. frontUVs?: Vector4;
  21911. backUVs?: Vector4;
  21912. invertUV?: boolean;
  21913. uvs?: Vector2[];
  21914. colors?: Color4[];
  21915. }): VertexData;
  21916. /**
  21917. * Creates the VertexData for a box
  21918. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21919. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21920. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21921. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21922. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21923. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21924. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21926. * * 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)
  21927. * * 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)
  21928. * @returns the VertexData of the box
  21929. */
  21930. static CreateBox(options: {
  21931. size?: number;
  21932. width?: number;
  21933. height?: number;
  21934. depth?: number;
  21935. faceUV?: Vector4[];
  21936. faceColors?: Color4[];
  21937. sideOrientation?: number;
  21938. frontUVs?: Vector4;
  21939. backUVs?: Vector4;
  21940. }): VertexData;
  21941. /**
  21942. * Creates the VertexData for a tiled box
  21943. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21944. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21945. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21946. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21947. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21948. * @returns the VertexData of the box
  21949. */
  21950. static CreateTiledBox(options: {
  21951. pattern?: number;
  21952. width?: number;
  21953. height?: number;
  21954. depth?: number;
  21955. tileSize?: number;
  21956. tileWidth?: number;
  21957. tileHeight?: number;
  21958. alignHorizontal?: number;
  21959. alignVertical?: number;
  21960. faceUV?: Vector4[];
  21961. faceColors?: Color4[];
  21962. sideOrientation?: number;
  21963. }): VertexData;
  21964. /**
  21965. * Creates the VertexData for a tiled plane
  21966. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21967. * * pattern a limited pattern arrangement depending on the number
  21968. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21969. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21970. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21971. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21972. * * 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)
  21973. * * 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)
  21974. * @returns the VertexData of the tiled plane
  21975. */
  21976. static CreateTiledPlane(options: {
  21977. pattern?: number;
  21978. tileSize?: number;
  21979. tileWidth?: number;
  21980. tileHeight?: number;
  21981. size?: number;
  21982. width?: number;
  21983. height?: number;
  21984. alignHorizontal?: number;
  21985. alignVertical?: number;
  21986. sideOrientation?: number;
  21987. frontUVs?: Vector4;
  21988. backUVs?: Vector4;
  21989. }): VertexData;
  21990. /**
  21991. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21992. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21993. * * segments sets the number of horizontal strips optional, default 32
  21994. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21995. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21996. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21997. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21998. * * 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
  21999. * * 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
  22000. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22001. * * 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)
  22002. * * 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)
  22003. * @returns the VertexData of the ellipsoid
  22004. */
  22005. static CreateSphere(options: {
  22006. segments?: number;
  22007. diameter?: number;
  22008. diameterX?: number;
  22009. diameterY?: number;
  22010. diameterZ?: number;
  22011. arc?: number;
  22012. slice?: number;
  22013. sideOrientation?: number;
  22014. frontUVs?: Vector4;
  22015. backUVs?: Vector4;
  22016. }): VertexData;
  22017. /**
  22018. * Creates the VertexData for a cylinder, cone or prism
  22019. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22020. * * height sets the height (y direction) of the cylinder, optional, default 2
  22021. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22022. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22023. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22024. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22025. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22026. * * 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
  22027. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22028. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22029. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22030. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22031. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22032. * * 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)
  22033. * * 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)
  22034. * @returns the VertexData of the cylinder, cone or prism
  22035. */
  22036. static CreateCylinder(options: {
  22037. height?: number;
  22038. diameterTop?: number;
  22039. diameterBottom?: number;
  22040. diameter?: number;
  22041. tessellation?: number;
  22042. subdivisions?: number;
  22043. arc?: number;
  22044. faceColors?: Color4[];
  22045. faceUV?: Vector4[];
  22046. hasRings?: boolean;
  22047. enclose?: boolean;
  22048. sideOrientation?: number;
  22049. frontUVs?: Vector4;
  22050. backUVs?: Vector4;
  22051. }): VertexData;
  22052. /**
  22053. * Creates the VertexData for a torus
  22054. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22055. * * diameter the diameter of the torus, optional default 1
  22056. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22057. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22058. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22059. * * 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)
  22060. * * 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)
  22061. * @returns the VertexData of the torus
  22062. */
  22063. static CreateTorus(options: {
  22064. diameter?: number;
  22065. thickness?: number;
  22066. tessellation?: number;
  22067. sideOrientation?: number;
  22068. frontUVs?: Vector4;
  22069. backUVs?: Vector4;
  22070. }): VertexData;
  22071. /**
  22072. * Creates the VertexData of the LineSystem
  22073. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22074. * - lines an array of lines, each line being an array of successive Vector3
  22075. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22076. * @returns the VertexData of the LineSystem
  22077. */
  22078. static CreateLineSystem(options: {
  22079. lines: Vector3[][];
  22080. colors?: Nullable<Color4[][]>;
  22081. }): VertexData;
  22082. /**
  22083. * Create the VertexData for a DashedLines
  22084. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22085. * - points an array successive Vector3
  22086. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22087. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22088. * - dashNb the intended total number of dashes, optional, default 200
  22089. * @returns the VertexData for the DashedLines
  22090. */
  22091. static CreateDashedLines(options: {
  22092. points: Vector3[];
  22093. dashSize?: number;
  22094. gapSize?: number;
  22095. dashNb?: number;
  22096. }): VertexData;
  22097. /**
  22098. * Creates the VertexData for a Ground
  22099. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22100. * - width the width (x direction) of the ground, optional, default 1
  22101. * - height the height (z direction) of the ground, optional, default 1
  22102. * - subdivisions the number of subdivisions per side, optional, default 1
  22103. * @returns the VertexData of the Ground
  22104. */
  22105. static CreateGround(options: {
  22106. width?: number;
  22107. height?: number;
  22108. subdivisions?: number;
  22109. subdivisionsX?: number;
  22110. subdivisionsY?: number;
  22111. }): VertexData;
  22112. /**
  22113. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22114. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22115. * * xmin the ground minimum X coordinate, optional, default -1
  22116. * * zmin the ground minimum Z coordinate, optional, default -1
  22117. * * xmax the ground maximum X coordinate, optional, default 1
  22118. * * zmax the ground maximum Z coordinate, optional, default 1
  22119. * * 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}
  22120. * * 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}
  22121. * @returns the VertexData of the TiledGround
  22122. */
  22123. static CreateTiledGround(options: {
  22124. xmin: number;
  22125. zmin: number;
  22126. xmax: number;
  22127. zmax: number;
  22128. subdivisions?: {
  22129. w: number;
  22130. h: number;
  22131. };
  22132. precision?: {
  22133. w: number;
  22134. h: number;
  22135. };
  22136. }): VertexData;
  22137. /**
  22138. * Creates the VertexData of the Ground designed from a heightmap
  22139. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22140. * * width the width (x direction) of the ground
  22141. * * height the height (z direction) of the ground
  22142. * * subdivisions the number of subdivisions per side
  22143. * * minHeight the minimum altitude on the ground, optional, default 0
  22144. * * maxHeight the maximum altitude on the ground, optional default 1
  22145. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22146. * * buffer the array holding the image color data
  22147. * * bufferWidth the width of image
  22148. * * bufferHeight the height of image
  22149. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22150. * @returns the VertexData of the Ground designed from a heightmap
  22151. */
  22152. static CreateGroundFromHeightMap(options: {
  22153. width: number;
  22154. height: number;
  22155. subdivisions: number;
  22156. minHeight: number;
  22157. maxHeight: number;
  22158. colorFilter: Color3;
  22159. buffer: Uint8Array;
  22160. bufferWidth: number;
  22161. bufferHeight: number;
  22162. alphaFilter: number;
  22163. }): VertexData;
  22164. /**
  22165. * Creates the VertexData for a Plane
  22166. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22167. * * size sets the width and height of the plane to the value of size, optional default 1
  22168. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22169. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22171. * * 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)
  22172. * * 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)
  22173. * @returns the VertexData of the box
  22174. */
  22175. static CreatePlane(options: {
  22176. size?: number;
  22177. width?: number;
  22178. height?: number;
  22179. sideOrientation?: number;
  22180. frontUVs?: Vector4;
  22181. backUVs?: Vector4;
  22182. }): VertexData;
  22183. /**
  22184. * Creates the VertexData of the Disc or regular Polygon
  22185. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22186. * * radius the radius of the disc, optional default 0.5
  22187. * * tessellation the number of polygon sides, optional, default 64
  22188. * * 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
  22189. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22190. * * 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)
  22191. * * 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)
  22192. * @returns the VertexData of the box
  22193. */
  22194. static CreateDisc(options: {
  22195. radius?: number;
  22196. tessellation?: number;
  22197. arc?: number;
  22198. sideOrientation?: number;
  22199. frontUVs?: Vector4;
  22200. backUVs?: Vector4;
  22201. }): VertexData;
  22202. /**
  22203. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22204. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22205. * @param polygon a mesh built from polygonTriangulation.build()
  22206. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22207. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22208. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22209. * @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)
  22210. * @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)
  22211. * @returns the VertexData of the Polygon
  22212. */
  22213. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22214. /**
  22215. * Creates the VertexData of the IcoSphere
  22216. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22217. * * radius the radius of the IcoSphere, optional default 1
  22218. * * radiusX allows stretching in the x direction, optional, default radius
  22219. * * radiusY allows stretching in the y direction, optional, default radius
  22220. * * radiusZ allows stretching in the z direction, optional, default radius
  22221. * * flat when true creates a flat shaded mesh, optional, default true
  22222. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22223. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22224. * * 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)
  22225. * * 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)
  22226. * @returns the VertexData of the IcoSphere
  22227. */
  22228. static CreateIcoSphere(options: {
  22229. radius?: number;
  22230. radiusX?: number;
  22231. radiusY?: number;
  22232. radiusZ?: number;
  22233. flat?: boolean;
  22234. subdivisions?: number;
  22235. sideOrientation?: number;
  22236. frontUVs?: Vector4;
  22237. backUVs?: Vector4;
  22238. }): VertexData;
  22239. /**
  22240. * Creates the VertexData for a Polyhedron
  22241. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22242. * * type provided types are:
  22243. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22244. * * 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)
  22245. * * size the size of the IcoSphere, optional default 1
  22246. * * sizeX allows stretching in the x direction, optional, default size
  22247. * * sizeY allows stretching in the y direction, optional, default size
  22248. * * sizeZ allows stretching in the z direction, optional, default size
  22249. * * 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
  22250. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22251. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22252. * * flat when true creates a flat shaded mesh, optional, default true
  22253. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22255. * * 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)
  22256. * * 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)
  22257. * @returns the VertexData of the Polyhedron
  22258. */
  22259. static CreatePolyhedron(options: {
  22260. type?: number;
  22261. size?: number;
  22262. sizeX?: number;
  22263. sizeY?: number;
  22264. sizeZ?: number;
  22265. custom?: any;
  22266. faceUV?: Vector4[];
  22267. faceColors?: Color4[];
  22268. flat?: boolean;
  22269. sideOrientation?: number;
  22270. frontUVs?: Vector4;
  22271. backUVs?: Vector4;
  22272. }): VertexData;
  22273. /**
  22274. * Creates the VertexData for a TorusKnot
  22275. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22276. * * radius the radius of the torus knot, optional, default 2
  22277. * * tube the thickness of the tube, optional, default 0.5
  22278. * * radialSegments the number of sides on each tube segments, optional, default 32
  22279. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22280. * * p the number of windings around the z axis, optional, default 2
  22281. * * q the number of windings around the x axis, optional, default 3
  22282. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22283. * * 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)
  22284. * * 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)
  22285. * @returns the VertexData of the Torus Knot
  22286. */
  22287. static CreateTorusKnot(options: {
  22288. radius?: number;
  22289. tube?: number;
  22290. radialSegments?: number;
  22291. tubularSegments?: number;
  22292. p?: number;
  22293. q?: number;
  22294. sideOrientation?: number;
  22295. frontUVs?: Vector4;
  22296. backUVs?: Vector4;
  22297. }): VertexData;
  22298. /**
  22299. * Compute normals for given positions and indices
  22300. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22301. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22302. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22303. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22304. * * facetNormals : optional array of facet normals (vector3)
  22305. * * facetPositions : optional array of facet positions (vector3)
  22306. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22307. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22308. * * bInfo : optional bounding info, required for facetPartitioning computation
  22309. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22310. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22311. * * useRightHandedSystem: optional boolean to for right handed system computation
  22312. * * depthSort : optional boolean to enable the facet depth sort computation
  22313. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22314. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22315. */
  22316. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22317. facetNormals?: any;
  22318. facetPositions?: any;
  22319. facetPartitioning?: any;
  22320. ratio?: number;
  22321. bInfo?: any;
  22322. bbSize?: Vector3;
  22323. subDiv?: any;
  22324. useRightHandedSystem?: boolean;
  22325. depthSort?: boolean;
  22326. distanceTo?: Vector3;
  22327. depthSortedFacets?: any;
  22328. }): void;
  22329. /** @hidden */
  22330. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22331. /**
  22332. * Applies VertexData created from the imported parameters to the geometry
  22333. * @param parsedVertexData the parsed data from an imported file
  22334. * @param geometry the geometry to apply the VertexData to
  22335. */
  22336. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22337. }
  22338. }
  22339. declare module "babylonjs/Morph/morphTarget" {
  22340. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22341. import { Observable } from "babylonjs/Misc/observable";
  22342. import { Nullable, FloatArray } from "babylonjs/types";
  22343. import { Scene } from "babylonjs/scene";
  22344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22345. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22346. /**
  22347. * Defines a target to use with MorphTargetManager
  22348. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22349. */
  22350. export class MorphTarget implements IAnimatable {
  22351. /** defines the name of the target */
  22352. name: string;
  22353. /**
  22354. * Gets or sets the list of animations
  22355. */
  22356. animations: import("babylonjs/Animations/animation").Animation[];
  22357. private _scene;
  22358. private _positions;
  22359. private _normals;
  22360. private _tangents;
  22361. private _uvs;
  22362. private _influence;
  22363. /**
  22364. * Observable raised when the influence changes
  22365. */
  22366. onInfluenceChanged: Observable<boolean>;
  22367. /** @hidden */
  22368. _onDataLayoutChanged: Observable<void>;
  22369. /**
  22370. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22371. */
  22372. influence: number;
  22373. /**
  22374. * Gets or sets the id of the morph Target
  22375. */
  22376. id: string;
  22377. private _animationPropertiesOverride;
  22378. /**
  22379. * Gets or sets the animation properties override
  22380. */
  22381. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22382. /**
  22383. * Creates a new MorphTarget
  22384. * @param name defines the name of the target
  22385. * @param influence defines the influence to use
  22386. * @param scene defines the scene the morphtarget belongs to
  22387. */
  22388. constructor(
  22389. /** defines the name of the target */
  22390. name: string, influence?: number, scene?: Nullable<Scene>);
  22391. /**
  22392. * Gets a boolean defining if the target contains position data
  22393. */
  22394. readonly hasPositions: boolean;
  22395. /**
  22396. * Gets a boolean defining if the target contains normal data
  22397. */
  22398. readonly hasNormals: boolean;
  22399. /**
  22400. * Gets a boolean defining if the target contains tangent data
  22401. */
  22402. readonly hasTangents: boolean;
  22403. /**
  22404. * Gets a boolean defining if the target contains texture coordinates data
  22405. */
  22406. readonly hasUVs: boolean;
  22407. /**
  22408. * Affects position data to this target
  22409. * @param data defines the position data to use
  22410. */
  22411. setPositions(data: Nullable<FloatArray>): void;
  22412. /**
  22413. * Gets the position data stored in this target
  22414. * @returns a FloatArray containing the position data (or null if not present)
  22415. */
  22416. getPositions(): Nullable<FloatArray>;
  22417. /**
  22418. * Affects normal data to this target
  22419. * @param data defines the normal data to use
  22420. */
  22421. setNormals(data: Nullable<FloatArray>): void;
  22422. /**
  22423. * Gets the normal data stored in this target
  22424. * @returns a FloatArray containing the normal data (or null if not present)
  22425. */
  22426. getNormals(): Nullable<FloatArray>;
  22427. /**
  22428. * Affects tangent data to this target
  22429. * @param data defines the tangent data to use
  22430. */
  22431. setTangents(data: Nullable<FloatArray>): void;
  22432. /**
  22433. * Gets the tangent data stored in this target
  22434. * @returns a FloatArray containing the tangent data (or null if not present)
  22435. */
  22436. getTangents(): Nullable<FloatArray>;
  22437. /**
  22438. * Affects texture coordinates data to this target
  22439. * @param data defines the texture coordinates data to use
  22440. */
  22441. setUVs(data: Nullable<FloatArray>): void;
  22442. /**
  22443. * Gets the texture coordinates data stored in this target
  22444. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22445. */
  22446. getUVs(): Nullable<FloatArray>;
  22447. /**
  22448. * Serializes the current target into a Serialization object
  22449. * @returns the serialized object
  22450. */
  22451. serialize(): any;
  22452. /**
  22453. * Returns the string "MorphTarget"
  22454. * @returns "MorphTarget"
  22455. */
  22456. getClassName(): string;
  22457. /**
  22458. * Creates a new target from serialized data
  22459. * @param serializationObject defines the serialized data to use
  22460. * @returns a new MorphTarget
  22461. */
  22462. static Parse(serializationObject: any): MorphTarget;
  22463. /**
  22464. * Creates a MorphTarget from mesh data
  22465. * @param mesh defines the source mesh
  22466. * @param name defines the name to use for the new target
  22467. * @param influence defines the influence to attach to the target
  22468. * @returns a new MorphTarget
  22469. */
  22470. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22471. }
  22472. }
  22473. declare module "babylonjs/Morph/morphTargetManager" {
  22474. import { Nullable } from "babylonjs/types";
  22475. import { Scene } from "babylonjs/scene";
  22476. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22477. /**
  22478. * This class is used to deform meshes using morphing between different targets
  22479. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22480. */
  22481. export class MorphTargetManager {
  22482. private _targets;
  22483. private _targetInfluenceChangedObservers;
  22484. private _targetDataLayoutChangedObservers;
  22485. private _activeTargets;
  22486. private _scene;
  22487. private _influences;
  22488. private _supportsNormals;
  22489. private _supportsTangents;
  22490. private _supportsUVs;
  22491. private _vertexCount;
  22492. private _uniqueId;
  22493. private _tempInfluences;
  22494. /**
  22495. * Gets or sets a boolean indicating if normals must be morphed
  22496. */
  22497. enableNormalMorphing: boolean;
  22498. /**
  22499. * Gets or sets a boolean indicating if tangents must be morphed
  22500. */
  22501. enableTangentMorphing: boolean;
  22502. /**
  22503. * Gets or sets a boolean indicating if UV must be morphed
  22504. */
  22505. enableUVMorphing: boolean;
  22506. /**
  22507. * Creates a new MorphTargetManager
  22508. * @param scene defines the current scene
  22509. */
  22510. constructor(scene?: Nullable<Scene>);
  22511. /**
  22512. * Gets the unique ID of this manager
  22513. */
  22514. readonly uniqueId: number;
  22515. /**
  22516. * Gets the number of vertices handled by this manager
  22517. */
  22518. readonly vertexCount: number;
  22519. /**
  22520. * Gets a boolean indicating if this manager supports morphing of normals
  22521. */
  22522. readonly supportsNormals: boolean;
  22523. /**
  22524. * Gets a boolean indicating if this manager supports morphing of tangents
  22525. */
  22526. readonly supportsTangents: boolean;
  22527. /**
  22528. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22529. */
  22530. readonly supportsUVs: boolean;
  22531. /**
  22532. * Gets the number of targets stored in this manager
  22533. */
  22534. readonly numTargets: number;
  22535. /**
  22536. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22537. */
  22538. readonly numInfluencers: number;
  22539. /**
  22540. * Gets the list of influences (one per target)
  22541. */
  22542. readonly influences: Float32Array;
  22543. /**
  22544. * Gets the active target at specified index. An active target is a target with an influence > 0
  22545. * @param index defines the index to check
  22546. * @returns the requested target
  22547. */
  22548. getActiveTarget(index: number): MorphTarget;
  22549. /**
  22550. * Gets the target at specified index
  22551. * @param index defines the index to check
  22552. * @returns the requested target
  22553. */
  22554. getTarget(index: number): MorphTarget;
  22555. /**
  22556. * Add a new target to this manager
  22557. * @param target defines the target to add
  22558. */
  22559. addTarget(target: MorphTarget): void;
  22560. /**
  22561. * Removes a target from the manager
  22562. * @param target defines the target to remove
  22563. */
  22564. removeTarget(target: MorphTarget): void;
  22565. /**
  22566. * Serializes the current manager into a Serialization object
  22567. * @returns the serialized object
  22568. */
  22569. serialize(): any;
  22570. private _syncActiveTargets;
  22571. /**
  22572. * Syncrhonize the targets with all the meshes using this morph target manager
  22573. */
  22574. synchronize(): void;
  22575. /**
  22576. * Creates a new MorphTargetManager from serialized data
  22577. * @param serializationObject defines the serialized data
  22578. * @param scene defines the hosting scene
  22579. * @returns the new MorphTargetManager
  22580. */
  22581. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22582. }
  22583. }
  22584. declare module "babylonjs/Meshes/meshLODLevel" {
  22585. import { Mesh } from "babylonjs/Meshes/mesh";
  22586. import { Nullable } from "babylonjs/types";
  22587. /**
  22588. * Class used to represent a specific level of detail of a mesh
  22589. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22590. */
  22591. export class MeshLODLevel {
  22592. /** Defines the distance where this level should star being displayed */
  22593. distance: number;
  22594. /** Defines the mesh to use to render this level */
  22595. mesh: Nullable<Mesh>;
  22596. /**
  22597. * Creates a new LOD level
  22598. * @param distance defines the distance where this level should star being displayed
  22599. * @param mesh defines the mesh to use to render this level
  22600. */
  22601. constructor(
  22602. /** Defines the distance where this level should star being displayed */
  22603. distance: number,
  22604. /** Defines the mesh to use to render this level */
  22605. mesh: Nullable<Mesh>);
  22606. }
  22607. }
  22608. declare module "babylonjs/Meshes/groundMesh" {
  22609. import { Scene } from "babylonjs/scene";
  22610. import { Vector3 } from "babylonjs/Maths/math.vector";
  22611. import { Mesh } from "babylonjs/Meshes/mesh";
  22612. /**
  22613. * Mesh representing the gorund
  22614. */
  22615. export class GroundMesh extends Mesh {
  22616. /** If octree should be generated */
  22617. generateOctree: boolean;
  22618. private _heightQuads;
  22619. /** @hidden */
  22620. _subdivisionsX: number;
  22621. /** @hidden */
  22622. _subdivisionsY: number;
  22623. /** @hidden */
  22624. _width: number;
  22625. /** @hidden */
  22626. _height: number;
  22627. /** @hidden */
  22628. _minX: number;
  22629. /** @hidden */
  22630. _maxX: number;
  22631. /** @hidden */
  22632. _minZ: number;
  22633. /** @hidden */
  22634. _maxZ: number;
  22635. constructor(name: string, scene: Scene);
  22636. /**
  22637. * "GroundMesh"
  22638. * @returns "GroundMesh"
  22639. */
  22640. getClassName(): string;
  22641. /**
  22642. * The minimum of x and y subdivisions
  22643. */
  22644. readonly subdivisions: number;
  22645. /**
  22646. * X subdivisions
  22647. */
  22648. readonly subdivisionsX: number;
  22649. /**
  22650. * Y subdivisions
  22651. */
  22652. readonly subdivisionsY: number;
  22653. /**
  22654. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22655. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22656. * @param chunksCount the number of subdivisions for x and y
  22657. * @param octreeBlocksSize (Default: 32)
  22658. */
  22659. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22660. /**
  22661. * Returns a height (y) value in the Worl system :
  22662. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22663. * @param x x coordinate
  22664. * @param z z coordinate
  22665. * @returns the ground y position if (x, z) are outside the ground surface.
  22666. */
  22667. getHeightAtCoordinates(x: number, z: number): number;
  22668. /**
  22669. * Returns a normalized vector (Vector3) orthogonal to the ground
  22670. * at the ground coordinates (x, z) expressed in the World system.
  22671. * @param x x coordinate
  22672. * @param z z coordinate
  22673. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22674. */
  22675. getNormalAtCoordinates(x: number, z: number): Vector3;
  22676. /**
  22677. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22678. * at the ground coordinates (x, z) expressed in the World system.
  22679. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22680. * @param x x coordinate
  22681. * @param z z coordinate
  22682. * @param ref vector to store the result
  22683. * @returns the GroundMesh.
  22684. */
  22685. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22686. /**
  22687. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22688. * if the ground has been updated.
  22689. * This can be used in the render loop.
  22690. * @returns the GroundMesh.
  22691. */
  22692. updateCoordinateHeights(): GroundMesh;
  22693. private _getFacetAt;
  22694. private _initHeightQuads;
  22695. private _computeHeightQuads;
  22696. /**
  22697. * Serializes this ground mesh
  22698. * @param serializationObject object to write serialization to
  22699. */
  22700. serialize(serializationObject: any): void;
  22701. /**
  22702. * Parses a serialized ground mesh
  22703. * @param parsedMesh the serialized mesh
  22704. * @param scene the scene to create the ground mesh in
  22705. * @returns the created ground mesh
  22706. */
  22707. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22708. }
  22709. }
  22710. declare module "babylonjs/Physics/physicsJoint" {
  22711. import { Vector3 } from "babylonjs/Maths/math.vector";
  22712. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22713. /**
  22714. * Interface for Physics-Joint data
  22715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22716. */
  22717. export interface PhysicsJointData {
  22718. /**
  22719. * The main pivot of the joint
  22720. */
  22721. mainPivot?: Vector3;
  22722. /**
  22723. * The connected pivot of the joint
  22724. */
  22725. connectedPivot?: Vector3;
  22726. /**
  22727. * The main axis of the joint
  22728. */
  22729. mainAxis?: Vector3;
  22730. /**
  22731. * The connected axis of the joint
  22732. */
  22733. connectedAxis?: Vector3;
  22734. /**
  22735. * The collision of the joint
  22736. */
  22737. collision?: boolean;
  22738. /**
  22739. * Native Oimo/Cannon/Energy data
  22740. */
  22741. nativeParams?: any;
  22742. }
  22743. /**
  22744. * This is a holder class for the physics joint created by the physics plugin
  22745. * It holds a set of functions to control the underlying joint
  22746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22747. */
  22748. export class PhysicsJoint {
  22749. /**
  22750. * The type of the physics joint
  22751. */
  22752. type: number;
  22753. /**
  22754. * The data for the physics joint
  22755. */
  22756. jointData: PhysicsJointData;
  22757. private _physicsJoint;
  22758. protected _physicsPlugin: IPhysicsEnginePlugin;
  22759. /**
  22760. * Initializes the physics joint
  22761. * @param type The type of the physics joint
  22762. * @param jointData The data for the physics joint
  22763. */
  22764. constructor(
  22765. /**
  22766. * The type of the physics joint
  22767. */
  22768. type: number,
  22769. /**
  22770. * The data for the physics joint
  22771. */
  22772. jointData: PhysicsJointData);
  22773. /**
  22774. * Gets the physics joint
  22775. */
  22776. /**
  22777. * Sets the physics joint
  22778. */
  22779. physicsJoint: any;
  22780. /**
  22781. * Sets the physics plugin
  22782. */
  22783. physicsPlugin: IPhysicsEnginePlugin;
  22784. /**
  22785. * Execute a function that is physics-plugin specific.
  22786. * @param {Function} func the function that will be executed.
  22787. * It accepts two parameters: the physics world and the physics joint
  22788. */
  22789. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22790. /**
  22791. * Distance-Joint type
  22792. */
  22793. static DistanceJoint: number;
  22794. /**
  22795. * Hinge-Joint type
  22796. */
  22797. static HingeJoint: number;
  22798. /**
  22799. * Ball-and-Socket joint type
  22800. */
  22801. static BallAndSocketJoint: number;
  22802. /**
  22803. * Wheel-Joint type
  22804. */
  22805. static WheelJoint: number;
  22806. /**
  22807. * Slider-Joint type
  22808. */
  22809. static SliderJoint: number;
  22810. /**
  22811. * Prismatic-Joint type
  22812. */
  22813. static PrismaticJoint: number;
  22814. /**
  22815. * Universal-Joint type
  22816. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22817. */
  22818. static UniversalJoint: number;
  22819. /**
  22820. * Hinge-Joint 2 type
  22821. */
  22822. static Hinge2Joint: number;
  22823. /**
  22824. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22825. */
  22826. static PointToPointJoint: number;
  22827. /**
  22828. * Spring-Joint type
  22829. */
  22830. static SpringJoint: number;
  22831. /**
  22832. * Lock-Joint type
  22833. */
  22834. static LockJoint: number;
  22835. }
  22836. /**
  22837. * A class representing a physics distance joint
  22838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22839. */
  22840. export class DistanceJoint extends PhysicsJoint {
  22841. /**
  22842. *
  22843. * @param jointData The data for the Distance-Joint
  22844. */
  22845. constructor(jointData: DistanceJointData);
  22846. /**
  22847. * Update the predefined distance.
  22848. * @param maxDistance The maximum preferred distance
  22849. * @param minDistance The minimum preferred distance
  22850. */
  22851. updateDistance(maxDistance: number, minDistance?: number): void;
  22852. }
  22853. /**
  22854. * Represents a Motor-Enabled Joint
  22855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22856. */
  22857. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22858. /**
  22859. * Initializes the Motor-Enabled Joint
  22860. * @param type The type of the joint
  22861. * @param jointData The physica joint data for the joint
  22862. */
  22863. constructor(type: number, jointData: PhysicsJointData);
  22864. /**
  22865. * Set the motor values.
  22866. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22867. * @param force the force to apply
  22868. * @param maxForce max force for this motor.
  22869. */
  22870. setMotor(force?: number, maxForce?: number): void;
  22871. /**
  22872. * Set the motor's limits.
  22873. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22874. * @param upperLimit The upper limit of the motor
  22875. * @param lowerLimit The lower limit of the motor
  22876. */
  22877. setLimit(upperLimit: number, lowerLimit?: number): void;
  22878. }
  22879. /**
  22880. * This class represents a single physics Hinge-Joint
  22881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22882. */
  22883. export class HingeJoint extends MotorEnabledJoint {
  22884. /**
  22885. * Initializes the Hinge-Joint
  22886. * @param jointData The joint data for the Hinge-Joint
  22887. */
  22888. constructor(jointData: PhysicsJointData);
  22889. /**
  22890. * Set the motor values.
  22891. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22892. * @param {number} force the force to apply
  22893. * @param {number} maxForce max force for this motor.
  22894. */
  22895. setMotor(force?: number, maxForce?: number): void;
  22896. /**
  22897. * Set the motor's limits.
  22898. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22899. * @param upperLimit The upper limit of the motor
  22900. * @param lowerLimit The lower limit of the motor
  22901. */
  22902. setLimit(upperLimit: number, lowerLimit?: number): void;
  22903. }
  22904. /**
  22905. * This class represents a dual hinge physics joint (same as wheel joint)
  22906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22907. */
  22908. export class Hinge2Joint extends MotorEnabledJoint {
  22909. /**
  22910. * Initializes the Hinge2-Joint
  22911. * @param jointData The joint data for the Hinge2-Joint
  22912. */
  22913. constructor(jointData: PhysicsJointData);
  22914. /**
  22915. * Set the motor values.
  22916. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22917. * @param {number} targetSpeed the speed the motor is to reach
  22918. * @param {number} maxForce max force for this motor.
  22919. * @param {motorIndex} the motor's index, 0 or 1.
  22920. */
  22921. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22922. /**
  22923. * Set the motor limits.
  22924. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22925. * @param {number} upperLimit the upper limit
  22926. * @param {number} lowerLimit lower limit
  22927. * @param {motorIndex} the motor's index, 0 or 1.
  22928. */
  22929. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22930. }
  22931. /**
  22932. * Interface for a motor enabled joint
  22933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22934. */
  22935. export interface IMotorEnabledJoint {
  22936. /**
  22937. * Physics joint
  22938. */
  22939. physicsJoint: any;
  22940. /**
  22941. * Sets the motor of the motor-enabled joint
  22942. * @param force The force of the motor
  22943. * @param maxForce The maximum force of the motor
  22944. * @param motorIndex The index of the motor
  22945. */
  22946. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22947. /**
  22948. * Sets the limit of the motor
  22949. * @param upperLimit The upper limit of the motor
  22950. * @param lowerLimit The lower limit of the motor
  22951. * @param motorIndex The index of the motor
  22952. */
  22953. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22954. }
  22955. /**
  22956. * Joint data for a Distance-Joint
  22957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22958. */
  22959. export interface DistanceJointData extends PhysicsJointData {
  22960. /**
  22961. * Max distance the 2 joint objects can be apart
  22962. */
  22963. maxDistance: number;
  22964. }
  22965. /**
  22966. * Joint data from a spring joint
  22967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22968. */
  22969. export interface SpringJointData extends PhysicsJointData {
  22970. /**
  22971. * Length of the spring
  22972. */
  22973. length: number;
  22974. /**
  22975. * Stiffness of the spring
  22976. */
  22977. stiffness: number;
  22978. /**
  22979. * Damping of the spring
  22980. */
  22981. damping: number;
  22982. /** this callback will be called when applying the force to the impostors. */
  22983. forceApplicationCallback: () => void;
  22984. }
  22985. }
  22986. declare module "babylonjs/Physics/physicsRaycastResult" {
  22987. import { Vector3 } from "babylonjs/Maths/math.vector";
  22988. /**
  22989. * Holds the data for the raycast result
  22990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22991. */
  22992. export class PhysicsRaycastResult {
  22993. private _hasHit;
  22994. private _hitDistance;
  22995. private _hitNormalWorld;
  22996. private _hitPointWorld;
  22997. private _rayFromWorld;
  22998. private _rayToWorld;
  22999. /**
  23000. * Gets if there was a hit
  23001. */
  23002. readonly hasHit: boolean;
  23003. /**
  23004. * Gets the distance from the hit
  23005. */
  23006. readonly hitDistance: number;
  23007. /**
  23008. * Gets the hit normal/direction in the world
  23009. */
  23010. readonly hitNormalWorld: Vector3;
  23011. /**
  23012. * Gets the hit point in the world
  23013. */
  23014. readonly hitPointWorld: Vector3;
  23015. /**
  23016. * Gets the ray "start point" of the ray in the world
  23017. */
  23018. readonly rayFromWorld: Vector3;
  23019. /**
  23020. * Gets the ray "end point" of the ray in the world
  23021. */
  23022. readonly rayToWorld: Vector3;
  23023. /**
  23024. * Sets the hit data (normal & point in world space)
  23025. * @param hitNormalWorld defines the normal in world space
  23026. * @param hitPointWorld defines the point in world space
  23027. */
  23028. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23029. /**
  23030. * Sets the distance from the start point to the hit point
  23031. * @param distance
  23032. */
  23033. setHitDistance(distance: number): void;
  23034. /**
  23035. * Calculates the distance manually
  23036. */
  23037. calculateHitDistance(): void;
  23038. /**
  23039. * Resets all the values to default
  23040. * @param from The from point on world space
  23041. * @param to The to point on world space
  23042. */
  23043. reset(from?: Vector3, to?: Vector3): void;
  23044. }
  23045. /**
  23046. * Interface for the size containing width and height
  23047. */
  23048. interface IXYZ {
  23049. /**
  23050. * X
  23051. */
  23052. x: number;
  23053. /**
  23054. * Y
  23055. */
  23056. y: number;
  23057. /**
  23058. * Z
  23059. */
  23060. z: number;
  23061. }
  23062. }
  23063. declare module "babylonjs/Physics/IPhysicsEngine" {
  23064. import { Nullable } from "babylonjs/types";
  23065. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23067. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23068. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23069. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23070. /**
  23071. * Interface used to describe a physics joint
  23072. */
  23073. export interface PhysicsImpostorJoint {
  23074. /** Defines the main impostor to which the joint is linked */
  23075. mainImpostor: PhysicsImpostor;
  23076. /** Defines the impostor that is connected to the main impostor using this joint */
  23077. connectedImpostor: PhysicsImpostor;
  23078. /** Defines the joint itself */
  23079. joint: PhysicsJoint;
  23080. }
  23081. /** @hidden */
  23082. export interface IPhysicsEnginePlugin {
  23083. world: any;
  23084. name: string;
  23085. setGravity(gravity: Vector3): void;
  23086. setTimeStep(timeStep: number): void;
  23087. getTimeStep(): number;
  23088. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23089. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23090. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23091. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23092. removePhysicsBody(impostor: PhysicsImpostor): void;
  23093. generateJoint(joint: PhysicsImpostorJoint): void;
  23094. removeJoint(joint: PhysicsImpostorJoint): void;
  23095. isSupported(): boolean;
  23096. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23097. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23098. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23099. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23100. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23101. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23102. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23103. getBodyMass(impostor: PhysicsImpostor): number;
  23104. getBodyFriction(impostor: PhysicsImpostor): number;
  23105. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23106. getBodyRestitution(impostor: PhysicsImpostor): number;
  23107. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23108. getBodyPressure?(impostor: PhysicsImpostor): number;
  23109. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23110. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23111. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23112. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23113. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23114. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23115. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23116. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23117. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23118. sleepBody(impostor: PhysicsImpostor): void;
  23119. wakeUpBody(impostor: PhysicsImpostor): void;
  23120. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23121. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23122. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23123. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23124. getRadius(impostor: PhysicsImpostor): number;
  23125. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23126. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23127. dispose(): void;
  23128. }
  23129. /**
  23130. * Interface used to define a physics engine
  23131. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23132. */
  23133. export interface IPhysicsEngine {
  23134. /**
  23135. * Gets the gravity vector used by the simulation
  23136. */
  23137. gravity: Vector3;
  23138. /**
  23139. * Sets the gravity vector used by the simulation
  23140. * @param gravity defines the gravity vector to use
  23141. */
  23142. setGravity(gravity: Vector3): void;
  23143. /**
  23144. * Set the time step of the physics engine.
  23145. * Default is 1/60.
  23146. * To slow it down, enter 1/600 for example.
  23147. * To speed it up, 1/30
  23148. * @param newTimeStep the new timestep to apply to this world.
  23149. */
  23150. setTimeStep(newTimeStep: number): void;
  23151. /**
  23152. * Get the time step of the physics engine.
  23153. * @returns the current time step
  23154. */
  23155. getTimeStep(): number;
  23156. /**
  23157. * Release all resources
  23158. */
  23159. dispose(): void;
  23160. /**
  23161. * Gets the name of the current physics plugin
  23162. * @returns the name of the plugin
  23163. */
  23164. getPhysicsPluginName(): string;
  23165. /**
  23166. * Adding a new impostor for the impostor tracking.
  23167. * This will be done by the impostor itself.
  23168. * @param impostor the impostor to add
  23169. */
  23170. addImpostor(impostor: PhysicsImpostor): void;
  23171. /**
  23172. * Remove an impostor from the engine.
  23173. * This impostor and its mesh will not longer be updated by the physics engine.
  23174. * @param impostor the impostor to remove
  23175. */
  23176. removeImpostor(impostor: PhysicsImpostor): void;
  23177. /**
  23178. * Add a joint to the physics engine
  23179. * @param mainImpostor defines the main impostor to which the joint is added.
  23180. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23181. * @param joint defines the joint that will connect both impostors.
  23182. */
  23183. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23184. /**
  23185. * Removes a joint from the simulation
  23186. * @param mainImpostor defines the impostor used with the joint
  23187. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23188. * @param joint defines the joint to remove
  23189. */
  23190. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23191. /**
  23192. * Gets the current plugin used to run the simulation
  23193. * @returns current plugin
  23194. */
  23195. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23196. /**
  23197. * Gets the list of physic impostors
  23198. * @returns an array of PhysicsImpostor
  23199. */
  23200. getImpostors(): Array<PhysicsImpostor>;
  23201. /**
  23202. * Gets the impostor for a physics enabled object
  23203. * @param object defines the object impersonated by the impostor
  23204. * @returns the PhysicsImpostor or null if not found
  23205. */
  23206. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23207. /**
  23208. * Gets the impostor for a physics body object
  23209. * @param body defines physics body used by the impostor
  23210. * @returns the PhysicsImpostor or null if not found
  23211. */
  23212. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23213. /**
  23214. * Does a raycast in the physics world
  23215. * @param from when should the ray start?
  23216. * @param to when should the ray end?
  23217. * @returns PhysicsRaycastResult
  23218. */
  23219. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23220. /**
  23221. * Called by the scene. No need to call it.
  23222. * @param delta defines the timespam between frames
  23223. */
  23224. _step(delta: number): void;
  23225. }
  23226. }
  23227. declare module "babylonjs/Physics/physicsImpostor" {
  23228. import { Nullable, IndicesArray } from "babylonjs/types";
  23229. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23230. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23232. import { Scene } from "babylonjs/scene";
  23233. import { Bone } from "babylonjs/Bones/bone";
  23234. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23235. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23236. import { Space } from "babylonjs/Maths/math.axis";
  23237. /**
  23238. * The interface for the physics imposter parameters
  23239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23240. */
  23241. export interface PhysicsImpostorParameters {
  23242. /**
  23243. * The mass of the physics imposter
  23244. */
  23245. mass: number;
  23246. /**
  23247. * The friction of the physics imposter
  23248. */
  23249. friction?: number;
  23250. /**
  23251. * The coefficient of restitution of the physics imposter
  23252. */
  23253. restitution?: number;
  23254. /**
  23255. * The native options of the physics imposter
  23256. */
  23257. nativeOptions?: any;
  23258. /**
  23259. * Specifies if the parent should be ignored
  23260. */
  23261. ignoreParent?: boolean;
  23262. /**
  23263. * Specifies if bi-directional transformations should be disabled
  23264. */
  23265. disableBidirectionalTransformation?: boolean;
  23266. /**
  23267. * The pressure inside the physics imposter, soft object only
  23268. */
  23269. pressure?: number;
  23270. /**
  23271. * The stiffness the physics imposter, soft object only
  23272. */
  23273. stiffness?: number;
  23274. /**
  23275. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23276. */
  23277. velocityIterations?: number;
  23278. /**
  23279. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23280. */
  23281. positionIterations?: number;
  23282. /**
  23283. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23284. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23285. * Add to fix multiple points
  23286. */
  23287. fixedPoints?: number;
  23288. /**
  23289. * The collision margin around a soft object
  23290. */
  23291. margin?: number;
  23292. /**
  23293. * The collision margin around a soft object
  23294. */
  23295. damping?: number;
  23296. /**
  23297. * The path for a rope based on an extrusion
  23298. */
  23299. path?: any;
  23300. /**
  23301. * The shape of an extrusion used for a rope based on an extrusion
  23302. */
  23303. shape?: any;
  23304. }
  23305. /**
  23306. * Interface for a physics-enabled object
  23307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23308. */
  23309. export interface IPhysicsEnabledObject {
  23310. /**
  23311. * The position of the physics-enabled object
  23312. */
  23313. position: Vector3;
  23314. /**
  23315. * The rotation of the physics-enabled object
  23316. */
  23317. rotationQuaternion: Nullable<Quaternion>;
  23318. /**
  23319. * The scale of the physics-enabled object
  23320. */
  23321. scaling: Vector3;
  23322. /**
  23323. * The rotation of the physics-enabled object
  23324. */
  23325. rotation?: Vector3;
  23326. /**
  23327. * The parent of the physics-enabled object
  23328. */
  23329. parent?: any;
  23330. /**
  23331. * The bounding info of the physics-enabled object
  23332. * @returns The bounding info of the physics-enabled object
  23333. */
  23334. getBoundingInfo(): BoundingInfo;
  23335. /**
  23336. * Computes the world matrix
  23337. * @param force Specifies if the world matrix should be computed by force
  23338. * @returns A world matrix
  23339. */
  23340. computeWorldMatrix(force: boolean): Matrix;
  23341. /**
  23342. * Gets the world matrix
  23343. * @returns A world matrix
  23344. */
  23345. getWorldMatrix?(): Matrix;
  23346. /**
  23347. * Gets the child meshes
  23348. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23349. * @returns An array of abstract meshes
  23350. */
  23351. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23352. /**
  23353. * Gets the vertex data
  23354. * @param kind The type of vertex data
  23355. * @returns A nullable array of numbers, or a float32 array
  23356. */
  23357. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23358. /**
  23359. * Gets the indices from the mesh
  23360. * @returns A nullable array of index arrays
  23361. */
  23362. getIndices?(): Nullable<IndicesArray>;
  23363. /**
  23364. * Gets the scene from the mesh
  23365. * @returns the indices array or null
  23366. */
  23367. getScene?(): Scene;
  23368. /**
  23369. * Gets the absolute position from the mesh
  23370. * @returns the absolute position
  23371. */
  23372. getAbsolutePosition(): Vector3;
  23373. /**
  23374. * Gets the absolute pivot point from the mesh
  23375. * @returns the absolute pivot point
  23376. */
  23377. getAbsolutePivotPoint(): Vector3;
  23378. /**
  23379. * Rotates the mesh
  23380. * @param axis The axis of rotation
  23381. * @param amount The amount of rotation
  23382. * @param space The space of the rotation
  23383. * @returns The rotation transform node
  23384. */
  23385. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23386. /**
  23387. * Translates the mesh
  23388. * @param axis The axis of translation
  23389. * @param distance The distance of translation
  23390. * @param space The space of the translation
  23391. * @returns The transform node
  23392. */
  23393. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23394. /**
  23395. * Sets the absolute position of the mesh
  23396. * @param absolutePosition The absolute position of the mesh
  23397. * @returns The transform node
  23398. */
  23399. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23400. /**
  23401. * Gets the class name of the mesh
  23402. * @returns The class name
  23403. */
  23404. getClassName(): string;
  23405. }
  23406. /**
  23407. * Represents a physics imposter
  23408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23409. */
  23410. export class PhysicsImpostor {
  23411. /**
  23412. * The physics-enabled object used as the physics imposter
  23413. */
  23414. object: IPhysicsEnabledObject;
  23415. /**
  23416. * The type of the physics imposter
  23417. */
  23418. type: number;
  23419. private _options;
  23420. private _scene?;
  23421. /**
  23422. * The default object size of the imposter
  23423. */
  23424. static DEFAULT_OBJECT_SIZE: Vector3;
  23425. /**
  23426. * The identity quaternion of the imposter
  23427. */
  23428. static IDENTITY_QUATERNION: Quaternion;
  23429. /** @hidden */
  23430. _pluginData: any;
  23431. private _physicsEngine;
  23432. private _physicsBody;
  23433. private _bodyUpdateRequired;
  23434. private _onBeforePhysicsStepCallbacks;
  23435. private _onAfterPhysicsStepCallbacks;
  23436. /** @hidden */
  23437. _onPhysicsCollideCallbacks: Array<{
  23438. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23439. otherImpostors: Array<PhysicsImpostor>;
  23440. }>;
  23441. private _deltaPosition;
  23442. private _deltaRotation;
  23443. private _deltaRotationConjugated;
  23444. /** @hidden */
  23445. _isFromLine: boolean;
  23446. private _parent;
  23447. private _isDisposed;
  23448. private static _tmpVecs;
  23449. private static _tmpQuat;
  23450. /**
  23451. * Specifies if the physics imposter is disposed
  23452. */
  23453. readonly isDisposed: boolean;
  23454. /**
  23455. * Gets the mass of the physics imposter
  23456. */
  23457. mass: number;
  23458. /**
  23459. * Gets the coefficient of friction
  23460. */
  23461. /**
  23462. * Sets the coefficient of friction
  23463. */
  23464. friction: number;
  23465. /**
  23466. * Gets the coefficient of restitution
  23467. */
  23468. /**
  23469. * Sets the coefficient of restitution
  23470. */
  23471. restitution: number;
  23472. /**
  23473. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23474. */
  23475. /**
  23476. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23477. */
  23478. pressure: number;
  23479. /**
  23480. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23481. */
  23482. /**
  23483. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23484. */
  23485. stiffness: number;
  23486. /**
  23487. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23488. */
  23489. /**
  23490. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23491. */
  23492. velocityIterations: number;
  23493. /**
  23494. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23495. */
  23496. /**
  23497. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23498. */
  23499. positionIterations: number;
  23500. /**
  23501. * The unique id of the physics imposter
  23502. * set by the physics engine when adding this impostor to the array
  23503. */
  23504. uniqueId: number;
  23505. /**
  23506. * @hidden
  23507. */
  23508. soft: boolean;
  23509. /**
  23510. * @hidden
  23511. */
  23512. segments: number;
  23513. private _joints;
  23514. /**
  23515. * Initializes the physics imposter
  23516. * @param object The physics-enabled object used as the physics imposter
  23517. * @param type The type of the physics imposter
  23518. * @param _options The options for the physics imposter
  23519. * @param _scene The Babylon scene
  23520. */
  23521. constructor(
  23522. /**
  23523. * The physics-enabled object used as the physics imposter
  23524. */
  23525. object: IPhysicsEnabledObject,
  23526. /**
  23527. * The type of the physics imposter
  23528. */
  23529. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23530. /**
  23531. * This function will completly initialize this impostor.
  23532. * It will create a new body - but only if this mesh has no parent.
  23533. * If it has, this impostor will not be used other than to define the impostor
  23534. * of the child mesh.
  23535. * @hidden
  23536. */
  23537. _init(): void;
  23538. private _getPhysicsParent;
  23539. /**
  23540. * Should a new body be generated.
  23541. * @returns boolean specifying if body initialization is required
  23542. */
  23543. isBodyInitRequired(): boolean;
  23544. /**
  23545. * Sets the updated scaling
  23546. * @param updated Specifies if the scaling is updated
  23547. */
  23548. setScalingUpdated(): void;
  23549. /**
  23550. * Force a regeneration of this or the parent's impostor's body.
  23551. * Use under cautious - This will remove all joints already implemented.
  23552. */
  23553. forceUpdate(): void;
  23554. /**
  23555. * Gets the body that holds this impostor. Either its own, or its parent.
  23556. */
  23557. /**
  23558. * Set the physics body. Used mainly by the physics engine/plugin
  23559. */
  23560. physicsBody: any;
  23561. /**
  23562. * Get the parent of the physics imposter
  23563. * @returns Physics imposter or null
  23564. */
  23565. /**
  23566. * Sets the parent of the physics imposter
  23567. */
  23568. parent: Nullable<PhysicsImpostor>;
  23569. /**
  23570. * Resets the update flags
  23571. */
  23572. resetUpdateFlags(): void;
  23573. /**
  23574. * Gets the object extend size
  23575. * @returns the object extend size
  23576. */
  23577. getObjectExtendSize(): Vector3;
  23578. /**
  23579. * Gets the object center
  23580. * @returns The object center
  23581. */
  23582. getObjectCenter(): Vector3;
  23583. /**
  23584. * Get a specific parametes from the options parameter
  23585. * @param paramName The object parameter name
  23586. * @returns The object parameter
  23587. */
  23588. getParam(paramName: string): any;
  23589. /**
  23590. * Sets a specific parameter in the options given to the physics plugin
  23591. * @param paramName The parameter name
  23592. * @param value The value of the parameter
  23593. */
  23594. setParam(paramName: string, value: number): void;
  23595. /**
  23596. * Specifically change the body's mass option. Won't recreate the physics body object
  23597. * @param mass The mass of the physics imposter
  23598. */
  23599. setMass(mass: number): void;
  23600. /**
  23601. * Gets the linear velocity
  23602. * @returns linear velocity or null
  23603. */
  23604. getLinearVelocity(): Nullable<Vector3>;
  23605. /**
  23606. * Sets the linear velocity
  23607. * @param velocity linear velocity or null
  23608. */
  23609. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23610. /**
  23611. * Gets the angular velocity
  23612. * @returns angular velocity or null
  23613. */
  23614. getAngularVelocity(): Nullable<Vector3>;
  23615. /**
  23616. * Sets the angular velocity
  23617. * @param velocity The velocity or null
  23618. */
  23619. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23620. /**
  23621. * Execute a function with the physics plugin native code
  23622. * Provide a function the will have two variables - the world object and the physics body object
  23623. * @param func The function to execute with the physics plugin native code
  23624. */
  23625. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23626. /**
  23627. * Register a function that will be executed before the physics world is stepping forward
  23628. * @param func The function to execute before the physics world is stepped forward
  23629. */
  23630. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23631. /**
  23632. * Unregister a function that will be executed before the physics world is stepping forward
  23633. * @param func The function to execute before the physics world is stepped forward
  23634. */
  23635. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23636. /**
  23637. * Register a function that will be executed after the physics step
  23638. * @param func The function to execute after physics step
  23639. */
  23640. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23641. /**
  23642. * Unregisters a function that will be executed after the physics step
  23643. * @param func The function to execute after physics step
  23644. */
  23645. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23646. /**
  23647. * register a function that will be executed when this impostor collides against a different body
  23648. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23649. * @param func Callback that is executed on collision
  23650. */
  23651. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23652. /**
  23653. * Unregisters the physics imposter on contact
  23654. * @param collideAgainst The physics object to collide against
  23655. * @param func Callback to execute on collision
  23656. */
  23657. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23658. private _tmpQuat;
  23659. private _tmpQuat2;
  23660. /**
  23661. * Get the parent rotation
  23662. * @returns The parent rotation
  23663. */
  23664. getParentsRotation(): Quaternion;
  23665. /**
  23666. * this function is executed by the physics engine.
  23667. */
  23668. beforeStep: () => void;
  23669. /**
  23670. * this function is executed by the physics engine
  23671. */
  23672. afterStep: () => void;
  23673. /**
  23674. * Legacy collision detection event support
  23675. */
  23676. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23677. /**
  23678. * event and body object due to cannon's event-based architecture.
  23679. */
  23680. onCollide: (e: {
  23681. body: any;
  23682. }) => void;
  23683. /**
  23684. * Apply a force
  23685. * @param force The force to apply
  23686. * @param contactPoint The contact point for the force
  23687. * @returns The physics imposter
  23688. */
  23689. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23690. /**
  23691. * Apply an impulse
  23692. * @param force The impulse force
  23693. * @param contactPoint The contact point for the impulse force
  23694. * @returns The physics imposter
  23695. */
  23696. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23697. /**
  23698. * A help function to create a joint
  23699. * @param otherImpostor A physics imposter used to create a joint
  23700. * @param jointType The type of joint
  23701. * @param jointData The data for the joint
  23702. * @returns The physics imposter
  23703. */
  23704. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23705. /**
  23706. * Add a joint to this impostor with a different impostor
  23707. * @param otherImpostor A physics imposter used to add a joint
  23708. * @param joint The joint to add
  23709. * @returns The physics imposter
  23710. */
  23711. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23712. /**
  23713. * Add an anchor to a cloth impostor
  23714. * @param otherImpostor rigid impostor to anchor to
  23715. * @param width ratio across width from 0 to 1
  23716. * @param height ratio up height from 0 to 1
  23717. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23718. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23719. * @returns impostor the soft imposter
  23720. */
  23721. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23722. /**
  23723. * Add a hook to a rope impostor
  23724. * @param otherImpostor rigid impostor to anchor to
  23725. * @param length ratio across rope from 0 to 1
  23726. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23727. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23728. * @returns impostor the rope imposter
  23729. */
  23730. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23731. /**
  23732. * Will keep this body still, in a sleep mode.
  23733. * @returns the physics imposter
  23734. */
  23735. sleep(): PhysicsImpostor;
  23736. /**
  23737. * Wake the body up.
  23738. * @returns The physics imposter
  23739. */
  23740. wakeUp(): PhysicsImpostor;
  23741. /**
  23742. * Clones the physics imposter
  23743. * @param newObject The physics imposter clones to this physics-enabled object
  23744. * @returns A nullable physics imposter
  23745. */
  23746. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23747. /**
  23748. * Disposes the physics imposter
  23749. */
  23750. dispose(): void;
  23751. /**
  23752. * Sets the delta position
  23753. * @param position The delta position amount
  23754. */
  23755. setDeltaPosition(position: Vector3): void;
  23756. /**
  23757. * Sets the delta rotation
  23758. * @param rotation The delta rotation amount
  23759. */
  23760. setDeltaRotation(rotation: Quaternion): void;
  23761. /**
  23762. * Gets the box size of the physics imposter and stores the result in the input parameter
  23763. * @param result Stores the box size
  23764. * @returns The physics imposter
  23765. */
  23766. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23767. /**
  23768. * Gets the radius of the physics imposter
  23769. * @returns Radius of the physics imposter
  23770. */
  23771. getRadius(): number;
  23772. /**
  23773. * Sync a bone with this impostor
  23774. * @param bone The bone to sync to the impostor.
  23775. * @param boneMesh The mesh that the bone is influencing.
  23776. * @param jointPivot The pivot of the joint / bone in local space.
  23777. * @param distToJoint Optional distance from the impostor to the joint.
  23778. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23779. */
  23780. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23781. /**
  23782. * Sync impostor to a bone
  23783. * @param bone The bone that the impostor will be synced to.
  23784. * @param boneMesh The mesh that the bone is influencing.
  23785. * @param jointPivot The pivot of the joint / bone in local space.
  23786. * @param distToJoint Optional distance from the impostor to the joint.
  23787. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23788. * @param boneAxis Optional vector3 axis the bone is aligned with
  23789. */
  23790. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23791. /**
  23792. * No-Imposter type
  23793. */
  23794. static NoImpostor: number;
  23795. /**
  23796. * Sphere-Imposter type
  23797. */
  23798. static SphereImpostor: number;
  23799. /**
  23800. * Box-Imposter type
  23801. */
  23802. static BoxImpostor: number;
  23803. /**
  23804. * Plane-Imposter type
  23805. */
  23806. static PlaneImpostor: number;
  23807. /**
  23808. * Mesh-imposter type
  23809. */
  23810. static MeshImpostor: number;
  23811. /**
  23812. * Capsule-Impostor type (Ammo.js plugin only)
  23813. */
  23814. static CapsuleImpostor: number;
  23815. /**
  23816. * Cylinder-Imposter type
  23817. */
  23818. static CylinderImpostor: number;
  23819. /**
  23820. * Particle-Imposter type
  23821. */
  23822. static ParticleImpostor: number;
  23823. /**
  23824. * Heightmap-Imposter type
  23825. */
  23826. static HeightmapImpostor: number;
  23827. /**
  23828. * ConvexHull-Impostor type (Ammo.js plugin only)
  23829. */
  23830. static ConvexHullImpostor: number;
  23831. /**
  23832. * Rope-Imposter type
  23833. */
  23834. static RopeImpostor: number;
  23835. /**
  23836. * Cloth-Imposter type
  23837. */
  23838. static ClothImpostor: number;
  23839. /**
  23840. * Softbody-Imposter type
  23841. */
  23842. static SoftbodyImpostor: number;
  23843. }
  23844. }
  23845. declare module "babylonjs/Meshes/mesh" {
  23846. import { Observable } from "babylonjs/Misc/observable";
  23847. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23848. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23849. import { Camera } from "babylonjs/Cameras/camera";
  23850. import { Scene } from "babylonjs/scene";
  23851. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23852. import { Color4 } from "babylonjs/Maths/math.color";
  23853. import { Engine } from "babylonjs/Engines/engine";
  23854. import { Node } from "babylonjs/node";
  23855. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23856. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23857. import { Buffer } from "babylonjs/Meshes/buffer";
  23858. import { Geometry } from "babylonjs/Meshes/geometry";
  23859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23860. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23861. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23862. import { Effect } from "babylonjs/Materials/effect";
  23863. import { Material } from "babylonjs/Materials/material";
  23864. import { Skeleton } from "babylonjs/Bones/skeleton";
  23865. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23866. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23867. import { Path3D } from "babylonjs/Maths/math.path";
  23868. import { Plane } from "babylonjs/Maths/math.plane";
  23869. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23870. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23871. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23872. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23873. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23874. /**
  23875. * @hidden
  23876. **/
  23877. export class _CreationDataStorage {
  23878. closePath?: boolean;
  23879. closeArray?: boolean;
  23880. idx: number[];
  23881. dashSize: number;
  23882. gapSize: number;
  23883. path3D: Path3D;
  23884. pathArray: Vector3[][];
  23885. arc: number;
  23886. radius: number;
  23887. cap: number;
  23888. tessellation: number;
  23889. }
  23890. /**
  23891. * @hidden
  23892. **/
  23893. class _InstanceDataStorage {
  23894. visibleInstances: any;
  23895. batchCache: _InstancesBatch;
  23896. instancesBufferSize: number;
  23897. instancesBuffer: Nullable<Buffer>;
  23898. instancesData: Float32Array;
  23899. overridenInstanceCount: number;
  23900. isFrozen: boolean;
  23901. previousBatch: Nullable<_InstancesBatch>;
  23902. hardwareInstancedRendering: boolean;
  23903. sideOrientation: number;
  23904. }
  23905. /**
  23906. * @hidden
  23907. **/
  23908. export class _InstancesBatch {
  23909. mustReturn: boolean;
  23910. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23911. renderSelf: boolean[];
  23912. hardwareInstancedRendering: boolean[];
  23913. }
  23914. /**
  23915. * Class used to represent renderable models
  23916. */
  23917. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23918. /**
  23919. * Mesh side orientation : usually the external or front surface
  23920. */
  23921. static readonly FRONTSIDE: number;
  23922. /**
  23923. * Mesh side orientation : usually the internal or back surface
  23924. */
  23925. static readonly BACKSIDE: number;
  23926. /**
  23927. * Mesh side orientation : both internal and external or front and back surfaces
  23928. */
  23929. static readonly DOUBLESIDE: number;
  23930. /**
  23931. * Mesh side orientation : by default, `FRONTSIDE`
  23932. */
  23933. static readonly DEFAULTSIDE: number;
  23934. /**
  23935. * Mesh cap setting : no cap
  23936. */
  23937. static readonly NO_CAP: number;
  23938. /**
  23939. * Mesh cap setting : one cap at the beginning of the mesh
  23940. */
  23941. static readonly CAP_START: number;
  23942. /**
  23943. * Mesh cap setting : one cap at the end of the mesh
  23944. */
  23945. static readonly CAP_END: number;
  23946. /**
  23947. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23948. */
  23949. static readonly CAP_ALL: number;
  23950. /**
  23951. * Mesh pattern setting : no flip or rotate
  23952. */
  23953. static readonly NO_FLIP: number;
  23954. /**
  23955. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23956. */
  23957. static readonly FLIP_TILE: number;
  23958. /**
  23959. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23960. */
  23961. static readonly ROTATE_TILE: number;
  23962. /**
  23963. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23964. */
  23965. static readonly FLIP_ROW: number;
  23966. /**
  23967. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23968. */
  23969. static readonly ROTATE_ROW: number;
  23970. /**
  23971. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23972. */
  23973. static readonly FLIP_N_ROTATE_TILE: number;
  23974. /**
  23975. * Mesh pattern setting : rotate pattern and rotate
  23976. */
  23977. static readonly FLIP_N_ROTATE_ROW: number;
  23978. /**
  23979. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23980. */
  23981. static readonly CENTER: number;
  23982. /**
  23983. * Mesh tile positioning : part tiles on left
  23984. */
  23985. static readonly LEFT: number;
  23986. /**
  23987. * Mesh tile positioning : part tiles on right
  23988. */
  23989. static readonly RIGHT: number;
  23990. /**
  23991. * Mesh tile positioning : part tiles on top
  23992. */
  23993. static readonly TOP: number;
  23994. /**
  23995. * Mesh tile positioning : part tiles on bottom
  23996. */
  23997. static readonly BOTTOM: number;
  23998. /**
  23999. * Gets the default side orientation.
  24000. * @param orientation the orientation to value to attempt to get
  24001. * @returns the default orientation
  24002. * @hidden
  24003. */
  24004. static _GetDefaultSideOrientation(orientation?: number): number;
  24005. private _internalMeshDataInfo;
  24006. /**
  24007. * An event triggered before rendering the mesh
  24008. */
  24009. readonly onBeforeRenderObservable: Observable<Mesh>;
  24010. /**
  24011. * An event triggered before binding the mesh
  24012. */
  24013. readonly onBeforeBindObservable: Observable<Mesh>;
  24014. /**
  24015. * An event triggered after rendering the mesh
  24016. */
  24017. readonly onAfterRenderObservable: Observable<Mesh>;
  24018. /**
  24019. * An event triggered before drawing the mesh
  24020. */
  24021. readonly onBeforeDrawObservable: Observable<Mesh>;
  24022. private _onBeforeDrawObserver;
  24023. /**
  24024. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24025. */
  24026. onBeforeDraw: () => void;
  24027. /**
  24028. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24029. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24030. */
  24031. delayLoadState: number;
  24032. /**
  24033. * Gets the list of instances created from this mesh
  24034. * it is not supposed to be modified manually.
  24035. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24036. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24037. */
  24038. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24039. /**
  24040. * Gets the file containing delay loading data for this mesh
  24041. */
  24042. delayLoadingFile: string;
  24043. /** @hidden */
  24044. _binaryInfo: any;
  24045. /**
  24046. * User defined function used to change how LOD level selection is done
  24047. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24048. */
  24049. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24050. /**
  24051. * Gets or sets the morph target manager
  24052. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24053. */
  24054. morphTargetManager: Nullable<MorphTargetManager>;
  24055. /** @hidden */
  24056. _creationDataStorage: Nullable<_CreationDataStorage>;
  24057. /** @hidden */
  24058. _geometry: Nullable<Geometry>;
  24059. /** @hidden */
  24060. _delayInfo: Array<string>;
  24061. /** @hidden */
  24062. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24063. /** @hidden */
  24064. _instanceDataStorage: _InstanceDataStorage;
  24065. private _effectiveMaterial;
  24066. /** @hidden */
  24067. _shouldGenerateFlatShading: boolean;
  24068. /** @hidden */
  24069. _originalBuilderSideOrientation: number;
  24070. /**
  24071. * Use this property to change the original side orientation defined at construction time
  24072. */
  24073. overrideMaterialSideOrientation: Nullable<number>;
  24074. /**
  24075. * Gets the source mesh (the one used to clone this one from)
  24076. */
  24077. readonly source: Nullable<Mesh>;
  24078. /**
  24079. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24080. */
  24081. isUnIndexed: boolean;
  24082. /**
  24083. * @constructor
  24084. * @param name The value used by scene.getMeshByName() to do a lookup.
  24085. * @param scene The scene to add this mesh to.
  24086. * @param parent The parent of this mesh, if it has one
  24087. * @param source An optional Mesh from which geometry is shared, cloned.
  24088. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24089. * When false, achieved by calling a clone(), also passing False.
  24090. * This will make creation of children, recursive.
  24091. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24092. */
  24093. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24094. /**
  24095. * Gets the class name
  24096. * @returns the string "Mesh".
  24097. */
  24098. getClassName(): string;
  24099. /** @hidden */
  24100. readonly _isMesh: boolean;
  24101. /**
  24102. * Returns a description of this mesh
  24103. * @param fullDetails define if full details about this mesh must be used
  24104. * @returns a descriptive string representing this mesh
  24105. */
  24106. toString(fullDetails?: boolean): string;
  24107. /** @hidden */
  24108. _unBindEffect(): void;
  24109. /**
  24110. * Gets a boolean indicating if this mesh has LOD
  24111. */
  24112. readonly hasLODLevels: boolean;
  24113. /**
  24114. * Gets the list of MeshLODLevel associated with the current mesh
  24115. * @returns an array of MeshLODLevel
  24116. */
  24117. getLODLevels(): MeshLODLevel[];
  24118. private _sortLODLevels;
  24119. /**
  24120. * Add a mesh as LOD level triggered at the given distance.
  24121. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24122. * @param distance The distance from the center of the object to show this level
  24123. * @param mesh The mesh to be added as LOD level (can be null)
  24124. * @return This mesh (for chaining)
  24125. */
  24126. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24127. /**
  24128. * Returns the LOD level mesh at the passed distance or null if not found.
  24129. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24130. * @param distance The distance from the center of the object to show this level
  24131. * @returns a Mesh or `null`
  24132. */
  24133. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24134. /**
  24135. * Remove a mesh from the LOD array
  24136. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24137. * @param mesh defines the mesh to be removed
  24138. * @return This mesh (for chaining)
  24139. */
  24140. removeLODLevel(mesh: Mesh): Mesh;
  24141. /**
  24142. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24143. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24144. * @param camera defines the camera to use to compute distance
  24145. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24146. * @return This mesh (for chaining)
  24147. */
  24148. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24149. /**
  24150. * Gets the mesh internal Geometry object
  24151. */
  24152. readonly geometry: Nullable<Geometry>;
  24153. /**
  24154. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24155. * @returns the total number of vertices
  24156. */
  24157. getTotalVertices(): number;
  24158. /**
  24159. * Returns the content of an associated vertex buffer
  24160. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24161. * - VertexBuffer.PositionKind
  24162. * - VertexBuffer.UVKind
  24163. * - VertexBuffer.UV2Kind
  24164. * - VertexBuffer.UV3Kind
  24165. * - VertexBuffer.UV4Kind
  24166. * - VertexBuffer.UV5Kind
  24167. * - VertexBuffer.UV6Kind
  24168. * - VertexBuffer.ColorKind
  24169. * - VertexBuffer.MatricesIndicesKind
  24170. * - VertexBuffer.MatricesIndicesExtraKind
  24171. * - VertexBuffer.MatricesWeightsKind
  24172. * - VertexBuffer.MatricesWeightsExtraKind
  24173. * @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
  24174. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24175. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24176. */
  24177. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24178. /**
  24179. * Returns the mesh VertexBuffer object from the requested `kind`
  24180. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24181. * - VertexBuffer.PositionKind
  24182. * - VertexBuffer.NormalKind
  24183. * - VertexBuffer.UVKind
  24184. * - VertexBuffer.UV2Kind
  24185. * - VertexBuffer.UV3Kind
  24186. * - VertexBuffer.UV4Kind
  24187. * - VertexBuffer.UV5Kind
  24188. * - VertexBuffer.UV6Kind
  24189. * - VertexBuffer.ColorKind
  24190. * - VertexBuffer.MatricesIndicesKind
  24191. * - VertexBuffer.MatricesIndicesExtraKind
  24192. * - VertexBuffer.MatricesWeightsKind
  24193. * - VertexBuffer.MatricesWeightsExtraKind
  24194. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24195. */
  24196. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24197. /**
  24198. * Tests if a specific vertex buffer is associated with this mesh
  24199. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24200. * - VertexBuffer.PositionKind
  24201. * - VertexBuffer.NormalKind
  24202. * - VertexBuffer.UVKind
  24203. * - VertexBuffer.UV2Kind
  24204. * - VertexBuffer.UV3Kind
  24205. * - VertexBuffer.UV4Kind
  24206. * - VertexBuffer.UV5Kind
  24207. * - VertexBuffer.UV6Kind
  24208. * - VertexBuffer.ColorKind
  24209. * - VertexBuffer.MatricesIndicesKind
  24210. * - VertexBuffer.MatricesIndicesExtraKind
  24211. * - VertexBuffer.MatricesWeightsKind
  24212. * - VertexBuffer.MatricesWeightsExtraKind
  24213. * @returns a boolean
  24214. */
  24215. isVerticesDataPresent(kind: string): boolean;
  24216. /**
  24217. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24218. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24219. * - VertexBuffer.PositionKind
  24220. * - VertexBuffer.UVKind
  24221. * - VertexBuffer.UV2Kind
  24222. * - VertexBuffer.UV3Kind
  24223. * - VertexBuffer.UV4Kind
  24224. * - VertexBuffer.UV5Kind
  24225. * - VertexBuffer.UV6Kind
  24226. * - VertexBuffer.ColorKind
  24227. * - VertexBuffer.MatricesIndicesKind
  24228. * - VertexBuffer.MatricesIndicesExtraKind
  24229. * - VertexBuffer.MatricesWeightsKind
  24230. * - VertexBuffer.MatricesWeightsExtraKind
  24231. * @returns a boolean
  24232. */
  24233. isVertexBufferUpdatable(kind: string): boolean;
  24234. /**
  24235. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24236. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24237. * - VertexBuffer.PositionKind
  24238. * - VertexBuffer.NormalKind
  24239. * - VertexBuffer.UVKind
  24240. * - VertexBuffer.UV2Kind
  24241. * - VertexBuffer.UV3Kind
  24242. * - VertexBuffer.UV4Kind
  24243. * - VertexBuffer.UV5Kind
  24244. * - VertexBuffer.UV6Kind
  24245. * - VertexBuffer.ColorKind
  24246. * - VertexBuffer.MatricesIndicesKind
  24247. * - VertexBuffer.MatricesIndicesExtraKind
  24248. * - VertexBuffer.MatricesWeightsKind
  24249. * - VertexBuffer.MatricesWeightsExtraKind
  24250. * @returns an array of strings
  24251. */
  24252. getVerticesDataKinds(): string[];
  24253. /**
  24254. * Returns a positive integer : the total number of indices in this mesh geometry.
  24255. * @returns the numner of indices or zero if the mesh has no geometry.
  24256. */
  24257. getTotalIndices(): number;
  24258. /**
  24259. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24260. * @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.
  24261. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24262. * @returns the indices array or an empty array if the mesh has no geometry
  24263. */
  24264. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24265. readonly isBlocked: boolean;
  24266. /**
  24267. * Determine if the current mesh is ready to be rendered
  24268. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24269. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24270. * @returns true if all associated assets are ready (material, textures, shaders)
  24271. */
  24272. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24273. /**
  24274. * 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.
  24275. */
  24276. readonly areNormalsFrozen: boolean;
  24277. /**
  24278. * 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.
  24279. * @returns the current mesh
  24280. */
  24281. freezeNormals(): Mesh;
  24282. /**
  24283. * 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
  24284. * @returns the current mesh
  24285. */
  24286. unfreezeNormals(): Mesh;
  24287. /**
  24288. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24289. */
  24290. overridenInstanceCount: number;
  24291. /** @hidden */
  24292. _preActivate(): Mesh;
  24293. /** @hidden */
  24294. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24295. /** @hidden */
  24296. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24297. /**
  24298. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24299. * This means the mesh underlying bounding box and sphere are recomputed.
  24300. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24301. * @returns the current mesh
  24302. */
  24303. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24304. /** @hidden */
  24305. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24306. /**
  24307. * This function will subdivide the mesh into multiple submeshes
  24308. * @param count defines the expected number of submeshes
  24309. */
  24310. subdivide(count: number): void;
  24311. /**
  24312. * Copy a FloatArray into a specific associated vertex buffer
  24313. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24314. * - VertexBuffer.PositionKind
  24315. * - VertexBuffer.UVKind
  24316. * - VertexBuffer.UV2Kind
  24317. * - VertexBuffer.UV3Kind
  24318. * - VertexBuffer.UV4Kind
  24319. * - VertexBuffer.UV5Kind
  24320. * - VertexBuffer.UV6Kind
  24321. * - VertexBuffer.ColorKind
  24322. * - VertexBuffer.MatricesIndicesKind
  24323. * - VertexBuffer.MatricesIndicesExtraKind
  24324. * - VertexBuffer.MatricesWeightsKind
  24325. * - VertexBuffer.MatricesWeightsExtraKind
  24326. * @param data defines the data source
  24327. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24328. * @param stride defines the data stride size (can be null)
  24329. * @returns the current mesh
  24330. */
  24331. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24332. /**
  24333. * Flags an associated vertex buffer as updatable
  24334. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24335. * - VertexBuffer.PositionKind
  24336. * - VertexBuffer.UVKind
  24337. * - VertexBuffer.UV2Kind
  24338. * - VertexBuffer.UV3Kind
  24339. * - VertexBuffer.UV4Kind
  24340. * - VertexBuffer.UV5Kind
  24341. * - VertexBuffer.UV6Kind
  24342. * - VertexBuffer.ColorKind
  24343. * - VertexBuffer.MatricesIndicesKind
  24344. * - VertexBuffer.MatricesIndicesExtraKind
  24345. * - VertexBuffer.MatricesWeightsKind
  24346. * - VertexBuffer.MatricesWeightsExtraKind
  24347. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24348. */
  24349. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24350. /**
  24351. * Sets the mesh global Vertex Buffer
  24352. * @param buffer defines the buffer to use
  24353. * @returns the current mesh
  24354. */
  24355. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24356. /**
  24357. * Update a specific associated vertex buffer
  24358. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24359. * - VertexBuffer.PositionKind
  24360. * - VertexBuffer.UVKind
  24361. * - VertexBuffer.UV2Kind
  24362. * - VertexBuffer.UV3Kind
  24363. * - VertexBuffer.UV4Kind
  24364. * - VertexBuffer.UV5Kind
  24365. * - VertexBuffer.UV6Kind
  24366. * - VertexBuffer.ColorKind
  24367. * - VertexBuffer.MatricesIndicesKind
  24368. * - VertexBuffer.MatricesIndicesExtraKind
  24369. * - VertexBuffer.MatricesWeightsKind
  24370. * - VertexBuffer.MatricesWeightsExtraKind
  24371. * @param data defines the data source
  24372. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24373. * @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)
  24374. * @returns the current mesh
  24375. */
  24376. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24377. /**
  24378. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24379. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24380. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24381. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24382. * @returns the current mesh
  24383. */
  24384. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24385. /**
  24386. * Creates a un-shared specific occurence of the geometry for the mesh.
  24387. * @returns the current mesh
  24388. */
  24389. makeGeometryUnique(): Mesh;
  24390. /**
  24391. * Set the index buffer of this mesh
  24392. * @param indices defines the source data
  24393. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24394. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24395. * @returns the current mesh
  24396. */
  24397. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24398. /**
  24399. * Update the current index buffer
  24400. * @param indices defines the source data
  24401. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24402. * @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)
  24403. * @returns the current mesh
  24404. */
  24405. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  24406. /**
  24407. * Invert the geometry to move from a right handed system to a left handed one.
  24408. * @returns the current mesh
  24409. */
  24410. toLeftHanded(): Mesh;
  24411. /** @hidden */
  24412. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24413. /** @hidden */
  24414. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24415. /**
  24416. * Registers for this mesh a javascript function called just before the rendering process
  24417. * @param func defines the function to call before rendering this mesh
  24418. * @returns the current mesh
  24419. */
  24420. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24421. /**
  24422. * Disposes a previously registered javascript function called before the rendering
  24423. * @param func defines the function to remove
  24424. * @returns the current mesh
  24425. */
  24426. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24427. /**
  24428. * Registers for this mesh a javascript function called just after the rendering is complete
  24429. * @param func defines the function to call after rendering this mesh
  24430. * @returns the current mesh
  24431. */
  24432. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24433. /**
  24434. * Disposes a previously registered javascript function called after the rendering.
  24435. * @param func defines the function to remove
  24436. * @returns the current mesh
  24437. */
  24438. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24439. /** @hidden */
  24440. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24441. /** @hidden */
  24442. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24443. /** @hidden */
  24444. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24445. /** @hidden */
  24446. _rebuild(): void;
  24447. /** @hidden */
  24448. _freeze(): void;
  24449. /** @hidden */
  24450. _unFreeze(): void;
  24451. /**
  24452. * 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
  24453. * @param subMesh defines the subMesh to render
  24454. * @param enableAlphaMode defines if alpha mode can be changed
  24455. * @returns the current mesh
  24456. */
  24457. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24458. private _onBeforeDraw;
  24459. /**
  24460. * Renormalize the mesh and patch it up if there are no weights
  24461. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24462. * However in the case of zero weights then we set just a single influence to 1.
  24463. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24464. */
  24465. cleanMatrixWeights(): void;
  24466. private normalizeSkinFourWeights;
  24467. private normalizeSkinWeightsAndExtra;
  24468. /**
  24469. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24470. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24471. * the user know there was an issue with importing the mesh
  24472. * @returns a validation object with skinned, valid and report string
  24473. */
  24474. validateSkinning(): {
  24475. skinned: boolean;
  24476. valid: boolean;
  24477. report: string;
  24478. };
  24479. /** @hidden */
  24480. _checkDelayState(): Mesh;
  24481. private _queueLoad;
  24482. /**
  24483. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24484. * A mesh is in the frustum if its bounding box intersects the frustum
  24485. * @param frustumPlanes defines the frustum to test
  24486. * @returns true if the mesh is in the frustum planes
  24487. */
  24488. isInFrustum(frustumPlanes: Plane[]): boolean;
  24489. /**
  24490. * Sets the mesh material by the material or multiMaterial `id` property
  24491. * @param id is a string identifying the material or the multiMaterial
  24492. * @returns the current mesh
  24493. */
  24494. setMaterialByID(id: string): Mesh;
  24495. /**
  24496. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24497. * @returns an array of IAnimatable
  24498. */
  24499. getAnimatables(): IAnimatable[];
  24500. /**
  24501. * Modifies the mesh geometry according to the passed transformation matrix.
  24502. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24503. * The mesh normals are modified using the same transformation.
  24504. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24505. * @param transform defines the transform matrix to use
  24506. * @see http://doc.babylonjs.com/resources/baking_transformations
  24507. * @returns the current mesh
  24508. */
  24509. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24510. /**
  24511. * Modifies the mesh geometry according to its own current World Matrix.
  24512. * The mesh World Matrix is then reset.
  24513. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24514. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24515. * @see http://doc.babylonjs.com/resources/baking_transformations
  24516. * @returns the current mesh
  24517. */
  24518. bakeCurrentTransformIntoVertices(): Mesh;
  24519. /** @hidden */
  24520. readonly _positions: Nullable<Vector3[]>;
  24521. /** @hidden */
  24522. _resetPointsArrayCache(): Mesh;
  24523. /** @hidden */
  24524. _generatePointsArray(): boolean;
  24525. /**
  24526. * Returns a new Mesh object generated from the current mesh properties.
  24527. * This method must not get confused with createInstance()
  24528. * @param name is a string, the name given to the new mesh
  24529. * @param newParent can be any Node object (default `null`)
  24530. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24531. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24532. * @returns a new mesh
  24533. */
  24534. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24535. /**
  24536. * Releases resources associated with this mesh.
  24537. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24538. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24539. */
  24540. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24541. /**
  24542. * Modifies the mesh geometry according to a displacement map.
  24543. * 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.
  24544. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24545. * @param url is a string, the URL from the image file is to be downloaded.
  24546. * @param minHeight is the lower limit of the displacement.
  24547. * @param maxHeight is the upper limit of the displacement.
  24548. * @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.
  24549. * @param uvOffset is an optional vector2 used to offset UV.
  24550. * @param uvScale is an optional vector2 used to scale UV.
  24551. * @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.
  24552. * @returns the Mesh.
  24553. */
  24554. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24555. /**
  24556. * Modifies the mesh geometry according to a displacementMap buffer.
  24557. * 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.
  24558. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24559. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24560. * @param heightMapWidth is the width of the buffer image.
  24561. * @param heightMapHeight is the height of the buffer image.
  24562. * @param minHeight is the lower limit of the displacement.
  24563. * @param maxHeight is the upper limit of the displacement.
  24564. * @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.
  24565. * @param uvOffset is an optional vector2 used to offset UV.
  24566. * @param uvScale is an optional vector2 used to scale UV.
  24567. * @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.
  24568. * @returns the Mesh.
  24569. */
  24570. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24571. /**
  24572. * Modify the mesh to get a flat shading rendering.
  24573. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24574. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24575. * @returns current mesh
  24576. */
  24577. convertToFlatShadedMesh(): Mesh;
  24578. /**
  24579. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24580. * In other words, more vertices, no more indices and a single bigger VBO.
  24581. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24582. * @returns current mesh
  24583. */
  24584. convertToUnIndexedMesh(): Mesh;
  24585. /**
  24586. * Inverses facet orientations.
  24587. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24588. * @param flipNormals will also inverts the normals
  24589. * @returns current mesh
  24590. */
  24591. flipFaces(flipNormals?: boolean): Mesh;
  24592. /**
  24593. * Increase the number of facets and hence vertices in a mesh
  24594. * Vertex normals are interpolated from existing vertex normals
  24595. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24596. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24597. */
  24598. increaseVertices(numberPerEdge: number): void;
  24599. /**
  24600. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24601. * This will undo any application of covertToFlatShadedMesh
  24602. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24603. */
  24604. forceSharedVertices(): void;
  24605. /** @hidden */
  24606. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24607. /** @hidden */
  24608. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24609. /**
  24610. * Creates a new InstancedMesh object from the mesh model.
  24611. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24612. * @param name defines the name of the new instance
  24613. * @returns a new InstancedMesh
  24614. */
  24615. createInstance(name: string): InstancedMesh;
  24616. /**
  24617. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24618. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24619. * @returns the current mesh
  24620. */
  24621. synchronizeInstances(): Mesh;
  24622. /**
  24623. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24624. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24625. * This should be used together with the simplification to avoid disappearing triangles.
  24626. * @param successCallback an optional success callback to be called after the optimization finished.
  24627. * @returns the current mesh
  24628. */
  24629. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24630. /**
  24631. * Serialize current mesh
  24632. * @param serializationObject defines the object which will receive the serialization data
  24633. */
  24634. serialize(serializationObject: any): void;
  24635. /** @hidden */
  24636. _syncGeometryWithMorphTargetManager(): void;
  24637. /** @hidden */
  24638. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24639. /**
  24640. * Returns a new Mesh object parsed from the source provided.
  24641. * @param parsedMesh is the source
  24642. * @param scene defines the hosting scene
  24643. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24644. * @returns a new Mesh
  24645. */
  24646. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24647. /**
  24648. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24649. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24650. * @param name defines the name of the mesh to create
  24651. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24652. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24653. * @param closePath creates a seam between the first and the last points of each path of the path array
  24654. * @param offset is taken in account only if the `pathArray` is containing a single path
  24655. * @param scene defines the hosting scene
  24656. * @param updatable defines if the mesh must be flagged as updatable
  24657. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24658. * @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)
  24659. * @returns a new Mesh
  24660. */
  24661. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24662. /**
  24663. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24664. * @param name defines the name of the mesh to create
  24665. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24666. * @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
  24667. * @param scene defines the hosting scene
  24668. * @param updatable defines if the mesh must be flagged as updatable
  24669. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24670. * @returns a new Mesh
  24671. */
  24672. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24673. /**
  24674. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24675. * @param name defines the name of the mesh to create
  24676. * @param size sets the size (float) of each box side (default 1)
  24677. * @param scene defines the hosting scene
  24678. * @param updatable defines if the mesh must be flagged as updatable
  24679. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24680. * @returns a new Mesh
  24681. */
  24682. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24683. /**
  24684. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24685. * @param name defines the name of the mesh to create
  24686. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24687. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24688. * @param scene defines the hosting scene
  24689. * @param updatable defines if the mesh must be flagged as updatable
  24690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24691. * @returns a new Mesh
  24692. */
  24693. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24694. /**
  24695. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24696. * @param name defines the name of the mesh to create
  24697. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24698. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24699. * @param scene defines the hosting scene
  24700. * @returns a new Mesh
  24701. */
  24702. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24703. /**
  24704. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24705. * @param name defines the name of the mesh to create
  24706. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24707. * @param diameterTop set the top cap diameter (floats, default 1)
  24708. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24709. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24710. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24711. * @param scene defines the hosting scene
  24712. * @param updatable defines if the mesh must be flagged as updatable
  24713. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24714. * @returns a new Mesh
  24715. */
  24716. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24717. /**
  24718. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24719. * @param name defines the name of the mesh to create
  24720. * @param diameter sets the diameter size (float) of the torus (default 1)
  24721. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24722. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24723. * @param scene defines the hosting scene
  24724. * @param updatable defines if the mesh must be flagged as updatable
  24725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24726. * @returns a new Mesh
  24727. */
  24728. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24729. /**
  24730. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24731. * @param name defines the name of the mesh to create
  24732. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24733. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24734. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24735. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24736. * @param p the number of windings on X axis (positive integers, default 2)
  24737. * @param q the number of windings on Y axis (positive integers, default 3)
  24738. * @param scene defines the hosting scene
  24739. * @param updatable defines if the mesh must be flagged as updatable
  24740. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24741. * @returns a new Mesh
  24742. */
  24743. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24744. /**
  24745. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24746. * @param name defines the name of the mesh to create
  24747. * @param points is an array successive Vector3
  24748. * @param scene defines the hosting scene
  24749. * @param updatable defines if the mesh must be flagged as updatable
  24750. * @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).
  24751. * @returns a new Mesh
  24752. */
  24753. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24754. /**
  24755. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24756. * @param name defines the name of the mesh to create
  24757. * @param points is an array successive Vector3
  24758. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24759. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24760. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24761. * @param scene defines the hosting scene
  24762. * @param updatable defines if the mesh must be flagged as updatable
  24763. * @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)
  24764. * @returns a new Mesh
  24765. */
  24766. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24767. /**
  24768. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24769. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24770. * 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.
  24771. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24772. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24773. * Remember you can only change the shape positions, not their number when updating a polygon.
  24774. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24775. * @param name defines the name of the mesh to create
  24776. * @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
  24777. * @param scene defines the hosting scene
  24778. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24779. * @param updatable defines if the mesh must be flagged as updatable
  24780. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24781. * @param earcutInjection can be used to inject your own earcut reference
  24782. * @returns a new Mesh
  24783. */
  24784. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24785. /**
  24786. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24787. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24788. * @param name defines the name of the mesh to create
  24789. * @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
  24790. * @param depth defines the height of extrusion
  24791. * @param scene defines the hosting scene
  24792. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24793. * @param updatable defines if the mesh must be flagged as updatable
  24794. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24795. * @param earcutInjection can be used to inject your own earcut reference
  24796. * @returns a new Mesh
  24797. */
  24798. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24799. /**
  24800. * Creates an extruded shape mesh.
  24801. * 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
  24802. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24803. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24804. * @param name defines the name of the mesh to create
  24805. * @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
  24806. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24807. * @param scale is the value to scale the shape
  24808. * @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
  24809. * @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
  24810. * @param scene defines the hosting scene
  24811. * @param updatable defines if the mesh must be flagged as updatable
  24812. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24813. * @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)
  24814. * @returns a new Mesh
  24815. */
  24816. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24817. /**
  24818. * Creates an custom extruded shape mesh.
  24819. * The custom extrusion is a parametric shape.
  24820. * It has no predefined shape. Its final shape will depend on the input parameters.
  24821. * Please consider using the same method from the MeshBuilder class instead
  24822. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24823. * @param name defines the name of the mesh to create
  24824. * @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
  24825. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24826. * @param scaleFunction is a custom Javascript function called on each path point
  24827. * @param rotationFunction is a custom Javascript function called on each path point
  24828. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24829. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24830. * @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
  24831. * @param scene defines the hosting scene
  24832. * @param updatable defines if the mesh must be flagged as updatable
  24833. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24834. * @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)
  24835. * @returns a new Mesh
  24836. */
  24837. 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;
  24838. /**
  24839. * Creates lathe mesh.
  24840. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24841. * Please consider using the same method from the MeshBuilder class instead
  24842. * @param name defines the name of the mesh to create
  24843. * @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
  24844. * @param radius is the radius value of the lathe
  24845. * @param tessellation is the side number of the lathe.
  24846. * @param scene defines the hosting scene
  24847. * @param updatable defines if the mesh must be flagged as updatable
  24848. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24849. * @returns a new Mesh
  24850. */
  24851. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24852. /**
  24853. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24854. * @param name defines the name of the mesh to create
  24855. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24856. * @param scene defines the hosting scene
  24857. * @param updatable defines if the mesh must be flagged as updatable
  24858. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24859. * @returns a new Mesh
  24860. */
  24861. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24862. /**
  24863. * Creates a ground mesh.
  24864. * Please consider using the same method from the MeshBuilder class instead
  24865. * @param name defines the name of the mesh to create
  24866. * @param width set the width of the ground
  24867. * @param height set the height of the ground
  24868. * @param subdivisions sets the number of subdivisions per side
  24869. * @param scene defines the hosting scene
  24870. * @param updatable defines if the mesh must be flagged as updatable
  24871. * @returns a new Mesh
  24872. */
  24873. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24874. /**
  24875. * Creates a tiled ground mesh.
  24876. * Please consider using the same method from the MeshBuilder class instead
  24877. * @param name defines the name of the mesh to create
  24878. * @param xmin set the ground minimum X coordinate
  24879. * @param zmin set the ground minimum Y coordinate
  24880. * @param xmax set the ground maximum X coordinate
  24881. * @param zmax set the ground maximum Z coordinate
  24882. * @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
  24883. * @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
  24884. * @param scene defines the hosting scene
  24885. * @param updatable defines if the mesh must be flagged as updatable
  24886. * @returns a new Mesh
  24887. */
  24888. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24889. w: number;
  24890. h: number;
  24891. }, precision: {
  24892. w: number;
  24893. h: number;
  24894. }, scene: Scene, updatable?: boolean): Mesh;
  24895. /**
  24896. * Creates a ground mesh from a height map.
  24897. * Please consider using the same method from the MeshBuilder class instead
  24898. * @see http://doc.babylonjs.com/babylon101/height_map
  24899. * @param name defines the name of the mesh to create
  24900. * @param url sets the URL of the height map image resource
  24901. * @param width set the ground width size
  24902. * @param height set the ground height size
  24903. * @param subdivisions sets the number of subdivision per side
  24904. * @param minHeight is the minimum altitude on the ground
  24905. * @param maxHeight is the maximum altitude on the ground
  24906. * @param scene defines the hosting scene
  24907. * @param updatable defines if the mesh must be flagged as updatable
  24908. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24909. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24910. * @returns a new Mesh
  24911. */
  24912. 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;
  24913. /**
  24914. * Creates a tube mesh.
  24915. * The tube is a parametric shape.
  24916. * It has no predefined shape. Its final shape will depend on the input parameters.
  24917. * Please consider using the same method from the MeshBuilder class instead
  24918. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24919. * @param name defines the name of the mesh to create
  24920. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24921. * @param radius sets the tube radius size
  24922. * @param tessellation is the number of sides on the tubular surface
  24923. * @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
  24924. * @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
  24925. * @param scene defines the hosting scene
  24926. * @param updatable defines if the mesh must be flagged as updatable
  24927. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24928. * @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)
  24929. * @returns a new Mesh
  24930. */
  24931. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24932. (i: number, distance: number): number;
  24933. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24934. /**
  24935. * Creates a polyhedron mesh.
  24936. * Please consider using the same method from the MeshBuilder class instead.
  24937. * * 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
  24938. * * The parameter `size` (positive float, default 1) sets the polygon size
  24939. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24940. * * 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`
  24941. * * 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
  24942. * * 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)`)
  24943. * * 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
  24944. * * 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
  24945. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24946. * * If you create a double-sided mesh, you can choose what parts of 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
  24947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24948. * @param name defines the name of the mesh to create
  24949. * @param options defines the options used to create the mesh
  24950. * @param scene defines the hosting scene
  24951. * @returns a new Mesh
  24952. */
  24953. static CreatePolyhedron(name: string, options: {
  24954. type?: number;
  24955. size?: number;
  24956. sizeX?: number;
  24957. sizeY?: number;
  24958. sizeZ?: number;
  24959. custom?: any;
  24960. faceUV?: Vector4[];
  24961. faceColors?: Color4[];
  24962. updatable?: boolean;
  24963. sideOrientation?: number;
  24964. }, scene: Scene): Mesh;
  24965. /**
  24966. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24967. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24968. * * 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`)
  24969. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24970. * * 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
  24971. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24972. * * If you create a double-sided mesh, you can choose what parts of 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
  24973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24974. * @param name defines the name of the mesh
  24975. * @param options defines the options used to create the mesh
  24976. * @param scene defines the hosting scene
  24977. * @returns a new Mesh
  24978. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24979. */
  24980. static CreateIcoSphere(name: string, options: {
  24981. radius?: number;
  24982. flat?: boolean;
  24983. subdivisions?: number;
  24984. sideOrientation?: number;
  24985. updatable?: boolean;
  24986. }, scene: Scene): Mesh;
  24987. /**
  24988. * Creates a decal mesh.
  24989. * Please consider using the same method from the MeshBuilder class instead.
  24990. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24991. * @param name defines the name of the mesh
  24992. * @param sourceMesh defines the mesh receiving the decal
  24993. * @param position sets the position of the decal in world coordinates
  24994. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24995. * @param size sets the decal scaling
  24996. * @param angle sets the angle to rotate the decal
  24997. * @returns a new Mesh
  24998. */
  24999. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25000. /**
  25001. * Prepare internal position array for software CPU skinning
  25002. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25003. */
  25004. setPositionsForCPUSkinning(): Float32Array;
  25005. /**
  25006. * Prepare internal normal array for software CPU skinning
  25007. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25008. */
  25009. setNormalsForCPUSkinning(): Float32Array;
  25010. /**
  25011. * Updates the vertex buffer by applying transformation from the bones
  25012. * @param skeleton defines the skeleton to apply to current mesh
  25013. * @returns the current mesh
  25014. */
  25015. applySkeleton(skeleton: Skeleton): Mesh;
  25016. /**
  25017. * 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
  25018. * @param meshes defines the list of meshes to scan
  25019. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25020. */
  25021. static MinMax(meshes: AbstractMesh[]): {
  25022. min: Vector3;
  25023. max: Vector3;
  25024. };
  25025. /**
  25026. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25027. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25028. * @returns a vector3
  25029. */
  25030. static Center(meshesOrMinMaxVector: {
  25031. min: Vector3;
  25032. max: Vector3;
  25033. } | AbstractMesh[]): Vector3;
  25034. /**
  25035. * Merge the array of meshes into a single mesh for performance reasons.
  25036. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25037. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25038. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25039. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25040. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25041. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25042. * @returns a new mesh
  25043. */
  25044. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25045. /** @hidden */
  25046. addInstance(instance: InstancedMesh): void;
  25047. /** @hidden */
  25048. removeInstance(instance: InstancedMesh): void;
  25049. }
  25050. }
  25051. declare module "babylonjs/Cameras/camera" {
  25052. import { SmartArray } from "babylonjs/Misc/smartArray";
  25053. import { Observable } from "babylonjs/Misc/observable";
  25054. import { Nullable } from "babylonjs/types";
  25055. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25056. import { Scene } from "babylonjs/scene";
  25057. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25058. import { Node } from "babylonjs/node";
  25059. import { Mesh } from "babylonjs/Meshes/mesh";
  25060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25061. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25062. import { Viewport } from "babylonjs/Maths/math.viewport";
  25063. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25064. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25065. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25066. import { Ray } from "babylonjs/Culling/ray";
  25067. /**
  25068. * This is the base class of all the camera used in the application.
  25069. * @see http://doc.babylonjs.com/features/cameras
  25070. */
  25071. export class Camera extends Node {
  25072. /** @hidden */
  25073. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25074. /**
  25075. * This is the default projection mode used by the cameras.
  25076. * It helps recreating a feeling of perspective and better appreciate depth.
  25077. * This is the best way to simulate real life cameras.
  25078. */
  25079. static readonly PERSPECTIVE_CAMERA: number;
  25080. /**
  25081. * This helps creating camera with an orthographic mode.
  25082. * 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.
  25083. */
  25084. static readonly ORTHOGRAPHIC_CAMERA: number;
  25085. /**
  25086. * This is the default FOV mode for perspective cameras.
  25087. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25088. */
  25089. static readonly FOVMODE_VERTICAL_FIXED: number;
  25090. /**
  25091. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25092. */
  25093. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25094. /**
  25095. * This specifies ther is no need for a camera rig.
  25096. * Basically only one eye is rendered corresponding to the camera.
  25097. */
  25098. static readonly RIG_MODE_NONE: number;
  25099. /**
  25100. * Simulates a camera Rig with one blue eye and one red eye.
  25101. * This can be use with 3d blue and red glasses.
  25102. */
  25103. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25104. /**
  25105. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25106. */
  25107. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25108. /**
  25109. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25110. */
  25111. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25112. /**
  25113. * Defines that both eyes of the camera will be rendered over under each other.
  25114. */
  25115. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25116. /**
  25117. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25118. */
  25119. static readonly RIG_MODE_VR: number;
  25120. /**
  25121. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25122. */
  25123. static readonly RIG_MODE_WEBVR: number;
  25124. /**
  25125. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25126. */
  25127. static readonly RIG_MODE_CUSTOM: number;
  25128. /**
  25129. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25130. */
  25131. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25132. /**
  25133. * Define the input manager associated with the camera.
  25134. */
  25135. inputs: CameraInputsManager<Camera>;
  25136. /** @hidden */
  25137. _position: Vector3;
  25138. /**
  25139. * Define the current local position of the camera in the scene
  25140. */
  25141. position: Vector3;
  25142. /**
  25143. * The vector the camera should consider as up.
  25144. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25145. */
  25146. upVector: Vector3;
  25147. /**
  25148. * Define the current limit on the left side for an orthographic camera
  25149. * In scene unit
  25150. */
  25151. orthoLeft: Nullable<number>;
  25152. /**
  25153. * Define the current limit on the right side for an orthographic camera
  25154. * In scene unit
  25155. */
  25156. orthoRight: Nullable<number>;
  25157. /**
  25158. * Define the current limit on the bottom side for an orthographic camera
  25159. * In scene unit
  25160. */
  25161. orthoBottom: Nullable<number>;
  25162. /**
  25163. * Define the current limit on the top side for an orthographic camera
  25164. * In scene unit
  25165. */
  25166. orthoTop: Nullable<number>;
  25167. /**
  25168. * Field Of View is set in Radians. (default is 0.8)
  25169. */
  25170. fov: number;
  25171. /**
  25172. * Define the minimum distance the camera can see from.
  25173. * This is important to note that the depth buffer are not infinite and the closer it starts
  25174. * the more your scene might encounter depth fighting issue.
  25175. */
  25176. minZ: number;
  25177. /**
  25178. * Define the maximum distance the camera can see to.
  25179. * This is important to note that the depth buffer are not infinite and the further it end
  25180. * the more your scene might encounter depth fighting issue.
  25181. */
  25182. maxZ: number;
  25183. /**
  25184. * Define the default inertia of the camera.
  25185. * This helps giving a smooth feeling to the camera movement.
  25186. */
  25187. inertia: number;
  25188. /**
  25189. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25190. */
  25191. mode: number;
  25192. /**
  25193. * Define wether the camera is intermediate.
  25194. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25195. */
  25196. isIntermediate: boolean;
  25197. /**
  25198. * Define the viewport of the camera.
  25199. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25200. */
  25201. viewport: Viewport;
  25202. /**
  25203. * Restricts the camera to viewing objects with the same layerMask.
  25204. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25205. */
  25206. layerMask: number;
  25207. /**
  25208. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25209. */
  25210. fovMode: number;
  25211. /**
  25212. * Rig mode of the camera.
  25213. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25214. * This is normally controlled byt the camera themselves as internal use.
  25215. */
  25216. cameraRigMode: number;
  25217. /**
  25218. * Defines the distance between both "eyes" in case of a RIG
  25219. */
  25220. interaxialDistance: number;
  25221. /**
  25222. * Defines if stereoscopic rendering is done side by side or over under.
  25223. */
  25224. isStereoscopicSideBySide: boolean;
  25225. /**
  25226. * 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
  25227. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25228. * else in the scene. (Eg. security camera)
  25229. *
  25230. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25231. */
  25232. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25233. /**
  25234. * When set, the camera will render to this render target instead of the default canvas
  25235. *
  25236. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25237. */
  25238. outputRenderTarget: Nullable<RenderTargetTexture>;
  25239. /**
  25240. * Observable triggered when the camera view matrix has changed.
  25241. */
  25242. onViewMatrixChangedObservable: Observable<Camera>;
  25243. /**
  25244. * Observable triggered when the camera Projection matrix has changed.
  25245. */
  25246. onProjectionMatrixChangedObservable: Observable<Camera>;
  25247. /**
  25248. * Observable triggered when the inputs have been processed.
  25249. */
  25250. onAfterCheckInputsObservable: Observable<Camera>;
  25251. /**
  25252. * Observable triggered when reset has been called and applied to the camera.
  25253. */
  25254. onRestoreStateObservable: Observable<Camera>;
  25255. /** @hidden */
  25256. _cameraRigParams: any;
  25257. /** @hidden */
  25258. _rigCameras: Camera[];
  25259. /** @hidden */
  25260. _rigPostProcess: Nullable<PostProcess>;
  25261. protected _webvrViewMatrix: Matrix;
  25262. /** @hidden */
  25263. _skipRendering: boolean;
  25264. /** @hidden */
  25265. _projectionMatrix: Matrix;
  25266. /** @hidden */
  25267. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25268. /** @hidden */
  25269. _activeMeshes: SmartArray<AbstractMesh>;
  25270. protected _globalPosition: Vector3;
  25271. /** @hidden */
  25272. _computedViewMatrix: Matrix;
  25273. private _doNotComputeProjectionMatrix;
  25274. private _transformMatrix;
  25275. private _frustumPlanes;
  25276. private _refreshFrustumPlanes;
  25277. private _storedFov;
  25278. private _stateStored;
  25279. /**
  25280. * Instantiates a new camera object.
  25281. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25282. * @see http://doc.babylonjs.com/features/cameras
  25283. * @param name Defines the name of the camera in the scene
  25284. * @param position Defines the position of the camera
  25285. * @param scene Defines the scene the camera belongs too
  25286. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25287. */
  25288. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25289. /**
  25290. * Store current camera state (fov, position, etc..)
  25291. * @returns the camera
  25292. */
  25293. storeState(): Camera;
  25294. /**
  25295. * Restores the camera state values if it has been stored. You must call storeState() first
  25296. */
  25297. protected _restoreStateValues(): boolean;
  25298. /**
  25299. * Restored camera state. You must call storeState() first.
  25300. * @returns true if restored and false otherwise
  25301. */
  25302. restoreState(): boolean;
  25303. /**
  25304. * Gets the class name of the camera.
  25305. * @returns the class name
  25306. */
  25307. getClassName(): string;
  25308. /** @hidden */
  25309. readonly _isCamera: boolean;
  25310. /**
  25311. * Gets a string representation of the camera useful for debug purpose.
  25312. * @param fullDetails Defines that a more verboe level of logging is required
  25313. * @returns the string representation
  25314. */
  25315. toString(fullDetails?: boolean): string;
  25316. /**
  25317. * Gets the current world space position of the camera.
  25318. */
  25319. readonly globalPosition: Vector3;
  25320. /**
  25321. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25322. * @returns the active meshe list
  25323. */
  25324. getActiveMeshes(): SmartArray<AbstractMesh>;
  25325. /**
  25326. * Check wether a mesh is part of the current active mesh list of the camera
  25327. * @param mesh Defines the mesh to check
  25328. * @returns true if active, false otherwise
  25329. */
  25330. isActiveMesh(mesh: Mesh): boolean;
  25331. /**
  25332. * Is this camera ready to be used/rendered
  25333. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25334. * @return true if the camera is ready
  25335. */
  25336. isReady(completeCheck?: boolean): boolean;
  25337. /** @hidden */
  25338. _initCache(): void;
  25339. /** @hidden */
  25340. _updateCache(ignoreParentClass?: boolean): void;
  25341. /** @hidden */
  25342. _isSynchronized(): boolean;
  25343. /** @hidden */
  25344. _isSynchronizedViewMatrix(): boolean;
  25345. /** @hidden */
  25346. _isSynchronizedProjectionMatrix(): boolean;
  25347. /**
  25348. * Attach the input controls to a specific dom element to get the input from.
  25349. * @param element Defines the element the controls should be listened from
  25350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25351. */
  25352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25353. /**
  25354. * Detach the current controls from the specified dom element.
  25355. * @param element Defines the element to stop listening the inputs from
  25356. */
  25357. detachControl(element: HTMLElement): void;
  25358. /**
  25359. * Update the camera state according to the different inputs gathered during the frame.
  25360. */
  25361. update(): void;
  25362. /** @hidden */
  25363. _checkInputs(): void;
  25364. /** @hidden */
  25365. readonly rigCameras: Camera[];
  25366. /**
  25367. * Gets the post process used by the rig cameras
  25368. */
  25369. readonly rigPostProcess: Nullable<PostProcess>;
  25370. /**
  25371. * Internal, gets the first post proces.
  25372. * @returns the first post process to be run on this camera.
  25373. */
  25374. _getFirstPostProcess(): Nullable<PostProcess>;
  25375. private _cascadePostProcessesToRigCams;
  25376. /**
  25377. * Attach a post process to the camera.
  25378. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25379. * @param postProcess The post process to attach to the camera
  25380. * @param insertAt The position of the post process in case several of them are in use in the scene
  25381. * @returns the position the post process has been inserted at
  25382. */
  25383. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25384. /**
  25385. * Detach a post process to the camera.
  25386. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25387. * @param postProcess The post process to detach from the camera
  25388. */
  25389. detachPostProcess(postProcess: PostProcess): void;
  25390. /**
  25391. * Gets the current world matrix of the camera
  25392. */
  25393. getWorldMatrix(): Matrix;
  25394. /** @hidden */
  25395. _getViewMatrix(): Matrix;
  25396. /**
  25397. * Gets the current view matrix of the camera.
  25398. * @param force forces the camera to recompute the matrix without looking at the cached state
  25399. * @returns the view matrix
  25400. */
  25401. getViewMatrix(force?: boolean): Matrix;
  25402. /**
  25403. * Freeze the projection matrix.
  25404. * It will prevent the cache check of the camera projection compute and can speed up perf
  25405. * if no parameter of the camera are meant to change
  25406. * @param projection Defines manually a projection if necessary
  25407. */
  25408. freezeProjectionMatrix(projection?: Matrix): void;
  25409. /**
  25410. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25411. */
  25412. unfreezeProjectionMatrix(): void;
  25413. /**
  25414. * Gets the current projection matrix of the camera.
  25415. * @param force forces the camera to recompute the matrix without looking at the cached state
  25416. * @returns the projection matrix
  25417. */
  25418. getProjectionMatrix(force?: boolean): Matrix;
  25419. /**
  25420. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25421. * @returns a Matrix
  25422. */
  25423. getTransformationMatrix(): Matrix;
  25424. private _updateFrustumPlanes;
  25425. /**
  25426. * Checks if a cullable object (mesh...) is in the camera frustum
  25427. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25428. * @param target The object to check
  25429. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25430. * @returns true if the object is in frustum otherwise false
  25431. */
  25432. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25433. /**
  25434. * Checks if a cullable object (mesh...) is in the camera frustum
  25435. * Unlike isInFrustum this cheks the full bounding box
  25436. * @param target The object to check
  25437. * @returns true if the object is in frustum otherwise false
  25438. */
  25439. isCompletelyInFrustum(target: ICullable): boolean;
  25440. /**
  25441. * Gets a ray in the forward direction from the camera.
  25442. * @param length Defines the length of the ray to create
  25443. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25444. * @param origin Defines the start point of the ray which defaults to the camera position
  25445. * @returns the forward ray
  25446. */
  25447. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25448. /**
  25449. * Releases resources associated with this node.
  25450. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25451. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25452. */
  25453. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25454. /** @hidden */
  25455. _isLeftCamera: boolean;
  25456. /**
  25457. * Gets the left camera of a rig setup in case of Rigged Camera
  25458. */
  25459. readonly isLeftCamera: boolean;
  25460. /** @hidden */
  25461. _isRightCamera: boolean;
  25462. /**
  25463. * Gets the right camera of a rig setup in case of Rigged Camera
  25464. */
  25465. readonly isRightCamera: boolean;
  25466. /**
  25467. * Gets the left camera of a rig setup in case of Rigged Camera
  25468. */
  25469. readonly leftCamera: Nullable<FreeCamera>;
  25470. /**
  25471. * Gets the right camera of a rig setup in case of Rigged Camera
  25472. */
  25473. readonly rightCamera: Nullable<FreeCamera>;
  25474. /**
  25475. * Gets the left camera target of a rig setup in case of Rigged Camera
  25476. * @returns the target position
  25477. */
  25478. getLeftTarget(): Nullable<Vector3>;
  25479. /**
  25480. * Gets the right camera target of a rig setup in case of Rigged Camera
  25481. * @returns the target position
  25482. */
  25483. getRightTarget(): Nullable<Vector3>;
  25484. /**
  25485. * @hidden
  25486. */
  25487. setCameraRigMode(mode: number, rigParams: any): void;
  25488. /** @hidden */
  25489. static _setStereoscopicRigMode(camera: Camera): void;
  25490. /** @hidden */
  25491. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25492. /** @hidden */
  25493. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25494. /** @hidden */
  25495. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25496. /** @hidden */
  25497. _getVRProjectionMatrix(): Matrix;
  25498. protected _updateCameraRotationMatrix(): void;
  25499. protected _updateWebVRCameraRotationMatrix(): void;
  25500. /**
  25501. * This function MUST be overwritten by the different WebVR cameras available.
  25502. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25503. * @hidden
  25504. */
  25505. _getWebVRProjectionMatrix(): Matrix;
  25506. /**
  25507. * This function MUST be overwritten by the different WebVR cameras available.
  25508. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25509. * @hidden
  25510. */
  25511. _getWebVRViewMatrix(): Matrix;
  25512. /** @hidden */
  25513. setCameraRigParameter(name: string, value: any): void;
  25514. /**
  25515. * needs to be overridden by children so sub has required properties to be copied
  25516. * @hidden
  25517. */
  25518. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25519. /**
  25520. * May need to be overridden by children
  25521. * @hidden
  25522. */
  25523. _updateRigCameras(): void;
  25524. /** @hidden */
  25525. _setupInputs(): void;
  25526. /**
  25527. * Serialiaze the camera setup to a json represention
  25528. * @returns the JSON representation
  25529. */
  25530. serialize(): any;
  25531. /**
  25532. * Clones the current camera.
  25533. * @param name The cloned camera name
  25534. * @returns the cloned camera
  25535. */
  25536. clone(name: string): Camera;
  25537. /**
  25538. * Gets the direction of the camera relative to a given local axis.
  25539. * @param localAxis Defines the reference axis to provide a relative direction.
  25540. * @return the direction
  25541. */
  25542. getDirection(localAxis: Vector3): Vector3;
  25543. /**
  25544. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25545. * @param localAxis Defines the reference axis to provide a relative direction.
  25546. * @param result Defines the vector to store the result in
  25547. */
  25548. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25549. /**
  25550. * Gets a camera constructor for a given camera type
  25551. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25552. * @param name The name of the camera the result will be able to instantiate
  25553. * @param scene The scene the result will construct the camera in
  25554. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25555. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25556. * @returns a factory method to construc the camera
  25557. */
  25558. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25559. /**
  25560. * Compute the world matrix of the camera.
  25561. * @returns the camera workd matrix
  25562. */
  25563. computeWorldMatrix(): Matrix;
  25564. /**
  25565. * Parse a JSON and creates the camera from the parsed information
  25566. * @param parsedCamera The JSON to parse
  25567. * @param scene The scene to instantiate the camera in
  25568. * @returns the newly constructed camera
  25569. */
  25570. static Parse(parsedCamera: any, scene: Scene): Camera;
  25571. }
  25572. }
  25573. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25574. import { Nullable } from "babylonjs/types";
  25575. import { Scene } from "babylonjs/scene";
  25576. import { Vector4 } from "babylonjs/Maths/math.vector";
  25577. import { Mesh } from "babylonjs/Meshes/mesh";
  25578. /**
  25579. * Class containing static functions to help procedurally build meshes
  25580. */
  25581. export class DiscBuilder {
  25582. /**
  25583. * Creates a plane polygonal mesh. By default, this is a disc
  25584. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25585. * * 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
  25586. * * 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
  25587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25590. * @param name defines the name of the mesh
  25591. * @param options defines the options used to create the mesh
  25592. * @param scene defines the hosting scene
  25593. * @returns the plane polygonal mesh
  25594. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25595. */
  25596. static CreateDisc(name: string, options: {
  25597. radius?: number;
  25598. tessellation?: number;
  25599. arc?: number;
  25600. updatable?: boolean;
  25601. sideOrientation?: number;
  25602. frontUVs?: Vector4;
  25603. backUVs?: Vector4;
  25604. }, scene?: Nullable<Scene>): Mesh;
  25605. }
  25606. }
  25607. declare module "babylonjs/Particles/solidParticleSystem" {
  25608. import { Vector3 } from "babylonjs/Maths/math.vector";
  25609. import { Mesh } from "babylonjs/Meshes/mesh";
  25610. import { Scene, IDisposable } from "babylonjs/scene";
  25611. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25612. /**
  25613. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25614. *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.
  25615. * The SPS is also a particle system. It provides some methods to manage the particles.
  25616. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25617. *
  25618. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25619. */
  25620. export class SolidParticleSystem implements IDisposable {
  25621. /**
  25622. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25623. * Example : var p = SPS.particles[i];
  25624. */
  25625. particles: SolidParticle[];
  25626. /**
  25627. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25628. */
  25629. nbParticles: number;
  25630. /**
  25631. * If the particles must ever face the camera (default false). Useful for planar particles.
  25632. */
  25633. billboard: boolean;
  25634. /**
  25635. * Recompute normals when adding a shape
  25636. */
  25637. recomputeNormals: boolean;
  25638. /**
  25639. * This a counter ofr your own usage. It's not set by any SPS functions.
  25640. */
  25641. counter: number;
  25642. /**
  25643. * The SPS name. This name is also given to the underlying mesh.
  25644. */
  25645. name: string;
  25646. /**
  25647. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25648. */
  25649. mesh: Mesh;
  25650. /**
  25651. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25652. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25653. */
  25654. vars: any;
  25655. /**
  25656. * This array is populated when the SPS is set as 'pickable'.
  25657. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25658. * Each element of this array is an object `{idx: int, faceId: int}`.
  25659. * `idx` is the picked particle index in the `SPS.particles` array
  25660. * `faceId` is the picked face index counted within this particle.
  25661. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25662. */
  25663. pickedParticles: {
  25664. idx: number;
  25665. faceId: number;
  25666. }[];
  25667. /**
  25668. * This array is populated when `enableDepthSort` is set to true.
  25669. * Each element of this array is an instance of the class DepthSortedParticle.
  25670. */
  25671. depthSortedParticles: DepthSortedParticle[];
  25672. /**
  25673. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25674. * @hidden
  25675. */
  25676. _bSphereOnly: boolean;
  25677. /**
  25678. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25679. * @hidden
  25680. */
  25681. _bSphereRadiusFactor: number;
  25682. private _scene;
  25683. private _positions;
  25684. private _indices;
  25685. private _normals;
  25686. private _colors;
  25687. private _uvs;
  25688. private _indices32;
  25689. private _positions32;
  25690. private _normals32;
  25691. private _fixedNormal32;
  25692. private _colors32;
  25693. private _uvs32;
  25694. private _index;
  25695. private _updatable;
  25696. private _pickable;
  25697. private _isVisibilityBoxLocked;
  25698. private _alwaysVisible;
  25699. private _depthSort;
  25700. private _shapeCounter;
  25701. private _copy;
  25702. private _color;
  25703. private _computeParticleColor;
  25704. private _computeParticleTexture;
  25705. private _computeParticleRotation;
  25706. private _computeParticleVertex;
  25707. private _computeBoundingBox;
  25708. private _depthSortParticles;
  25709. private _camera;
  25710. private _mustUnrotateFixedNormals;
  25711. private _particlesIntersect;
  25712. private _needs32Bits;
  25713. /**
  25714. * Creates a SPS (Solid Particle System) object.
  25715. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25716. * @param scene (Scene) is the scene in which the SPS is added.
  25717. * @param options defines the options of the sps e.g.
  25718. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25719. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25720. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25721. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25722. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25723. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25724. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25725. */
  25726. constructor(name: string, scene: Scene, options?: {
  25727. updatable?: boolean;
  25728. isPickable?: boolean;
  25729. enableDepthSort?: boolean;
  25730. particleIntersection?: boolean;
  25731. boundingSphereOnly?: boolean;
  25732. bSphereRadiusFactor?: number;
  25733. });
  25734. /**
  25735. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25736. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25737. * @returns the created mesh
  25738. */
  25739. buildMesh(): Mesh;
  25740. /**
  25741. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25742. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25743. * Thus the particles generated from `digest()` have their property `position` set yet.
  25744. * @param mesh ( Mesh ) is the mesh to be digested
  25745. * @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
  25746. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25747. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25748. * @returns the current SPS
  25749. */
  25750. digest(mesh: Mesh, options?: {
  25751. facetNb?: number;
  25752. number?: number;
  25753. delta?: number;
  25754. }): SolidParticleSystem;
  25755. private _unrotateFixedNormals;
  25756. private _resetCopy;
  25757. private _meshBuilder;
  25758. private _posToShape;
  25759. private _uvsToShapeUV;
  25760. private _addParticle;
  25761. /**
  25762. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25763. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25764. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25765. * @param nb (positive integer) the number of particles to be created from this model
  25766. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25767. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25768. * @returns the number of shapes in the system
  25769. */
  25770. addShape(mesh: Mesh, nb: number, options?: {
  25771. positionFunction?: any;
  25772. vertexFunction?: any;
  25773. }): number;
  25774. private _rebuildParticle;
  25775. /**
  25776. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25777. * @returns the SPS.
  25778. */
  25779. rebuildMesh(): SolidParticleSystem;
  25780. /**
  25781. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25782. * This method calls `updateParticle()` for each particle of the SPS.
  25783. * For an animated SPS, it is usually called within the render loop.
  25784. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25785. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25786. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25787. * @returns the SPS.
  25788. */
  25789. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25790. /**
  25791. * Disposes the SPS.
  25792. */
  25793. dispose(): void;
  25794. /**
  25795. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25796. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25797. * @returns the SPS.
  25798. */
  25799. refreshVisibleSize(): SolidParticleSystem;
  25800. /**
  25801. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25802. * @param size the size (float) of the visibility box
  25803. * note : this doesn't lock the SPS mesh bounding box.
  25804. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25805. */
  25806. setVisibilityBox(size: number): void;
  25807. /**
  25808. * Gets whether the SPS as always visible or not
  25809. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25810. */
  25811. /**
  25812. * Sets the SPS as always visible or not
  25813. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25814. */
  25815. isAlwaysVisible: boolean;
  25816. /**
  25817. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25818. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25819. */
  25820. /**
  25821. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25822. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25823. */
  25824. isVisibilityBoxLocked: boolean;
  25825. /**
  25826. * Tells to `setParticles()` to compute the particle rotations or not.
  25827. * Default value : true. The SPS is faster when it's set to false.
  25828. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25829. */
  25830. /**
  25831. * Gets if `setParticles()` computes the particle rotations or not.
  25832. * Default value : true. The SPS is faster when it's set to false.
  25833. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25834. */
  25835. computeParticleRotation: boolean;
  25836. /**
  25837. * Tells to `setParticles()` to compute the particle colors or not.
  25838. * Default value : true. The SPS is faster when it's set to false.
  25839. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25840. */
  25841. /**
  25842. * Gets if `setParticles()` computes the particle colors or not.
  25843. * Default value : true. The SPS is faster when it's set to false.
  25844. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25845. */
  25846. computeParticleColor: boolean;
  25847. /**
  25848. * Gets if `setParticles()` computes the particle textures or not.
  25849. * Default value : true. The SPS is faster when it's set to false.
  25850. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25851. */
  25852. computeParticleTexture: boolean;
  25853. /**
  25854. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25855. * Default value : false. The SPS is faster when it's set to false.
  25856. * Note : the particle custom vertex positions aren't stored values.
  25857. */
  25858. /**
  25859. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25860. * Default value : false. The SPS is faster when it's set to false.
  25861. * Note : the particle custom vertex positions aren't stored values.
  25862. */
  25863. computeParticleVertex: boolean;
  25864. /**
  25865. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25866. */
  25867. /**
  25868. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25869. */
  25870. computeBoundingBox: boolean;
  25871. /**
  25872. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25873. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25874. * Default : `true`
  25875. */
  25876. /**
  25877. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25878. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25879. * Default : `true`
  25880. */
  25881. depthSortParticles: boolean;
  25882. /**
  25883. * This function does nothing. It may be overwritten to set all the particle first values.
  25884. * The SPS doesn't call this function, you may have to call it by your own.
  25885. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25886. */
  25887. initParticles(): void;
  25888. /**
  25889. * This function does nothing. It may be overwritten to recycle a particle.
  25890. * The SPS doesn't call this function, you may have to call it by your own.
  25891. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25892. * @param particle The particle to recycle
  25893. * @returns the recycled particle
  25894. */
  25895. recycleParticle(particle: SolidParticle): SolidParticle;
  25896. /**
  25897. * Updates a particle : this function should be overwritten by the user.
  25898. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25899. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25900. * @example : just set a particle position or velocity and recycle conditions
  25901. * @param particle The particle to update
  25902. * @returns the updated particle
  25903. */
  25904. updateParticle(particle: SolidParticle): SolidParticle;
  25905. /**
  25906. * Updates a vertex of a particle : it can be overwritten by the user.
  25907. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25908. * @param particle the current particle
  25909. * @param vertex the current index of the current particle
  25910. * @param pt the index of the current vertex in the particle shape
  25911. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25912. * @example : just set a vertex particle position
  25913. * @returns the updated vertex
  25914. */
  25915. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25916. /**
  25917. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25918. * This does nothing and may be overwritten by the user.
  25919. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25920. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25921. * @param update the boolean update value actually passed to setParticles()
  25922. */
  25923. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25924. /**
  25925. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25926. * This will be passed three parameters.
  25927. * This does nothing and may be overwritten by the user.
  25928. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25929. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25930. * @param update the boolean update value actually passed to setParticles()
  25931. */
  25932. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25933. }
  25934. }
  25935. declare module "babylonjs/Particles/solidParticle" {
  25936. import { Nullable } from "babylonjs/types";
  25937. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25938. import { Color4 } from "babylonjs/Maths/math.color";
  25939. import { Mesh } from "babylonjs/Meshes/mesh";
  25940. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25941. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25942. import { Plane } from "babylonjs/Maths/math.plane";
  25943. /**
  25944. * Represents one particle of a solid particle system.
  25945. */
  25946. export class SolidParticle {
  25947. /**
  25948. * particle global index
  25949. */
  25950. idx: number;
  25951. /**
  25952. * The color of the particle
  25953. */
  25954. color: Nullable<Color4>;
  25955. /**
  25956. * The world space position of the particle.
  25957. */
  25958. position: Vector3;
  25959. /**
  25960. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25961. */
  25962. rotation: Vector3;
  25963. /**
  25964. * The world space rotation quaternion of the particle.
  25965. */
  25966. rotationQuaternion: Nullable<Quaternion>;
  25967. /**
  25968. * The scaling of the particle.
  25969. */
  25970. scaling: Vector3;
  25971. /**
  25972. * The uvs of the particle.
  25973. */
  25974. uvs: Vector4;
  25975. /**
  25976. * The current speed of the particle.
  25977. */
  25978. velocity: Vector3;
  25979. /**
  25980. * The pivot point in the particle local space.
  25981. */
  25982. pivot: Vector3;
  25983. /**
  25984. * Must the particle be translated from its pivot point in its local space ?
  25985. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25986. * Default : false
  25987. */
  25988. translateFromPivot: boolean;
  25989. /**
  25990. * Is the particle active or not ?
  25991. */
  25992. alive: boolean;
  25993. /**
  25994. * Is the particle visible or not ?
  25995. */
  25996. isVisible: boolean;
  25997. /**
  25998. * Index of this particle in the global "positions" array (Internal use)
  25999. * @hidden
  26000. */
  26001. _pos: number;
  26002. /**
  26003. * @hidden Index of this particle in the global "indices" array (Internal use)
  26004. */
  26005. _ind: number;
  26006. /**
  26007. * @hidden ModelShape of this particle (Internal use)
  26008. */
  26009. _model: ModelShape;
  26010. /**
  26011. * ModelShape id of this particle
  26012. */
  26013. shapeId: number;
  26014. /**
  26015. * Index of the particle in its shape id (Internal use)
  26016. */
  26017. idxInShape: number;
  26018. /**
  26019. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26020. */
  26021. _modelBoundingInfo: BoundingInfo;
  26022. /**
  26023. * @hidden Particle BoundingInfo object (Internal use)
  26024. */
  26025. _boundingInfo: BoundingInfo;
  26026. /**
  26027. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26028. */
  26029. _sps: SolidParticleSystem;
  26030. /**
  26031. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26032. */
  26033. _stillInvisible: boolean;
  26034. /**
  26035. * @hidden Last computed particle rotation matrix
  26036. */
  26037. _rotationMatrix: number[];
  26038. /**
  26039. * Parent particle Id, if any.
  26040. * Default null.
  26041. */
  26042. parentId: Nullable<number>;
  26043. /**
  26044. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26045. * The possible values are :
  26046. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26047. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26048. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26049. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26050. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26051. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26052. * */
  26053. cullingStrategy: number;
  26054. /**
  26055. * @hidden Internal global position in the SPS.
  26056. */
  26057. _globalPosition: Vector3;
  26058. /**
  26059. * Creates a Solid Particle object.
  26060. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26061. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26062. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26063. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26064. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26065. * @param shapeId (integer) is the model shape identifier in the SPS.
  26066. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26067. * @param sps defines the sps it is associated to
  26068. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26069. */
  26070. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26071. /**
  26072. * Legacy support, changed scale to scaling
  26073. */
  26074. /**
  26075. * Legacy support, changed scale to scaling
  26076. */
  26077. scale: Vector3;
  26078. /**
  26079. * Legacy support, changed quaternion to rotationQuaternion
  26080. */
  26081. /**
  26082. * Legacy support, changed quaternion to rotationQuaternion
  26083. */
  26084. quaternion: Nullable<Quaternion>;
  26085. /**
  26086. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26087. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26088. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26089. * @returns true if it intersects
  26090. */
  26091. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26092. /**
  26093. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26094. * A particle is in the frustum if its bounding box intersects the frustum
  26095. * @param frustumPlanes defines the frustum to test
  26096. * @returns true if the particle is in the frustum planes
  26097. */
  26098. isInFrustum(frustumPlanes: Plane[]): boolean;
  26099. /**
  26100. * get the rotation matrix of the particle
  26101. * @hidden
  26102. */
  26103. getRotationMatrix(m: Matrix): void;
  26104. }
  26105. /**
  26106. * Represents the shape of the model used by one particle of a solid particle system.
  26107. * SPS internal tool, don't use it manually.
  26108. */
  26109. export class ModelShape {
  26110. /**
  26111. * The shape id
  26112. * @hidden
  26113. */
  26114. shapeID: number;
  26115. /**
  26116. * flat array of model positions (internal use)
  26117. * @hidden
  26118. */
  26119. _shape: Vector3[];
  26120. /**
  26121. * flat array of model UVs (internal use)
  26122. * @hidden
  26123. */
  26124. _shapeUV: number[];
  26125. /**
  26126. * length of the shape in the model indices array (internal use)
  26127. * @hidden
  26128. */
  26129. _indicesLength: number;
  26130. /**
  26131. * Custom position function (internal use)
  26132. * @hidden
  26133. */
  26134. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26135. /**
  26136. * Custom vertex function (internal use)
  26137. * @hidden
  26138. */
  26139. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26140. /**
  26141. * 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.
  26142. * SPS internal tool, don't use it manually.
  26143. * @hidden
  26144. */
  26145. 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>);
  26146. }
  26147. /**
  26148. * Represents a Depth Sorted Particle in the solid particle system.
  26149. */
  26150. export class DepthSortedParticle {
  26151. /**
  26152. * Index of the particle in the "indices" array
  26153. */
  26154. ind: number;
  26155. /**
  26156. * Length of the particle shape in the "indices" array
  26157. */
  26158. indicesLength: number;
  26159. /**
  26160. * Squared distance from the particle to the camera
  26161. */
  26162. sqDistance: number;
  26163. }
  26164. }
  26165. declare module "babylonjs/Collisions/meshCollisionData" {
  26166. import { Collider } from "babylonjs/Collisions/collider";
  26167. import { Vector3 } from "babylonjs/Maths/math.vector";
  26168. import { Nullable } from "babylonjs/types";
  26169. import { Observer } from "babylonjs/Misc/observable";
  26170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26171. /**
  26172. * @hidden
  26173. */
  26174. export class _MeshCollisionData {
  26175. _checkCollisions: boolean;
  26176. _collisionMask: number;
  26177. _collisionGroup: number;
  26178. _collider: Nullable<Collider>;
  26179. _oldPositionForCollisions: Vector3;
  26180. _diffPositionForCollisions: Vector3;
  26181. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26182. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26183. }
  26184. }
  26185. declare module "babylonjs/Meshes/abstractMesh" {
  26186. import { Observable } from "babylonjs/Misc/observable";
  26187. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26188. import { Camera } from "babylonjs/Cameras/camera";
  26189. import { Scene, IDisposable } from "babylonjs/scene";
  26190. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26191. import { Node } from "babylonjs/node";
  26192. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26193. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26194. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26195. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26196. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26197. import { Material } from "babylonjs/Materials/material";
  26198. import { Light } from "babylonjs/Lights/light";
  26199. import { Skeleton } from "babylonjs/Bones/skeleton";
  26200. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26201. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26202. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26203. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26204. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26205. import { Plane } from "babylonjs/Maths/math.plane";
  26206. import { Ray } from "babylonjs/Culling/ray";
  26207. import { Collider } from "babylonjs/Collisions/collider";
  26208. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26209. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26210. /** @hidden */
  26211. class _FacetDataStorage {
  26212. facetPositions: Vector3[];
  26213. facetNormals: Vector3[];
  26214. facetPartitioning: number[][];
  26215. facetNb: number;
  26216. partitioningSubdivisions: number;
  26217. partitioningBBoxRatio: number;
  26218. facetDataEnabled: boolean;
  26219. facetParameters: any;
  26220. bbSize: Vector3;
  26221. subDiv: {
  26222. max: number;
  26223. X: number;
  26224. Y: number;
  26225. Z: number;
  26226. };
  26227. facetDepthSort: boolean;
  26228. facetDepthSortEnabled: boolean;
  26229. depthSortedIndices: IndicesArray;
  26230. depthSortedFacets: {
  26231. ind: number;
  26232. sqDistance: number;
  26233. }[];
  26234. facetDepthSortFunction: (f1: {
  26235. ind: number;
  26236. sqDistance: number;
  26237. }, f2: {
  26238. ind: number;
  26239. sqDistance: number;
  26240. }) => number;
  26241. facetDepthSortFrom: Vector3;
  26242. facetDepthSortOrigin: Vector3;
  26243. invertedMatrix: Matrix;
  26244. }
  26245. /**
  26246. * @hidden
  26247. **/
  26248. class _InternalAbstractMeshDataInfo {
  26249. _hasVertexAlpha: boolean;
  26250. _useVertexColors: boolean;
  26251. _numBoneInfluencers: number;
  26252. _applyFog: boolean;
  26253. _receiveShadows: boolean;
  26254. _facetData: _FacetDataStorage;
  26255. _visibility: number;
  26256. _skeleton: Nullable<Skeleton>;
  26257. _layerMask: number;
  26258. _computeBonesUsingShaders: boolean;
  26259. _isActive: boolean;
  26260. _onlyForInstances: boolean;
  26261. _isActiveIntermediate: boolean;
  26262. _onlyForInstancesIntermediate: boolean;
  26263. }
  26264. /**
  26265. * Class used to store all common mesh properties
  26266. */
  26267. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26268. /** No occlusion */
  26269. static OCCLUSION_TYPE_NONE: number;
  26270. /** Occlusion set to optimisitic */
  26271. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26272. /** Occlusion set to strict */
  26273. static OCCLUSION_TYPE_STRICT: number;
  26274. /** Use an accurante occlusion algorithm */
  26275. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26276. /** Use a conservative occlusion algorithm */
  26277. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26278. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26279. * Test order :
  26280. * Is the bounding sphere outside the frustum ?
  26281. * If not, are the bounding box vertices outside the frustum ?
  26282. * It not, then the cullable object is in the frustum.
  26283. */
  26284. static readonly CULLINGSTRATEGY_STANDARD: number;
  26285. /** Culling strategy : Bounding Sphere Only.
  26286. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26287. * It's also less accurate than the standard because some not visible objects can still be selected.
  26288. * Test : is the bounding sphere outside the frustum ?
  26289. * If not, then the cullable object is in the frustum.
  26290. */
  26291. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26292. /** Culling strategy : Optimistic Inclusion.
  26293. * This in an inclusion test first, then the standard exclusion test.
  26294. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26295. * 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.
  26296. * Anyway, it's as accurate as the standard strategy.
  26297. * Test :
  26298. * Is the cullable object bounding sphere center in the frustum ?
  26299. * If not, apply the default culling strategy.
  26300. */
  26301. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26302. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26303. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26304. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26305. * 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.
  26306. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26307. * Test :
  26308. * Is the cullable object bounding sphere center in the frustum ?
  26309. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26310. */
  26311. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26312. /**
  26313. * No billboard
  26314. */
  26315. static readonly BILLBOARDMODE_NONE: number;
  26316. /** Billboard on X axis */
  26317. static readonly BILLBOARDMODE_X: number;
  26318. /** Billboard on Y axis */
  26319. static readonly BILLBOARDMODE_Y: number;
  26320. /** Billboard on Z axis */
  26321. static readonly BILLBOARDMODE_Z: number;
  26322. /** Billboard on all axes */
  26323. static readonly BILLBOARDMODE_ALL: number;
  26324. /** @hidden */
  26325. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26326. /**
  26327. * The culling strategy to use to check whether the mesh must be rendered or not.
  26328. * This value can be changed at any time and will be used on the next render mesh selection.
  26329. * The possible values are :
  26330. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26331. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26332. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26333. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26334. * Please read each static variable documentation to get details about the culling process.
  26335. * */
  26336. cullingStrategy: number;
  26337. /**
  26338. * Gets the number of facets in the mesh
  26339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26340. */
  26341. readonly facetNb: number;
  26342. /**
  26343. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26345. */
  26346. partitioningSubdivisions: number;
  26347. /**
  26348. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26349. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26351. */
  26352. partitioningBBoxRatio: number;
  26353. /**
  26354. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26355. * Works only for updatable meshes.
  26356. * Doesn't work with multi-materials
  26357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26358. */
  26359. mustDepthSortFacets: boolean;
  26360. /**
  26361. * The location (Vector3) where the facet depth sort must be computed from.
  26362. * By default, the active camera position.
  26363. * Used only when facet depth sort is enabled
  26364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26365. */
  26366. facetDepthSortFrom: Vector3;
  26367. /**
  26368. * gets a boolean indicating if facetData is enabled
  26369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26370. */
  26371. readonly isFacetDataEnabled: boolean;
  26372. /** @hidden */
  26373. _updateNonUniformScalingState(value: boolean): boolean;
  26374. /**
  26375. * An event triggered when this mesh collides with another one
  26376. */
  26377. onCollideObservable: Observable<AbstractMesh>;
  26378. /** Set a function to call when this mesh collides with another one */
  26379. onCollide: () => void;
  26380. /**
  26381. * An event triggered when the collision's position changes
  26382. */
  26383. onCollisionPositionChangeObservable: Observable<Vector3>;
  26384. /** Set a function to call when the collision's position changes */
  26385. onCollisionPositionChange: () => void;
  26386. /**
  26387. * An event triggered when material is changed
  26388. */
  26389. onMaterialChangedObservable: Observable<AbstractMesh>;
  26390. /**
  26391. * Gets or sets the orientation for POV movement & rotation
  26392. */
  26393. definedFacingForward: boolean;
  26394. /** @hidden */
  26395. _occlusionQuery: Nullable<WebGLQuery>;
  26396. /** @hidden */
  26397. _renderingGroup: Nullable<RenderingGroup>;
  26398. /**
  26399. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26400. */
  26401. /**
  26402. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26403. */
  26404. visibility: number;
  26405. /** Gets or sets the alpha index used to sort transparent meshes
  26406. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26407. */
  26408. alphaIndex: number;
  26409. /**
  26410. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26411. */
  26412. isVisible: boolean;
  26413. /**
  26414. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26415. */
  26416. isPickable: boolean;
  26417. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26418. showSubMeshesBoundingBox: boolean;
  26419. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26420. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26421. */
  26422. isBlocker: boolean;
  26423. /**
  26424. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26425. */
  26426. enablePointerMoveEvents: boolean;
  26427. /**
  26428. * Specifies the rendering group id for this mesh (0 by default)
  26429. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26430. */
  26431. renderingGroupId: number;
  26432. private _material;
  26433. /** Gets or sets current material */
  26434. material: Nullable<Material>;
  26435. /**
  26436. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26437. * @see http://doc.babylonjs.com/babylon101/shadows
  26438. */
  26439. receiveShadows: boolean;
  26440. /** Defines color to use when rendering outline */
  26441. outlineColor: Color3;
  26442. /** Define width to use when rendering outline */
  26443. outlineWidth: number;
  26444. /** Defines color to use when rendering overlay */
  26445. overlayColor: Color3;
  26446. /** Defines alpha to use when rendering overlay */
  26447. overlayAlpha: number;
  26448. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26449. hasVertexAlpha: boolean;
  26450. /** 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) */
  26451. useVertexColors: boolean;
  26452. /**
  26453. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26454. */
  26455. computeBonesUsingShaders: boolean;
  26456. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26457. numBoneInfluencers: number;
  26458. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26459. applyFog: boolean;
  26460. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26461. useOctreeForRenderingSelection: boolean;
  26462. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26463. useOctreeForPicking: boolean;
  26464. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26465. useOctreeForCollisions: boolean;
  26466. /**
  26467. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26468. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26469. */
  26470. layerMask: number;
  26471. /**
  26472. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26473. */
  26474. alwaysSelectAsActiveMesh: boolean;
  26475. /**
  26476. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26477. */
  26478. doNotSyncBoundingInfo: boolean;
  26479. /**
  26480. * Gets or sets the current action manager
  26481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26482. */
  26483. actionManager: Nullable<AbstractActionManager>;
  26484. private _meshCollisionData;
  26485. /**
  26486. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26487. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26488. */
  26489. ellipsoid: Vector3;
  26490. /**
  26491. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26492. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26493. */
  26494. ellipsoidOffset: Vector3;
  26495. /**
  26496. * Gets or sets a collision mask used to mask collisions (default is -1).
  26497. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26498. */
  26499. collisionMask: number;
  26500. /**
  26501. * Gets or sets the current collision group mask (-1 by default).
  26502. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26503. */
  26504. collisionGroup: number;
  26505. /**
  26506. * Defines edge width used when edgesRenderer is enabled
  26507. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26508. */
  26509. edgesWidth: number;
  26510. /**
  26511. * Defines edge color used when edgesRenderer is enabled
  26512. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26513. */
  26514. edgesColor: Color4;
  26515. /** @hidden */
  26516. _edgesRenderer: Nullable<IEdgesRenderer>;
  26517. /** @hidden */
  26518. _masterMesh: Nullable<AbstractMesh>;
  26519. /** @hidden */
  26520. _boundingInfo: Nullable<BoundingInfo>;
  26521. /** @hidden */
  26522. _renderId: number;
  26523. /**
  26524. * Gets or sets the list of subMeshes
  26525. * @see http://doc.babylonjs.com/how_to/multi_materials
  26526. */
  26527. subMeshes: SubMesh[];
  26528. /** @hidden */
  26529. _intersectionsInProgress: AbstractMesh[];
  26530. /** @hidden */
  26531. _unIndexed: boolean;
  26532. /** @hidden */
  26533. _lightSources: Light[];
  26534. /** Gets the list of lights affecting that mesh */
  26535. readonly lightSources: Light[];
  26536. /** @hidden */
  26537. readonly _positions: Nullable<Vector3[]>;
  26538. /** @hidden */
  26539. _waitingData: {
  26540. lods: Nullable<any>;
  26541. actions: Nullable<any>;
  26542. freezeWorldMatrix: Nullable<boolean>;
  26543. };
  26544. /** @hidden */
  26545. _bonesTransformMatrices: Nullable<Float32Array>;
  26546. /** @hidden */
  26547. _transformMatrixTexture: Nullable<RawTexture>;
  26548. /**
  26549. * Gets or sets a skeleton to apply skining transformations
  26550. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26551. */
  26552. skeleton: Nullable<Skeleton>;
  26553. /**
  26554. * An event triggered when the mesh is rebuilt.
  26555. */
  26556. onRebuildObservable: Observable<AbstractMesh>;
  26557. /**
  26558. * Creates a new AbstractMesh
  26559. * @param name defines the name of the mesh
  26560. * @param scene defines the hosting scene
  26561. */
  26562. constructor(name: string, scene?: Nullable<Scene>);
  26563. /**
  26564. * Returns the string "AbstractMesh"
  26565. * @returns "AbstractMesh"
  26566. */
  26567. getClassName(): string;
  26568. /**
  26569. * Gets a string representation of the current mesh
  26570. * @param fullDetails defines a boolean indicating if full details must be included
  26571. * @returns a string representation of the current mesh
  26572. */
  26573. toString(fullDetails?: boolean): string;
  26574. /**
  26575. * @hidden
  26576. */
  26577. protected _getEffectiveParent(): Nullable<Node>;
  26578. /** @hidden */
  26579. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26580. /** @hidden */
  26581. _rebuild(): void;
  26582. /** @hidden */
  26583. _resyncLightSources(): void;
  26584. /** @hidden */
  26585. _resyncLighSource(light: Light): void;
  26586. /** @hidden */
  26587. _unBindEffect(): void;
  26588. /** @hidden */
  26589. _removeLightSource(light: Light): void;
  26590. private _markSubMeshesAsDirty;
  26591. /** @hidden */
  26592. _markSubMeshesAsLightDirty(): void;
  26593. /** @hidden */
  26594. _markSubMeshesAsAttributesDirty(): void;
  26595. /** @hidden */
  26596. _markSubMeshesAsMiscDirty(): void;
  26597. /**
  26598. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26599. */
  26600. scaling: Vector3;
  26601. /**
  26602. * Returns true if the mesh is blocked. Implemented by child classes
  26603. */
  26604. readonly isBlocked: boolean;
  26605. /**
  26606. * Returns the mesh itself by default. Implemented by child classes
  26607. * @param camera defines the camera to use to pick the right LOD level
  26608. * @returns the currentAbstractMesh
  26609. */
  26610. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26611. /**
  26612. * Returns 0 by default. Implemented by child classes
  26613. * @returns an integer
  26614. */
  26615. getTotalVertices(): number;
  26616. /**
  26617. * Returns a positive integer : the total number of indices in this mesh geometry.
  26618. * @returns the numner of indices or zero if the mesh has no geometry.
  26619. */
  26620. getTotalIndices(): number;
  26621. /**
  26622. * Returns null by default. Implemented by child classes
  26623. * @returns null
  26624. */
  26625. getIndices(): Nullable<IndicesArray>;
  26626. /**
  26627. * Returns the array of the requested vertex data kind. Implemented by child classes
  26628. * @param kind defines the vertex data kind to use
  26629. * @returns null
  26630. */
  26631. getVerticesData(kind: string): Nullable<FloatArray>;
  26632. /**
  26633. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26634. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26635. * Note that a new underlying VertexBuffer object is created each call.
  26636. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26637. * @param kind defines vertex data kind:
  26638. * * VertexBuffer.PositionKind
  26639. * * VertexBuffer.UVKind
  26640. * * VertexBuffer.UV2Kind
  26641. * * VertexBuffer.UV3Kind
  26642. * * VertexBuffer.UV4Kind
  26643. * * VertexBuffer.UV5Kind
  26644. * * VertexBuffer.UV6Kind
  26645. * * VertexBuffer.ColorKind
  26646. * * VertexBuffer.MatricesIndicesKind
  26647. * * VertexBuffer.MatricesIndicesExtraKind
  26648. * * VertexBuffer.MatricesWeightsKind
  26649. * * VertexBuffer.MatricesWeightsExtraKind
  26650. * @param data defines the data source
  26651. * @param updatable defines if the data must be flagged as updatable (or static)
  26652. * @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
  26653. * @returns the current mesh
  26654. */
  26655. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26656. /**
  26657. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26658. * If the mesh has no geometry, it is simply returned as it is.
  26659. * @param kind defines vertex data kind:
  26660. * * VertexBuffer.PositionKind
  26661. * * VertexBuffer.UVKind
  26662. * * VertexBuffer.UV2Kind
  26663. * * VertexBuffer.UV3Kind
  26664. * * VertexBuffer.UV4Kind
  26665. * * VertexBuffer.UV5Kind
  26666. * * VertexBuffer.UV6Kind
  26667. * * VertexBuffer.ColorKind
  26668. * * VertexBuffer.MatricesIndicesKind
  26669. * * VertexBuffer.MatricesIndicesExtraKind
  26670. * * VertexBuffer.MatricesWeightsKind
  26671. * * VertexBuffer.MatricesWeightsExtraKind
  26672. * @param data defines the data source
  26673. * @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
  26674. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26675. * @returns the current mesh
  26676. */
  26677. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26678. /**
  26679. * Sets the mesh indices,
  26680. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26681. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26682. * @param totalVertices Defines the total number of vertices
  26683. * @returns the current mesh
  26684. */
  26685. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26686. /**
  26687. * Gets a boolean indicating if specific vertex data is present
  26688. * @param kind defines the vertex data kind to use
  26689. * @returns true is data kind is present
  26690. */
  26691. isVerticesDataPresent(kind: string): boolean;
  26692. /**
  26693. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26694. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26695. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26696. * @returns a BoundingInfo
  26697. */
  26698. getBoundingInfo(): BoundingInfo;
  26699. /**
  26700. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26701. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26702. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26703. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26704. * @returns the current mesh
  26705. */
  26706. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26707. /**
  26708. * Overwrite the current bounding info
  26709. * @param boundingInfo defines the new bounding info
  26710. * @returns the current mesh
  26711. */
  26712. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26713. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26714. readonly useBones: boolean;
  26715. /** @hidden */
  26716. _preActivate(): void;
  26717. /** @hidden */
  26718. _preActivateForIntermediateRendering(renderId: number): void;
  26719. /** @hidden */
  26720. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26721. /** @hidden */
  26722. _postActivate(): void;
  26723. /** @hidden */
  26724. _freeze(): void;
  26725. /** @hidden */
  26726. _unFreeze(): void;
  26727. /**
  26728. * Gets the current world matrix
  26729. * @returns a Matrix
  26730. */
  26731. getWorldMatrix(): Matrix;
  26732. /** @hidden */
  26733. _getWorldMatrixDeterminant(): number;
  26734. /**
  26735. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26736. */
  26737. readonly isAnInstance: boolean;
  26738. /**
  26739. * Perform relative position change from the point of view of behind the front of the mesh.
  26740. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26741. * Supports definition of mesh facing forward or backward
  26742. * @param amountRight defines the distance on the right axis
  26743. * @param amountUp defines the distance on the up axis
  26744. * @param amountForward defines the distance on the forward axis
  26745. * @returns the current mesh
  26746. */
  26747. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26748. /**
  26749. * Calculate relative position change from the point of view of behind the front of the mesh.
  26750. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26751. * Supports definition of mesh facing forward or backward
  26752. * @param amountRight defines the distance on the right axis
  26753. * @param amountUp defines the distance on the up axis
  26754. * @param amountForward defines the distance on the forward axis
  26755. * @returns the new displacement vector
  26756. */
  26757. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26758. /**
  26759. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26760. * Supports definition of mesh facing forward or backward
  26761. * @param flipBack defines the flip
  26762. * @param twirlClockwise defines the twirl
  26763. * @param tiltRight defines the tilt
  26764. * @returns the current mesh
  26765. */
  26766. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26767. /**
  26768. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26769. * Supports definition of mesh facing forward or backward.
  26770. * @param flipBack defines the flip
  26771. * @param twirlClockwise defines the twirl
  26772. * @param tiltRight defines the tilt
  26773. * @returns the new rotation vector
  26774. */
  26775. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26776. /**
  26777. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26778. * This means the mesh underlying bounding box and sphere are recomputed.
  26779. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26780. * @returns the current mesh
  26781. */
  26782. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26783. /** @hidden */
  26784. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26785. /** @hidden */
  26786. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26787. /** @hidden */
  26788. _updateBoundingInfo(): AbstractMesh;
  26789. /** @hidden */
  26790. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26791. /** @hidden */
  26792. protected _afterComputeWorldMatrix(): void;
  26793. /** @hidden */
  26794. readonly _effectiveMesh: AbstractMesh;
  26795. /**
  26796. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26797. * A mesh is in the frustum if its bounding box intersects the frustum
  26798. * @param frustumPlanes defines the frustum to test
  26799. * @returns true if the mesh is in the frustum planes
  26800. */
  26801. isInFrustum(frustumPlanes: Plane[]): boolean;
  26802. /**
  26803. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26804. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26805. * @param frustumPlanes defines the frustum to test
  26806. * @returns true if the mesh is completely in the frustum planes
  26807. */
  26808. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26809. /**
  26810. * True if the mesh intersects another mesh or a SolidParticle object
  26811. * @param mesh defines a target mesh or SolidParticle to test
  26812. * @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)
  26813. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26814. * @returns true if there is an intersection
  26815. */
  26816. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26817. /**
  26818. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26819. * @param point defines the point to test
  26820. * @returns true if there is an intersection
  26821. */
  26822. intersectsPoint(point: Vector3): boolean;
  26823. /**
  26824. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26825. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26826. */
  26827. checkCollisions: boolean;
  26828. /**
  26829. * Gets Collider object used to compute collisions (not physics)
  26830. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26831. */
  26832. readonly collider: Nullable<Collider>;
  26833. /**
  26834. * Move the mesh using collision engine
  26835. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26836. * @param displacement defines the requested displacement vector
  26837. * @returns the current mesh
  26838. */
  26839. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26840. private _onCollisionPositionChange;
  26841. /** @hidden */
  26842. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26843. /** @hidden */
  26844. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26845. /** @hidden */
  26846. _checkCollision(collider: Collider): AbstractMesh;
  26847. /** @hidden */
  26848. _generatePointsArray(): boolean;
  26849. /**
  26850. * Checks if the passed Ray intersects with the mesh
  26851. * @param ray defines the ray to use
  26852. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26853. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26854. * @returns the picking info
  26855. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26856. */
  26857. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26858. /**
  26859. * Clones the current mesh
  26860. * @param name defines the mesh name
  26861. * @param newParent defines the new mesh parent
  26862. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26863. * @returns the new mesh
  26864. */
  26865. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26866. /**
  26867. * Disposes all the submeshes of the current meshnp
  26868. * @returns the current mesh
  26869. */
  26870. releaseSubMeshes(): AbstractMesh;
  26871. /**
  26872. * Releases resources associated with this abstract mesh.
  26873. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26874. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26875. */
  26876. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26877. /**
  26878. * Adds the passed mesh as a child to the current mesh
  26879. * @param mesh defines the child mesh
  26880. * @returns the current mesh
  26881. */
  26882. addChild(mesh: AbstractMesh): AbstractMesh;
  26883. /**
  26884. * Removes the passed mesh from the current mesh children list
  26885. * @param mesh defines the child mesh
  26886. * @returns the current mesh
  26887. */
  26888. removeChild(mesh: AbstractMesh): AbstractMesh;
  26889. /** @hidden */
  26890. private _initFacetData;
  26891. /**
  26892. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26893. * This method can be called within the render loop.
  26894. * 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
  26895. * @returns the current mesh
  26896. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26897. */
  26898. updateFacetData(): AbstractMesh;
  26899. /**
  26900. * Returns the facetLocalNormals array.
  26901. * The normals are expressed in the mesh local spac
  26902. * @returns an array of Vector3
  26903. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26904. */
  26905. getFacetLocalNormals(): Vector3[];
  26906. /**
  26907. * Returns the facetLocalPositions array.
  26908. * The facet positions are expressed in the mesh local space
  26909. * @returns an array of Vector3
  26910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26911. */
  26912. getFacetLocalPositions(): Vector3[];
  26913. /**
  26914. * Returns the facetLocalPartioning array
  26915. * @returns an array of array of numbers
  26916. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26917. */
  26918. getFacetLocalPartitioning(): number[][];
  26919. /**
  26920. * Returns the i-th facet position in the world system.
  26921. * This method allocates a new Vector3 per call
  26922. * @param i defines the facet index
  26923. * @returns a new Vector3
  26924. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26925. */
  26926. getFacetPosition(i: number): Vector3;
  26927. /**
  26928. * Sets the reference Vector3 with the i-th facet position in the world system
  26929. * @param i defines the facet index
  26930. * @param ref defines the target vector
  26931. * @returns the current mesh
  26932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26933. */
  26934. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26935. /**
  26936. * Returns the i-th facet normal in the world system.
  26937. * This method allocates a new Vector3 per call
  26938. * @param i defines the facet index
  26939. * @returns a new Vector3
  26940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26941. */
  26942. getFacetNormal(i: number): Vector3;
  26943. /**
  26944. * Sets the reference Vector3 with the i-th facet normal in the world system
  26945. * @param i defines the facet index
  26946. * @param ref defines the target vector
  26947. * @returns the current mesh
  26948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26949. */
  26950. getFacetNormalToRef(i: number, ref: Vector3): this;
  26951. /**
  26952. * 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)
  26953. * @param x defines x coordinate
  26954. * @param y defines y coordinate
  26955. * @param z defines z coordinate
  26956. * @returns the array of facet indexes
  26957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26958. */
  26959. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26960. /**
  26961. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26962. * @param projected sets as the (x,y,z) world projection on the facet
  26963. * @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
  26964. * @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
  26965. * @param x defines x coordinate
  26966. * @param y defines y coordinate
  26967. * @param z defines z coordinate
  26968. * @returns the face index if found (or null instead)
  26969. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26970. */
  26971. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26972. /**
  26973. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26974. * @param projected sets as the (x,y,z) local projection on the facet
  26975. * @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
  26976. * @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
  26977. * @param x defines x coordinate
  26978. * @param y defines y coordinate
  26979. * @param z defines z coordinate
  26980. * @returns the face index if found (or null instead)
  26981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26982. */
  26983. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26984. /**
  26985. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26986. * @returns the parameters
  26987. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26988. */
  26989. getFacetDataParameters(): any;
  26990. /**
  26991. * Disables the feature FacetData and frees the related memory
  26992. * @returns the current mesh
  26993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26994. */
  26995. disableFacetData(): AbstractMesh;
  26996. /**
  26997. * Updates the AbstractMesh indices array
  26998. * @param indices defines the data source
  26999. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27000. * @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)
  27001. * @returns the current mesh
  27002. */
  27003. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27004. /**
  27005. * Creates new normals data for the mesh
  27006. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27007. * @returns the current mesh
  27008. */
  27009. createNormals(updatable: boolean): AbstractMesh;
  27010. /**
  27011. * Align the mesh with a normal
  27012. * @param normal defines the normal to use
  27013. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27014. * @returns the current mesh
  27015. */
  27016. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27017. /** @hidden */
  27018. _checkOcclusionQuery(): boolean;
  27019. /**
  27020. * Disables the mesh edge rendering mode
  27021. * @returns the currentAbstractMesh
  27022. */
  27023. disableEdgesRendering(): AbstractMesh;
  27024. /**
  27025. * Enables the edge rendering mode on the mesh.
  27026. * This mode makes the mesh edges visible
  27027. * @param epsilon defines the maximal distance between two angles to detect a face
  27028. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27029. * @returns the currentAbstractMesh
  27030. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27031. */
  27032. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27033. }
  27034. }
  27035. declare module "babylonjs/Actions/actionEvent" {
  27036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27037. import { Nullable } from "babylonjs/types";
  27038. import { Sprite } from "babylonjs/Sprites/sprite";
  27039. import { Scene } from "babylonjs/scene";
  27040. import { Vector2 } from "babylonjs/Maths/math.vector";
  27041. /**
  27042. * Interface used to define ActionEvent
  27043. */
  27044. export interface IActionEvent {
  27045. /** The mesh or sprite that triggered the action */
  27046. source: any;
  27047. /** The X mouse cursor position at the time of the event */
  27048. pointerX: number;
  27049. /** The Y mouse cursor position at the time of the event */
  27050. pointerY: number;
  27051. /** The mesh that is currently pointed at (can be null) */
  27052. meshUnderPointer: Nullable<AbstractMesh>;
  27053. /** the original (browser) event that triggered the ActionEvent */
  27054. sourceEvent?: any;
  27055. /** additional data for the event */
  27056. additionalData?: any;
  27057. }
  27058. /**
  27059. * ActionEvent is the event being sent when an action is triggered.
  27060. */
  27061. export class ActionEvent implements IActionEvent {
  27062. /** The mesh or sprite that triggered the action */
  27063. source: any;
  27064. /** The X mouse cursor position at the time of the event */
  27065. pointerX: number;
  27066. /** The Y mouse cursor position at the time of the event */
  27067. pointerY: number;
  27068. /** The mesh that is currently pointed at (can be null) */
  27069. meshUnderPointer: Nullable<AbstractMesh>;
  27070. /** the original (browser) event that triggered the ActionEvent */
  27071. sourceEvent?: any;
  27072. /** additional data for the event */
  27073. additionalData?: any;
  27074. /**
  27075. * Creates a new ActionEvent
  27076. * @param source The mesh or sprite that triggered the action
  27077. * @param pointerX The X mouse cursor position at the time of the event
  27078. * @param pointerY The Y mouse cursor position at the time of the event
  27079. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27080. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27081. * @param additionalData additional data for the event
  27082. */
  27083. constructor(
  27084. /** The mesh or sprite that triggered the action */
  27085. source: any,
  27086. /** The X mouse cursor position at the time of the event */
  27087. pointerX: number,
  27088. /** The Y mouse cursor position at the time of the event */
  27089. pointerY: number,
  27090. /** The mesh that is currently pointed at (can be null) */
  27091. meshUnderPointer: Nullable<AbstractMesh>,
  27092. /** the original (browser) event that triggered the ActionEvent */
  27093. sourceEvent?: any,
  27094. /** additional data for the event */
  27095. additionalData?: any);
  27096. /**
  27097. * Helper function to auto-create an ActionEvent from a source mesh.
  27098. * @param source The source mesh that triggered the event
  27099. * @param evt The original (browser) event
  27100. * @param additionalData additional data for the event
  27101. * @returns the new ActionEvent
  27102. */
  27103. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27104. /**
  27105. * Helper function to auto-create an ActionEvent from a source sprite
  27106. * @param source The source sprite that triggered the event
  27107. * @param scene Scene associated with the sprite
  27108. * @param evt The original (browser) event
  27109. * @param additionalData additional data for the event
  27110. * @returns the new ActionEvent
  27111. */
  27112. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27113. /**
  27114. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27115. * @param scene the scene where the event occurred
  27116. * @param evt The original (browser) event
  27117. * @returns the new ActionEvent
  27118. */
  27119. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27120. /**
  27121. * Helper function to auto-create an ActionEvent from a primitive
  27122. * @param prim defines the target primitive
  27123. * @param pointerPos defines the pointer position
  27124. * @param evt The original (browser) event
  27125. * @param additionalData additional data for the event
  27126. * @returns the new ActionEvent
  27127. */
  27128. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27129. }
  27130. }
  27131. declare module "babylonjs/Actions/abstractActionManager" {
  27132. import { IDisposable } from "babylonjs/scene";
  27133. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27134. import { IAction } from "babylonjs/Actions/action";
  27135. import { Nullable } from "babylonjs/types";
  27136. /**
  27137. * Abstract class used to decouple action Manager from scene and meshes.
  27138. * Do not instantiate.
  27139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27140. */
  27141. export abstract class AbstractActionManager implements IDisposable {
  27142. /** Gets the list of active triggers */
  27143. static Triggers: {
  27144. [key: string]: number;
  27145. };
  27146. /** Gets the cursor to use when hovering items */
  27147. hoverCursor: string;
  27148. /** Gets the list of actions */
  27149. actions: IAction[];
  27150. /**
  27151. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27152. */
  27153. isRecursive: boolean;
  27154. /**
  27155. * Releases all associated resources
  27156. */
  27157. abstract dispose(): void;
  27158. /**
  27159. * Does this action manager has pointer triggers
  27160. */
  27161. abstract readonly hasPointerTriggers: boolean;
  27162. /**
  27163. * Does this action manager has pick triggers
  27164. */
  27165. abstract readonly hasPickTriggers: boolean;
  27166. /**
  27167. * Process a specific trigger
  27168. * @param trigger defines the trigger to process
  27169. * @param evt defines the event details to be processed
  27170. */
  27171. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27172. /**
  27173. * Does this action manager handles actions of any of the given triggers
  27174. * @param triggers defines the triggers to be tested
  27175. * @return a boolean indicating whether one (or more) of the triggers is handled
  27176. */
  27177. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27178. /**
  27179. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27180. * speed.
  27181. * @param triggerA defines the trigger to be tested
  27182. * @param triggerB defines the trigger to be tested
  27183. * @return a boolean indicating whether one (or more) of the triggers is handled
  27184. */
  27185. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27186. /**
  27187. * Does this action manager handles actions of a given trigger
  27188. * @param trigger defines the trigger to be tested
  27189. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27190. * @return whether the trigger is handled
  27191. */
  27192. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27193. /**
  27194. * Serialize this manager to a JSON object
  27195. * @param name defines the property name to store this manager
  27196. * @returns a JSON representation of this manager
  27197. */
  27198. abstract serialize(name: string): any;
  27199. /**
  27200. * Registers an action to this action manager
  27201. * @param action defines the action to be registered
  27202. * @return the action amended (prepared) after registration
  27203. */
  27204. abstract registerAction(action: IAction): Nullable<IAction>;
  27205. /**
  27206. * Unregisters an action to this action manager
  27207. * @param action defines the action to be unregistered
  27208. * @return a boolean indicating whether the action has been unregistered
  27209. */
  27210. abstract unregisterAction(action: IAction): Boolean;
  27211. /**
  27212. * Does exist one action manager with at least one trigger
  27213. **/
  27214. static readonly HasTriggers: boolean;
  27215. /**
  27216. * Does exist one action manager with at least one pick trigger
  27217. **/
  27218. static readonly HasPickTriggers: boolean;
  27219. /**
  27220. * Does exist one action manager that handles actions of a given trigger
  27221. * @param trigger defines the trigger to be tested
  27222. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27223. **/
  27224. static HasSpecificTrigger(trigger: number): boolean;
  27225. }
  27226. }
  27227. declare module "babylonjs/node" {
  27228. import { Scene } from "babylonjs/scene";
  27229. import { Nullable } from "babylonjs/types";
  27230. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27231. import { Engine } from "babylonjs/Engines/engine";
  27232. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27233. import { Observable } from "babylonjs/Misc/observable";
  27234. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27235. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27236. import { Animatable } from "babylonjs/Animations/animatable";
  27237. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27238. import { Animation } from "babylonjs/Animations/animation";
  27239. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27241. /**
  27242. * Defines how a node can be built from a string name.
  27243. */
  27244. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27245. /**
  27246. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27247. */
  27248. export class Node implements IBehaviorAware<Node> {
  27249. /** @hidden */
  27250. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27251. private static _NodeConstructors;
  27252. /**
  27253. * Add a new node constructor
  27254. * @param type defines the type name of the node to construct
  27255. * @param constructorFunc defines the constructor function
  27256. */
  27257. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27258. /**
  27259. * Returns a node constructor based on type name
  27260. * @param type defines the type name
  27261. * @param name defines the new node name
  27262. * @param scene defines the hosting scene
  27263. * @param options defines optional options to transmit to constructors
  27264. * @returns the new constructor or null
  27265. */
  27266. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27267. /**
  27268. * Gets or sets the name of the node
  27269. */
  27270. name: string;
  27271. /**
  27272. * Gets or sets the id of the node
  27273. */
  27274. id: string;
  27275. /**
  27276. * Gets or sets the unique id of the node
  27277. */
  27278. uniqueId: number;
  27279. /**
  27280. * Gets or sets a string used to store user defined state for the node
  27281. */
  27282. state: string;
  27283. /**
  27284. * Gets or sets an object used to store user defined information for the node
  27285. */
  27286. metadata: any;
  27287. /**
  27288. * For internal use only. Please do not use.
  27289. */
  27290. reservedDataStore: any;
  27291. /**
  27292. * List of inspectable custom properties (used by the Inspector)
  27293. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27294. */
  27295. inspectableCustomProperties: IInspectable[];
  27296. /**
  27297. * Gets or sets a boolean used to define if the node must be serialized
  27298. */
  27299. doNotSerialize: boolean;
  27300. /** @hidden */
  27301. _isDisposed: boolean;
  27302. /**
  27303. * Gets a list of Animations associated with the node
  27304. */
  27305. animations: import("babylonjs/Animations/animation").Animation[];
  27306. protected _ranges: {
  27307. [name: string]: Nullable<AnimationRange>;
  27308. };
  27309. /**
  27310. * Callback raised when the node is ready to be used
  27311. */
  27312. onReady: Nullable<(node: Node) => void>;
  27313. private _isEnabled;
  27314. private _isParentEnabled;
  27315. private _isReady;
  27316. /** @hidden */
  27317. _currentRenderId: number;
  27318. private _parentUpdateId;
  27319. /** @hidden */
  27320. _childUpdateId: number;
  27321. /** @hidden */
  27322. _waitingParentId: Nullable<string>;
  27323. /** @hidden */
  27324. _scene: Scene;
  27325. /** @hidden */
  27326. _cache: any;
  27327. private _parentNode;
  27328. private _children;
  27329. /** @hidden */
  27330. _worldMatrix: Matrix;
  27331. /** @hidden */
  27332. _worldMatrixDeterminant: number;
  27333. /** @hidden */
  27334. _worldMatrixDeterminantIsDirty: boolean;
  27335. /** @hidden */
  27336. private _sceneRootNodesIndex;
  27337. /**
  27338. * Gets a boolean indicating if the node has been disposed
  27339. * @returns true if the node was disposed
  27340. */
  27341. isDisposed(): boolean;
  27342. /**
  27343. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27344. * @see https://doc.babylonjs.com/how_to/parenting
  27345. */
  27346. parent: Nullable<Node>;
  27347. private addToSceneRootNodes;
  27348. private removeFromSceneRootNodes;
  27349. private _animationPropertiesOverride;
  27350. /**
  27351. * Gets or sets the animation properties override
  27352. */
  27353. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27354. /**
  27355. * Gets a string idenfifying the name of the class
  27356. * @returns "Node" string
  27357. */
  27358. getClassName(): string;
  27359. /** @hidden */
  27360. readonly _isNode: boolean;
  27361. /**
  27362. * An event triggered when the mesh is disposed
  27363. */
  27364. onDisposeObservable: Observable<Node>;
  27365. private _onDisposeObserver;
  27366. /**
  27367. * Sets a callback that will be raised when the node will be disposed
  27368. */
  27369. onDispose: () => void;
  27370. /**
  27371. * Creates a new Node
  27372. * @param name the name and id to be given to this node
  27373. * @param scene the scene this node will be added to
  27374. * @param addToRootNodes the node will be added to scene.rootNodes
  27375. */
  27376. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27377. /**
  27378. * Gets the scene of the node
  27379. * @returns a scene
  27380. */
  27381. getScene(): Scene;
  27382. /**
  27383. * Gets the engine of the node
  27384. * @returns a Engine
  27385. */
  27386. getEngine(): Engine;
  27387. private _behaviors;
  27388. /**
  27389. * Attach a behavior to the node
  27390. * @see http://doc.babylonjs.com/features/behaviour
  27391. * @param behavior defines the behavior to attach
  27392. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27393. * @returns the current Node
  27394. */
  27395. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27396. /**
  27397. * Remove an attached behavior
  27398. * @see http://doc.babylonjs.com/features/behaviour
  27399. * @param behavior defines the behavior to attach
  27400. * @returns the current Node
  27401. */
  27402. removeBehavior(behavior: Behavior<Node>): Node;
  27403. /**
  27404. * Gets the list of attached behaviors
  27405. * @see http://doc.babylonjs.com/features/behaviour
  27406. */
  27407. readonly behaviors: Behavior<Node>[];
  27408. /**
  27409. * Gets an attached behavior by name
  27410. * @param name defines the name of the behavior to look for
  27411. * @see http://doc.babylonjs.com/features/behaviour
  27412. * @returns null if behavior was not found else the requested behavior
  27413. */
  27414. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27415. /**
  27416. * Returns the latest update of the World matrix
  27417. * @returns a Matrix
  27418. */
  27419. getWorldMatrix(): Matrix;
  27420. /** @hidden */
  27421. _getWorldMatrixDeterminant(): number;
  27422. /**
  27423. * Returns directly the latest state of the mesh World matrix.
  27424. * A Matrix is returned.
  27425. */
  27426. readonly worldMatrixFromCache: Matrix;
  27427. /** @hidden */
  27428. _initCache(): void;
  27429. /** @hidden */
  27430. updateCache(force?: boolean): void;
  27431. /** @hidden */
  27432. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27433. /** @hidden */
  27434. _updateCache(ignoreParentClass?: boolean): void;
  27435. /** @hidden */
  27436. _isSynchronized(): boolean;
  27437. /** @hidden */
  27438. _markSyncedWithParent(): void;
  27439. /** @hidden */
  27440. isSynchronizedWithParent(): boolean;
  27441. /** @hidden */
  27442. isSynchronized(): boolean;
  27443. /**
  27444. * Is this node ready to be used/rendered
  27445. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27446. * @return true if the node is ready
  27447. */
  27448. isReady(completeCheck?: boolean): boolean;
  27449. /**
  27450. * Is this node enabled?
  27451. * 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
  27452. * @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
  27453. * @return whether this node (and its parent) is enabled
  27454. */
  27455. isEnabled(checkAncestors?: boolean): boolean;
  27456. /** @hidden */
  27457. protected _syncParentEnabledState(): void;
  27458. /**
  27459. * Set the enabled state of this node
  27460. * @param value defines the new enabled state
  27461. */
  27462. setEnabled(value: boolean): void;
  27463. /**
  27464. * Is this node a descendant of the given node?
  27465. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27466. * @param ancestor defines the parent node to inspect
  27467. * @returns a boolean indicating if this node is a descendant of the given node
  27468. */
  27469. isDescendantOf(ancestor: Node): boolean;
  27470. /** @hidden */
  27471. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27472. /**
  27473. * Will return all nodes that have this node as ascendant
  27474. * @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
  27475. * @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
  27476. * @return all children nodes of all types
  27477. */
  27478. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27479. /**
  27480. * Get all child-meshes of this node
  27481. * @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)
  27482. * @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
  27483. * @returns an array of AbstractMesh
  27484. */
  27485. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27486. /**
  27487. * Get all direct children of this node
  27488. * @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
  27489. * @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)
  27490. * @returns an array of Node
  27491. */
  27492. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27493. /** @hidden */
  27494. _setReady(state: boolean): void;
  27495. /**
  27496. * Get an animation by name
  27497. * @param name defines the name of the animation to look for
  27498. * @returns null if not found else the requested animation
  27499. */
  27500. getAnimationByName(name: string): Nullable<Animation>;
  27501. /**
  27502. * Creates an animation range for this node
  27503. * @param name defines the name of the range
  27504. * @param from defines the starting key
  27505. * @param to defines the end key
  27506. */
  27507. createAnimationRange(name: string, from: number, to: number): void;
  27508. /**
  27509. * Delete a specific animation range
  27510. * @param name defines the name of the range to delete
  27511. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27512. */
  27513. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27514. /**
  27515. * Get an animation range by name
  27516. * @param name defines the name of the animation range to look for
  27517. * @returns null if not found else the requested animation range
  27518. */
  27519. getAnimationRange(name: string): Nullable<AnimationRange>;
  27520. /**
  27521. * Gets the list of all animation ranges defined on this node
  27522. * @returns an array
  27523. */
  27524. getAnimationRanges(): Nullable<AnimationRange>[];
  27525. /**
  27526. * Will start the animation sequence
  27527. * @param name defines the range frames for animation sequence
  27528. * @param loop defines if the animation should loop (false by default)
  27529. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27530. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27531. * @returns the object created for this animation. If range does not exist, it will return null
  27532. */
  27533. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27534. /**
  27535. * Serialize animation ranges into a JSON compatible object
  27536. * @returns serialization object
  27537. */
  27538. serializeAnimationRanges(): any;
  27539. /**
  27540. * Computes the world matrix of the node
  27541. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27542. * @returns the world matrix
  27543. */
  27544. computeWorldMatrix(force?: boolean): Matrix;
  27545. /**
  27546. * Releases resources associated with this node.
  27547. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27548. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27549. */
  27550. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27551. /**
  27552. * Parse animation range data from a serialization object and store them into a given node
  27553. * @param node defines where to store the animation ranges
  27554. * @param parsedNode defines the serialization object to read data from
  27555. * @param scene defines the hosting scene
  27556. */
  27557. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27558. /**
  27559. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27560. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27561. * @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
  27562. * @returns the new bounding vectors
  27563. */
  27564. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27565. min: Vector3;
  27566. max: Vector3;
  27567. };
  27568. }
  27569. }
  27570. declare module "babylonjs/Animations/animation" {
  27571. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27572. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27573. import { Color3 } from "babylonjs/Maths/math.color";
  27574. import { Nullable } from "babylonjs/types";
  27575. import { Scene } from "babylonjs/scene";
  27576. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27577. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27578. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27579. import { Node } from "babylonjs/node";
  27580. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27581. import { Size } from "babylonjs/Maths/math.size";
  27582. import { Animatable } from "babylonjs/Animations/animatable";
  27583. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27584. /**
  27585. * @hidden
  27586. */
  27587. export class _IAnimationState {
  27588. key: number;
  27589. repeatCount: number;
  27590. workValue?: any;
  27591. loopMode?: number;
  27592. offsetValue?: any;
  27593. highLimitValue?: any;
  27594. }
  27595. /**
  27596. * Class used to store any kind of animation
  27597. */
  27598. export class Animation {
  27599. /**Name of the animation */
  27600. name: string;
  27601. /**Property to animate */
  27602. targetProperty: string;
  27603. /**The frames per second of the animation */
  27604. framePerSecond: number;
  27605. /**The data type of the animation */
  27606. dataType: number;
  27607. /**The loop mode of the animation */
  27608. loopMode?: number | undefined;
  27609. /**Specifies if blending should be enabled */
  27610. enableBlending?: boolean | undefined;
  27611. /**
  27612. * Use matrix interpolation instead of using direct key value when animating matrices
  27613. */
  27614. static AllowMatricesInterpolation: boolean;
  27615. /**
  27616. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27617. */
  27618. static AllowMatrixDecomposeForInterpolation: boolean;
  27619. /**
  27620. * Stores the key frames of the animation
  27621. */
  27622. private _keys;
  27623. /**
  27624. * Stores the easing function of the animation
  27625. */
  27626. private _easingFunction;
  27627. /**
  27628. * @hidden Internal use only
  27629. */
  27630. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27631. /**
  27632. * The set of event that will be linked to this animation
  27633. */
  27634. private _events;
  27635. /**
  27636. * Stores an array of target property paths
  27637. */
  27638. targetPropertyPath: string[];
  27639. /**
  27640. * Stores the blending speed of the animation
  27641. */
  27642. blendingSpeed: number;
  27643. /**
  27644. * Stores the animation ranges for the animation
  27645. */
  27646. private _ranges;
  27647. /**
  27648. * @hidden Internal use
  27649. */
  27650. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27651. /**
  27652. * Sets up an animation
  27653. * @param property The property to animate
  27654. * @param animationType The animation type to apply
  27655. * @param framePerSecond The frames per second of the animation
  27656. * @param easingFunction The easing function used in the animation
  27657. * @returns The created animation
  27658. */
  27659. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27660. /**
  27661. * Create and start an animation on a node
  27662. * @param name defines the name of the global animation that will be run on all nodes
  27663. * @param node defines the root node where the animation will take place
  27664. * @param targetProperty defines property to animate
  27665. * @param framePerSecond defines the number of frame per second yo use
  27666. * @param totalFrame defines the number of frames in total
  27667. * @param from defines the initial value
  27668. * @param to defines the final value
  27669. * @param loopMode defines which loop mode you want to use (off by default)
  27670. * @param easingFunction defines the easing function to use (linear by default)
  27671. * @param onAnimationEnd defines the callback to call when animation end
  27672. * @returns the animatable created for this animation
  27673. */
  27674. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27675. /**
  27676. * Create and start an animation on a node and its descendants
  27677. * @param name defines the name of the global animation that will be run on all nodes
  27678. * @param node defines the root node where the animation will take place
  27679. * @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
  27680. * @param targetProperty defines property to animate
  27681. * @param framePerSecond defines the number of frame per second to use
  27682. * @param totalFrame defines the number of frames in total
  27683. * @param from defines the initial value
  27684. * @param to defines the final value
  27685. * @param loopMode defines which loop mode you want to use (off by default)
  27686. * @param easingFunction defines the easing function to use (linear by default)
  27687. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27688. * @returns the list of animatables created for all nodes
  27689. * @example https://www.babylonjs-playground.com/#MH0VLI
  27690. */
  27691. 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[]>;
  27692. /**
  27693. * Creates a new animation, merges it with the existing animations and starts it
  27694. * @param name Name of the animation
  27695. * @param node Node which contains the scene that begins the animations
  27696. * @param targetProperty Specifies which property to animate
  27697. * @param framePerSecond The frames per second of the animation
  27698. * @param totalFrame The total number of frames
  27699. * @param from The frame at the beginning of the animation
  27700. * @param to The frame at the end of the animation
  27701. * @param loopMode Specifies the loop mode of the animation
  27702. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27703. * @param onAnimationEnd Callback to run once the animation is complete
  27704. * @returns Nullable animation
  27705. */
  27706. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27707. /**
  27708. * Transition property of an host to the target Value
  27709. * @param property The property to transition
  27710. * @param targetValue The target Value of the property
  27711. * @param host The object where the property to animate belongs
  27712. * @param scene Scene used to run the animation
  27713. * @param frameRate Framerate (in frame/s) to use
  27714. * @param transition The transition type we want to use
  27715. * @param duration The duration of the animation, in milliseconds
  27716. * @param onAnimationEnd Callback trigger at the end of the animation
  27717. * @returns Nullable animation
  27718. */
  27719. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27720. /**
  27721. * Return the array of runtime animations currently using this animation
  27722. */
  27723. readonly runtimeAnimations: RuntimeAnimation[];
  27724. /**
  27725. * Specifies if any of the runtime animations are currently running
  27726. */
  27727. readonly hasRunningRuntimeAnimations: boolean;
  27728. /**
  27729. * Initializes the animation
  27730. * @param name Name of the animation
  27731. * @param targetProperty Property to animate
  27732. * @param framePerSecond The frames per second of the animation
  27733. * @param dataType The data type of the animation
  27734. * @param loopMode The loop mode of the animation
  27735. * @param enableBlending Specifies if blending should be enabled
  27736. */
  27737. constructor(
  27738. /**Name of the animation */
  27739. name: string,
  27740. /**Property to animate */
  27741. targetProperty: string,
  27742. /**The frames per second of the animation */
  27743. framePerSecond: number,
  27744. /**The data type of the animation */
  27745. dataType: number,
  27746. /**The loop mode of the animation */
  27747. loopMode?: number | undefined,
  27748. /**Specifies if blending should be enabled */
  27749. enableBlending?: boolean | undefined);
  27750. /**
  27751. * Converts the animation to a string
  27752. * @param fullDetails support for multiple levels of logging within scene loading
  27753. * @returns String form of the animation
  27754. */
  27755. toString(fullDetails?: boolean): string;
  27756. /**
  27757. * Add an event to this animation
  27758. * @param event Event to add
  27759. */
  27760. addEvent(event: AnimationEvent): void;
  27761. /**
  27762. * Remove all events found at the given frame
  27763. * @param frame The frame to remove events from
  27764. */
  27765. removeEvents(frame: number): void;
  27766. /**
  27767. * Retrieves all the events from the animation
  27768. * @returns Events from the animation
  27769. */
  27770. getEvents(): AnimationEvent[];
  27771. /**
  27772. * Creates an animation range
  27773. * @param name Name of the animation range
  27774. * @param from Starting frame of the animation range
  27775. * @param to Ending frame of the animation
  27776. */
  27777. createRange(name: string, from: number, to: number): void;
  27778. /**
  27779. * Deletes an animation range by name
  27780. * @param name Name of the animation range to delete
  27781. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27782. */
  27783. deleteRange(name: string, deleteFrames?: boolean): void;
  27784. /**
  27785. * Gets the animation range by name, or null if not defined
  27786. * @param name Name of the animation range
  27787. * @returns Nullable animation range
  27788. */
  27789. getRange(name: string): Nullable<AnimationRange>;
  27790. /**
  27791. * Gets the key frames from the animation
  27792. * @returns The key frames of the animation
  27793. */
  27794. getKeys(): Array<IAnimationKey>;
  27795. /**
  27796. * Gets the highest frame rate of the animation
  27797. * @returns Highest frame rate of the animation
  27798. */
  27799. getHighestFrame(): number;
  27800. /**
  27801. * Gets the easing function of the animation
  27802. * @returns Easing function of the animation
  27803. */
  27804. getEasingFunction(): IEasingFunction;
  27805. /**
  27806. * Sets the easing function of the animation
  27807. * @param easingFunction A custom mathematical formula for animation
  27808. */
  27809. setEasingFunction(easingFunction: EasingFunction): void;
  27810. /**
  27811. * Interpolates a scalar linearly
  27812. * @param startValue Start value of the animation curve
  27813. * @param endValue End value of the animation curve
  27814. * @param gradient Scalar amount to interpolate
  27815. * @returns Interpolated scalar value
  27816. */
  27817. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27818. /**
  27819. * Interpolates a scalar cubically
  27820. * @param startValue Start value of the animation curve
  27821. * @param outTangent End tangent of the animation
  27822. * @param endValue End value of the animation curve
  27823. * @param inTangent Start tangent of the animation curve
  27824. * @param gradient Scalar amount to interpolate
  27825. * @returns Interpolated scalar value
  27826. */
  27827. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27828. /**
  27829. * Interpolates a quaternion using a spherical linear interpolation
  27830. * @param startValue Start value of the animation curve
  27831. * @param endValue End value of the animation curve
  27832. * @param gradient Scalar amount to interpolate
  27833. * @returns Interpolated quaternion value
  27834. */
  27835. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27836. /**
  27837. * Interpolates a quaternion cubically
  27838. * @param startValue Start value of the animation curve
  27839. * @param outTangent End tangent of the animation curve
  27840. * @param endValue End value of the animation curve
  27841. * @param inTangent Start tangent of the animation curve
  27842. * @param gradient Scalar amount to interpolate
  27843. * @returns Interpolated quaternion value
  27844. */
  27845. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27846. /**
  27847. * Interpolates a Vector3 linearl
  27848. * @param startValue Start value of the animation curve
  27849. * @param endValue End value of the animation curve
  27850. * @param gradient Scalar amount to interpolate
  27851. * @returns Interpolated scalar value
  27852. */
  27853. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27854. /**
  27855. * Interpolates a Vector3 cubically
  27856. * @param startValue Start value of the animation curve
  27857. * @param outTangent End tangent of the animation
  27858. * @param endValue End value of the animation curve
  27859. * @param inTangent Start tangent of the animation curve
  27860. * @param gradient Scalar amount to interpolate
  27861. * @returns InterpolatedVector3 value
  27862. */
  27863. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27864. /**
  27865. * Interpolates a Vector2 linearly
  27866. * @param startValue Start value of the animation curve
  27867. * @param endValue End value of the animation curve
  27868. * @param gradient Scalar amount to interpolate
  27869. * @returns Interpolated Vector2 value
  27870. */
  27871. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27872. /**
  27873. * Interpolates a Vector2 cubically
  27874. * @param startValue Start value of the animation curve
  27875. * @param outTangent End tangent of the animation
  27876. * @param endValue End value of the animation curve
  27877. * @param inTangent Start tangent of the animation curve
  27878. * @param gradient Scalar amount to interpolate
  27879. * @returns Interpolated Vector2 value
  27880. */
  27881. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27882. /**
  27883. * Interpolates a size linearly
  27884. * @param startValue Start value of the animation curve
  27885. * @param endValue End value of the animation curve
  27886. * @param gradient Scalar amount to interpolate
  27887. * @returns Interpolated Size value
  27888. */
  27889. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27890. /**
  27891. * Interpolates a Color3 linearly
  27892. * @param startValue Start value of the animation curve
  27893. * @param endValue End value of the animation curve
  27894. * @param gradient Scalar amount to interpolate
  27895. * @returns Interpolated Color3 value
  27896. */
  27897. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27898. /**
  27899. * @hidden Internal use only
  27900. */
  27901. _getKeyValue(value: any): any;
  27902. /**
  27903. * @hidden Internal use only
  27904. */
  27905. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27906. /**
  27907. * Defines the function to use to interpolate matrices
  27908. * @param startValue defines the start matrix
  27909. * @param endValue defines the end matrix
  27910. * @param gradient defines the gradient between both matrices
  27911. * @param result defines an optional target matrix where to store the interpolation
  27912. * @returns the interpolated matrix
  27913. */
  27914. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27915. /**
  27916. * Makes a copy of the animation
  27917. * @returns Cloned animation
  27918. */
  27919. clone(): Animation;
  27920. /**
  27921. * Sets the key frames of the animation
  27922. * @param values The animation key frames to set
  27923. */
  27924. setKeys(values: Array<IAnimationKey>): void;
  27925. /**
  27926. * Serializes the animation to an object
  27927. * @returns Serialized object
  27928. */
  27929. serialize(): any;
  27930. /**
  27931. * Float animation type
  27932. */
  27933. private static _ANIMATIONTYPE_FLOAT;
  27934. /**
  27935. * Vector3 animation type
  27936. */
  27937. private static _ANIMATIONTYPE_VECTOR3;
  27938. /**
  27939. * Quaternion animation type
  27940. */
  27941. private static _ANIMATIONTYPE_QUATERNION;
  27942. /**
  27943. * Matrix animation type
  27944. */
  27945. private static _ANIMATIONTYPE_MATRIX;
  27946. /**
  27947. * Color3 animation type
  27948. */
  27949. private static _ANIMATIONTYPE_COLOR3;
  27950. /**
  27951. * Vector2 animation type
  27952. */
  27953. private static _ANIMATIONTYPE_VECTOR2;
  27954. /**
  27955. * Size animation type
  27956. */
  27957. private static _ANIMATIONTYPE_SIZE;
  27958. /**
  27959. * Relative Loop Mode
  27960. */
  27961. private static _ANIMATIONLOOPMODE_RELATIVE;
  27962. /**
  27963. * Cycle Loop Mode
  27964. */
  27965. private static _ANIMATIONLOOPMODE_CYCLE;
  27966. /**
  27967. * Constant Loop Mode
  27968. */
  27969. private static _ANIMATIONLOOPMODE_CONSTANT;
  27970. /**
  27971. * Get the float animation type
  27972. */
  27973. static readonly ANIMATIONTYPE_FLOAT: number;
  27974. /**
  27975. * Get the Vector3 animation type
  27976. */
  27977. static readonly ANIMATIONTYPE_VECTOR3: number;
  27978. /**
  27979. * Get the Vector2 animation type
  27980. */
  27981. static readonly ANIMATIONTYPE_VECTOR2: number;
  27982. /**
  27983. * Get the Size animation type
  27984. */
  27985. static readonly ANIMATIONTYPE_SIZE: number;
  27986. /**
  27987. * Get the Quaternion animation type
  27988. */
  27989. static readonly ANIMATIONTYPE_QUATERNION: number;
  27990. /**
  27991. * Get the Matrix animation type
  27992. */
  27993. static readonly ANIMATIONTYPE_MATRIX: number;
  27994. /**
  27995. * Get the Color3 animation type
  27996. */
  27997. static readonly ANIMATIONTYPE_COLOR3: number;
  27998. /**
  27999. * Get the Relative Loop Mode
  28000. */
  28001. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28002. /**
  28003. * Get the Cycle Loop Mode
  28004. */
  28005. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28006. /**
  28007. * Get the Constant Loop Mode
  28008. */
  28009. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28010. /** @hidden */
  28011. static _UniversalLerp(left: any, right: any, amount: number): any;
  28012. /**
  28013. * Parses an animation object and creates an animation
  28014. * @param parsedAnimation Parsed animation object
  28015. * @returns Animation object
  28016. */
  28017. static Parse(parsedAnimation: any): Animation;
  28018. /**
  28019. * Appends the serialized animations from the source animations
  28020. * @param source Source containing the animations
  28021. * @param destination Target to store the animations
  28022. */
  28023. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28024. }
  28025. }
  28026. declare module "babylonjs/Animations/animatable.interface" {
  28027. import { Nullable } from "babylonjs/types";
  28028. import { Animation } from "babylonjs/Animations/animation";
  28029. /**
  28030. * Interface containing an array of animations
  28031. */
  28032. export interface IAnimatable {
  28033. /**
  28034. * Array of animations
  28035. */
  28036. animations: Nullable<Array<Animation>>;
  28037. }
  28038. }
  28039. declare module "babylonjs/Materials/fresnelParameters" {
  28040. import { Color3 } from "babylonjs/Maths/math.color";
  28041. /**
  28042. * This represents all the required information to add a fresnel effect on a material:
  28043. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28044. */
  28045. export class FresnelParameters {
  28046. private _isEnabled;
  28047. /**
  28048. * Define if the fresnel effect is enable or not.
  28049. */
  28050. isEnabled: boolean;
  28051. /**
  28052. * Define the color used on edges (grazing angle)
  28053. */
  28054. leftColor: Color3;
  28055. /**
  28056. * Define the color used on center
  28057. */
  28058. rightColor: Color3;
  28059. /**
  28060. * Define bias applied to computed fresnel term
  28061. */
  28062. bias: number;
  28063. /**
  28064. * Defined the power exponent applied to fresnel term
  28065. */
  28066. power: number;
  28067. /**
  28068. * Clones the current fresnel and its valuues
  28069. * @returns a clone fresnel configuration
  28070. */
  28071. clone(): FresnelParameters;
  28072. /**
  28073. * Serializes the current fresnel parameters to a JSON representation.
  28074. * @return the JSON serialization
  28075. */
  28076. serialize(): any;
  28077. /**
  28078. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28079. * @param parsedFresnelParameters Define the JSON representation
  28080. * @returns the parsed parameters
  28081. */
  28082. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28083. }
  28084. }
  28085. declare module "babylonjs/Misc/decorators" {
  28086. import { Nullable } from "babylonjs/types";
  28087. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28088. import { Scene } from "babylonjs/scene";
  28089. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28090. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28091. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28092. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28093. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28094. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28095. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28096. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28097. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28098. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28099. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28100. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28101. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28102. /**
  28103. * Decorator used to define property that can be serialized as reference to a camera
  28104. * @param sourceName defines the name of the property to decorate
  28105. */
  28106. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28107. /**
  28108. * Class used to help serialization objects
  28109. */
  28110. export class SerializationHelper {
  28111. /** @hidden */
  28112. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28113. /** @hidden */
  28114. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28115. /** @hidden */
  28116. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28117. /** @hidden */
  28118. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28119. /**
  28120. * Appends the serialized animations from the source animations
  28121. * @param source Source containing the animations
  28122. * @param destination Target to store the animations
  28123. */
  28124. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28125. /**
  28126. * Static function used to serialized a specific entity
  28127. * @param entity defines the entity to serialize
  28128. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28129. * @returns a JSON compatible object representing the serialization of the entity
  28130. */
  28131. static Serialize<T>(entity: T, serializationObject?: any): any;
  28132. /**
  28133. * Creates a new entity from a serialization data object
  28134. * @param creationFunction defines a function used to instanciated the new entity
  28135. * @param source defines the source serialization data
  28136. * @param scene defines the hosting scene
  28137. * @param rootUrl defines the root url for resources
  28138. * @returns a new entity
  28139. */
  28140. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28141. /**
  28142. * Clones an object
  28143. * @param creationFunction defines the function used to instanciate the new object
  28144. * @param source defines the source object
  28145. * @returns the cloned object
  28146. */
  28147. static Clone<T>(creationFunction: () => T, source: T): T;
  28148. /**
  28149. * Instanciates a new object based on a source one (some data will be shared between both object)
  28150. * @param creationFunction defines the function used to instanciate the new object
  28151. * @param source defines the source object
  28152. * @returns the new object
  28153. */
  28154. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28155. }
  28156. }
  28157. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28158. import { Nullable } from "babylonjs/types";
  28159. /**
  28160. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28161. */
  28162. export interface CubeMapInfo {
  28163. /**
  28164. * The pixel array for the front face.
  28165. * This is stored in format, left to right, up to down format.
  28166. */
  28167. front: Nullable<ArrayBufferView>;
  28168. /**
  28169. * The pixel array for the back face.
  28170. * This is stored in format, left to right, up to down format.
  28171. */
  28172. back: Nullable<ArrayBufferView>;
  28173. /**
  28174. * The pixel array for the left face.
  28175. * This is stored in format, left to right, up to down format.
  28176. */
  28177. left: Nullable<ArrayBufferView>;
  28178. /**
  28179. * The pixel array for the right face.
  28180. * This is stored in format, left to right, up to down format.
  28181. */
  28182. right: Nullable<ArrayBufferView>;
  28183. /**
  28184. * The pixel array for the up face.
  28185. * This is stored in format, left to right, up to down format.
  28186. */
  28187. up: Nullable<ArrayBufferView>;
  28188. /**
  28189. * The pixel array for the down face.
  28190. * This is stored in format, left to right, up to down format.
  28191. */
  28192. down: Nullable<ArrayBufferView>;
  28193. /**
  28194. * The size of the cubemap stored.
  28195. *
  28196. * Each faces will be size * size pixels.
  28197. */
  28198. size: number;
  28199. /**
  28200. * The format of the texture.
  28201. *
  28202. * RGBA, RGB.
  28203. */
  28204. format: number;
  28205. /**
  28206. * The type of the texture data.
  28207. *
  28208. * UNSIGNED_INT, FLOAT.
  28209. */
  28210. type: number;
  28211. /**
  28212. * Specifies whether the texture is in gamma space.
  28213. */
  28214. gammaSpace: boolean;
  28215. }
  28216. /**
  28217. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28218. */
  28219. export class PanoramaToCubeMapTools {
  28220. private static FACE_FRONT;
  28221. private static FACE_BACK;
  28222. private static FACE_RIGHT;
  28223. private static FACE_LEFT;
  28224. private static FACE_DOWN;
  28225. private static FACE_UP;
  28226. /**
  28227. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28228. *
  28229. * @param float32Array The source data.
  28230. * @param inputWidth The width of the input panorama.
  28231. * @param inputHeight The height of the input panorama.
  28232. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28233. * @return The cubemap data
  28234. */
  28235. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28236. private static CreateCubemapTexture;
  28237. private static CalcProjectionSpherical;
  28238. }
  28239. }
  28240. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28241. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28242. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28243. import { Nullable } from "babylonjs/types";
  28244. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28245. /**
  28246. * Helper class dealing with the extraction of spherical polynomial dataArray
  28247. * from a cube map.
  28248. */
  28249. export class CubeMapToSphericalPolynomialTools {
  28250. private static FileFaces;
  28251. /**
  28252. * Converts a texture to the according Spherical Polynomial data.
  28253. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28254. *
  28255. * @param texture The texture to extract the information from.
  28256. * @return The Spherical Polynomial data.
  28257. */
  28258. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28259. /**
  28260. * Converts a cubemap to the according Spherical Polynomial data.
  28261. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28262. *
  28263. * @param cubeInfo The Cube map to extract the information from.
  28264. * @return The Spherical Polynomial data.
  28265. */
  28266. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28267. }
  28268. }
  28269. declare module "babylonjs/Misc/guid" {
  28270. /**
  28271. * Class used to manipulate GUIDs
  28272. */
  28273. export class GUID {
  28274. /**
  28275. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28276. * Be aware Math.random() could cause collisions, but:
  28277. * "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"
  28278. * @returns a pseudo random id
  28279. */
  28280. static RandomId(): string;
  28281. }
  28282. }
  28283. declare module "babylonjs/Materials/Textures/baseTexture" {
  28284. import { Observable } from "babylonjs/Misc/observable";
  28285. import { Nullable } from "babylonjs/types";
  28286. import { Scene } from "babylonjs/scene";
  28287. import { Matrix } from "babylonjs/Maths/math.vector";
  28288. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28289. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28290. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28291. import { ISize } from "babylonjs/Maths/math.size";
  28292. /**
  28293. * Base class of all the textures in babylon.
  28294. * It groups all the common properties the materials, post process, lights... might need
  28295. * in order to make a correct use of the texture.
  28296. */
  28297. export class BaseTexture implements IAnimatable {
  28298. /**
  28299. * Default anisotropic filtering level for the application.
  28300. * It is set to 4 as a good tradeoff between perf and quality.
  28301. */
  28302. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28303. /**
  28304. * Gets or sets the unique id of the texture
  28305. */
  28306. uniqueId: number;
  28307. /**
  28308. * Define the name of the texture.
  28309. */
  28310. name: string;
  28311. /**
  28312. * Gets or sets an object used to store user defined information.
  28313. */
  28314. metadata: any;
  28315. /**
  28316. * For internal use only. Please do not use.
  28317. */
  28318. reservedDataStore: any;
  28319. private _hasAlpha;
  28320. /**
  28321. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28322. */
  28323. hasAlpha: boolean;
  28324. /**
  28325. * Defines if the alpha value should be determined via the rgb values.
  28326. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28327. */
  28328. getAlphaFromRGB: boolean;
  28329. /**
  28330. * Intensity or strength of the texture.
  28331. * It is commonly used by materials to fine tune the intensity of the texture
  28332. */
  28333. level: number;
  28334. /**
  28335. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28336. * This is part of the texture as textures usually maps to one uv set.
  28337. */
  28338. coordinatesIndex: number;
  28339. private _coordinatesMode;
  28340. /**
  28341. * How a texture is mapped.
  28342. *
  28343. * | Value | Type | Description |
  28344. * | ----- | ----------------------------------- | ----------- |
  28345. * | 0 | EXPLICIT_MODE | |
  28346. * | 1 | SPHERICAL_MODE | |
  28347. * | 2 | PLANAR_MODE | |
  28348. * | 3 | CUBIC_MODE | |
  28349. * | 4 | PROJECTION_MODE | |
  28350. * | 5 | SKYBOX_MODE | |
  28351. * | 6 | INVCUBIC_MODE | |
  28352. * | 7 | EQUIRECTANGULAR_MODE | |
  28353. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28354. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28355. */
  28356. coordinatesMode: number;
  28357. /**
  28358. * | Value | Type | Description |
  28359. * | ----- | ------------------ | ----------- |
  28360. * | 0 | CLAMP_ADDRESSMODE | |
  28361. * | 1 | WRAP_ADDRESSMODE | |
  28362. * | 2 | MIRROR_ADDRESSMODE | |
  28363. */
  28364. wrapU: number;
  28365. /**
  28366. * | Value | Type | Description |
  28367. * | ----- | ------------------ | ----------- |
  28368. * | 0 | CLAMP_ADDRESSMODE | |
  28369. * | 1 | WRAP_ADDRESSMODE | |
  28370. * | 2 | MIRROR_ADDRESSMODE | |
  28371. */
  28372. wrapV: number;
  28373. /**
  28374. * | Value | Type | Description |
  28375. * | ----- | ------------------ | ----------- |
  28376. * | 0 | CLAMP_ADDRESSMODE | |
  28377. * | 1 | WRAP_ADDRESSMODE | |
  28378. * | 2 | MIRROR_ADDRESSMODE | |
  28379. */
  28380. wrapR: number;
  28381. /**
  28382. * With compliant hardware and browser (supporting anisotropic filtering)
  28383. * this defines the level of anisotropic filtering in the texture.
  28384. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28385. */
  28386. anisotropicFilteringLevel: number;
  28387. /**
  28388. * Define if the texture is a cube texture or if false a 2d texture.
  28389. */
  28390. isCube: boolean;
  28391. /**
  28392. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28393. */
  28394. is3D: boolean;
  28395. /**
  28396. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28397. * HDR texture are usually stored in linear space.
  28398. * This only impacts the PBR and Background materials
  28399. */
  28400. gammaSpace: boolean;
  28401. /**
  28402. * Gets whether or not the texture contains RGBD data.
  28403. */
  28404. readonly isRGBD: boolean;
  28405. /**
  28406. * Is Z inverted in the texture (useful in a cube texture).
  28407. */
  28408. invertZ: boolean;
  28409. /**
  28410. * Are mip maps generated for this texture or not.
  28411. */
  28412. readonly noMipmap: boolean;
  28413. /**
  28414. * @hidden
  28415. */
  28416. lodLevelInAlpha: boolean;
  28417. /**
  28418. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28419. */
  28420. lodGenerationOffset: number;
  28421. /**
  28422. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28423. */
  28424. lodGenerationScale: number;
  28425. /**
  28426. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28427. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28428. * average roughness values.
  28429. */
  28430. linearSpecularLOD: boolean;
  28431. /**
  28432. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28433. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28434. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28435. */
  28436. irradianceTexture: Nullable<BaseTexture>;
  28437. /**
  28438. * Define if the texture is a render target.
  28439. */
  28440. isRenderTarget: boolean;
  28441. /**
  28442. * Define the unique id of the texture in the scene.
  28443. */
  28444. readonly uid: string;
  28445. /**
  28446. * Return a string representation of the texture.
  28447. * @returns the texture as a string
  28448. */
  28449. toString(): string;
  28450. /**
  28451. * Get the class name of the texture.
  28452. * @returns "BaseTexture"
  28453. */
  28454. getClassName(): string;
  28455. /**
  28456. * Define the list of animation attached to the texture.
  28457. */
  28458. animations: import("babylonjs/Animations/animation").Animation[];
  28459. /**
  28460. * An event triggered when the texture is disposed.
  28461. */
  28462. onDisposeObservable: Observable<BaseTexture>;
  28463. private _onDisposeObserver;
  28464. /**
  28465. * Callback triggered when the texture has been disposed.
  28466. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28467. */
  28468. onDispose: () => void;
  28469. /**
  28470. * Define the current state of the loading sequence when in delayed load mode.
  28471. */
  28472. delayLoadState: number;
  28473. private _scene;
  28474. /** @hidden */
  28475. _texture: Nullable<InternalTexture>;
  28476. private _uid;
  28477. /**
  28478. * Define if the texture is preventinga material to render or not.
  28479. * If not and the texture is not ready, the engine will use a default black texture instead.
  28480. */
  28481. readonly isBlocking: boolean;
  28482. /**
  28483. * Instantiates a new BaseTexture.
  28484. * Base class of all the textures in babylon.
  28485. * It groups all the common properties the materials, post process, lights... might need
  28486. * in order to make a correct use of the texture.
  28487. * @param scene Define the scene the texture blongs to
  28488. */
  28489. constructor(scene: Nullable<Scene>);
  28490. /**
  28491. * Get the scene the texture belongs to.
  28492. * @returns the scene or null if undefined
  28493. */
  28494. getScene(): Nullable<Scene>;
  28495. /**
  28496. * Get the texture transform matrix used to offset tile the texture for istance.
  28497. * @returns the transformation matrix
  28498. */
  28499. getTextureMatrix(): Matrix;
  28500. /**
  28501. * Get the texture reflection matrix used to rotate/transform the reflection.
  28502. * @returns the reflection matrix
  28503. */
  28504. getReflectionTextureMatrix(): Matrix;
  28505. /**
  28506. * Get the underlying lower level texture from Babylon.
  28507. * @returns the insternal texture
  28508. */
  28509. getInternalTexture(): Nullable<InternalTexture>;
  28510. /**
  28511. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28512. * @returns true if ready or not blocking
  28513. */
  28514. isReadyOrNotBlocking(): boolean;
  28515. /**
  28516. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28517. * @returns true if fully ready
  28518. */
  28519. isReady(): boolean;
  28520. private _cachedSize;
  28521. /**
  28522. * Get the size of the texture.
  28523. * @returns the texture size.
  28524. */
  28525. getSize(): ISize;
  28526. /**
  28527. * Get the base size of the texture.
  28528. * It can be different from the size if the texture has been resized for POT for instance
  28529. * @returns the base size
  28530. */
  28531. getBaseSize(): ISize;
  28532. /**
  28533. * Update the sampling mode of the texture.
  28534. * Default is Trilinear mode.
  28535. *
  28536. * | Value | Type | Description |
  28537. * | ----- | ------------------ | ----------- |
  28538. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28539. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28540. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28541. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28542. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28543. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28544. * | 7 | NEAREST_LINEAR | |
  28545. * | 8 | NEAREST_NEAREST | |
  28546. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28547. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28548. * | 11 | LINEAR_LINEAR | |
  28549. * | 12 | LINEAR_NEAREST | |
  28550. *
  28551. * > _mag_: magnification filter (close to the viewer)
  28552. * > _min_: minification filter (far from the viewer)
  28553. * > _mip_: filter used between mip map levels
  28554. *@param samplingMode Define the new sampling mode of the texture
  28555. */
  28556. updateSamplingMode(samplingMode: number): void;
  28557. /**
  28558. * Scales the texture if is `canRescale()`
  28559. * @param ratio the resize factor we want to use to rescale
  28560. */
  28561. scale(ratio: number): void;
  28562. /**
  28563. * Get if the texture can rescale.
  28564. */
  28565. readonly canRescale: boolean;
  28566. /** @hidden */
  28567. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28568. /** @hidden */
  28569. _rebuild(): void;
  28570. /**
  28571. * Triggers the load sequence in delayed load mode.
  28572. */
  28573. delayLoad(): void;
  28574. /**
  28575. * Clones the texture.
  28576. * @returns the cloned texture
  28577. */
  28578. clone(): Nullable<BaseTexture>;
  28579. /**
  28580. * Get the texture underlying type (INT, FLOAT...)
  28581. */
  28582. readonly textureType: number;
  28583. /**
  28584. * Get the texture underlying format (RGB, RGBA...)
  28585. */
  28586. readonly textureFormat: number;
  28587. /**
  28588. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28589. * This will returns an RGBA array buffer containing either in values (0-255) or
  28590. * float values (0-1) depending of the underlying buffer type.
  28591. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28592. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28593. * @param buffer defines a user defined buffer to fill with data (can be null)
  28594. * @returns The Array buffer containing the pixels data.
  28595. */
  28596. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28597. /**
  28598. * Release and destroy the underlying lower level texture aka internalTexture.
  28599. */
  28600. releaseInternalTexture(): void;
  28601. /**
  28602. * Get the polynomial representation of the texture data.
  28603. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28604. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28605. */
  28606. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28607. /** @hidden */
  28608. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28609. /** @hidden */
  28610. readonly _lodTextureMid: Nullable<BaseTexture>;
  28611. /** @hidden */
  28612. readonly _lodTextureLow: Nullable<BaseTexture>;
  28613. /**
  28614. * Dispose the texture and release its associated resources.
  28615. */
  28616. dispose(): void;
  28617. /**
  28618. * Serialize the texture into a JSON representation that can be parsed later on.
  28619. * @returns the JSON representation of the texture
  28620. */
  28621. serialize(): any;
  28622. /**
  28623. * Helper function to be called back once a list of texture contains only ready textures.
  28624. * @param textures Define the list of textures to wait for
  28625. * @param callback Define the callback triggered once the entire list will be ready
  28626. */
  28627. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28628. }
  28629. }
  28630. declare module "babylonjs/Materials/Textures/internalTexture" {
  28631. import { Observable } from "babylonjs/Misc/observable";
  28632. import { Nullable, int } from "babylonjs/types";
  28633. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28634. import { Engine } from "babylonjs/Engines/engine";
  28635. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28636. /**
  28637. * Class used to store data associated with WebGL texture data for the engine
  28638. * This class should not be used directly
  28639. */
  28640. export class InternalTexture {
  28641. /** @hidden */
  28642. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28643. /**
  28644. * The source of the texture data is unknown
  28645. */
  28646. static DATASOURCE_UNKNOWN: number;
  28647. /**
  28648. * Texture data comes from an URL
  28649. */
  28650. static DATASOURCE_URL: number;
  28651. /**
  28652. * Texture data is only used for temporary storage
  28653. */
  28654. static DATASOURCE_TEMP: number;
  28655. /**
  28656. * Texture data comes from raw data (ArrayBuffer)
  28657. */
  28658. static DATASOURCE_RAW: number;
  28659. /**
  28660. * Texture content is dynamic (video or dynamic texture)
  28661. */
  28662. static DATASOURCE_DYNAMIC: number;
  28663. /**
  28664. * Texture content is generated by rendering to it
  28665. */
  28666. static DATASOURCE_RENDERTARGET: number;
  28667. /**
  28668. * Texture content is part of a multi render target process
  28669. */
  28670. static DATASOURCE_MULTIRENDERTARGET: number;
  28671. /**
  28672. * Texture data comes from a cube data file
  28673. */
  28674. static DATASOURCE_CUBE: number;
  28675. /**
  28676. * Texture data comes from a raw cube data
  28677. */
  28678. static DATASOURCE_CUBERAW: number;
  28679. /**
  28680. * Texture data come from a prefiltered cube data file
  28681. */
  28682. static DATASOURCE_CUBEPREFILTERED: number;
  28683. /**
  28684. * Texture content is raw 3D data
  28685. */
  28686. static DATASOURCE_RAW3D: number;
  28687. /**
  28688. * Texture content is a depth texture
  28689. */
  28690. static DATASOURCE_DEPTHTEXTURE: number;
  28691. /**
  28692. * Texture data comes from a raw cube data encoded with RGBD
  28693. */
  28694. static DATASOURCE_CUBERAW_RGBD: number;
  28695. /**
  28696. * Defines if the texture is ready
  28697. */
  28698. isReady: boolean;
  28699. /**
  28700. * Defines if the texture is a cube texture
  28701. */
  28702. isCube: boolean;
  28703. /**
  28704. * Defines if the texture contains 3D data
  28705. */
  28706. is3D: boolean;
  28707. /**
  28708. * Defines if the texture contains multiview data
  28709. */
  28710. isMultiview: boolean;
  28711. /**
  28712. * Gets the URL used to load this texture
  28713. */
  28714. url: string;
  28715. /**
  28716. * Gets the sampling mode of the texture
  28717. */
  28718. samplingMode: number;
  28719. /**
  28720. * Gets a boolean indicating if the texture needs mipmaps generation
  28721. */
  28722. generateMipMaps: boolean;
  28723. /**
  28724. * Gets the number of samples used by the texture (WebGL2+ only)
  28725. */
  28726. samples: number;
  28727. /**
  28728. * Gets the type of the texture (int, float...)
  28729. */
  28730. type: number;
  28731. /**
  28732. * Gets the format of the texture (RGB, RGBA...)
  28733. */
  28734. format: number;
  28735. /**
  28736. * Observable called when the texture is loaded
  28737. */
  28738. onLoadedObservable: Observable<InternalTexture>;
  28739. /**
  28740. * Gets the width of the texture
  28741. */
  28742. width: number;
  28743. /**
  28744. * Gets the height of the texture
  28745. */
  28746. height: number;
  28747. /**
  28748. * Gets the depth of the texture
  28749. */
  28750. depth: number;
  28751. /**
  28752. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28753. */
  28754. baseWidth: number;
  28755. /**
  28756. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28757. */
  28758. baseHeight: number;
  28759. /**
  28760. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28761. */
  28762. baseDepth: number;
  28763. /**
  28764. * Gets a boolean indicating if the texture is inverted on Y axis
  28765. */
  28766. invertY: boolean;
  28767. /** @hidden */
  28768. _invertVScale: boolean;
  28769. /** @hidden */
  28770. _associatedChannel: number;
  28771. /** @hidden */
  28772. _dataSource: number;
  28773. /** @hidden */
  28774. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28775. /** @hidden */
  28776. _bufferView: Nullable<ArrayBufferView>;
  28777. /** @hidden */
  28778. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28779. /** @hidden */
  28780. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28781. /** @hidden */
  28782. _size: number;
  28783. /** @hidden */
  28784. _extension: string;
  28785. /** @hidden */
  28786. _files: Nullable<string[]>;
  28787. /** @hidden */
  28788. _workingCanvas: Nullable<HTMLCanvasElement>;
  28789. /** @hidden */
  28790. _workingContext: Nullable<CanvasRenderingContext2D>;
  28791. /** @hidden */
  28792. _framebuffer: Nullable<WebGLFramebuffer>;
  28793. /** @hidden */
  28794. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28795. /** @hidden */
  28796. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28797. /** @hidden */
  28798. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28799. /** @hidden */
  28800. _attachments: Nullable<number[]>;
  28801. /** @hidden */
  28802. _cachedCoordinatesMode: Nullable<number>;
  28803. /** @hidden */
  28804. _cachedWrapU: Nullable<number>;
  28805. /** @hidden */
  28806. _cachedWrapV: Nullable<number>;
  28807. /** @hidden */
  28808. _cachedWrapR: Nullable<number>;
  28809. /** @hidden */
  28810. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28811. /** @hidden */
  28812. _isDisabled: boolean;
  28813. /** @hidden */
  28814. _compression: Nullable<string>;
  28815. /** @hidden */
  28816. _generateStencilBuffer: boolean;
  28817. /** @hidden */
  28818. _generateDepthBuffer: boolean;
  28819. /** @hidden */
  28820. _comparisonFunction: number;
  28821. /** @hidden */
  28822. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28823. /** @hidden */
  28824. _lodGenerationScale: number;
  28825. /** @hidden */
  28826. _lodGenerationOffset: number;
  28827. /** @hidden */
  28828. _colorTextureArray: Nullable<WebGLTexture>;
  28829. /** @hidden */
  28830. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28831. /** @hidden */
  28832. _lodTextureHigh: Nullable<BaseTexture>;
  28833. /** @hidden */
  28834. _lodTextureMid: Nullable<BaseTexture>;
  28835. /** @hidden */
  28836. _lodTextureLow: Nullable<BaseTexture>;
  28837. /** @hidden */
  28838. _isRGBD: boolean;
  28839. /** @hidden */
  28840. _linearSpecularLOD: boolean;
  28841. /** @hidden */
  28842. _irradianceTexture: Nullable<BaseTexture>;
  28843. /** @hidden */
  28844. _webGLTexture: Nullable<WebGLTexture>;
  28845. /** @hidden */
  28846. _references: number;
  28847. private _engine;
  28848. /**
  28849. * Gets the Engine the texture belongs to.
  28850. * @returns The babylon engine
  28851. */
  28852. getEngine(): Engine;
  28853. /**
  28854. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28855. */
  28856. readonly dataSource: number;
  28857. /**
  28858. * Creates a new InternalTexture
  28859. * @param engine defines the engine to use
  28860. * @param dataSource defines the type of data that will be used
  28861. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28862. */
  28863. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28864. /**
  28865. * Increments the number of references (ie. the number of Texture that point to it)
  28866. */
  28867. incrementReferences(): void;
  28868. /**
  28869. * Change the size of the texture (not the size of the content)
  28870. * @param width defines the new width
  28871. * @param height defines the new height
  28872. * @param depth defines the new depth (1 by default)
  28873. */
  28874. updateSize(width: int, height: int, depth?: int): void;
  28875. /** @hidden */
  28876. _rebuild(): void;
  28877. /** @hidden */
  28878. _swapAndDie(target: InternalTexture): void;
  28879. /**
  28880. * Dispose the current allocated resources
  28881. */
  28882. dispose(): void;
  28883. }
  28884. }
  28885. declare module "babylonjs/Materials/effect" {
  28886. import { Observable } from "babylonjs/Misc/observable";
  28887. import { Nullable } from "babylonjs/types";
  28888. import { IDisposable } from "babylonjs/scene";
  28889. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28890. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28891. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28892. import { Engine } from "babylonjs/Engines/engine";
  28893. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28896. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28898. /**
  28899. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28900. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28901. */
  28902. export class EffectFallbacks {
  28903. private _defines;
  28904. private _currentRank;
  28905. private _maxRank;
  28906. private _mesh;
  28907. /**
  28908. * Removes the fallback from the bound mesh.
  28909. */
  28910. unBindMesh(): void;
  28911. /**
  28912. * Adds a fallback on the specified property.
  28913. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28914. * @param define The name of the define in the shader
  28915. */
  28916. addFallback(rank: number, define: string): void;
  28917. /**
  28918. * Sets the mesh to use CPU skinning when needing to fallback.
  28919. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28920. * @param mesh The mesh to use the fallbacks.
  28921. */
  28922. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28923. /**
  28924. * Checks to see if more fallbacks are still availible.
  28925. */
  28926. readonly isMoreFallbacks: boolean;
  28927. /**
  28928. * Removes the defines that should be removed when falling back.
  28929. * @param currentDefines defines the current define statements for the shader.
  28930. * @param effect defines the current effect we try to compile
  28931. * @returns The resulting defines with defines of the current rank removed.
  28932. */
  28933. reduce(currentDefines: string, effect: Effect): string;
  28934. }
  28935. /**
  28936. * Options to be used when creating an effect.
  28937. */
  28938. export class EffectCreationOptions {
  28939. /**
  28940. * Atrributes that will be used in the shader.
  28941. */
  28942. attributes: string[];
  28943. /**
  28944. * Uniform varible names that will be set in the shader.
  28945. */
  28946. uniformsNames: string[];
  28947. /**
  28948. * Uniform buffer varible names that will be set in the shader.
  28949. */
  28950. uniformBuffersNames: string[];
  28951. /**
  28952. * Sampler texture variable names that will be set in the shader.
  28953. */
  28954. samplers: string[];
  28955. /**
  28956. * Define statements that will be set in the shader.
  28957. */
  28958. defines: any;
  28959. /**
  28960. * Possible fallbacks for this effect to improve performance when needed.
  28961. */
  28962. fallbacks: Nullable<EffectFallbacks>;
  28963. /**
  28964. * Callback that will be called when the shader is compiled.
  28965. */
  28966. onCompiled: Nullable<(effect: Effect) => void>;
  28967. /**
  28968. * Callback that will be called if an error occurs during shader compilation.
  28969. */
  28970. onError: Nullable<(effect: Effect, errors: string) => void>;
  28971. /**
  28972. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28973. */
  28974. indexParameters: any;
  28975. /**
  28976. * Max number of lights that can be used in the shader.
  28977. */
  28978. maxSimultaneousLights: number;
  28979. /**
  28980. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28981. */
  28982. transformFeedbackVaryings: Nullable<string[]>;
  28983. }
  28984. /**
  28985. * Effect containing vertex and fragment shader that can be executed on an object.
  28986. */
  28987. export class Effect implements IDisposable {
  28988. /**
  28989. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28990. */
  28991. static ShadersRepository: string;
  28992. /**
  28993. * Name of the effect.
  28994. */
  28995. name: any;
  28996. /**
  28997. * String container all the define statements that should be set on the shader.
  28998. */
  28999. defines: string;
  29000. /**
  29001. * Callback that will be called when the shader is compiled.
  29002. */
  29003. onCompiled: Nullable<(effect: Effect) => void>;
  29004. /**
  29005. * Callback that will be called if an error occurs during shader compilation.
  29006. */
  29007. onError: Nullable<(effect: Effect, errors: string) => void>;
  29008. /**
  29009. * Callback that will be called when effect is bound.
  29010. */
  29011. onBind: Nullable<(effect: Effect) => void>;
  29012. /**
  29013. * Unique ID of the effect.
  29014. */
  29015. uniqueId: number;
  29016. /**
  29017. * Observable that will be called when the shader is compiled.
  29018. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29019. */
  29020. onCompileObservable: Observable<Effect>;
  29021. /**
  29022. * Observable that will be called if an error occurs during shader compilation.
  29023. */
  29024. onErrorObservable: Observable<Effect>;
  29025. /** @hidden */
  29026. _onBindObservable: Nullable<Observable<Effect>>;
  29027. /**
  29028. * Observable that will be called when effect is bound.
  29029. */
  29030. readonly onBindObservable: Observable<Effect>;
  29031. /** @hidden */
  29032. _bonesComputationForcedToCPU: boolean;
  29033. private static _uniqueIdSeed;
  29034. private _engine;
  29035. private _uniformBuffersNames;
  29036. private _uniformsNames;
  29037. private _samplerList;
  29038. private _samplers;
  29039. private _isReady;
  29040. private _compilationError;
  29041. private _attributesNames;
  29042. private _attributes;
  29043. private _uniforms;
  29044. /**
  29045. * Key for the effect.
  29046. * @hidden
  29047. */
  29048. _key: string;
  29049. private _indexParameters;
  29050. private _fallbacks;
  29051. private _vertexSourceCode;
  29052. private _fragmentSourceCode;
  29053. private _vertexSourceCodeOverride;
  29054. private _fragmentSourceCodeOverride;
  29055. private _transformFeedbackVaryings;
  29056. /**
  29057. * Compiled shader to webGL program.
  29058. * @hidden
  29059. */
  29060. _pipelineContext: Nullable<IPipelineContext>;
  29061. private _valueCache;
  29062. private static _baseCache;
  29063. /**
  29064. * Instantiates an effect.
  29065. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29066. * @param baseName Name of the effect.
  29067. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29068. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29069. * @param samplers List of sampler variables that will be passed to the shader.
  29070. * @param engine Engine to be used to render the effect
  29071. * @param defines Define statements to be added to the shader.
  29072. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29073. * @param onCompiled Callback that will be called when the shader is compiled.
  29074. * @param onError Callback that will be called if an error occurs during shader compilation.
  29075. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29076. */
  29077. 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);
  29078. private _useFinalCode;
  29079. /**
  29080. * Unique key for this effect
  29081. */
  29082. readonly key: string;
  29083. /**
  29084. * If the effect has been compiled and prepared.
  29085. * @returns if the effect is compiled and prepared.
  29086. */
  29087. isReady(): boolean;
  29088. /**
  29089. * The engine the effect was initialized with.
  29090. * @returns the engine.
  29091. */
  29092. getEngine(): Engine;
  29093. /**
  29094. * The pipeline context for this effect
  29095. * @returns the associated pipeline context
  29096. */
  29097. getPipelineContext(): Nullable<IPipelineContext>;
  29098. /**
  29099. * The set of names of attribute variables for the shader.
  29100. * @returns An array of attribute names.
  29101. */
  29102. getAttributesNames(): string[];
  29103. /**
  29104. * Returns the attribute at the given index.
  29105. * @param index The index of the attribute.
  29106. * @returns The location of the attribute.
  29107. */
  29108. getAttributeLocation(index: number): number;
  29109. /**
  29110. * Returns the attribute based on the name of the variable.
  29111. * @param name of the attribute to look up.
  29112. * @returns the attribute location.
  29113. */
  29114. getAttributeLocationByName(name: string): number;
  29115. /**
  29116. * The number of attributes.
  29117. * @returns the numnber of attributes.
  29118. */
  29119. getAttributesCount(): number;
  29120. /**
  29121. * Gets the index of a uniform variable.
  29122. * @param uniformName of the uniform to look up.
  29123. * @returns the index.
  29124. */
  29125. getUniformIndex(uniformName: string): number;
  29126. /**
  29127. * Returns the attribute based on the name of the variable.
  29128. * @param uniformName of the uniform to look up.
  29129. * @returns the location of the uniform.
  29130. */
  29131. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29132. /**
  29133. * Returns an array of sampler variable names
  29134. * @returns The array of sampler variable neames.
  29135. */
  29136. getSamplers(): string[];
  29137. /**
  29138. * The error from the last compilation.
  29139. * @returns the error string.
  29140. */
  29141. getCompilationError(): string;
  29142. /**
  29143. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29144. * @param func The callback to be used.
  29145. */
  29146. executeWhenCompiled(func: (effect: Effect) => void): void;
  29147. private _checkIsReady;
  29148. /** @hidden */
  29149. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29150. /** @hidden */
  29151. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29152. /** @hidden */
  29153. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29154. /**
  29155. * Recompiles the webGL program
  29156. * @param vertexSourceCode The source code for the vertex shader.
  29157. * @param fragmentSourceCode The source code for the fragment shader.
  29158. * @param onCompiled Callback called when completed.
  29159. * @param onError Callback called on error.
  29160. * @hidden
  29161. */
  29162. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29163. /**
  29164. * Prepares the effect
  29165. * @hidden
  29166. */
  29167. _prepareEffect(): void;
  29168. /**
  29169. * Checks if the effect is supported. (Must be called after compilation)
  29170. */
  29171. readonly isSupported: boolean;
  29172. /**
  29173. * Binds a texture to the engine to be used as output of the shader.
  29174. * @param channel Name of the output variable.
  29175. * @param texture Texture to bind.
  29176. * @hidden
  29177. */
  29178. _bindTexture(channel: string, texture: InternalTexture): void;
  29179. /**
  29180. * Sets a texture on the engine to be used in the shader.
  29181. * @param channel Name of the sampler variable.
  29182. * @param texture Texture to set.
  29183. */
  29184. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29185. /**
  29186. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29187. * @param channel Name of the sampler variable.
  29188. * @param texture Texture to set.
  29189. */
  29190. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29191. /**
  29192. * Sets an array of textures on the engine to be used in the shader.
  29193. * @param channel Name of the variable.
  29194. * @param textures Textures to set.
  29195. */
  29196. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29197. /**
  29198. * 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)
  29199. * @param channel Name of the sampler variable.
  29200. * @param postProcess Post process to get the input texture from.
  29201. */
  29202. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29203. /**
  29204. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29205. * 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)
  29206. * @param channel Name of the sampler variable.
  29207. * @param postProcess Post process to get the output texture from.
  29208. */
  29209. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29210. /** @hidden */
  29211. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29212. /** @hidden */
  29213. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29214. /** @hidden */
  29215. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29216. /** @hidden */
  29217. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29218. /**
  29219. * Binds a buffer to a uniform.
  29220. * @param buffer Buffer to bind.
  29221. * @param name Name of the uniform variable to bind to.
  29222. */
  29223. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29224. /**
  29225. * Binds block to a uniform.
  29226. * @param blockName Name of the block to bind.
  29227. * @param index Index to bind.
  29228. */
  29229. bindUniformBlock(blockName: string, index: number): void;
  29230. /**
  29231. * Sets an interger value on a uniform variable.
  29232. * @param uniformName Name of the variable.
  29233. * @param value Value to be set.
  29234. * @returns this effect.
  29235. */
  29236. setInt(uniformName: string, value: number): Effect;
  29237. /**
  29238. * Sets an int array on a uniform variable.
  29239. * @param uniformName Name of the variable.
  29240. * @param array array to be set.
  29241. * @returns this effect.
  29242. */
  29243. setIntArray(uniformName: string, array: Int32Array): Effect;
  29244. /**
  29245. * 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)
  29246. * @param uniformName Name of the variable.
  29247. * @param array array to be set.
  29248. * @returns this effect.
  29249. */
  29250. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29251. /**
  29252. * 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)
  29253. * @param uniformName Name of the variable.
  29254. * @param array array to be set.
  29255. * @returns this effect.
  29256. */
  29257. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29258. /**
  29259. * 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)
  29260. * @param uniformName Name of the variable.
  29261. * @param array array to be set.
  29262. * @returns this effect.
  29263. */
  29264. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29265. /**
  29266. * Sets an float array on a uniform variable.
  29267. * @param uniformName Name of the variable.
  29268. * @param array array to be set.
  29269. * @returns this effect.
  29270. */
  29271. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29272. /**
  29273. * 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)
  29274. * @param uniformName Name of the variable.
  29275. * @param array array to be set.
  29276. * @returns this effect.
  29277. */
  29278. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29279. /**
  29280. * 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)
  29281. * @param uniformName Name of the variable.
  29282. * @param array array to be set.
  29283. * @returns this effect.
  29284. */
  29285. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29286. /**
  29287. * 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)
  29288. * @param uniformName Name of the variable.
  29289. * @param array array to be set.
  29290. * @returns this effect.
  29291. */
  29292. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29293. /**
  29294. * Sets an array on a uniform variable.
  29295. * @param uniformName Name of the variable.
  29296. * @param array array to be set.
  29297. * @returns this effect.
  29298. */
  29299. setArray(uniformName: string, array: number[]): Effect;
  29300. /**
  29301. * 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)
  29302. * @param uniformName Name of the variable.
  29303. * @param array array to be set.
  29304. * @returns this effect.
  29305. */
  29306. setArray2(uniformName: string, array: number[]): Effect;
  29307. /**
  29308. * 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)
  29309. * @param uniformName Name of the variable.
  29310. * @param array array to be set.
  29311. * @returns this effect.
  29312. */
  29313. setArray3(uniformName: string, array: number[]): Effect;
  29314. /**
  29315. * 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)
  29316. * @param uniformName Name of the variable.
  29317. * @param array array to be set.
  29318. * @returns this effect.
  29319. */
  29320. setArray4(uniformName: string, array: number[]): Effect;
  29321. /**
  29322. * Sets matrices on a uniform variable.
  29323. * @param uniformName Name of the variable.
  29324. * @param matrices matrices to be set.
  29325. * @returns this effect.
  29326. */
  29327. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29328. /**
  29329. * Sets matrix on a uniform variable.
  29330. * @param uniformName Name of the variable.
  29331. * @param matrix matrix to be set.
  29332. * @returns this effect.
  29333. */
  29334. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29335. /**
  29336. * 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)
  29337. * @param uniformName Name of the variable.
  29338. * @param matrix matrix to be set.
  29339. * @returns this effect.
  29340. */
  29341. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29342. /**
  29343. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29344. * @param uniformName Name of the variable.
  29345. * @param matrix matrix to be set.
  29346. * @returns this effect.
  29347. */
  29348. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29349. /**
  29350. * Sets a float on a uniform variable.
  29351. * @param uniformName Name of the variable.
  29352. * @param value value to be set.
  29353. * @returns this effect.
  29354. */
  29355. setFloat(uniformName: string, value: number): Effect;
  29356. /**
  29357. * Sets a boolean on a uniform variable.
  29358. * @param uniformName Name of the variable.
  29359. * @param bool value to be set.
  29360. * @returns this effect.
  29361. */
  29362. setBool(uniformName: string, bool: boolean): Effect;
  29363. /**
  29364. * Sets a Vector2 on a uniform variable.
  29365. * @param uniformName Name of the variable.
  29366. * @param vector2 vector2 to be set.
  29367. * @returns this effect.
  29368. */
  29369. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29370. /**
  29371. * Sets a float2 on a uniform variable.
  29372. * @param uniformName Name of the variable.
  29373. * @param x First float in float2.
  29374. * @param y Second float in float2.
  29375. * @returns this effect.
  29376. */
  29377. setFloat2(uniformName: string, x: number, y: number): Effect;
  29378. /**
  29379. * Sets a Vector3 on a uniform variable.
  29380. * @param uniformName Name of the variable.
  29381. * @param vector3 Value to be set.
  29382. * @returns this effect.
  29383. */
  29384. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29385. /**
  29386. * Sets a float3 on a uniform variable.
  29387. * @param uniformName Name of the variable.
  29388. * @param x First float in float3.
  29389. * @param y Second float in float3.
  29390. * @param z Third float in float3.
  29391. * @returns this effect.
  29392. */
  29393. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29394. /**
  29395. * Sets a Vector4 on a uniform variable.
  29396. * @param uniformName Name of the variable.
  29397. * @param vector4 Value to be set.
  29398. * @returns this effect.
  29399. */
  29400. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29401. /**
  29402. * Sets a float4 on a uniform variable.
  29403. * @param uniformName Name of the variable.
  29404. * @param x First float in float4.
  29405. * @param y Second float in float4.
  29406. * @param z Third float in float4.
  29407. * @param w Fourth float in float4.
  29408. * @returns this effect.
  29409. */
  29410. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29411. /**
  29412. * Sets a Color3 on a uniform variable.
  29413. * @param uniformName Name of the variable.
  29414. * @param color3 Value to be set.
  29415. * @returns this effect.
  29416. */
  29417. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29418. /**
  29419. * Sets a Color4 on a uniform variable.
  29420. * @param uniformName Name of the variable.
  29421. * @param color3 Value to be set.
  29422. * @param alpha Alpha value to be set.
  29423. * @returns this effect.
  29424. */
  29425. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29426. /**
  29427. * Sets a Color4 on a uniform variable
  29428. * @param uniformName defines the name of the variable
  29429. * @param color4 defines the value to be set
  29430. * @returns this effect.
  29431. */
  29432. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29433. /** Release all associated resources */
  29434. dispose(): void;
  29435. /**
  29436. * This function will add a new shader to the shader store
  29437. * @param name the name of the shader
  29438. * @param pixelShader optional pixel shader content
  29439. * @param vertexShader optional vertex shader content
  29440. */
  29441. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29442. /**
  29443. * Store of each shader (The can be looked up using effect.key)
  29444. */
  29445. static ShadersStore: {
  29446. [key: string]: string;
  29447. };
  29448. /**
  29449. * Store of each included file for a shader (The can be looked up using effect.key)
  29450. */
  29451. static IncludesShadersStore: {
  29452. [key: string]: string;
  29453. };
  29454. /**
  29455. * Resets the cache of effects.
  29456. */
  29457. static ResetCache(): void;
  29458. }
  29459. }
  29460. declare module "babylonjs/Materials/uniformBuffer" {
  29461. import { Nullable, FloatArray } from "babylonjs/types";
  29462. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29463. import { Engine } from "babylonjs/Engines/engine";
  29464. import { Effect } from "babylonjs/Materials/effect";
  29465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29466. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29467. import { Color3 } from "babylonjs/Maths/math.color";
  29468. /**
  29469. * Uniform buffer objects.
  29470. *
  29471. * Handles blocks of uniform on the GPU.
  29472. *
  29473. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29474. *
  29475. * For more information, please refer to :
  29476. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29477. */
  29478. export class UniformBuffer {
  29479. private _engine;
  29480. private _buffer;
  29481. private _data;
  29482. private _bufferData;
  29483. private _dynamic?;
  29484. private _uniformLocations;
  29485. private _uniformSizes;
  29486. private _uniformLocationPointer;
  29487. private _needSync;
  29488. private _noUBO;
  29489. private _currentEffect;
  29490. private static _MAX_UNIFORM_SIZE;
  29491. private static _tempBuffer;
  29492. /**
  29493. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29494. * This is dynamic to allow compat with webgl 1 and 2.
  29495. * You will need to pass the name of the uniform as well as the value.
  29496. */
  29497. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29498. /**
  29499. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29500. * This is dynamic to allow compat with webgl 1 and 2.
  29501. * You will need to pass the name of the uniform as well as the value.
  29502. */
  29503. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29504. /**
  29505. * Lambda to Update a single float in a uniform buffer.
  29506. * This is dynamic to allow compat with webgl 1 and 2.
  29507. * You will need to pass the name of the uniform as well as the value.
  29508. */
  29509. updateFloat: (name: string, x: number) => void;
  29510. /**
  29511. * Lambda to Update a vec2 of float in a uniform buffer.
  29512. * This is dynamic to allow compat with webgl 1 and 2.
  29513. * You will need to pass the name of the uniform as well as the value.
  29514. */
  29515. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29516. /**
  29517. * Lambda to Update a vec3 of float in a uniform buffer.
  29518. * This is dynamic to allow compat with webgl 1 and 2.
  29519. * You will need to pass the name of the uniform as well as the value.
  29520. */
  29521. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29522. /**
  29523. * Lambda to Update a vec4 of float in a uniform buffer.
  29524. * This is dynamic to allow compat with webgl 1 and 2.
  29525. * You will need to pass the name of the uniform as well as the value.
  29526. */
  29527. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29528. /**
  29529. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29530. * This is dynamic to allow compat with webgl 1 and 2.
  29531. * You will need to pass the name of the uniform as well as the value.
  29532. */
  29533. updateMatrix: (name: string, mat: Matrix) => void;
  29534. /**
  29535. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29536. * This is dynamic to allow compat with webgl 1 and 2.
  29537. * You will need to pass the name of the uniform as well as the value.
  29538. */
  29539. updateVector3: (name: string, vector: Vector3) => void;
  29540. /**
  29541. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29542. * This is dynamic to allow compat with webgl 1 and 2.
  29543. * You will need to pass the name of the uniform as well as the value.
  29544. */
  29545. updateVector4: (name: string, vector: Vector4) => void;
  29546. /**
  29547. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29548. * This is dynamic to allow compat with webgl 1 and 2.
  29549. * You will need to pass the name of the uniform as well as the value.
  29550. */
  29551. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29552. /**
  29553. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29554. * This is dynamic to allow compat with webgl 1 and 2.
  29555. * You will need to pass the name of the uniform as well as the value.
  29556. */
  29557. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29558. /**
  29559. * Instantiates a new Uniform buffer objects.
  29560. *
  29561. * Handles blocks of uniform on the GPU.
  29562. *
  29563. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29564. *
  29565. * For more information, please refer to :
  29566. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29567. * @param engine Define the engine the buffer is associated with
  29568. * @param data Define the data contained in the buffer
  29569. * @param dynamic Define if the buffer is updatable
  29570. */
  29571. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29572. /**
  29573. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29574. * or just falling back on setUniformXXX calls.
  29575. */
  29576. readonly useUbo: boolean;
  29577. /**
  29578. * Indicates if the WebGL underlying uniform buffer is in sync
  29579. * with the javascript cache data.
  29580. */
  29581. readonly isSync: boolean;
  29582. /**
  29583. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29584. * Also, a dynamic UniformBuffer will disable cache verification and always
  29585. * update the underlying WebGL uniform buffer to the GPU.
  29586. * @returns if Dynamic, otherwise false
  29587. */
  29588. isDynamic(): boolean;
  29589. /**
  29590. * The data cache on JS side.
  29591. * @returns the underlying data as a float array
  29592. */
  29593. getData(): Float32Array;
  29594. /**
  29595. * The underlying WebGL Uniform buffer.
  29596. * @returns the webgl buffer
  29597. */
  29598. getBuffer(): Nullable<DataBuffer>;
  29599. /**
  29600. * std140 layout specifies how to align data within an UBO structure.
  29601. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29602. * for specs.
  29603. */
  29604. private _fillAlignment;
  29605. /**
  29606. * Adds an uniform in the buffer.
  29607. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29608. * for the layout to be correct !
  29609. * @param name Name of the uniform, as used in the uniform block in the shader.
  29610. * @param size Data size, or data directly.
  29611. */
  29612. addUniform(name: string, size: number | number[]): void;
  29613. /**
  29614. * Adds a Matrix 4x4 to the uniform buffer.
  29615. * @param name Name of the uniform, as used in the uniform block in the shader.
  29616. * @param mat A 4x4 matrix.
  29617. */
  29618. addMatrix(name: string, mat: Matrix): void;
  29619. /**
  29620. * Adds a vec2 to the uniform buffer.
  29621. * @param name Name of the uniform, as used in the uniform block in the shader.
  29622. * @param x Define the x component value of the vec2
  29623. * @param y Define the y component value of the vec2
  29624. */
  29625. addFloat2(name: string, x: number, y: number): void;
  29626. /**
  29627. * Adds a vec3 to the uniform buffer.
  29628. * @param name Name of the uniform, as used in the uniform block in the shader.
  29629. * @param x Define the x component value of the vec3
  29630. * @param y Define the y component value of the vec3
  29631. * @param z Define the z component value of the vec3
  29632. */
  29633. addFloat3(name: string, x: number, y: number, z: number): void;
  29634. /**
  29635. * Adds a vec3 to the uniform buffer.
  29636. * @param name Name of the uniform, as used in the uniform block in the shader.
  29637. * @param color Define the vec3 from a Color
  29638. */
  29639. addColor3(name: string, color: Color3): void;
  29640. /**
  29641. * Adds a vec4 to the uniform buffer.
  29642. * @param name Name of the uniform, as used in the uniform block in the shader.
  29643. * @param color Define the rgb components from a Color
  29644. * @param alpha Define the a component of the vec4
  29645. */
  29646. addColor4(name: string, color: Color3, alpha: number): void;
  29647. /**
  29648. * Adds a vec3 to the uniform buffer.
  29649. * @param name Name of the uniform, as used in the uniform block in the shader.
  29650. * @param vector Define the vec3 components from a Vector
  29651. */
  29652. addVector3(name: string, vector: Vector3): void;
  29653. /**
  29654. * Adds a Matrix 3x3 to the uniform buffer.
  29655. * @param name Name of the uniform, as used in the uniform block in the shader.
  29656. */
  29657. addMatrix3x3(name: string): void;
  29658. /**
  29659. * Adds a Matrix 2x2 to the uniform buffer.
  29660. * @param name Name of the uniform, as used in the uniform block in the shader.
  29661. */
  29662. addMatrix2x2(name: string): void;
  29663. /**
  29664. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29665. */
  29666. create(): void;
  29667. /** @hidden */
  29668. _rebuild(): void;
  29669. /**
  29670. * Updates the WebGL Uniform Buffer on the GPU.
  29671. * If the `dynamic` flag is set to true, no cache comparison is done.
  29672. * Otherwise, the buffer will be updated only if the cache differs.
  29673. */
  29674. update(): void;
  29675. /**
  29676. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29677. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29678. * @param data Define the flattened data
  29679. * @param size Define the size of the data.
  29680. */
  29681. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29682. private _updateMatrix3x3ForUniform;
  29683. private _updateMatrix3x3ForEffect;
  29684. private _updateMatrix2x2ForEffect;
  29685. private _updateMatrix2x2ForUniform;
  29686. private _updateFloatForEffect;
  29687. private _updateFloatForUniform;
  29688. private _updateFloat2ForEffect;
  29689. private _updateFloat2ForUniform;
  29690. private _updateFloat3ForEffect;
  29691. private _updateFloat3ForUniform;
  29692. private _updateFloat4ForEffect;
  29693. private _updateFloat4ForUniform;
  29694. private _updateMatrixForEffect;
  29695. private _updateMatrixForUniform;
  29696. private _updateVector3ForEffect;
  29697. private _updateVector3ForUniform;
  29698. private _updateVector4ForEffect;
  29699. private _updateVector4ForUniform;
  29700. private _updateColor3ForEffect;
  29701. private _updateColor3ForUniform;
  29702. private _updateColor4ForEffect;
  29703. private _updateColor4ForUniform;
  29704. /**
  29705. * Sets a sampler uniform on the effect.
  29706. * @param name Define the name of the sampler.
  29707. * @param texture Define the texture to set in the sampler
  29708. */
  29709. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29710. /**
  29711. * Directly updates the value of the uniform in the cache AND on the GPU.
  29712. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29713. * @param data Define the flattened data
  29714. */
  29715. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29716. /**
  29717. * Binds this uniform buffer to an effect.
  29718. * @param effect Define the effect to bind the buffer to
  29719. * @param name Name of the uniform block in the shader.
  29720. */
  29721. bindToEffect(effect: Effect, name: string): void;
  29722. /**
  29723. * Disposes the uniform buffer.
  29724. */
  29725. dispose(): void;
  29726. }
  29727. }
  29728. declare module "babylonjs/Audio/analyser" {
  29729. import { Scene } from "babylonjs/scene";
  29730. /**
  29731. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29733. */
  29734. export class Analyser {
  29735. /**
  29736. * Gets or sets the smoothing
  29737. * @ignorenaming
  29738. */
  29739. SMOOTHING: number;
  29740. /**
  29741. * Gets or sets the FFT table size
  29742. * @ignorenaming
  29743. */
  29744. FFT_SIZE: number;
  29745. /**
  29746. * Gets or sets the bar graph amplitude
  29747. * @ignorenaming
  29748. */
  29749. BARGRAPHAMPLITUDE: number;
  29750. /**
  29751. * Gets or sets the position of the debug canvas
  29752. * @ignorenaming
  29753. */
  29754. DEBUGCANVASPOS: {
  29755. x: number;
  29756. y: number;
  29757. };
  29758. /**
  29759. * Gets or sets the debug canvas size
  29760. * @ignorenaming
  29761. */
  29762. DEBUGCANVASSIZE: {
  29763. width: number;
  29764. height: number;
  29765. };
  29766. private _byteFreqs;
  29767. private _byteTime;
  29768. private _floatFreqs;
  29769. private _webAudioAnalyser;
  29770. private _debugCanvas;
  29771. private _debugCanvasContext;
  29772. private _scene;
  29773. private _registerFunc;
  29774. private _audioEngine;
  29775. /**
  29776. * Creates a new analyser
  29777. * @param scene defines hosting scene
  29778. */
  29779. constructor(scene: Scene);
  29780. /**
  29781. * Get the number of data values you will have to play with for the visualization
  29782. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29783. * @returns a number
  29784. */
  29785. getFrequencyBinCount(): number;
  29786. /**
  29787. * Gets the current frequency data as a byte array
  29788. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29789. * @returns a Uint8Array
  29790. */
  29791. getByteFrequencyData(): Uint8Array;
  29792. /**
  29793. * Gets the current waveform as a byte array
  29794. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29795. * @returns a Uint8Array
  29796. */
  29797. getByteTimeDomainData(): Uint8Array;
  29798. /**
  29799. * Gets the current frequency data as a float array
  29800. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29801. * @returns a Float32Array
  29802. */
  29803. getFloatFrequencyData(): Float32Array;
  29804. /**
  29805. * Renders the debug canvas
  29806. */
  29807. drawDebugCanvas(): void;
  29808. /**
  29809. * Stops rendering the debug canvas and removes it
  29810. */
  29811. stopDebugCanvas(): void;
  29812. /**
  29813. * Connects two audio nodes
  29814. * @param inputAudioNode defines first node to connect
  29815. * @param outputAudioNode defines second node to connect
  29816. */
  29817. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29818. /**
  29819. * Releases all associated resources
  29820. */
  29821. dispose(): void;
  29822. }
  29823. }
  29824. declare module "babylonjs/Audio/audioEngine" {
  29825. import { IDisposable } from "babylonjs/scene";
  29826. import { Analyser } from "babylonjs/Audio/analyser";
  29827. import { Nullable } from "babylonjs/types";
  29828. import { Observable } from "babylonjs/Misc/observable";
  29829. /**
  29830. * This represents an audio engine and it is responsible
  29831. * to play, synchronize and analyse sounds throughout the application.
  29832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29833. */
  29834. export interface IAudioEngine extends IDisposable {
  29835. /**
  29836. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29837. */
  29838. readonly canUseWebAudio: boolean;
  29839. /**
  29840. * Gets the current AudioContext if available.
  29841. */
  29842. readonly audioContext: Nullable<AudioContext>;
  29843. /**
  29844. * The master gain node defines the global audio volume of your audio engine.
  29845. */
  29846. readonly masterGain: GainNode;
  29847. /**
  29848. * Gets whether or not mp3 are supported by your browser.
  29849. */
  29850. readonly isMP3supported: boolean;
  29851. /**
  29852. * Gets whether or not ogg are supported by your browser.
  29853. */
  29854. readonly isOGGsupported: boolean;
  29855. /**
  29856. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29857. * @ignoreNaming
  29858. */
  29859. WarnedWebAudioUnsupported: boolean;
  29860. /**
  29861. * Defines if the audio engine relies on a custom unlocked button.
  29862. * In this case, the embedded button will not be displayed.
  29863. */
  29864. useCustomUnlockedButton: boolean;
  29865. /**
  29866. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29867. */
  29868. readonly unlocked: boolean;
  29869. /**
  29870. * Event raised when audio has been unlocked on the browser.
  29871. */
  29872. onAudioUnlockedObservable: Observable<AudioEngine>;
  29873. /**
  29874. * Event raised when audio has been locked on the browser.
  29875. */
  29876. onAudioLockedObservable: Observable<AudioEngine>;
  29877. /**
  29878. * Flags the audio engine in Locked state.
  29879. * This happens due to new browser policies preventing audio to autoplay.
  29880. */
  29881. lock(): void;
  29882. /**
  29883. * Unlocks the audio engine once a user action has been done on the dom.
  29884. * This is helpful to resume play once browser policies have been satisfied.
  29885. */
  29886. unlock(): void;
  29887. }
  29888. /**
  29889. * This represents the default audio engine used in babylon.
  29890. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29892. */
  29893. export class AudioEngine implements IAudioEngine {
  29894. private _audioContext;
  29895. private _audioContextInitialized;
  29896. private _muteButton;
  29897. private _hostElement;
  29898. /**
  29899. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29900. */
  29901. canUseWebAudio: boolean;
  29902. /**
  29903. * The master gain node defines the global audio volume of your audio engine.
  29904. */
  29905. masterGain: GainNode;
  29906. /**
  29907. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29908. * @ignoreNaming
  29909. */
  29910. WarnedWebAudioUnsupported: boolean;
  29911. /**
  29912. * Gets whether or not mp3 are supported by your browser.
  29913. */
  29914. isMP3supported: boolean;
  29915. /**
  29916. * Gets whether or not ogg are supported by your browser.
  29917. */
  29918. isOGGsupported: boolean;
  29919. /**
  29920. * Gets whether audio has been unlocked on the device.
  29921. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29922. * a user interaction has happened.
  29923. */
  29924. unlocked: boolean;
  29925. /**
  29926. * Defines if the audio engine relies on a custom unlocked button.
  29927. * In this case, the embedded button will not be displayed.
  29928. */
  29929. useCustomUnlockedButton: boolean;
  29930. /**
  29931. * Event raised when audio has been unlocked on the browser.
  29932. */
  29933. onAudioUnlockedObservable: Observable<AudioEngine>;
  29934. /**
  29935. * Event raised when audio has been locked on the browser.
  29936. */
  29937. onAudioLockedObservable: Observable<AudioEngine>;
  29938. /**
  29939. * Gets the current AudioContext if available.
  29940. */
  29941. readonly audioContext: Nullable<AudioContext>;
  29942. private _connectedAnalyser;
  29943. /**
  29944. * Instantiates a new audio engine.
  29945. *
  29946. * There should be only one per page as some browsers restrict the number
  29947. * of audio contexts you can create.
  29948. * @param hostElement defines the host element where to display the mute icon if necessary
  29949. */
  29950. constructor(hostElement?: Nullable<HTMLElement>);
  29951. /**
  29952. * Flags the audio engine in Locked state.
  29953. * This happens due to new browser policies preventing audio to autoplay.
  29954. */
  29955. lock(): void;
  29956. /**
  29957. * Unlocks the audio engine once a user action has been done on the dom.
  29958. * This is helpful to resume play once browser policies have been satisfied.
  29959. */
  29960. unlock(): void;
  29961. private _resumeAudioContext;
  29962. private _initializeAudioContext;
  29963. private _tryToRun;
  29964. private _triggerRunningState;
  29965. private _triggerSuspendedState;
  29966. private _displayMuteButton;
  29967. private _moveButtonToTopLeft;
  29968. private _onResize;
  29969. private _hideMuteButton;
  29970. /**
  29971. * Destroy and release the resources associated with the audio ccontext.
  29972. */
  29973. dispose(): void;
  29974. /**
  29975. * Gets the global volume sets on the master gain.
  29976. * @returns the global volume if set or -1 otherwise
  29977. */
  29978. getGlobalVolume(): number;
  29979. /**
  29980. * Sets the global volume of your experience (sets on the master gain).
  29981. * @param newVolume Defines the new global volume of the application
  29982. */
  29983. setGlobalVolume(newVolume: number): void;
  29984. /**
  29985. * Connect the audio engine to an audio analyser allowing some amazing
  29986. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29988. * @param analyser The analyser to connect to the engine
  29989. */
  29990. connectToAnalyser(analyser: Analyser): void;
  29991. }
  29992. }
  29993. declare module "babylonjs/Loading/loadingScreen" {
  29994. /**
  29995. * Interface used to present a loading screen while loading a scene
  29996. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29997. */
  29998. export interface ILoadingScreen {
  29999. /**
  30000. * Function called to display the loading screen
  30001. */
  30002. displayLoadingUI: () => void;
  30003. /**
  30004. * Function called to hide the loading screen
  30005. */
  30006. hideLoadingUI: () => void;
  30007. /**
  30008. * Gets or sets the color to use for the background
  30009. */
  30010. loadingUIBackgroundColor: string;
  30011. /**
  30012. * Gets or sets the text to display while loading
  30013. */
  30014. loadingUIText: string;
  30015. }
  30016. /**
  30017. * Class used for the default loading screen
  30018. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30019. */
  30020. export class DefaultLoadingScreen implements ILoadingScreen {
  30021. private _renderingCanvas;
  30022. private _loadingText;
  30023. private _loadingDivBackgroundColor;
  30024. private _loadingDiv;
  30025. private _loadingTextDiv;
  30026. /** Gets or sets the logo url to use for the default loading screen */
  30027. static DefaultLogoUrl: string;
  30028. /** Gets or sets the spinner url to use for the default loading screen */
  30029. static DefaultSpinnerUrl: string;
  30030. /**
  30031. * Creates a new default loading screen
  30032. * @param _renderingCanvas defines the canvas used to render the scene
  30033. * @param _loadingText defines the default text to display
  30034. * @param _loadingDivBackgroundColor defines the default background color
  30035. */
  30036. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30037. /**
  30038. * Function called to display the loading screen
  30039. */
  30040. displayLoadingUI(): void;
  30041. /**
  30042. * Function called to hide the loading screen
  30043. */
  30044. hideLoadingUI(): void;
  30045. /**
  30046. * Gets or sets the text to display while loading
  30047. */
  30048. loadingUIText: string;
  30049. /**
  30050. * Gets or sets the color to use for the background
  30051. */
  30052. loadingUIBackgroundColor: string;
  30053. private _resizeLoadingUI;
  30054. }
  30055. }
  30056. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30057. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30058. import { Engine } from "babylonjs/Engines/engine";
  30059. import { Nullable } from "babylonjs/types";
  30060. /** @hidden */
  30061. export class WebGLPipelineContext implements IPipelineContext {
  30062. engine: Engine;
  30063. program: Nullable<WebGLProgram>;
  30064. context?: WebGLRenderingContext;
  30065. vertexShader?: WebGLShader;
  30066. fragmentShader?: WebGLShader;
  30067. isParallelCompiled: boolean;
  30068. onCompiled?: () => void;
  30069. transformFeedback?: WebGLTransformFeedback | null;
  30070. readonly isAsync: boolean;
  30071. readonly isReady: boolean;
  30072. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30073. }
  30074. }
  30075. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30076. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30077. /** @hidden */
  30078. export class WebGLDataBuffer extends DataBuffer {
  30079. private _buffer;
  30080. constructor(resource: WebGLBuffer);
  30081. readonly underlyingResource: any;
  30082. }
  30083. }
  30084. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30085. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30086. /** @hidden */
  30087. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30088. attributeProcessor(attribute: string): string;
  30089. varyingProcessor(varying: string, isFragment: boolean): string;
  30090. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30091. }
  30092. }
  30093. declare module "babylonjs/Misc/perfCounter" {
  30094. /**
  30095. * This class is used to track a performance counter which is number based.
  30096. * The user has access to many properties which give statistics of different nature.
  30097. *
  30098. * The implementer can track two kinds of Performance Counter: time and count.
  30099. * 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.
  30100. * 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.
  30101. */
  30102. export class PerfCounter {
  30103. /**
  30104. * Gets or sets a global boolean to turn on and off all the counters
  30105. */
  30106. static Enabled: boolean;
  30107. /**
  30108. * Returns the smallest value ever
  30109. */
  30110. readonly min: number;
  30111. /**
  30112. * Returns the biggest value ever
  30113. */
  30114. readonly max: number;
  30115. /**
  30116. * Returns the average value since the performance counter is running
  30117. */
  30118. readonly average: number;
  30119. /**
  30120. * Returns the average value of the last second the counter was monitored
  30121. */
  30122. readonly lastSecAverage: number;
  30123. /**
  30124. * Returns the current value
  30125. */
  30126. readonly current: number;
  30127. /**
  30128. * Gets the accumulated total
  30129. */
  30130. readonly total: number;
  30131. /**
  30132. * Gets the total value count
  30133. */
  30134. readonly count: number;
  30135. /**
  30136. * Creates a new counter
  30137. */
  30138. constructor();
  30139. /**
  30140. * Call this method to start monitoring a new frame.
  30141. * 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.
  30142. */
  30143. fetchNewFrame(): void;
  30144. /**
  30145. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30146. * @param newCount the count value to add to the monitored count
  30147. * @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.
  30148. */
  30149. addCount(newCount: number, fetchResult: boolean): void;
  30150. /**
  30151. * Start monitoring this performance counter
  30152. */
  30153. beginMonitoring(): void;
  30154. /**
  30155. * Compute the time lapsed since the previous beginMonitoring() call.
  30156. * @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
  30157. */
  30158. endMonitoring(newFrame?: boolean): void;
  30159. private _fetchResult;
  30160. private _startMonitoringTime;
  30161. private _min;
  30162. private _max;
  30163. private _average;
  30164. private _current;
  30165. private _totalValueCount;
  30166. private _totalAccumulated;
  30167. private _lastSecAverage;
  30168. private _lastSecAccumulated;
  30169. private _lastSecTime;
  30170. private _lastSecValueCount;
  30171. }
  30172. }
  30173. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30174. /**
  30175. * Interface for any object that can request an animation frame
  30176. */
  30177. export interface ICustomAnimationFrameRequester {
  30178. /**
  30179. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30180. */
  30181. renderFunction?: Function;
  30182. /**
  30183. * Called to request the next frame to render to
  30184. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30185. */
  30186. requestAnimationFrame: Function;
  30187. /**
  30188. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30189. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30190. */
  30191. requestID?: number;
  30192. }
  30193. }
  30194. declare module "babylonjs/Materials/Textures/videoTexture" {
  30195. import { Observable } from "babylonjs/Misc/observable";
  30196. import { Nullable } from "babylonjs/types";
  30197. import { Scene } from "babylonjs/scene";
  30198. import { Texture } from "babylonjs/Materials/Textures/texture";
  30199. /**
  30200. * Settings for finer control over video usage
  30201. */
  30202. export interface VideoTextureSettings {
  30203. /**
  30204. * Applies `autoplay` to video, if specified
  30205. */
  30206. autoPlay?: boolean;
  30207. /**
  30208. * Applies `loop` to video, if specified
  30209. */
  30210. loop?: boolean;
  30211. /**
  30212. * Automatically updates internal texture from video at every frame in the render loop
  30213. */
  30214. autoUpdateTexture: boolean;
  30215. /**
  30216. * Image src displayed during the video loading or until the user interacts with the video.
  30217. */
  30218. poster?: string;
  30219. }
  30220. /**
  30221. * If you want to display a video in your scene, this is the special texture for that.
  30222. * This special texture works similar to other textures, with the exception of a few parameters.
  30223. * @see https://doc.babylonjs.com/how_to/video_texture
  30224. */
  30225. export class VideoTexture extends Texture {
  30226. /**
  30227. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30228. */
  30229. readonly autoUpdateTexture: boolean;
  30230. /**
  30231. * The video instance used by the texture internally
  30232. */
  30233. readonly video: HTMLVideoElement;
  30234. private _onUserActionRequestedObservable;
  30235. /**
  30236. * Event triggerd when a dom action is required by the user to play the video.
  30237. * This happens due to recent changes in browser policies preventing video to auto start.
  30238. */
  30239. readonly onUserActionRequestedObservable: Observable<Texture>;
  30240. private _generateMipMaps;
  30241. private _engine;
  30242. private _stillImageCaptured;
  30243. private _displayingPosterTexture;
  30244. private _settings;
  30245. private _createInternalTextureOnEvent;
  30246. /**
  30247. * Creates a video texture.
  30248. * If you want to display a video in your scene, this is the special texture for that.
  30249. * This special texture works similar to other textures, with the exception of a few parameters.
  30250. * @see https://doc.babylonjs.com/how_to/video_texture
  30251. * @param name optional name, will detect from video source, if not defined
  30252. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30253. * @param scene is obviously the current scene.
  30254. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30255. * @param invertY is false by default but can be used to invert video on Y axis
  30256. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30257. * @param settings allows finer control over video usage
  30258. */
  30259. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30260. private _getName;
  30261. private _getVideo;
  30262. private _createInternalTexture;
  30263. private reset;
  30264. /**
  30265. * @hidden Internal method to initiate `update`.
  30266. */
  30267. _rebuild(): void;
  30268. /**
  30269. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30270. */
  30271. update(): void;
  30272. /**
  30273. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30274. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30275. */
  30276. updateTexture(isVisible: boolean): void;
  30277. protected _updateInternalTexture: () => void;
  30278. /**
  30279. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30280. * @param url New url.
  30281. */
  30282. updateURL(url: string): void;
  30283. /**
  30284. * Dispose the texture and release its associated resources.
  30285. */
  30286. dispose(): void;
  30287. /**
  30288. * Creates a video texture straight from a stream.
  30289. * @param scene Define the scene the texture should be created in
  30290. * @param stream Define the stream the texture should be created from
  30291. * @returns The created video texture as a promise
  30292. */
  30293. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30294. /**
  30295. * Creates a video texture straight from your WebCam video feed.
  30296. * @param scene Define the scene the texture should be created in
  30297. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30298. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30299. * @returns The created video texture as a promise
  30300. */
  30301. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30302. minWidth: number;
  30303. maxWidth: number;
  30304. minHeight: number;
  30305. maxHeight: number;
  30306. deviceId: string;
  30307. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30308. /**
  30309. * Creates a video texture straight from your WebCam video feed.
  30310. * @param scene Define the scene the texture should be created in
  30311. * @param onReady Define a callback to triggered once the texture will be ready
  30312. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30313. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30314. */
  30315. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30316. minWidth: number;
  30317. maxWidth: number;
  30318. minHeight: number;
  30319. maxHeight: number;
  30320. deviceId: string;
  30321. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30322. }
  30323. }
  30324. declare module "babylonjs/Engines/engine" {
  30325. import { Observable } from "babylonjs/Misc/observable";
  30326. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30327. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30328. import { Scene } from "babylonjs/scene";
  30329. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30330. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30331. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30332. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30333. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30334. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30335. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30336. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30337. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30338. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30339. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30340. import { WebRequest } from "babylonjs/Misc/webRequest";
  30341. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30342. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30343. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30344. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30345. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30346. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30347. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30348. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30349. import { Material } from "babylonjs/Materials/material";
  30350. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30351. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30352. /**
  30353. * Defines the interface used by objects containing a viewport (like a camera)
  30354. */
  30355. interface IViewportOwnerLike {
  30356. /**
  30357. * Gets or sets the viewport
  30358. */
  30359. viewport: IViewportLike;
  30360. }
  30361. /**
  30362. * Interface for attribute information associated with buffer instanciation
  30363. */
  30364. export class InstancingAttributeInfo {
  30365. /**
  30366. * Index/offset of the attribute in the vertex shader
  30367. */
  30368. index: number;
  30369. /**
  30370. * size of the attribute, 1, 2, 3 or 4
  30371. */
  30372. attributeSize: number;
  30373. /**
  30374. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30375. * default is FLOAT
  30376. */
  30377. attribyteType: number;
  30378. /**
  30379. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30380. */
  30381. normalized: boolean;
  30382. /**
  30383. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30384. */
  30385. offset: number;
  30386. /**
  30387. * Name of the GLSL attribute, for debugging purpose only
  30388. */
  30389. attributeName: string;
  30390. }
  30391. /**
  30392. * Define options used to create a depth texture
  30393. */
  30394. export class DepthTextureCreationOptions {
  30395. /** Specifies whether or not a stencil should be allocated in the texture */
  30396. generateStencil?: boolean;
  30397. /** Specifies whether or not bilinear filtering is enable on the texture */
  30398. bilinearFiltering?: boolean;
  30399. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30400. comparisonFunction?: number;
  30401. /** Specifies if the created texture is a cube texture */
  30402. isCube?: boolean;
  30403. }
  30404. /**
  30405. * Class used to describe the capabilities of the engine relatively to the current browser
  30406. */
  30407. export class EngineCapabilities {
  30408. /** Maximum textures units per fragment shader */
  30409. maxTexturesImageUnits: number;
  30410. /** Maximum texture units per vertex shader */
  30411. maxVertexTextureImageUnits: number;
  30412. /** Maximum textures units in the entire pipeline */
  30413. maxCombinedTexturesImageUnits: number;
  30414. /** Maximum texture size */
  30415. maxTextureSize: number;
  30416. /** Maximum cube texture size */
  30417. maxCubemapTextureSize: number;
  30418. /** Maximum render texture size */
  30419. maxRenderTextureSize: number;
  30420. /** Maximum number of vertex attributes */
  30421. maxVertexAttribs: number;
  30422. /** Maximum number of varyings */
  30423. maxVaryingVectors: number;
  30424. /** Maximum number of uniforms per vertex shader */
  30425. maxVertexUniformVectors: number;
  30426. /** Maximum number of uniforms per fragment shader */
  30427. maxFragmentUniformVectors: number;
  30428. /** Defines if standard derivates (dx/dy) are supported */
  30429. standardDerivatives: boolean;
  30430. /** Defines if s3tc texture compression is supported */
  30431. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30432. /** Defines if pvrtc texture compression is supported */
  30433. pvrtc: any;
  30434. /** Defines if etc1 texture compression is supported */
  30435. etc1: any;
  30436. /** Defines if etc2 texture compression is supported */
  30437. etc2: any;
  30438. /** Defines if astc texture compression is supported */
  30439. astc: any;
  30440. /** Defines if float textures are supported */
  30441. textureFloat: boolean;
  30442. /** Defines if vertex array objects are supported */
  30443. vertexArrayObject: boolean;
  30444. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30445. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30446. /** Gets the maximum level of anisotropy supported */
  30447. maxAnisotropy: number;
  30448. /** Defines if instancing is supported */
  30449. instancedArrays: boolean;
  30450. /** Defines if 32 bits indices are supported */
  30451. uintIndices: boolean;
  30452. /** Defines if high precision shaders are supported */
  30453. highPrecisionShaderSupported: boolean;
  30454. /** Defines if depth reading in the fragment shader is supported */
  30455. fragmentDepthSupported: boolean;
  30456. /** Defines if float texture linear filtering is supported*/
  30457. textureFloatLinearFiltering: boolean;
  30458. /** Defines if rendering to float textures is supported */
  30459. textureFloatRender: boolean;
  30460. /** Defines if half float textures are supported*/
  30461. textureHalfFloat: boolean;
  30462. /** Defines if half float texture linear filtering is supported*/
  30463. textureHalfFloatLinearFiltering: boolean;
  30464. /** Defines if rendering to half float textures is supported */
  30465. textureHalfFloatRender: boolean;
  30466. /** Defines if textureLOD shader command is supported */
  30467. textureLOD: boolean;
  30468. /** Defines if draw buffers extension is supported */
  30469. drawBuffersExtension: boolean;
  30470. /** Defines if depth textures are supported */
  30471. depthTextureExtension: boolean;
  30472. /** Defines if float color buffer are supported */
  30473. colorBufferFloat: boolean;
  30474. /** Gets disjoint timer query extension (null if not supported) */
  30475. timerQuery: EXT_disjoint_timer_query;
  30476. /** Defines if timestamp can be used with timer query */
  30477. canUseTimestampForTimerQuery: boolean;
  30478. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30479. multiview: any;
  30480. /** Function used to let the system compiles shaders in background */
  30481. parallelShaderCompile: {
  30482. COMPLETION_STATUS_KHR: number;
  30483. };
  30484. }
  30485. /** Interface defining initialization parameters for Engine class */
  30486. export interface EngineOptions extends WebGLContextAttributes {
  30487. /**
  30488. * Defines if the engine should no exceed a specified device ratio
  30489. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30490. */
  30491. limitDeviceRatio?: number;
  30492. /**
  30493. * Defines if webvr should be enabled automatically
  30494. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30495. */
  30496. autoEnableWebVR?: boolean;
  30497. /**
  30498. * Defines if webgl2 should be turned off even if supported
  30499. * @see http://doc.babylonjs.com/features/webgl2
  30500. */
  30501. disableWebGL2Support?: boolean;
  30502. /**
  30503. * Defines if webaudio should be initialized as well
  30504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30505. */
  30506. audioEngine?: boolean;
  30507. /**
  30508. * Defines if animations should run using a deterministic lock step
  30509. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30510. */
  30511. deterministicLockstep?: boolean;
  30512. /** Defines the maximum steps to use with deterministic lock step mode */
  30513. lockstepMaxSteps?: number;
  30514. /**
  30515. * Defines that engine should ignore context lost events
  30516. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30517. */
  30518. doNotHandleContextLost?: boolean;
  30519. /**
  30520. * Defines that engine should ignore modifying touch action attribute and style
  30521. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30522. */
  30523. doNotHandleTouchAction?: boolean;
  30524. /**
  30525. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30526. */
  30527. useHighPrecisionFloats?: boolean;
  30528. }
  30529. /**
  30530. * Defines the interface used by display changed events
  30531. */
  30532. export interface IDisplayChangedEventArgs {
  30533. /** Gets the vrDisplay object (if any) */
  30534. vrDisplay: Nullable<any>;
  30535. /** Gets a boolean indicating if webVR is supported */
  30536. vrSupported: boolean;
  30537. }
  30538. /**
  30539. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30540. */
  30541. export class Engine {
  30542. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30543. static ExceptionList: ({
  30544. key: string;
  30545. capture: string;
  30546. captureConstraint: number;
  30547. targets: string[];
  30548. } | {
  30549. key: string;
  30550. capture: null;
  30551. captureConstraint: null;
  30552. targets: string[];
  30553. })[];
  30554. /** Gets the list of created engines */
  30555. static readonly Instances: Engine[];
  30556. /**
  30557. * Gets the latest created engine
  30558. */
  30559. static readonly LastCreatedEngine: Nullable<Engine>;
  30560. /**
  30561. * Gets the latest created scene
  30562. */
  30563. static readonly LastCreatedScene: Nullable<Scene>;
  30564. /**
  30565. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30566. * @param flag defines which part of the materials must be marked as dirty
  30567. * @param predicate defines a predicate used to filter which materials should be affected
  30568. */
  30569. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30570. /** @hidden */
  30571. static _TextureLoaders: IInternalTextureLoader[];
  30572. /** Defines that alpha blending is disabled */
  30573. static readonly ALPHA_DISABLE: number;
  30574. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30575. static readonly ALPHA_ADD: number;
  30576. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30577. static readonly ALPHA_COMBINE: number;
  30578. /** Defines that alpha blending to DEST - SRC * DEST */
  30579. static readonly ALPHA_SUBTRACT: number;
  30580. /** Defines that alpha blending to SRC * DEST */
  30581. static readonly ALPHA_MULTIPLY: number;
  30582. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30583. static readonly ALPHA_MAXIMIZED: number;
  30584. /** Defines that alpha blending to SRC + DEST */
  30585. static readonly ALPHA_ONEONE: number;
  30586. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30587. static readonly ALPHA_PREMULTIPLIED: number;
  30588. /**
  30589. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30590. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30591. */
  30592. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30593. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30594. static readonly ALPHA_INTERPOLATE: number;
  30595. /**
  30596. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30597. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30598. */
  30599. static readonly ALPHA_SCREENMODE: number;
  30600. /** Defines that the ressource is not delayed*/
  30601. static readonly DELAYLOADSTATE_NONE: number;
  30602. /** Defines that the ressource was successfully delay loaded */
  30603. static readonly DELAYLOADSTATE_LOADED: number;
  30604. /** Defines that the ressource is currently delay loading */
  30605. static readonly DELAYLOADSTATE_LOADING: number;
  30606. /** Defines that the ressource is delayed and has not started loading */
  30607. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30608. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30609. static readonly NEVER: number;
  30610. /** 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 */
  30611. static readonly ALWAYS: number;
  30612. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30613. static readonly LESS: number;
  30614. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30615. static readonly EQUAL: number;
  30616. /** 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 */
  30617. static readonly LEQUAL: number;
  30618. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30619. static readonly GREATER: number;
  30620. /** 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 */
  30621. static readonly GEQUAL: number;
  30622. /** 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 */
  30623. static readonly NOTEQUAL: number;
  30624. /** Passed to stencilOperation to specify that stencil value must be kept */
  30625. static readonly KEEP: number;
  30626. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30627. static readonly REPLACE: number;
  30628. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30629. static readonly INCR: number;
  30630. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30631. static readonly DECR: number;
  30632. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30633. static readonly INVERT: number;
  30634. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30635. static readonly INCR_WRAP: number;
  30636. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30637. static readonly DECR_WRAP: number;
  30638. /** Texture is not repeating outside of 0..1 UVs */
  30639. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30640. /** Texture is repeating outside of 0..1 UVs */
  30641. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30642. /** Texture is repeating and mirrored */
  30643. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30644. /** ALPHA */
  30645. static readonly TEXTUREFORMAT_ALPHA: number;
  30646. /** LUMINANCE */
  30647. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30648. /** LUMINANCE_ALPHA */
  30649. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30650. /** RGB */
  30651. static readonly TEXTUREFORMAT_RGB: number;
  30652. /** RGBA */
  30653. static readonly TEXTUREFORMAT_RGBA: number;
  30654. /** RED */
  30655. static readonly TEXTUREFORMAT_RED: number;
  30656. /** RED (2nd reference) */
  30657. static readonly TEXTUREFORMAT_R: number;
  30658. /** RG */
  30659. static readonly TEXTUREFORMAT_RG: number;
  30660. /** RED_INTEGER */
  30661. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30662. /** RED_INTEGER (2nd reference) */
  30663. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30664. /** RG_INTEGER */
  30665. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30666. /** RGB_INTEGER */
  30667. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30668. /** RGBA_INTEGER */
  30669. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30670. /** UNSIGNED_BYTE */
  30671. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30672. /** UNSIGNED_BYTE (2nd reference) */
  30673. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30674. /** FLOAT */
  30675. static readonly TEXTURETYPE_FLOAT: number;
  30676. /** HALF_FLOAT */
  30677. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30678. /** BYTE */
  30679. static readonly TEXTURETYPE_BYTE: number;
  30680. /** SHORT */
  30681. static readonly TEXTURETYPE_SHORT: number;
  30682. /** UNSIGNED_SHORT */
  30683. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30684. /** INT */
  30685. static readonly TEXTURETYPE_INT: number;
  30686. /** UNSIGNED_INT */
  30687. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30688. /** UNSIGNED_SHORT_4_4_4_4 */
  30689. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30690. /** UNSIGNED_SHORT_5_5_5_1 */
  30691. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30692. /** UNSIGNED_SHORT_5_6_5 */
  30693. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30694. /** UNSIGNED_INT_2_10_10_10_REV */
  30695. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30696. /** UNSIGNED_INT_24_8 */
  30697. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30698. /** UNSIGNED_INT_10F_11F_11F_REV */
  30699. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30700. /** UNSIGNED_INT_5_9_9_9_REV */
  30701. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30702. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30703. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30704. /** nearest is mag = nearest and min = nearest and mip = linear */
  30705. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30706. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30707. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30708. /** Trilinear is mag = linear and min = linear and mip = linear */
  30709. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30710. /** nearest is mag = nearest and min = nearest and mip = linear */
  30711. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30712. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30713. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30714. /** Trilinear is mag = linear and min = linear and mip = linear */
  30715. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30716. /** mag = nearest and min = nearest and mip = nearest */
  30717. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30718. /** mag = nearest and min = linear and mip = nearest */
  30719. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30720. /** mag = nearest and min = linear and mip = linear */
  30721. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30722. /** mag = nearest and min = linear and mip = none */
  30723. static readonly TEXTURE_NEAREST_LINEAR: number;
  30724. /** mag = nearest and min = nearest and mip = none */
  30725. static readonly TEXTURE_NEAREST_NEAREST: number;
  30726. /** mag = linear and min = nearest and mip = nearest */
  30727. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30728. /** mag = linear and min = nearest and mip = linear */
  30729. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30730. /** mag = linear and min = linear and mip = none */
  30731. static readonly TEXTURE_LINEAR_LINEAR: number;
  30732. /** mag = linear and min = nearest and mip = none */
  30733. static readonly TEXTURE_LINEAR_NEAREST: number;
  30734. /** Explicit coordinates mode */
  30735. static readonly TEXTURE_EXPLICIT_MODE: number;
  30736. /** Spherical coordinates mode */
  30737. static readonly TEXTURE_SPHERICAL_MODE: number;
  30738. /** Planar coordinates mode */
  30739. static readonly TEXTURE_PLANAR_MODE: number;
  30740. /** Cubic coordinates mode */
  30741. static readonly TEXTURE_CUBIC_MODE: number;
  30742. /** Projection coordinates mode */
  30743. static readonly TEXTURE_PROJECTION_MODE: number;
  30744. /** Skybox coordinates mode */
  30745. static readonly TEXTURE_SKYBOX_MODE: number;
  30746. /** Inverse Cubic coordinates mode */
  30747. static readonly TEXTURE_INVCUBIC_MODE: number;
  30748. /** Equirectangular coordinates mode */
  30749. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30750. /** Equirectangular Fixed coordinates mode */
  30751. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30752. /** Equirectangular Fixed Mirrored coordinates mode */
  30753. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30754. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30755. static readonly SCALEMODE_FLOOR: number;
  30756. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30757. static readonly SCALEMODE_NEAREST: number;
  30758. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30759. static readonly SCALEMODE_CEILING: number;
  30760. /**
  30761. * Returns the current npm package of the sdk
  30762. */
  30763. static readonly NpmPackage: string;
  30764. /**
  30765. * Returns the current version of the framework
  30766. */
  30767. static readonly Version: string;
  30768. /**
  30769. * Returns a string describing the current engine
  30770. */
  30771. readonly description: string;
  30772. /**
  30773. * Gets or sets the epsilon value used by collision engine
  30774. */
  30775. static CollisionsEpsilon: number;
  30776. /**
  30777. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30778. */
  30779. static ShadersRepository: string;
  30780. /**
  30781. * Method called to create the default loading screen.
  30782. * This can be overriden in your own app.
  30783. * @param canvas The rendering canvas element
  30784. * @returns The loading screen
  30785. */
  30786. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30787. /**
  30788. * Method called to create the default rescale post process on each engine.
  30789. */
  30790. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30791. /** @hidden */
  30792. _shaderProcessor: IShaderProcessor;
  30793. /**
  30794. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30795. */
  30796. forcePOTTextures: boolean;
  30797. /**
  30798. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30799. */
  30800. isFullscreen: boolean;
  30801. /**
  30802. * Gets a boolean indicating if the pointer is currently locked
  30803. */
  30804. isPointerLock: boolean;
  30805. /**
  30806. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30807. */
  30808. cullBackFaces: boolean;
  30809. /**
  30810. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30811. */
  30812. renderEvenInBackground: boolean;
  30813. /**
  30814. * Gets or sets a boolean indicating that cache can be kept between frames
  30815. */
  30816. preventCacheWipeBetweenFrames: boolean;
  30817. /**
  30818. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30819. **/
  30820. enableOfflineSupport: boolean;
  30821. /**
  30822. * 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)
  30823. **/
  30824. disableManifestCheck: boolean;
  30825. /**
  30826. * Gets the list of created scenes
  30827. */
  30828. scenes: Scene[];
  30829. /**
  30830. * Event raised when a new scene is created
  30831. */
  30832. onNewSceneAddedObservable: Observable<Scene>;
  30833. /**
  30834. * Gets the list of created postprocesses
  30835. */
  30836. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30837. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30838. validateShaderPrograms: boolean;
  30839. /**
  30840. * Observable event triggered each time the rendering canvas is resized
  30841. */
  30842. onResizeObservable: Observable<Engine>;
  30843. /**
  30844. * Observable event triggered each time the canvas loses focus
  30845. */
  30846. onCanvasBlurObservable: Observable<Engine>;
  30847. /**
  30848. * Observable event triggered each time the canvas gains focus
  30849. */
  30850. onCanvasFocusObservable: Observable<Engine>;
  30851. /**
  30852. * Observable event triggered each time the canvas receives pointerout event
  30853. */
  30854. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30855. /**
  30856. * Observable event triggered before each texture is initialized
  30857. */
  30858. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30859. /**
  30860. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30861. */
  30862. disableUniformBuffers: boolean;
  30863. /** @hidden */
  30864. _uniformBuffers: UniformBuffer[];
  30865. /**
  30866. * Gets a boolean indicating that the engine supports uniform buffers
  30867. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30868. */
  30869. readonly supportsUniformBuffers: boolean;
  30870. /**
  30871. * Observable raised when the engine begins a new frame
  30872. */
  30873. onBeginFrameObservable: Observable<Engine>;
  30874. /**
  30875. * If set, will be used to request the next animation frame for the render loop
  30876. */
  30877. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30878. /**
  30879. * Observable raised when the engine ends the current frame
  30880. */
  30881. onEndFrameObservable: Observable<Engine>;
  30882. /**
  30883. * Observable raised when the engine is about to compile a shader
  30884. */
  30885. onBeforeShaderCompilationObservable: Observable<Engine>;
  30886. /**
  30887. * Observable raised when the engine has jsut compiled a shader
  30888. */
  30889. onAfterShaderCompilationObservable: Observable<Engine>;
  30890. /** @hidden */
  30891. _gl: WebGLRenderingContext;
  30892. private _renderingCanvas;
  30893. private _windowIsBackground;
  30894. private _webGLVersion;
  30895. protected _highPrecisionShadersAllowed: boolean;
  30896. /** @hidden */
  30897. readonly _shouldUseHighPrecisionShader: boolean;
  30898. /**
  30899. * Gets a boolean indicating that only power of 2 textures are supported
  30900. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30901. */
  30902. readonly needPOTTextures: boolean;
  30903. /** @hidden */
  30904. _badOS: boolean;
  30905. /** @hidden */
  30906. _badDesktopOS: boolean;
  30907. /**
  30908. * Gets the audio engine
  30909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30910. * @ignorenaming
  30911. */
  30912. static audioEngine: IAudioEngine;
  30913. /**
  30914. * Default AudioEngine factory responsible of creating the Audio Engine.
  30915. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30916. */
  30917. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30918. /**
  30919. * Default offline support factory responsible of creating a tool used to store data locally.
  30920. * By default, this will create a Database object if the workload has been embedded.
  30921. */
  30922. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30923. private _onFocus;
  30924. private _onBlur;
  30925. private _onCanvasPointerOut;
  30926. private _onCanvasBlur;
  30927. private _onCanvasFocus;
  30928. private _onFullscreenChange;
  30929. private _onPointerLockChange;
  30930. private _hardwareScalingLevel;
  30931. /** @hidden */
  30932. _caps: EngineCapabilities;
  30933. private _pointerLockRequested;
  30934. private _isStencilEnable;
  30935. private _colorWrite;
  30936. private _loadingScreen;
  30937. /** @hidden */
  30938. _drawCalls: PerfCounter;
  30939. private _glVersion;
  30940. private _glRenderer;
  30941. private _glVendor;
  30942. private _videoTextureSupported;
  30943. private _renderingQueueLaunched;
  30944. private _activeRenderLoops;
  30945. private _deterministicLockstep;
  30946. private _lockstepMaxSteps;
  30947. /**
  30948. * Observable signaled when a context lost event is raised
  30949. */
  30950. onContextLostObservable: Observable<Engine>;
  30951. /**
  30952. * Observable signaled when a context restored event is raised
  30953. */
  30954. onContextRestoredObservable: Observable<Engine>;
  30955. private _onContextLost;
  30956. private _onContextRestored;
  30957. private _contextWasLost;
  30958. /** @hidden */
  30959. _doNotHandleContextLost: boolean;
  30960. /**
  30961. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30962. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30963. */
  30964. doNotHandleContextLost: boolean;
  30965. private _performanceMonitor;
  30966. private _fps;
  30967. private _deltaTime;
  30968. /**
  30969. * Turn this value on if you want to pause FPS computation when in background
  30970. */
  30971. disablePerformanceMonitorInBackground: boolean;
  30972. /**
  30973. * Gets the performance monitor attached to this engine
  30974. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30975. */
  30976. readonly performanceMonitor: PerformanceMonitor;
  30977. /**
  30978. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30979. */
  30980. disableVertexArrayObjects: boolean;
  30981. /** @hidden */
  30982. protected _depthCullingState: _DepthCullingState;
  30983. /** @hidden */
  30984. protected _stencilState: _StencilState;
  30985. /** @hidden */
  30986. protected _alphaState: _AlphaState;
  30987. /** @hidden */
  30988. protected _alphaMode: number;
  30989. /** @hidden */
  30990. _internalTexturesCache: InternalTexture[];
  30991. /** @hidden */
  30992. protected _activeChannel: number;
  30993. private _currentTextureChannel;
  30994. /** @hidden */
  30995. protected _boundTexturesCache: {
  30996. [key: string]: Nullable<InternalTexture>;
  30997. };
  30998. /** @hidden */
  30999. protected _currentEffect: Nullable<Effect>;
  31000. /** @hidden */
  31001. protected _currentProgram: Nullable<WebGLProgram>;
  31002. private _compiledEffects;
  31003. private _vertexAttribArraysEnabled;
  31004. /** @hidden */
  31005. protected _cachedViewport: Nullable<IViewportLike>;
  31006. private _cachedVertexArrayObject;
  31007. /** @hidden */
  31008. protected _cachedVertexBuffers: any;
  31009. /** @hidden */
  31010. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31011. /** @hidden */
  31012. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31013. /** @hidden */
  31014. _currentRenderTarget: Nullable<InternalTexture>;
  31015. private _uintIndicesCurrentlySet;
  31016. private _currentBoundBuffer;
  31017. /** @hidden */
  31018. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31019. private _currentBufferPointers;
  31020. private _currentInstanceLocations;
  31021. private _currentInstanceBuffers;
  31022. private _textureUnits;
  31023. /** @hidden */
  31024. _workingCanvas: Nullable<HTMLCanvasElement>;
  31025. /** @hidden */
  31026. _workingContext: Nullable<CanvasRenderingContext2D>;
  31027. private _rescalePostProcess;
  31028. private _dummyFramebuffer;
  31029. private _externalData;
  31030. /** @hidden */
  31031. _bindedRenderFunction: any;
  31032. private _vaoRecordInProgress;
  31033. private _mustWipeVertexAttributes;
  31034. private _emptyTexture;
  31035. private _emptyCubeTexture;
  31036. private _emptyTexture3D;
  31037. /** @hidden */
  31038. _frameHandler: number;
  31039. private _nextFreeTextureSlots;
  31040. private _maxSimultaneousTextures;
  31041. private _activeRequests;
  31042. private _texturesSupported;
  31043. /** @hidden */
  31044. _textureFormatInUse: Nullable<string>;
  31045. /**
  31046. * Gets the list of texture formats supported
  31047. */
  31048. readonly texturesSupported: Array<string>;
  31049. /**
  31050. * Gets the list of texture formats in use
  31051. */
  31052. readonly textureFormatInUse: Nullable<string>;
  31053. /**
  31054. * Gets the current viewport
  31055. */
  31056. readonly currentViewport: Nullable<IViewportLike>;
  31057. /**
  31058. * Gets the default empty texture
  31059. */
  31060. readonly emptyTexture: InternalTexture;
  31061. /**
  31062. * Gets the default empty 3D texture
  31063. */
  31064. readonly emptyTexture3D: InternalTexture;
  31065. /**
  31066. * Gets the default empty cube texture
  31067. */
  31068. readonly emptyCubeTexture: InternalTexture;
  31069. /**
  31070. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31071. */
  31072. readonly premultipliedAlpha: boolean;
  31073. /**
  31074. * Creates a new engine
  31075. * @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
  31076. * @param antialias defines enable antialiasing (default: false)
  31077. * @param options defines further options to be sent to the getContext() function
  31078. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31079. */
  31080. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31081. /**
  31082. * Initializes a webVR display and starts listening to display change events
  31083. * The onVRDisplayChangedObservable will be notified upon these changes
  31084. * @returns The onVRDisplayChangedObservable
  31085. */
  31086. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31087. /** @hidden */
  31088. _prepareVRComponent(): void;
  31089. /** @hidden */
  31090. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31091. /** @hidden */
  31092. _submitVRFrame(): void;
  31093. /**
  31094. * Call this function to leave webVR mode
  31095. * Will do nothing if webVR is not supported or if there is no webVR device
  31096. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31097. */
  31098. disableVR(): void;
  31099. /**
  31100. * Gets a boolean indicating that the system is in VR mode and is presenting
  31101. * @returns true if VR mode is engaged
  31102. */
  31103. isVRPresenting(): boolean;
  31104. /** @hidden */
  31105. _requestVRFrame(): void;
  31106. private _disableTouchAction;
  31107. private _rebuildInternalTextures;
  31108. private _rebuildEffects;
  31109. /**
  31110. * Gets a boolean indicating if all created effects are ready
  31111. * @returns true if all effects are ready
  31112. */
  31113. areAllEffectsReady(): boolean;
  31114. private _rebuildBuffers;
  31115. private _initGLContext;
  31116. /**
  31117. * Gets version of the current webGL context
  31118. */
  31119. readonly webGLVersion: number;
  31120. /**
  31121. * Gets a string idenfifying the name of the class
  31122. * @returns "Engine" string
  31123. */
  31124. getClassName(): string;
  31125. /**
  31126. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31127. */
  31128. readonly isStencilEnable: boolean;
  31129. /** @hidden */
  31130. _prepareWorkingCanvas(): void;
  31131. /**
  31132. * Reset the texture cache to empty state
  31133. */
  31134. resetTextureCache(): void;
  31135. /**
  31136. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31137. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31138. * @returns true if engine is in deterministic lock step mode
  31139. */
  31140. isDeterministicLockStep(): boolean;
  31141. /**
  31142. * Gets the max steps when engine is running in deterministic lock step
  31143. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31144. * @returns the max steps
  31145. */
  31146. getLockstepMaxSteps(): number;
  31147. /**
  31148. * Gets an object containing information about the current webGL context
  31149. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31150. */
  31151. getGlInfo(): {
  31152. vendor: string;
  31153. renderer: string;
  31154. version: string;
  31155. };
  31156. /**
  31157. * Gets current aspect ratio
  31158. * @param viewportOwner defines the camera to use to get the aspect ratio
  31159. * @param useScreen defines if screen size must be used (or the current render target if any)
  31160. * @returns a number defining the aspect ratio
  31161. */
  31162. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31163. /**
  31164. * Gets current screen aspect ratio
  31165. * @returns a number defining the aspect ratio
  31166. */
  31167. getScreenAspectRatio(): number;
  31168. /**
  31169. * Gets the current render width
  31170. * @param useScreen defines if screen size must be used (or the current render target if any)
  31171. * @returns a number defining the current render width
  31172. */
  31173. getRenderWidth(useScreen?: boolean): number;
  31174. /**
  31175. * Gets the current render height
  31176. * @param useScreen defines if screen size must be used (or the current render target if any)
  31177. * @returns a number defining the current render height
  31178. */
  31179. getRenderHeight(useScreen?: boolean): number;
  31180. /**
  31181. * Gets the HTML canvas attached with the current webGL context
  31182. * @returns a HTML canvas
  31183. */
  31184. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31185. /**
  31186. * Gets the client rect of the HTML canvas attached with the current webGL context
  31187. * @returns a client rectanglee
  31188. */
  31189. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31190. /**
  31191. * Defines the hardware scaling level.
  31192. * By default the hardware scaling level is computed from the window device ratio.
  31193. * 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.
  31194. * @param level defines the level to use
  31195. */
  31196. setHardwareScalingLevel(level: number): void;
  31197. /**
  31198. * Gets the current hardware scaling level.
  31199. * By default the hardware scaling level is computed from the window device ratio.
  31200. * 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.
  31201. * @returns a number indicating the current hardware scaling level
  31202. */
  31203. getHardwareScalingLevel(): number;
  31204. /**
  31205. * Gets the list of loaded textures
  31206. * @returns an array containing all loaded textures
  31207. */
  31208. getLoadedTexturesCache(): InternalTexture[];
  31209. /**
  31210. * Gets the object containing all engine capabilities
  31211. * @returns the EngineCapabilities object
  31212. */
  31213. getCaps(): EngineCapabilities;
  31214. /**
  31215. * Gets the current depth function
  31216. * @returns a number defining the depth function
  31217. */
  31218. getDepthFunction(): Nullable<number>;
  31219. /**
  31220. * Sets the current depth function
  31221. * @param depthFunc defines the function to use
  31222. */
  31223. setDepthFunction(depthFunc: number): void;
  31224. /**
  31225. * Sets the current depth function to GREATER
  31226. */
  31227. setDepthFunctionToGreater(): void;
  31228. /**
  31229. * Sets the current depth function to GEQUAL
  31230. */
  31231. setDepthFunctionToGreaterOrEqual(): void;
  31232. /**
  31233. * Sets the current depth function to LESS
  31234. */
  31235. setDepthFunctionToLess(): void;
  31236. private _cachedStencilBuffer;
  31237. private _cachedStencilFunction;
  31238. private _cachedStencilMask;
  31239. private _cachedStencilOperationPass;
  31240. private _cachedStencilOperationFail;
  31241. private _cachedStencilOperationDepthFail;
  31242. private _cachedStencilReference;
  31243. /**
  31244. * Caches the the state of the stencil buffer
  31245. */
  31246. cacheStencilState(): void;
  31247. /**
  31248. * Restores the state of the stencil buffer
  31249. */
  31250. restoreStencilState(): void;
  31251. /**
  31252. * Sets the current depth function to LEQUAL
  31253. */
  31254. setDepthFunctionToLessOrEqual(): void;
  31255. /**
  31256. * Gets a boolean indicating if stencil buffer is enabled
  31257. * @returns the current stencil buffer state
  31258. */
  31259. getStencilBuffer(): boolean;
  31260. /**
  31261. * Enable or disable the stencil buffer
  31262. * @param enable defines if the stencil buffer must be enabled or disabled
  31263. */
  31264. setStencilBuffer(enable: boolean): void;
  31265. /**
  31266. * Gets the current stencil mask
  31267. * @returns a number defining the new stencil mask to use
  31268. */
  31269. getStencilMask(): number;
  31270. /**
  31271. * Sets the current stencil mask
  31272. * @param mask defines the new stencil mask to use
  31273. */
  31274. setStencilMask(mask: number): void;
  31275. /**
  31276. * Gets the current stencil function
  31277. * @returns a number defining the stencil function to use
  31278. */
  31279. getStencilFunction(): number;
  31280. /**
  31281. * Gets the current stencil reference value
  31282. * @returns a number defining the stencil reference value to use
  31283. */
  31284. getStencilFunctionReference(): number;
  31285. /**
  31286. * Gets the current stencil mask
  31287. * @returns a number defining the stencil mask to use
  31288. */
  31289. getStencilFunctionMask(): number;
  31290. /**
  31291. * Sets the current stencil function
  31292. * @param stencilFunc defines the new stencil function to use
  31293. */
  31294. setStencilFunction(stencilFunc: number): void;
  31295. /**
  31296. * Sets the current stencil reference
  31297. * @param reference defines the new stencil reference to use
  31298. */
  31299. setStencilFunctionReference(reference: number): void;
  31300. /**
  31301. * Sets the current stencil mask
  31302. * @param mask defines the new stencil mask to use
  31303. */
  31304. setStencilFunctionMask(mask: number): void;
  31305. /**
  31306. * Gets the current stencil operation when stencil fails
  31307. * @returns a number defining stencil operation to use when stencil fails
  31308. */
  31309. getStencilOperationFail(): number;
  31310. /**
  31311. * Gets the current stencil operation when depth fails
  31312. * @returns a number defining stencil operation to use when depth fails
  31313. */
  31314. getStencilOperationDepthFail(): number;
  31315. /**
  31316. * Gets the current stencil operation when stencil passes
  31317. * @returns a number defining stencil operation to use when stencil passes
  31318. */
  31319. getStencilOperationPass(): number;
  31320. /**
  31321. * Sets the stencil operation to use when stencil fails
  31322. * @param operation defines the stencil operation to use when stencil fails
  31323. */
  31324. setStencilOperationFail(operation: number): void;
  31325. /**
  31326. * Sets the stencil operation to use when depth fails
  31327. * @param operation defines the stencil operation to use when depth fails
  31328. */
  31329. setStencilOperationDepthFail(operation: number): void;
  31330. /**
  31331. * Sets the stencil operation to use when stencil passes
  31332. * @param operation defines the stencil operation to use when stencil passes
  31333. */
  31334. setStencilOperationPass(operation: number): void;
  31335. /**
  31336. * Sets a boolean indicating if the dithering state is enabled or disabled
  31337. * @param value defines the dithering state
  31338. */
  31339. setDitheringState(value: boolean): void;
  31340. /**
  31341. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31342. * @param value defines the rasterizer state
  31343. */
  31344. setRasterizerState(value: boolean): void;
  31345. /**
  31346. * stop executing a render loop function and remove it from the execution array
  31347. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31348. */
  31349. stopRenderLoop(renderFunction?: () => void): void;
  31350. /** @hidden */
  31351. _renderLoop(): void;
  31352. /**
  31353. * Register and execute a render loop. The engine can have more than one render function
  31354. * @param renderFunction defines the function to continuously execute
  31355. */
  31356. runRenderLoop(renderFunction: () => void): void;
  31357. /**
  31358. * Toggle full screen mode
  31359. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31360. */
  31361. switchFullscreen(requestPointerLock: boolean): void;
  31362. /**
  31363. * Enters full screen mode
  31364. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31365. */
  31366. enterFullscreen(requestPointerLock: boolean): void;
  31367. /**
  31368. * Exits full screen mode
  31369. */
  31370. exitFullscreen(): void;
  31371. /**
  31372. * Enters Pointerlock mode
  31373. */
  31374. enterPointerlock(): void;
  31375. /**
  31376. * Exits Pointerlock mode
  31377. */
  31378. exitPointerlock(): void;
  31379. /**
  31380. * Clear the current render buffer or the current render target (if any is set up)
  31381. * @param color defines the color to use
  31382. * @param backBuffer defines if the back buffer must be cleared
  31383. * @param depth defines if the depth buffer must be cleared
  31384. * @param stencil defines if the stencil buffer must be cleared
  31385. */
  31386. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31387. /**
  31388. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31389. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31390. * @param y defines the y-coordinate of the corner of the clear rectangle
  31391. * @param width defines the width of the clear rectangle
  31392. * @param height defines the height of the clear rectangle
  31393. * @param clearColor defines the clear color
  31394. */
  31395. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31396. /**
  31397. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31398. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31399. * @param y defines the y-coordinate of the corner of the clear rectangle
  31400. * @param width defines the width of the clear rectangle
  31401. * @param height defines the height of the clear rectangle
  31402. */
  31403. enableScissor(x: number, y: number, width: number, height: number): void;
  31404. /**
  31405. * Disable previously set scissor test rectangle
  31406. */
  31407. disableScissor(): void;
  31408. private _viewportCached;
  31409. /** @hidden */
  31410. _viewport(x: number, y: number, width: number, height: number): void;
  31411. /**
  31412. * Set the WebGL's viewport
  31413. * @param viewport defines the viewport element to be used
  31414. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31415. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31416. */
  31417. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31418. /**
  31419. * Directly set the WebGL Viewport
  31420. * @param x defines the x coordinate of the viewport (in screen space)
  31421. * @param y defines the y coordinate of the viewport (in screen space)
  31422. * @param width defines the width of the viewport (in screen space)
  31423. * @param height defines the height of the viewport (in screen space)
  31424. * @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
  31425. */
  31426. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31427. /**
  31428. * Begin a new frame
  31429. */
  31430. beginFrame(): void;
  31431. /**
  31432. * Enf the current frame
  31433. */
  31434. endFrame(): void;
  31435. /**
  31436. * Resize the view according to the canvas' size
  31437. */
  31438. resize(): void;
  31439. /**
  31440. * Force a specific size of the canvas
  31441. * @param width defines the new canvas' width
  31442. * @param height defines the new canvas' height
  31443. */
  31444. setSize(width: number, height: number): void;
  31445. /**
  31446. * Binds the frame buffer to the specified texture.
  31447. * @param texture The texture to render to or null for the default canvas
  31448. * @param faceIndex The face of the texture to render to in case of cube texture
  31449. * @param requiredWidth The width of the target to render to
  31450. * @param requiredHeight The height of the target to render to
  31451. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31452. * @param depthStencilTexture The depth stencil texture to use to render
  31453. * @param lodLevel defines le lod level to bind to the frame buffer
  31454. */
  31455. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31456. /** @hidden */
  31457. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31458. /**
  31459. * Unbind the current render target texture from the webGL context
  31460. * @param texture defines the render target texture to unbind
  31461. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31462. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31463. */
  31464. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31465. /**
  31466. * Force the mipmap generation for the given render target texture
  31467. * @param texture defines the render target texture to use
  31468. */
  31469. generateMipMapsForCubemap(texture: InternalTexture): void;
  31470. /**
  31471. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31472. */
  31473. flushFramebuffer(): void;
  31474. /**
  31475. * Unbind the current render target and bind the default framebuffer
  31476. */
  31477. restoreDefaultFramebuffer(): void;
  31478. /**
  31479. * Create an uniform buffer
  31480. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31481. * @param elements defines the content of the uniform buffer
  31482. * @returns the webGL uniform buffer
  31483. */
  31484. createUniformBuffer(elements: FloatArray): DataBuffer;
  31485. /**
  31486. * Create a dynamic uniform buffer
  31487. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31488. * @param elements defines the content of the uniform buffer
  31489. * @returns the webGL uniform buffer
  31490. */
  31491. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31492. /**
  31493. * Update an existing uniform buffer
  31494. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31495. * @param uniformBuffer defines the target uniform buffer
  31496. * @param elements defines the content to update
  31497. * @param offset defines the offset in the uniform buffer where update should start
  31498. * @param count defines the size of the data to update
  31499. */
  31500. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31501. private _resetVertexBufferBinding;
  31502. /**
  31503. * Creates a vertex buffer
  31504. * @param data the data for the vertex buffer
  31505. * @returns the new WebGL static buffer
  31506. */
  31507. createVertexBuffer(data: DataArray): DataBuffer;
  31508. /**
  31509. * Creates a dynamic vertex buffer
  31510. * @param data the data for the dynamic vertex buffer
  31511. * @returns the new WebGL dynamic buffer
  31512. */
  31513. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31514. /**
  31515. * Update a dynamic index buffer
  31516. * @param indexBuffer defines the target index buffer
  31517. * @param indices defines the data to update
  31518. * @param offset defines the offset in the target index buffer where update should start
  31519. */
  31520. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31521. /**
  31522. * Updates a dynamic vertex buffer.
  31523. * @param vertexBuffer the vertex buffer to update
  31524. * @param data the data used to update the vertex buffer
  31525. * @param byteOffset the byte offset of the data
  31526. * @param byteLength the byte length of the data
  31527. */
  31528. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31529. private _resetIndexBufferBinding;
  31530. /**
  31531. * Creates a new index buffer
  31532. * @param indices defines the content of the index buffer
  31533. * @param updatable defines if the index buffer must be updatable
  31534. * @returns a new webGL buffer
  31535. */
  31536. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31537. /**
  31538. * Bind a webGL buffer to the webGL context
  31539. * @param buffer defines the buffer to bind
  31540. */
  31541. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31542. /**
  31543. * Bind an uniform buffer to the current webGL context
  31544. * @param buffer defines the buffer to bind
  31545. */
  31546. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31547. /**
  31548. * Bind a buffer to the current webGL context at a given location
  31549. * @param buffer defines the buffer to bind
  31550. * @param location defines the index where to bind the buffer
  31551. */
  31552. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31553. /**
  31554. * Bind a specific block at a given index in a specific shader program
  31555. * @param pipelineContext defines the pipeline context to use
  31556. * @param blockName defines the block name
  31557. * @param index defines the index where to bind the block
  31558. */
  31559. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31560. private bindIndexBuffer;
  31561. private bindBuffer;
  31562. /**
  31563. * update the bound buffer with the given data
  31564. * @param data defines the data to update
  31565. */
  31566. updateArrayBuffer(data: Float32Array): void;
  31567. private _vertexAttribPointer;
  31568. private _bindIndexBufferWithCache;
  31569. private _bindVertexBuffersAttributes;
  31570. /**
  31571. * Records a vertex array object
  31572. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31573. * @param vertexBuffers defines the list of vertex buffers to store
  31574. * @param indexBuffer defines the index buffer to store
  31575. * @param effect defines the effect to store
  31576. * @returns the new vertex array object
  31577. */
  31578. recordVertexArrayObject(vertexBuffers: {
  31579. [key: string]: VertexBuffer;
  31580. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31581. /**
  31582. * Bind a specific vertex array object
  31583. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31584. * @param vertexArrayObject defines the vertex array object to bind
  31585. * @param indexBuffer defines the index buffer to bind
  31586. */
  31587. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31588. /**
  31589. * Bind webGl buffers directly to the webGL context
  31590. * @param vertexBuffer defines the vertex buffer to bind
  31591. * @param indexBuffer defines the index buffer to bind
  31592. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31593. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31594. * @param effect defines the effect associated with the vertex buffer
  31595. */
  31596. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31597. private _unbindVertexArrayObject;
  31598. /**
  31599. * Bind a list of vertex buffers to the webGL context
  31600. * @param vertexBuffers defines the list of vertex buffers to bind
  31601. * @param indexBuffer defines the index buffer to bind
  31602. * @param effect defines the effect associated with the vertex buffers
  31603. */
  31604. bindBuffers(vertexBuffers: {
  31605. [key: string]: Nullable<VertexBuffer>;
  31606. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31607. /**
  31608. * Unbind all instance attributes
  31609. */
  31610. unbindInstanceAttributes(): void;
  31611. /**
  31612. * Release and free the memory of a vertex array object
  31613. * @param vao defines the vertex array object to delete
  31614. */
  31615. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31616. /** @hidden */
  31617. _releaseBuffer(buffer: DataBuffer): boolean;
  31618. /**
  31619. * Creates a webGL buffer to use with instanciation
  31620. * @param capacity defines the size of the buffer
  31621. * @returns the webGL buffer
  31622. */
  31623. createInstancesBuffer(capacity: number): DataBuffer;
  31624. /**
  31625. * Delete a webGL buffer used with instanciation
  31626. * @param buffer defines the webGL buffer to delete
  31627. */
  31628. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31629. /**
  31630. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31631. * @param instancesBuffer defines the webGL buffer to update and bind
  31632. * @param data defines the data to store in the buffer
  31633. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31634. */
  31635. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31636. /**
  31637. * Apply all cached states (depth, culling, stencil and alpha)
  31638. */
  31639. applyStates(): void;
  31640. /**
  31641. * Send a draw order
  31642. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31643. * @param indexStart defines the starting index
  31644. * @param indexCount defines the number of index to draw
  31645. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31646. */
  31647. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31648. /**
  31649. * Draw a list of points
  31650. * @param verticesStart defines the index of first vertex to draw
  31651. * @param verticesCount defines the count of vertices to draw
  31652. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31653. */
  31654. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31655. /**
  31656. * Draw a list of unindexed primitives
  31657. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31658. * @param verticesStart defines the index of first vertex to draw
  31659. * @param verticesCount defines the count of vertices to draw
  31660. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31661. */
  31662. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31663. /**
  31664. * Draw a list of indexed primitives
  31665. * @param fillMode defines the primitive to use
  31666. * @param indexStart defines the starting index
  31667. * @param indexCount defines the number of index to draw
  31668. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31669. */
  31670. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31671. /**
  31672. * Draw a list of unindexed primitives
  31673. * @param fillMode defines the primitive to use
  31674. * @param verticesStart defines the index of first vertex to draw
  31675. * @param verticesCount defines the count of vertices to draw
  31676. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31677. */
  31678. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31679. private _drawMode;
  31680. /** @hidden */
  31681. _releaseEffect(effect: Effect): void;
  31682. /** @hidden */
  31683. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31684. /**
  31685. * Create a new effect (used to store vertex/fragment shaders)
  31686. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31687. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31688. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31689. * @param samplers defines an array of string used to represent textures
  31690. * @param defines defines the string containing the defines to use to compile the shaders
  31691. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31692. * @param onCompiled defines a function to call when the effect creation is successful
  31693. * @param onError defines a function to call when the effect creation has failed
  31694. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31695. * @returns the new Effect
  31696. */
  31697. 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;
  31698. private _compileShader;
  31699. private _compileRawShader;
  31700. /**
  31701. * Directly creates a webGL program
  31702. * @param pipelineContext defines the pipeline context to attach to
  31703. * @param vertexCode defines the vertex shader code to use
  31704. * @param fragmentCode defines the fragment shader code to use
  31705. * @param context defines the webGL context to use (if not set, the current one will be used)
  31706. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31707. * @returns the new webGL program
  31708. */
  31709. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31710. /**
  31711. * Creates a webGL program
  31712. * @param pipelineContext defines the pipeline context to attach to
  31713. * @param vertexCode defines the vertex shader code to use
  31714. * @param fragmentCode defines the fragment shader code to use
  31715. * @param defines defines the string containing the defines to use to compile the shaders
  31716. * @param context defines the webGL context to use (if not set, the current one will be used)
  31717. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31718. * @returns the new webGL program
  31719. */
  31720. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31721. /**
  31722. * Creates a new pipeline context
  31723. * @returns the new pipeline
  31724. */
  31725. createPipelineContext(): WebGLPipelineContext;
  31726. private _createShaderProgram;
  31727. private _finalizePipelineContext;
  31728. /** @hidden */
  31729. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31730. /** @hidden */
  31731. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31732. /** @hidden */
  31733. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31734. /**
  31735. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31736. * @param pipelineContext defines the pipeline context to use
  31737. * @param uniformsNames defines the list of uniform names
  31738. * @returns an array of webGL uniform locations
  31739. */
  31740. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31741. /**
  31742. * Gets the lsit of active attributes for a given webGL program
  31743. * @param pipelineContext defines the pipeline context to use
  31744. * @param attributesNames defines the list of attribute names to get
  31745. * @returns an array of indices indicating the offset of each attribute
  31746. */
  31747. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31748. /**
  31749. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31750. * @param effect defines the effect to activate
  31751. */
  31752. enableEffect(effect: Nullable<Effect>): void;
  31753. /**
  31754. * Set the value of an uniform to an array of int32
  31755. * @param uniform defines the webGL uniform location where to store the value
  31756. * @param array defines the array of int32 to store
  31757. */
  31758. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31759. /**
  31760. * Set the value of an uniform to an array of int32 (stored as vec2)
  31761. * @param uniform defines the webGL uniform location where to store the value
  31762. * @param array defines the array of int32 to store
  31763. */
  31764. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31765. /**
  31766. * Set the value of an uniform to an array of int32 (stored as vec3)
  31767. * @param uniform defines the webGL uniform location where to store the value
  31768. * @param array defines the array of int32 to store
  31769. */
  31770. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31771. /**
  31772. * Set the value of an uniform to an array of int32 (stored as vec4)
  31773. * @param uniform defines the webGL uniform location where to store the value
  31774. * @param array defines the array of int32 to store
  31775. */
  31776. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31777. /**
  31778. * Set the value of an uniform to an array of float32
  31779. * @param uniform defines the webGL uniform location where to store the value
  31780. * @param array defines the array of float32 to store
  31781. */
  31782. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31783. /**
  31784. * Set the value of an uniform to an array of float32 (stored as vec2)
  31785. * @param uniform defines the webGL uniform location where to store the value
  31786. * @param array defines the array of float32 to store
  31787. */
  31788. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31789. /**
  31790. * Set the value of an uniform to an array of float32 (stored as vec3)
  31791. * @param uniform defines the webGL uniform location where to store the value
  31792. * @param array defines the array of float32 to store
  31793. */
  31794. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31795. /**
  31796. * Set the value of an uniform to an array of float32 (stored as vec4)
  31797. * @param uniform defines the webGL uniform location where to store the value
  31798. * @param array defines the array of float32 to store
  31799. */
  31800. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31801. /**
  31802. * Set the value of an uniform to an array of number
  31803. * @param uniform defines the webGL uniform location where to store the value
  31804. * @param array defines the array of number to store
  31805. */
  31806. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31807. /**
  31808. * Set the value of an uniform to an array of number (stored as vec2)
  31809. * @param uniform defines the webGL uniform location where to store the value
  31810. * @param array defines the array of number to store
  31811. */
  31812. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31813. /**
  31814. * Set the value of an uniform to an array of number (stored as vec3)
  31815. * @param uniform defines the webGL uniform location where to store the value
  31816. * @param array defines the array of number to store
  31817. */
  31818. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31819. /**
  31820. * Set the value of an uniform to an array of number (stored as vec4)
  31821. * @param uniform defines the webGL uniform location where to store the value
  31822. * @param array defines the array of number to store
  31823. */
  31824. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31825. /**
  31826. * Set the value of an uniform to an array of float32 (stored as matrices)
  31827. * @param uniform defines the webGL uniform location where to store the value
  31828. * @param matrices defines the array of float32 to store
  31829. */
  31830. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31831. /**
  31832. * Set the value of an uniform to a matrix (3x3)
  31833. * @param uniform defines the webGL uniform location where to store the value
  31834. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31835. */
  31836. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31837. /**
  31838. * Set the value of an uniform to a matrix (2x2)
  31839. * @param uniform defines the webGL uniform location where to store the value
  31840. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31841. */
  31842. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31843. /**
  31844. * Set the value of an uniform to a number (int)
  31845. * @param uniform defines the webGL uniform location where to store the value
  31846. * @param value defines the int number to store
  31847. */
  31848. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31849. /**
  31850. * Set the value of an uniform to a number (float)
  31851. * @param uniform defines the webGL uniform location where to store the value
  31852. * @param value defines the float number to store
  31853. */
  31854. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31855. /**
  31856. * Set the value of an uniform to a vec2
  31857. * @param uniform defines the webGL uniform location where to store the value
  31858. * @param x defines the 1st component of the value
  31859. * @param y defines the 2nd component of the value
  31860. */
  31861. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31862. /**
  31863. * Set the value of an uniform to a vec3
  31864. * @param uniform defines the webGL uniform location where to store the value
  31865. * @param x defines the 1st component of the value
  31866. * @param y defines the 2nd component of the value
  31867. * @param z defines the 3rd component of the value
  31868. */
  31869. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31870. /**
  31871. * Set the value of an uniform to a boolean
  31872. * @param uniform defines the webGL uniform location where to store the value
  31873. * @param bool defines the boolean to store
  31874. */
  31875. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31876. /**
  31877. * Set the value of an uniform to a vec4
  31878. * @param uniform defines the webGL uniform location where to store the value
  31879. * @param x defines the 1st component of the value
  31880. * @param y defines the 2nd component of the value
  31881. * @param z defines the 3rd component of the value
  31882. * @param w defines the 4th component of the value
  31883. */
  31884. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31885. /**
  31886. * Sets a Color4 on a uniform variable
  31887. * @param uniform defines the uniform location
  31888. * @param color4 defines the value to be set
  31889. */
  31890. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31891. /**
  31892. * Set various states to the webGL context
  31893. * @param culling defines backface culling state
  31894. * @param zOffset defines the value to apply to zOffset (0 by default)
  31895. * @param force defines if states must be applied even if cache is up to date
  31896. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31897. */
  31898. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31899. /**
  31900. * Set the z offset to apply to current rendering
  31901. * @param value defines the offset to apply
  31902. */
  31903. setZOffset(value: number): void;
  31904. /**
  31905. * Gets the current value of the zOffset
  31906. * @returns the current zOffset state
  31907. */
  31908. getZOffset(): number;
  31909. /**
  31910. * Enable or disable depth buffering
  31911. * @param enable defines the state to set
  31912. */
  31913. setDepthBuffer(enable: boolean): void;
  31914. /**
  31915. * Gets a boolean indicating if depth writing is enabled
  31916. * @returns the current depth writing state
  31917. */
  31918. getDepthWrite(): boolean;
  31919. /**
  31920. * Enable or disable depth writing
  31921. * @param enable defines the state to set
  31922. */
  31923. setDepthWrite(enable: boolean): void;
  31924. /**
  31925. * Enable or disable color writing
  31926. * @param enable defines the state to set
  31927. */
  31928. setColorWrite(enable: boolean): void;
  31929. /**
  31930. * Gets a boolean indicating if color writing is enabled
  31931. * @returns the current color writing state
  31932. */
  31933. getColorWrite(): boolean;
  31934. /**
  31935. * Sets alpha constants used by some alpha blending modes
  31936. * @param r defines the red component
  31937. * @param g defines the green component
  31938. * @param b defines the blue component
  31939. * @param a defines the alpha component
  31940. */
  31941. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31942. /**
  31943. * Sets the current alpha mode
  31944. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31945. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31946. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31947. */
  31948. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31949. /**
  31950. * Gets the current alpha mode
  31951. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31952. * @returns the current alpha mode
  31953. */
  31954. getAlphaMode(): number;
  31955. /**
  31956. * Clears the list of texture accessible through engine.
  31957. * This can help preventing texture load conflict due to name collision.
  31958. */
  31959. clearInternalTexturesCache(): void;
  31960. /**
  31961. * Force the entire cache to be cleared
  31962. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31963. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31964. */
  31965. wipeCaches(bruteForce?: boolean): void;
  31966. /**
  31967. * Set the compressed texture format to use, based on the formats you have, and the formats
  31968. * supported by the hardware / browser.
  31969. *
  31970. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31971. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31972. * to API arguments needed to compressed textures. This puts the burden on the container
  31973. * generator to house the arcane code for determining these for current & future formats.
  31974. *
  31975. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31976. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31977. *
  31978. * Note: The result of this call is not taken into account when a texture is base64.
  31979. *
  31980. * @param formatsAvailable defines the list of those format families you have created
  31981. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31982. *
  31983. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31984. * @returns The extension selected.
  31985. */
  31986. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31987. /** @hidden */
  31988. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31989. min: number;
  31990. mag: number;
  31991. };
  31992. /** @hidden */
  31993. _createTexture(): WebGLTexture;
  31994. /**
  31995. * Usually called from Texture.ts.
  31996. * Passed information to create a WebGLTexture
  31997. * @param urlArg defines a value which contains one of the following:
  31998. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31999. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32000. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32001. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32002. * @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)
  32003. * @param scene needed for loading to the correct scene
  32004. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32005. * @param onLoad optional callback to be called upon successful completion
  32006. * @param onError optional callback to be called upon failure
  32007. * @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
  32008. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32009. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32010. * @param forcedExtension defines the extension to use to pick the right loader
  32011. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32012. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32013. */
  32014. 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;
  32015. /**
  32016. * @hidden
  32017. * Rescales a texture
  32018. * @param source input texutre
  32019. * @param destination destination texture
  32020. * @param scene scene to use to render the resize
  32021. * @param internalFormat format to use when resizing
  32022. * @param onComplete callback to be called when resize has completed
  32023. */
  32024. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32025. private _unpackFlipYCached;
  32026. /**
  32027. * In case you are sharing the context with other applications, it might
  32028. * be interested to not cache the unpack flip y state to ensure a consistent
  32029. * value would be set.
  32030. */
  32031. enableUnpackFlipYCached: boolean;
  32032. /** @hidden */
  32033. _unpackFlipY(value: boolean): void;
  32034. /** @hidden */
  32035. _getUnpackAlignement(): number;
  32036. /**
  32037. * Creates a dynamic texture
  32038. * @param width defines the width of the texture
  32039. * @param height defines the height of the texture
  32040. * @param generateMipMaps defines if the engine should generate the mip levels
  32041. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32042. * @returns the dynamic texture inside an InternalTexture
  32043. */
  32044. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32045. /**
  32046. * Update the sampling mode of a given texture
  32047. * @param samplingMode defines the required sampling mode
  32048. * @param texture defines the texture to update
  32049. */
  32050. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32051. /**
  32052. * Update the content of a dynamic texture
  32053. * @param texture defines the texture to update
  32054. * @param canvas defines the canvas containing the source
  32055. * @param invertY defines if data must be stored with Y axis inverted
  32056. * @param premulAlpha defines if alpha is stored as premultiplied
  32057. * @param format defines the format of the data
  32058. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32059. */
  32060. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32061. /**
  32062. * Update a video texture
  32063. * @param texture defines the texture to update
  32064. * @param video defines the video element to use
  32065. * @param invertY defines if data must be stored with Y axis inverted
  32066. */
  32067. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32068. /**
  32069. * Updates a depth texture Comparison Mode and Function.
  32070. * If the comparison Function is equal to 0, the mode will be set to none.
  32071. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32072. * @param texture The texture to set the comparison function for
  32073. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32074. */
  32075. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32076. /** @hidden */
  32077. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32078. width: number;
  32079. height: number;
  32080. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32081. /**
  32082. * Creates a depth stencil texture.
  32083. * This is only available in WebGL 2 or with the depth texture extension available.
  32084. * @param size The size of face edge in the texture.
  32085. * @param options The options defining the texture.
  32086. * @returns The texture
  32087. */
  32088. createDepthStencilTexture(size: number | {
  32089. width: number;
  32090. height: number;
  32091. }, options: DepthTextureCreationOptions): InternalTexture;
  32092. /**
  32093. * Creates a depth stencil texture.
  32094. * This is only available in WebGL 2 or with the depth texture extension available.
  32095. * @param size The size of face edge in the texture.
  32096. * @param options The options defining the texture.
  32097. * @returns The texture
  32098. */
  32099. private _createDepthStencilTexture;
  32100. /**
  32101. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32102. * @param renderTarget The render target to set the frame buffer for
  32103. */
  32104. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32105. /**
  32106. * Creates a new render target texture
  32107. * @param size defines the size of the texture
  32108. * @param options defines the options used to create the texture
  32109. * @returns a new render target texture stored in an InternalTexture
  32110. */
  32111. createRenderTargetTexture(size: number | {
  32112. width: number;
  32113. height: number;
  32114. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32115. /** @hidden */
  32116. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32117. /**
  32118. * Updates the sample count of a render target texture
  32119. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32120. * @param texture defines the texture to update
  32121. * @param samples defines the sample count to set
  32122. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32123. */
  32124. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32125. /** @hidden */
  32126. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32127. /** @hidden */
  32128. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32129. /** @hidden */
  32130. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32131. /** @hidden */
  32132. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32133. /**
  32134. * @hidden
  32135. */
  32136. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32137. private _prepareWebGLTextureContinuation;
  32138. private _prepareWebGLTexture;
  32139. /** @hidden */
  32140. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32141. /** @hidden */
  32142. _releaseFramebufferObjects(texture: InternalTexture): void;
  32143. /** @hidden */
  32144. _releaseTexture(texture: InternalTexture): void;
  32145. private setProgram;
  32146. private _boundUniforms;
  32147. /**
  32148. * Binds an effect to the webGL context
  32149. * @param effect defines the effect to bind
  32150. */
  32151. bindSamplers(effect: Effect): void;
  32152. private _activateCurrentTexture;
  32153. /** @hidden */
  32154. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32155. /** @hidden */
  32156. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32157. /**
  32158. * Sets a texture to the webGL context from a postprocess
  32159. * @param channel defines the channel to use
  32160. * @param postProcess defines the source postprocess
  32161. */
  32162. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32163. /**
  32164. * Binds the output of the passed in post process to the texture channel specified
  32165. * @param channel The channel the texture should be bound to
  32166. * @param postProcess The post process which's output should be bound
  32167. */
  32168. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32169. /**
  32170. * Unbind all textures from the webGL context
  32171. */
  32172. unbindAllTextures(): void;
  32173. /**
  32174. * Sets a texture to the according uniform.
  32175. * @param channel The texture channel
  32176. * @param uniform The uniform to set
  32177. * @param texture The texture to apply
  32178. */
  32179. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32180. /**
  32181. * Sets a depth stencil texture from a render target to the according uniform.
  32182. * @param channel The texture channel
  32183. * @param uniform The uniform to set
  32184. * @param texture The render target texture containing the depth stencil texture to apply
  32185. */
  32186. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32187. private _bindSamplerUniformToChannel;
  32188. private _getTextureWrapMode;
  32189. private _setTexture;
  32190. /**
  32191. * Sets an array of texture to the webGL context
  32192. * @param channel defines the channel where the texture array must be set
  32193. * @param uniform defines the associated uniform location
  32194. * @param textures defines the array of textures to bind
  32195. */
  32196. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32197. /** @hidden */
  32198. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32199. private _setTextureParameterFloat;
  32200. private _setTextureParameterInteger;
  32201. /**
  32202. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32203. * @param x defines the x coordinate of the rectangle where pixels must be read
  32204. * @param y defines the y coordinate of the rectangle where pixels must be read
  32205. * @param width defines the width of the rectangle where pixels must be read
  32206. * @param height defines the height of the rectangle where pixels must be read
  32207. * @returns a Uint8Array containing RGBA colors
  32208. */
  32209. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32210. /**
  32211. * Add an externaly attached data from its key.
  32212. * This method call will fail and return false, if such key already exists.
  32213. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32214. * @param key the unique key that identifies the data
  32215. * @param data the data object to associate to the key for this Engine instance
  32216. * @return true if no such key were already present and the data was added successfully, false otherwise
  32217. */
  32218. addExternalData<T>(key: string, data: T): boolean;
  32219. /**
  32220. * Get an externaly attached data from its key
  32221. * @param key the unique key that identifies the data
  32222. * @return the associated data, if present (can be null), or undefined if not present
  32223. */
  32224. getExternalData<T>(key: string): T;
  32225. /**
  32226. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32227. * @param key the unique key that identifies the data
  32228. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32229. * @return the associated data, can be null if the factory returned null.
  32230. */
  32231. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32232. /**
  32233. * Remove an externaly attached data from the Engine instance
  32234. * @param key the unique key that identifies the data
  32235. * @return true if the data was successfully removed, false if it doesn't exist
  32236. */
  32237. removeExternalData(key: string): boolean;
  32238. /**
  32239. * Unbind all vertex attributes from the webGL context
  32240. */
  32241. unbindAllAttributes(): void;
  32242. /**
  32243. * 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
  32244. */
  32245. releaseEffects(): void;
  32246. /**
  32247. * Dispose and release all associated resources
  32248. */
  32249. dispose(): void;
  32250. /**
  32251. * Display the loading screen
  32252. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32253. */
  32254. displayLoadingUI(): void;
  32255. /**
  32256. * Hide the loading screen
  32257. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32258. */
  32259. hideLoadingUI(): void;
  32260. /**
  32261. * Gets the current loading screen object
  32262. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32263. */
  32264. /**
  32265. * Sets the current loading screen object
  32266. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32267. */
  32268. loadingScreen: ILoadingScreen;
  32269. /**
  32270. * Sets the current loading screen text
  32271. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32272. */
  32273. loadingUIText: string;
  32274. /**
  32275. * Sets the current loading screen background color
  32276. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32277. */
  32278. loadingUIBackgroundColor: string;
  32279. /**
  32280. * Attach a new callback raised when context lost event is fired
  32281. * @param callback defines the callback to call
  32282. */
  32283. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32284. /**
  32285. * Attach a new callback raised when context restored event is fired
  32286. * @param callback defines the callback to call
  32287. */
  32288. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32289. /**
  32290. * Gets the source code of the vertex shader associated with a specific webGL program
  32291. * @param program defines the program to use
  32292. * @returns a string containing the source code of the vertex shader associated with the program
  32293. */
  32294. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32295. /**
  32296. * Gets the source code of the fragment shader associated with a specific webGL program
  32297. * @param program defines the program to use
  32298. * @returns a string containing the source code of the fragment shader associated with the program
  32299. */
  32300. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32301. /**
  32302. * Get the current error code of the webGL context
  32303. * @returns the error code
  32304. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32305. */
  32306. getError(): number;
  32307. /**
  32308. * Gets the current framerate
  32309. * @returns a number representing the framerate
  32310. */
  32311. getFps(): number;
  32312. /**
  32313. * Gets the time spent between current and previous frame
  32314. * @returns a number representing the delta time in ms
  32315. */
  32316. getDeltaTime(): number;
  32317. private _measureFps;
  32318. /** @hidden */
  32319. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32320. private _canRenderToFloatFramebuffer;
  32321. private _canRenderToHalfFloatFramebuffer;
  32322. private _canRenderToFramebuffer;
  32323. /** @hidden */
  32324. _getWebGLTextureType(type: number): number;
  32325. /** @hidden */
  32326. _getInternalFormat(format: number): number;
  32327. /** @hidden */
  32328. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32329. /** @hidden */
  32330. _getRGBAMultiSampleBufferFormat(type: number): number;
  32331. /** @hidden */
  32332. _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;
  32333. /** @hidden */
  32334. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32335. /**
  32336. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32337. * @returns true if the engine can be created
  32338. * @ignorenaming
  32339. */
  32340. static isSupported(): boolean;
  32341. /**
  32342. * Find the next highest power of two.
  32343. * @param x Number to start search from.
  32344. * @return Next highest power of two.
  32345. */
  32346. static CeilingPOT(x: number): number;
  32347. /**
  32348. * Find the next lowest power of two.
  32349. * @param x Number to start search from.
  32350. * @return Next lowest power of two.
  32351. */
  32352. static FloorPOT(x: number): number;
  32353. /**
  32354. * Find the nearest power of two.
  32355. * @param x Number to start search from.
  32356. * @return Next nearest power of two.
  32357. */
  32358. static NearestPOT(x: number): number;
  32359. /**
  32360. * Get the closest exponent of two
  32361. * @param value defines the value to approximate
  32362. * @param max defines the maximum value to return
  32363. * @param mode defines how to define the closest value
  32364. * @returns closest exponent of two of the given value
  32365. */
  32366. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32367. /**
  32368. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32369. * @param func - the function to be called
  32370. * @param requester - the object that will request the next frame. Falls back to window.
  32371. * @returns frame number
  32372. */
  32373. static QueueNewFrame(func: () => void, requester?: any): number;
  32374. /**
  32375. * Ask the browser to promote the current element to pointerlock mode
  32376. * @param element defines the DOM element to promote
  32377. */
  32378. static _RequestPointerlock(element: HTMLElement): void;
  32379. /**
  32380. * Asks the browser to exit pointerlock mode
  32381. */
  32382. static _ExitPointerlock(): void;
  32383. /**
  32384. * Ask the browser to promote the current element to fullscreen rendering mode
  32385. * @param element defines the DOM element to promote
  32386. */
  32387. static _RequestFullscreen(element: HTMLElement): void;
  32388. /**
  32389. * Asks the browser to exit fullscreen mode
  32390. */
  32391. static _ExitFullscreen(): void;
  32392. }
  32393. }
  32394. declare module "babylonjs/Engines/engineStore" {
  32395. import { Nullable } from "babylonjs/types";
  32396. import { Engine } from "babylonjs/Engines/engine";
  32397. import { Scene } from "babylonjs/scene";
  32398. /**
  32399. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32400. * during the life time of the application.
  32401. */
  32402. export class EngineStore {
  32403. /** Gets the list of created engines */
  32404. static Instances: import("babylonjs/Engines/engine").Engine[];
  32405. /** @hidden */
  32406. static _LastCreatedScene: Nullable<Scene>;
  32407. /**
  32408. * Gets the latest created engine
  32409. */
  32410. static readonly LastCreatedEngine: Nullable<Engine>;
  32411. /**
  32412. * Gets the latest created scene
  32413. */
  32414. static readonly LastCreatedScene: Nullable<Scene>;
  32415. /**
  32416. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32417. * @ignorenaming
  32418. */
  32419. static UseFallbackTexture: boolean;
  32420. /**
  32421. * Texture content used if a texture cannot loaded
  32422. * @ignorenaming
  32423. */
  32424. static FallbackTexture: string;
  32425. }
  32426. }
  32427. declare module "babylonjs/Misc/promise" {
  32428. /**
  32429. * Helper class that provides a small promise polyfill
  32430. */
  32431. export class PromisePolyfill {
  32432. /**
  32433. * Static function used to check if the polyfill is required
  32434. * If this is the case then the function will inject the polyfill to window.Promise
  32435. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32436. */
  32437. static Apply(force?: boolean): void;
  32438. }
  32439. }
  32440. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32441. /**
  32442. * Interface for screenshot methods with describe argument called `size` as object with options
  32443. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32444. */
  32445. export interface IScreenshotSize {
  32446. /**
  32447. * number in pixels for canvas height
  32448. */
  32449. height?: number;
  32450. /**
  32451. * multiplier allowing render at a higher or lower resolution
  32452. * If value is defined then height and width will be ignored and taken from camera
  32453. */
  32454. precision?: number;
  32455. /**
  32456. * number in pixels for canvas width
  32457. */
  32458. width?: number;
  32459. }
  32460. }
  32461. declare module "babylonjs/Misc/tools" {
  32462. import { Nullable, float } from "babylonjs/types";
  32463. import { DomManagement } from "babylonjs/Misc/domManagement";
  32464. import { WebRequest } from "babylonjs/Misc/webRequest";
  32465. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32466. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32467. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32468. import { Camera } from "babylonjs/Cameras/camera";
  32469. import { Engine } from "babylonjs/Engines/engine";
  32470. interface IColor4Like {
  32471. r: float;
  32472. g: float;
  32473. b: float;
  32474. a: float;
  32475. }
  32476. /**
  32477. * Class containing a set of static utilities functions
  32478. */
  32479. export class Tools {
  32480. /**
  32481. * Gets or sets the base URL to use to load assets
  32482. */
  32483. static BaseUrl: string;
  32484. /**
  32485. * Enable/Disable Custom HTTP Request Headers globally.
  32486. * default = false
  32487. * @see CustomRequestHeaders
  32488. */
  32489. static UseCustomRequestHeaders: boolean;
  32490. /**
  32491. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32492. * i.e. when loading files, where the server/service expects an Authorization header
  32493. */
  32494. static CustomRequestHeaders: {
  32495. [key: string]: string;
  32496. };
  32497. /**
  32498. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32499. */
  32500. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32501. /**
  32502. * Default behaviour for cors in the application.
  32503. * It can be a string if the expected behavior is identical in the entire app.
  32504. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32505. */
  32506. static CorsBehavior: string | ((url: string | string[]) => string);
  32507. /**
  32508. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32509. * @ignorenaming
  32510. */
  32511. static UseFallbackTexture: boolean;
  32512. /**
  32513. * Use this object to register external classes like custom textures or material
  32514. * to allow the laoders to instantiate them
  32515. */
  32516. static RegisteredExternalClasses: {
  32517. [key: string]: Object;
  32518. };
  32519. /**
  32520. * Texture content used if a texture cannot loaded
  32521. * @ignorenaming
  32522. */
  32523. static fallbackTexture: string;
  32524. /**
  32525. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32526. * @param u defines the coordinate on X axis
  32527. * @param v defines the coordinate on Y axis
  32528. * @param width defines the width of the source data
  32529. * @param height defines the height of the source data
  32530. * @param pixels defines the source byte array
  32531. * @param color defines the output color
  32532. */
  32533. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32534. /**
  32535. * Interpolates between a and b via alpha
  32536. * @param a The lower value (returned when alpha = 0)
  32537. * @param b The upper value (returned when alpha = 1)
  32538. * @param alpha The interpolation-factor
  32539. * @return The mixed value
  32540. */
  32541. static Mix(a: number, b: number, alpha: number): number;
  32542. /**
  32543. * Tries to instantiate a new object from a given class name
  32544. * @param className defines the class name to instantiate
  32545. * @returns the new object or null if the system was not able to do the instantiation
  32546. */
  32547. static Instantiate(className: string): any;
  32548. /**
  32549. * Provides a slice function that will work even on IE
  32550. * @param data defines the array to slice
  32551. * @param start defines the start of the data (optional)
  32552. * @param end defines the end of the data (optional)
  32553. * @returns the new sliced array
  32554. */
  32555. static Slice<T>(data: T, start?: number, end?: number): T;
  32556. /**
  32557. * Polyfill for setImmediate
  32558. * @param action defines the action to execute after the current execution block
  32559. */
  32560. static SetImmediate(action: () => void): void;
  32561. /**
  32562. * Function indicating if a number is an exponent of 2
  32563. * @param value defines the value to test
  32564. * @returns true if the value is an exponent of 2
  32565. */
  32566. static IsExponentOfTwo(value: number): boolean;
  32567. private static _tmpFloatArray;
  32568. /**
  32569. * Returns the nearest 32-bit single precision float representation of a Number
  32570. * @param value A Number. If the parameter is of a different type, it will get converted
  32571. * to a number or to NaN if it cannot be converted
  32572. * @returns number
  32573. */
  32574. static FloatRound(value: number): number;
  32575. /**
  32576. * Extracts the filename from a path
  32577. * @param path defines the path to use
  32578. * @returns the filename
  32579. */
  32580. static GetFilename(path: string): string;
  32581. /**
  32582. * Extracts the "folder" part of a path (everything before the filename).
  32583. * @param uri The URI to extract the info from
  32584. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32585. * @returns The "folder" part of the path
  32586. */
  32587. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32588. /**
  32589. * Extracts text content from a DOM element hierarchy
  32590. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32591. */
  32592. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32593. /**
  32594. * Convert an angle in radians to degrees
  32595. * @param angle defines the angle to convert
  32596. * @returns the angle in degrees
  32597. */
  32598. static ToDegrees(angle: number): number;
  32599. /**
  32600. * Convert an angle in degrees to radians
  32601. * @param angle defines the angle to convert
  32602. * @returns the angle in radians
  32603. */
  32604. static ToRadians(angle: number): number;
  32605. /**
  32606. * Encode a buffer to a base64 string
  32607. * @param buffer defines the buffer to encode
  32608. * @returns the encoded string
  32609. */
  32610. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32611. /**
  32612. * Returns an array if obj is not an array
  32613. * @param obj defines the object to evaluate as an array
  32614. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32615. * @returns either obj directly if obj is an array or a new array containing obj
  32616. */
  32617. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32618. /**
  32619. * Gets the pointer prefix to use
  32620. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32621. */
  32622. static GetPointerPrefix(): string;
  32623. /**
  32624. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32625. * @param url define the url we are trying
  32626. * @param element define the dom element where to configure the cors policy
  32627. */
  32628. static SetCorsBehavior(url: string | string[], element: {
  32629. crossOrigin: string | null;
  32630. }): void;
  32631. /**
  32632. * Removes unwanted characters from an url
  32633. * @param url defines the url to clean
  32634. * @returns the cleaned url
  32635. */
  32636. static CleanUrl(url: string): string;
  32637. /**
  32638. * Gets or sets a function used to pre-process url before using them to load assets
  32639. */
  32640. static PreprocessUrl: (url: string) => string;
  32641. /**
  32642. * Loads an image as an HTMLImageElement.
  32643. * @param input url string, ArrayBuffer, or Blob to load
  32644. * @param onLoad callback called when the image successfully loads
  32645. * @param onError callback called when the image fails to load
  32646. * @param offlineProvider offline provider for caching
  32647. * @returns the HTMLImageElement of the loaded image
  32648. */
  32649. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32650. /**
  32651. * Loads a file
  32652. * @param url url string, ArrayBuffer, or Blob to load
  32653. * @param onSuccess callback called when the file successfully loads
  32654. * @param onProgress callback called while file is loading (if the server supports this mode)
  32655. * @param offlineProvider defines the offline provider for caching
  32656. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32657. * @param onError callback called when the file fails to load
  32658. * @returns a file request object
  32659. */
  32660. 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;
  32661. /**
  32662. * Loads a file from a url
  32663. * @param url the file url to load
  32664. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32665. */
  32666. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32667. /**
  32668. * Load a script (identified by an url). When the url returns, the
  32669. * content of this file is added into a new script element, attached to the DOM (body element)
  32670. * @param scriptUrl defines the url of the script to laod
  32671. * @param onSuccess defines the callback called when the script is loaded
  32672. * @param onError defines the callback to call if an error occurs
  32673. * @param scriptId defines the id of the script element
  32674. */
  32675. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32676. /**
  32677. * Load an asynchronous script (identified by an url). When the url returns, the
  32678. * content of this file is added into a new script element, attached to the DOM (body element)
  32679. * @param scriptUrl defines the url of the script to laod
  32680. * @param scriptId defines the id of the script element
  32681. * @returns a promise request object
  32682. */
  32683. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32684. /**
  32685. * Loads a file from a blob
  32686. * @param fileToLoad defines the blob to use
  32687. * @param callback defines the callback to call when data is loaded
  32688. * @param progressCallback defines the callback to call during loading process
  32689. * @returns a file request object
  32690. */
  32691. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32692. /**
  32693. * Loads a file
  32694. * @param fileToLoad defines the file to load
  32695. * @param callback defines the callback to call when data is loaded
  32696. * @param progressCallBack defines the callback to call during loading process
  32697. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32698. * @returns a file request object
  32699. */
  32700. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32701. /**
  32702. * Creates a data url from a given string content
  32703. * @param content defines the content to convert
  32704. * @returns the new data url link
  32705. */
  32706. static FileAsURL(content: string): string;
  32707. /**
  32708. * Format the given number to a specific decimal format
  32709. * @param value defines the number to format
  32710. * @param decimals defines the number of decimals to use
  32711. * @returns the formatted string
  32712. */
  32713. static Format(value: number, decimals?: number): string;
  32714. /**
  32715. * Tries to copy an object by duplicating every property
  32716. * @param source defines the source object
  32717. * @param destination defines the target object
  32718. * @param doNotCopyList defines a list of properties to avoid
  32719. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32720. */
  32721. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32722. /**
  32723. * Gets a boolean indicating if the given object has no own property
  32724. * @param obj defines the object to test
  32725. * @returns true if object has no own property
  32726. */
  32727. static IsEmpty(obj: any): boolean;
  32728. /**
  32729. * Function used to register events at window level
  32730. * @param events defines the events to register
  32731. */
  32732. static RegisterTopRootEvents(events: {
  32733. name: string;
  32734. handler: Nullable<(e: FocusEvent) => any>;
  32735. }[]): void;
  32736. /**
  32737. * Function used to unregister events from window level
  32738. * @param events defines the events to unregister
  32739. */
  32740. static UnregisterTopRootEvents(events: {
  32741. name: string;
  32742. handler: Nullable<(e: FocusEvent) => any>;
  32743. }[]): void;
  32744. /**
  32745. * @ignore
  32746. */
  32747. static _ScreenshotCanvas: HTMLCanvasElement;
  32748. /**
  32749. * Dumps the current bound framebuffer
  32750. * @param width defines the rendering width
  32751. * @param height defines the rendering height
  32752. * @param engine defines the hosting engine
  32753. * @param successCallback defines the callback triggered once the data are available
  32754. * @param mimeType defines the mime type of the result
  32755. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32756. */
  32757. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32758. /**
  32759. * Converts the canvas data to blob.
  32760. * This acts as a polyfill for browsers not supporting the to blob function.
  32761. * @param canvas Defines the canvas to extract the data from
  32762. * @param successCallback Defines the callback triggered once the data are available
  32763. * @param mimeType Defines the mime type of the result
  32764. */
  32765. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32766. /**
  32767. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32768. * @param successCallback defines the callback triggered once the data are available
  32769. * @param mimeType defines the mime type of the result
  32770. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32771. */
  32772. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32773. /**
  32774. * Downloads a blob in the browser
  32775. * @param blob defines the blob to download
  32776. * @param fileName defines the name of the downloaded file
  32777. */
  32778. static Download(blob: Blob, fileName: string): void;
  32779. /**
  32780. * Captures a screenshot of the current rendering
  32781. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32782. * @param engine defines the rendering engine
  32783. * @param camera defines the source camera
  32784. * @param size This parameter can be set to a single number or to an object with the
  32785. * following (optional) properties: precision, width, height. If a single number is passed,
  32786. * it will be used for both width and height. If an object is passed, the screenshot size
  32787. * will be derived from the parameters. The precision property is a multiplier allowing
  32788. * rendering at a higher or lower resolution
  32789. * @param successCallback defines the callback receives a single parameter which contains the
  32790. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32791. * src parameter of an <img> to display it
  32792. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32793. * Check your browser for supported MIME types
  32794. */
  32795. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32796. /**
  32797. * Captures a screenshot of the current rendering
  32798. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32799. * @param engine defines the rendering engine
  32800. * @param camera defines the source camera
  32801. * @param size This parameter can be set to a single number or to an object with the
  32802. * following (optional) properties: precision, width, height. If a single number is passed,
  32803. * it will be used for both width and height. If an object is passed, the screenshot size
  32804. * will be derived from the parameters. The precision property is a multiplier allowing
  32805. * rendering at a higher or lower resolution
  32806. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32807. * Check your browser for supported MIME types
  32808. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32809. * to the src parameter of an <img> to display it
  32810. */
  32811. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32812. /**
  32813. * Generates an image screenshot from the specified camera.
  32814. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32815. * @param engine The engine to use for rendering
  32816. * @param camera The camera to use for rendering
  32817. * @param size This parameter can be set to a single number or to an object with the
  32818. * following (optional) properties: precision, width, height. If a single number is passed,
  32819. * it will be used for both width and height. If an object is passed, the screenshot size
  32820. * will be derived from the parameters. The precision property is a multiplier allowing
  32821. * rendering at a higher or lower resolution
  32822. * @param successCallback The callback receives a single parameter which contains the
  32823. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32824. * src parameter of an <img> to display it
  32825. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32826. * Check your browser for supported MIME types
  32827. * @param samples Texture samples (default: 1)
  32828. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32829. * @param fileName A name for for the downloaded file.
  32830. */
  32831. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32832. /**
  32833. * Generates an image screenshot from the specified camera.
  32834. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32835. * @param engine The engine to use for rendering
  32836. * @param camera The camera to use for rendering
  32837. * @param size This parameter can be set to a single number or to an object with the
  32838. * following (optional) properties: precision, width, height. If a single number is passed,
  32839. * it will be used for both width and height. If an object is passed, the screenshot size
  32840. * will be derived from the parameters. The precision property is a multiplier allowing
  32841. * rendering at a higher or lower resolution
  32842. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32843. * Check your browser for supported MIME types
  32844. * @param samples Texture samples (default: 1)
  32845. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32846. * @param fileName A name for for the downloaded file.
  32847. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32848. * to the src parameter of an <img> to display it
  32849. */
  32850. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32851. /**
  32852. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32853. * Be aware Math.random() could cause collisions, but:
  32854. * "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"
  32855. * @returns a pseudo random id
  32856. */
  32857. static RandomId(): string;
  32858. /**
  32859. * Test if the given uri is a base64 string
  32860. * @param uri The uri to test
  32861. * @return True if the uri is a base64 string or false otherwise
  32862. */
  32863. static IsBase64(uri: string): boolean;
  32864. /**
  32865. * Decode the given base64 uri.
  32866. * @param uri The uri to decode
  32867. * @return The decoded base64 data.
  32868. */
  32869. static DecodeBase64(uri: string): ArrayBuffer;
  32870. /**
  32871. * Gets the absolute url.
  32872. * @param url the input url
  32873. * @return the absolute url
  32874. */
  32875. static GetAbsoluteUrl(url: string): string;
  32876. /**
  32877. * No log
  32878. */
  32879. static readonly NoneLogLevel: number;
  32880. /**
  32881. * Only message logs
  32882. */
  32883. static readonly MessageLogLevel: number;
  32884. /**
  32885. * Only warning logs
  32886. */
  32887. static readonly WarningLogLevel: number;
  32888. /**
  32889. * Only error logs
  32890. */
  32891. static readonly ErrorLogLevel: number;
  32892. /**
  32893. * All logs
  32894. */
  32895. static readonly AllLogLevel: number;
  32896. /**
  32897. * Gets a value indicating the number of loading errors
  32898. * @ignorenaming
  32899. */
  32900. static readonly errorsCount: number;
  32901. /**
  32902. * Callback called when a new log is added
  32903. */
  32904. static OnNewCacheEntry: (entry: string) => void;
  32905. /**
  32906. * Log a message to the console
  32907. * @param message defines the message to log
  32908. */
  32909. static Log(message: string): void;
  32910. /**
  32911. * Write a warning message to the console
  32912. * @param message defines the message to log
  32913. */
  32914. static Warn(message: string): void;
  32915. /**
  32916. * Write an error message to the console
  32917. * @param message defines the message to log
  32918. */
  32919. static Error(message: string): void;
  32920. /**
  32921. * Gets current log cache (list of logs)
  32922. */
  32923. static readonly LogCache: string;
  32924. /**
  32925. * Clears the log cache
  32926. */
  32927. static ClearLogCache(): void;
  32928. /**
  32929. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32930. */
  32931. static LogLevels: number;
  32932. /**
  32933. * Checks if the window object exists
  32934. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32935. */
  32936. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32937. /**
  32938. * No performance log
  32939. */
  32940. static readonly PerformanceNoneLogLevel: number;
  32941. /**
  32942. * Use user marks to log performance
  32943. */
  32944. static readonly PerformanceUserMarkLogLevel: number;
  32945. /**
  32946. * Log performance to the console
  32947. */
  32948. static readonly PerformanceConsoleLogLevel: number;
  32949. private static _performance;
  32950. /**
  32951. * Sets the current performance log level
  32952. */
  32953. static PerformanceLogLevel: number;
  32954. private static _StartPerformanceCounterDisabled;
  32955. private static _EndPerformanceCounterDisabled;
  32956. private static _StartUserMark;
  32957. private static _EndUserMark;
  32958. private static _StartPerformanceConsole;
  32959. private static _EndPerformanceConsole;
  32960. /**
  32961. * Starts a performance counter
  32962. */
  32963. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32964. /**
  32965. * Ends a specific performance coutner
  32966. */
  32967. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32968. /**
  32969. * Gets either window.performance.now() if supported or Date.now() else
  32970. */
  32971. static readonly Now: number;
  32972. /**
  32973. * This method will return the name of the class used to create the instance of the given object.
  32974. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32975. * @param object the object to get the class name from
  32976. * @param isType defines if the object is actually a type
  32977. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32978. */
  32979. static GetClassName(object: any, isType?: boolean): string;
  32980. /**
  32981. * Gets the first element of an array satisfying a given predicate
  32982. * @param array defines the array to browse
  32983. * @param predicate defines the predicate to use
  32984. * @returns null if not found or the element
  32985. */
  32986. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32987. /**
  32988. * This method will return the name of the full name of the class, including its owning module (if any).
  32989. * 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).
  32990. * @param object the object to get the class name from
  32991. * @param isType defines if the object is actually a type
  32992. * @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.
  32993. * @ignorenaming
  32994. */
  32995. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32996. /**
  32997. * Returns a promise that resolves after the given amount of time.
  32998. * @param delay Number of milliseconds to delay
  32999. * @returns Promise that resolves after the given amount of time
  33000. */
  33001. static DelayAsync(delay: number): Promise<void>;
  33002. }
  33003. /**
  33004. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33005. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33006. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33007. * @param name The name of the class, case should be preserved
  33008. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33009. */
  33010. export function className(name: string, module?: string): (target: Object) => void;
  33011. /**
  33012. * An implementation of a loop for asynchronous functions.
  33013. */
  33014. export class AsyncLoop {
  33015. /**
  33016. * Defines the number of iterations for the loop
  33017. */
  33018. iterations: number;
  33019. /**
  33020. * Defines the current index of the loop.
  33021. */
  33022. index: number;
  33023. private _done;
  33024. private _fn;
  33025. private _successCallback;
  33026. /**
  33027. * Constructor.
  33028. * @param iterations the number of iterations.
  33029. * @param func the function to run each iteration
  33030. * @param successCallback the callback that will be called upon succesful execution
  33031. * @param offset starting offset.
  33032. */
  33033. constructor(
  33034. /**
  33035. * Defines the number of iterations for the loop
  33036. */
  33037. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33038. /**
  33039. * Execute the next iteration. Must be called after the last iteration was finished.
  33040. */
  33041. executeNext(): void;
  33042. /**
  33043. * Break the loop and run the success callback.
  33044. */
  33045. breakLoop(): void;
  33046. /**
  33047. * Create and run an async loop.
  33048. * @param iterations the number of iterations.
  33049. * @param fn the function to run each iteration
  33050. * @param successCallback the callback that will be called upon succesful execution
  33051. * @param offset starting offset.
  33052. * @returns the created async loop object
  33053. */
  33054. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33055. /**
  33056. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33057. * @param iterations total number of iterations
  33058. * @param syncedIterations number of synchronous iterations in each async iteration.
  33059. * @param fn the function to call each iteration.
  33060. * @param callback a success call back that will be called when iterating stops.
  33061. * @param breakFunction a break condition (optional)
  33062. * @param timeout timeout settings for the setTimeout function. default - 0.
  33063. * @returns the created async loop object
  33064. */
  33065. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33066. }
  33067. }
  33068. declare module "babylonjs/Collisions/collisionCoordinator" {
  33069. import { Nullable } from "babylonjs/types";
  33070. import { Scene } from "babylonjs/scene";
  33071. import { Vector3 } from "babylonjs/Maths/math.vector";
  33072. import { Collider } from "babylonjs/Collisions/collider";
  33073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33074. /** @hidden */
  33075. export interface ICollisionCoordinator {
  33076. createCollider(): Collider;
  33077. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33078. init(scene: Scene): void;
  33079. }
  33080. /** @hidden */
  33081. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33082. private _scene;
  33083. private _scaledPosition;
  33084. private _scaledVelocity;
  33085. private _finalPosition;
  33086. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33087. createCollider(): Collider;
  33088. init(scene: Scene): void;
  33089. private _collideWithWorld;
  33090. }
  33091. }
  33092. declare module "babylonjs/Inputs/scene.inputManager" {
  33093. import { Nullable } from "babylonjs/types";
  33094. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33095. import { Vector2 } from "babylonjs/Maths/math.vector";
  33096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33097. import { Scene } from "babylonjs/scene";
  33098. /**
  33099. * Class used to manage all inputs for the scene.
  33100. */
  33101. export class InputManager {
  33102. /** The distance in pixel that you have to move to prevent some events */
  33103. static DragMovementThreshold: number;
  33104. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33105. static LongPressDelay: number;
  33106. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33107. static DoubleClickDelay: number;
  33108. /** If you need to check double click without raising a single click at first click, enable this flag */
  33109. static ExclusiveDoubleClickMode: boolean;
  33110. private _wheelEventName;
  33111. private _onPointerMove;
  33112. private _onPointerDown;
  33113. private _onPointerUp;
  33114. private _initClickEvent;
  33115. private _initActionManager;
  33116. private _delayedSimpleClick;
  33117. private _delayedSimpleClickTimeout;
  33118. private _previousDelayedSimpleClickTimeout;
  33119. private _meshPickProceed;
  33120. private _previousButtonPressed;
  33121. private _currentPickResult;
  33122. private _previousPickResult;
  33123. private _totalPointersPressed;
  33124. private _doubleClickOccured;
  33125. private _pointerOverMesh;
  33126. private _pickedDownMesh;
  33127. private _pickedUpMesh;
  33128. private _pointerX;
  33129. private _pointerY;
  33130. private _unTranslatedPointerX;
  33131. private _unTranslatedPointerY;
  33132. private _startingPointerPosition;
  33133. private _previousStartingPointerPosition;
  33134. private _startingPointerTime;
  33135. private _previousStartingPointerTime;
  33136. private _pointerCaptures;
  33137. private _onKeyDown;
  33138. private _onKeyUp;
  33139. private _onCanvasFocusObserver;
  33140. private _onCanvasBlurObserver;
  33141. private _scene;
  33142. /**
  33143. * Creates a new InputManager
  33144. * @param scene defines the hosting scene
  33145. */
  33146. constructor(scene: Scene);
  33147. /**
  33148. * Gets the mesh that is currently under the pointer
  33149. */
  33150. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33151. /**
  33152. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33153. */
  33154. readonly unTranslatedPointer: Vector2;
  33155. /**
  33156. * Gets or sets the current on-screen X position of the pointer
  33157. */
  33158. pointerX: number;
  33159. /**
  33160. * Gets or sets the current on-screen Y position of the pointer
  33161. */
  33162. pointerY: number;
  33163. private _updatePointerPosition;
  33164. private _processPointerMove;
  33165. private _setRayOnPointerInfo;
  33166. private _checkPrePointerObservable;
  33167. /**
  33168. * Use this method to simulate a pointer move on a mesh
  33169. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33170. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33171. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33172. */
  33173. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33174. /**
  33175. * Use this method to simulate a pointer down on a mesh
  33176. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33177. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33178. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33179. */
  33180. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33181. private _processPointerDown;
  33182. /** @hidden */
  33183. _isPointerSwiping(): boolean;
  33184. /**
  33185. * Use this method to simulate a pointer up on a mesh
  33186. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33187. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33188. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33189. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33190. */
  33191. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33192. private _processPointerUp;
  33193. /**
  33194. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33195. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33196. * @returns true if the pointer was captured
  33197. */
  33198. isPointerCaptured(pointerId?: number): boolean;
  33199. /**
  33200. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33201. * @param attachUp defines if you want to attach events to pointerup
  33202. * @param attachDown defines if you want to attach events to pointerdown
  33203. * @param attachMove defines if you want to attach events to pointermove
  33204. */
  33205. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33206. /**
  33207. * Detaches all event handlers
  33208. */
  33209. detachControl(): void;
  33210. /**
  33211. * Force the value of meshUnderPointer
  33212. * @param mesh defines the mesh to use
  33213. */
  33214. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33215. /**
  33216. * Gets the mesh under the pointer
  33217. * @returns a Mesh or null if no mesh is under the pointer
  33218. */
  33219. getPointerOverMesh(): Nullable<AbstractMesh>;
  33220. }
  33221. }
  33222. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33223. /**
  33224. * Helper class used to generate session unique ID
  33225. */
  33226. export class UniqueIdGenerator {
  33227. private static _UniqueIdCounter;
  33228. /**
  33229. * Gets an unique (relatively to the current scene) Id
  33230. */
  33231. static readonly UniqueId: number;
  33232. }
  33233. }
  33234. declare module "babylonjs/Animations/animationGroup" {
  33235. import { Animatable } from "babylonjs/Animations/animatable";
  33236. import { Animation } from "babylonjs/Animations/animation";
  33237. import { Scene, IDisposable } from "babylonjs/scene";
  33238. import { Observable } from "babylonjs/Misc/observable";
  33239. import { Nullable } from "babylonjs/types";
  33240. import "babylonjs/Animations/animatable";
  33241. /**
  33242. * This class defines the direct association between an animation and a target
  33243. */
  33244. export class TargetedAnimation {
  33245. /**
  33246. * Animation to perform
  33247. */
  33248. animation: Animation;
  33249. /**
  33250. * Target to animate
  33251. */
  33252. target: any;
  33253. /**
  33254. * Serialize the object
  33255. * @returns the JSON object representing the current entity
  33256. */
  33257. serialize(): any;
  33258. }
  33259. /**
  33260. * Use this class to create coordinated animations on multiple targets
  33261. */
  33262. export class AnimationGroup implements IDisposable {
  33263. /** The name of the animation group */
  33264. name: string;
  33265. private _scene;
  33266. private _targetedAnimations;
  33267. private _animatables;
  33268. private _from;
  33269. private _to;
  33270. private _isStarted;
  33271. private _isPaused;
  33272. private _speedRatio;
  33273. private _loopAnimation;
  33274. /**
  33275. * Gets or sets the unique id of the node
  33276. */
  33277. uniqueId: number;
  33278. /**
  33279. * This observable will notify when one animation have ended
  33280. */
  33281. onAnimationEndObservable: Observable<TargetedAnimation>;
  33282. /**
  33283. * Observer raised when one animation loops
  33284. */
  33285. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33286. /**
  33287. * This observable will notify when all animations have ended.
  33288. */
  33289. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33290. /**
  33291. * This observable will notify when all animations have paused.
  33292. */
  33293. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33294. /**
  33295. * This observable will notify when all animations are playing.
  33296. */
  33297. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33298. /**
  33299. * Gets the first frame
  33300. */
  33301. readonly from: number;
  33302. /**
  33303. * Gets the last frame
  33304. */
  33305. readonly to: number;
  33306. /**
  33307. * Define if the animations are started
  33308. */
  33309. readonly isStarted: boolean;
  33310. /**
  33311. * Gets a value indicating that the current group is playing
  33312. */
  33313. readonly isPlaying: boolean;
  33314. /**
  33315. * Gets or sets the speed ratio to use for all animations
  33316. */
  33317. /**
  33318. * Gets or sets the speed ratio to use for all animations
  33319. */
  33320. speedRatio: number;
  33321. /**
  33322. * Gets or sets if all animations should loop or not
  33323. */
  33324. loopAnimation: boolean;
  33325. /**
  33326. * Gets the targeted animations for this animation group
  33327. */
  33328. readonly targetedAnimations: Array<TargetedAnimation>;
  33329. /**
  33330. * returning the list of animatables controlled by this animation group.
  33331. */
  33332. readonly animatables: Array<Animatable>;
  33333. /**
  33334. * Instantiates a new Animation Group.
  33335. * This helps managing several animations at once.
  33336. * @see http://doc.babylonjs.com/how_to/group
  33337. * @param name Defines the name of the group
  33338. * @param scene Defines the scene the group belongs to
  33339. */
  33340. constructor(
  33341. /** The name of the animation group */
  33342. name: string, scene?: Nullable<Scene>);
  33343. /**
  33344. * Add an animation (with its target) in the group
  33345. * @param animation defines the animation we want to add
  33346. * @param target defines the target of the animation
  33347. * @returns the TargetedAnimation object
  33348. */
  33349. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33350. /**
  33351. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33352. * It can add constant keys at begin or end
  33353. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33354. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33355. * @returns the animation group
  33356. */
  33357. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33358. /**
  33359. * Start all animations on given targets
  33360. * @param loop defines if animations must loop
  33361. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33362. * @param from defines the from key (optional)
  33363. * @param to defines the to key (optional)
  33364. * @returns the current animation group
  33365. */
  33366. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33367. /**
  33368. * Pause all animations
  33369. * @returns the animation group
  33370. */
  33371. pause(): AnimationGroup;
  33372. /**
  33373. * Play all animations to initial state
  33374. * This function will start() the animations if they were not started or will restart() them if they were paused
  33375. * @param loop defines if animations must loop
  33376. * @returns the animation group
  33377. */
  33378. play(loop?: boolean): AnimationGroup;
  33379. /**
  33380. * Reset all animations to initial state
  33381. * @returns the animation group
  33382. */
  33383. reset(): AnimationGroup;
  33384. /**
  33385. * Restart animations from key 0
  33386. * @returns the animation group
  33387. */
  33388. restart(): AnimationGroup;
  33389. /**
  33390. * Stop all animations
  33391. * @returns the animation group
  33392. */
  33393. stop(): AnimationGroup;
  33394. /**
  33395. * Set animation weight for all animatables
  33396. * @param weight defines the weight to use
  33397. * @return the animationGroup
  33398. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33399. */
  33400. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33401. /**
  33402. * Synchronize and normalize all animatables with a source animatable
  33403. * @param root defines the root animatable to synchronize with
  33404. * @return the animationGroup
  33405. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33406. */
  33407. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33408. /**
  33409. * Goes to a specific frame in this animation group
  33410. * @param frame the frame number to go to
  33411. * @return the animationGroup
  33412. */
  33413. goToFrame(frame: number): AnimationGroup;
  33414. /**
  33415. * Dispose all associated resources
  33416. */
  33417. dispose(): void;
  33418. private _checkAnimationGroupEnded;
  33419. /**
  33420. * Clone the current animation group and returns a copy
  33421. * @param newName defines the name of the new group
  33422. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33423. * @returns the new aniamtion group
  33424. */
  33425. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33426. /**
  33427. * Serializes the animationGroup to an object
  33428. * @returns Serialized object
  33429. */
  33430. serialize(): any;
  33431. /**
  33432. * Returns a new AnimationGroup object parsed from the source provided.
  33433. * @param parsedAnimationGroup defines the source
  33434. * @param scene defines the scene that will receive the animationGroup
  33435. * @returns a new AnimationGroup
  33436. */
  33437. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33438. /**
  33439. * Returns the string "AnimationGroup"
  33440. * @returns "AnimationGroup"
  33441. */
  33442. getClassName(): string;
  33443. /**
  33444. * Creates a detailled string about the object
  33445. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33446. * @returns a string representing the object
  33447. */
  33448. toString(fullDetails?: boolean): string;
  33449. }
  33450. }
  33451. declare module "babylonjs/scene" {
  33452. import { Nullable } from "babylonjs/types";
  33453. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33454. import { Observable } from "babylonjs/Misc/observable";
  33455. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33456. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33457. import { Geometry } from "babylonjs/Meshes/geometry";
  33458. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33459. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33461. import { Mesh } from "babylonjs/Meshes/mesh";
  33462. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33463. import { Bone } from "babylonjs/Bones/bone";
  33464. import { Skeleton } from "babylonjs/Bones/skeleton";
  33465. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33466. import { Camera } from "babylonjs/Cameras/camera";
  33467. import { AbstractScene } from "babylonjs/abstractScene";
  33468. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33469. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33470. import { Material } from "babylonjs/Materials/material";
  33471. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33472. import { Effect } from "babylonjs/Materials/effect";
  33473. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33474. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33475. import { Light } from "babylonjs/Lights/light";
  33476. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33477. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33478. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33479. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33480. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33481. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33482. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33483. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33484. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33485. import { Engine } from "babylonjs/Engines/engine";
  33486. import { Node } from "babylonjs/node";
  33487. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33488. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33489. import { WebRequest } from "babylonjs/Misc/webRequest";
  33490. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33491. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33492. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33493. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33494. import { Plane } from "babylonjs/Maths/math.plane";
  33495. import { Ray } from "babylonjs/Culling/ray";
  33496. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33497. import { Animation } from "babylonjs/Animations/animation";
  33498. import { Animatable } from "babylonjs/Animations/animatable";
  33499. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33500. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33501. import { Collider } from "babylonjs/Collisions/collider";
  33502. /**
  33503. * Define an interface for all classes that will hold resources
  33504. */
  33505. export interface IDisposable {
  33506. /**
  33507. * Releases all held resources
  33508. */
  33509. dispose(): void;
  33510. }
  33511. /** Interface defining initialization parameters for Scene class */
  33512. export interface SceneOptions {
  33513. /**
  33514. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33515. * It will improve performance when the number of geometries becomes important.
  33516. */
  33517. useGeometryUniqueIdsMap?: boolean;
  33518. /**
  33519. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33520. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33521. */
  33522. useMaterialMeshMap?: boolean;
  33523. /**
  33524. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33525. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33526. */
  33527. useClonedMeshhMap?: boolean;
  33528. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33529. virtual?: boolean;
  33530. }
  33531. /**
  33532. * Represents a scene to be rendered by the engine.
  33533. * @see http://doc.babylonjs.com/features/scene
  33534. */
  33535. export class Scene extends AbstractScene implements IAnimatable {
  33536. /** The fog is deactivated */
  33537. static readonly FOGMODE_NONE: number;
  33538. /** The fog density is following an exponential function */
  33539. static readonly FOGMODE_EXP: number;
  33540. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33541. static readonly FOGMODE_EXP2: number;
  33542. /** The fog density is following a linear function. */
  33543. static readonly FOGMODE_LINEAR: number;
  33544. /**
  33545. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33546. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33547. */
  33548. static MinDeltaTime: number;
  33549. /**
  33550. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33551. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33552. */
  33553. static MaxDeltaTime: number;
  33554. /**
  33555. * Factory used to create the default material.
  33556. * @param name The name of the material to create
  33557. * @param scene The scene to create the material for
  33558. * @returns The default material
  33559. */
  33560. static DefaultMaterialFactory(scene: Scene): Material;
  33561. /**
  33562. * Factory used to create the a collision coordinator.
  33563. * @returns The collision coordinator
  33564. */
  33565. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33566. /** @hidden */
  33567. _inputManager: InputManager;
  33568. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33569. cameraToUseForPointers: Nullable<Camera>;
  33570. /** @hidden */
  33571. readonly _isScene: boolean;
  33572. /**
  33573. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33574. */
  33575. autoClear: boolean;
  33576. /**
  33577. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33578. */
  33579. autoClearDepthAndStencil: boolean;
  33580. /**
  33581. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33582. */
  33583. clearColor: Color4;
  33584. /**
  33585. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33586. */
  33587. ambientColor: Color3;
  33588. /**
  33589. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33590. * It should only be one of the following (if not the default embedded one):
  33591. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33592. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33593. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33594. * The material properties need to be setup according to the type of texture in use.
  33595. */
  33596. environmentBRDFTexture: BaseTexture;
  33597. /** @hidden */
  33598. protected _environmentTexture: Nullable<BaseTexture>;
  33599. /**
  33600. * Texture used in all pbr material as the reflection texture.
  33601. * As in the majority of the scene they are the same (exception for multi room and so on),
  33602. * this is easier to reference from here than from all the materials.
  33603. */
  33604. /**
  33605. * Texture used in all pbr material as the reflection texture.
  33606. * As in the majority of the scene they are the same (exception for multi room and so on),
  33607. * this is easier to set here than in all the materials.
  33608. */
  33609. environmentTexture: Nullable<BaseTexture>;
  33610. /** @hidden */
  33611. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33612. /**
  33613. * Default image processing configuration used either in the rendering
  33614. * Forward main pass or through the imageProcessingPostProcess if present.
  33615. * As in the majority of the scene they are the same (exception for multi camera),
  33616. * this is easier to reference from here than from all the materials and post process.
  33617. *
  33618. * No setter as we it is a shared configuration, you can set the values instead.
  33619. */
  33620. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33621. private _forceWireframe;
  33622. /**
  33623. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33624. */
  33625. forceWireframe: boolean;
  33626. private _forcePointsCloud;
  33627. /**
  33628. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33629. */
  33630. forcePointsCloud: boolean;
  33631. /**
  33632. * Gets or sets the active clipplane 1
  33633. */
  33634. clipPlane: Nullable<Plane>;
  33635. /**
  33636. * Gets or sets the active clipplane 2
  33637. */
  33638. clipPlane2: Nullable<Plane>;
  33639. /**
  33640. * Gets or sets the active clipplane 3
  33641. */
  33642. clipPlane3: Nullable<Plane>;
  33643. /**
  33644. * Gets or sets the active clipplane 4
  33645. */
  33646. clipPlane4: Nullable<Plane>;
  33647. /**
  33648. * Gets or sets a boolean indicating if animations are enabled
  33649. */
  33650. animationsEnabled: boolean;
  33651. private _animationPropertiesOverride;
  33652. /**
  33653. * Gets or sets the animation properties override
  33654. */
  33655. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33656. /**
  33657. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33658. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33659. */
  33660. useConstantAnimationDeltaTime: boolean;
  33661. /**
  33662. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33663. * Please note that it requires to run a ray cast through the scene on every frame
  33664. */
  33665. constantlyUpdateMeshUnderPointer: boolean;
  33666. /**
  33667. * Defines the HTML cursor to use when hovering over interactive elements
  33668. */
  33669. hoverCursor: string;
  33670. /**
  33671. * Defines the HTML default cursor to use (empty by default)
  33672. */
  33673. defaultCursor: string;
  33674. /**
  33675. * This is used to call preventDefault() on pointer down
  33676. * in order to block unwanted artifacts like system double clicks
  33677. */
  33678. preventDefaultOnPointerDown: boolean;
  33679. /**
  33680. * This is used to call preventDefault() on pointer up
  33681. * in order to block unwanted artifacts like system double clicks
  33682. */
  33683. preventDefaultOnPointerUp: boolean;
  33684. /**
  33685. * Gets or sets user defined metadata
  33686. */
  33687. metadata: any;
  33688. /**
  33689. * For internal use only. Please do not use.
  33690. */
  33691. reservedDataStore: any;
  33692. /**
  33693. * Gets the name of the plugin used to load this scene (null by default)
  33694. */
  33695. loadingPluginName: string;
  33696. /**
  33697. * Use this array to add regular expressions used to disable offline support for specific urls
  33698. */
  33699. disableOfflineSupportExceptionRules: RegExp[];
  33700. /**
  33701. * An event triggered when the scene is disposed.
  33702. */
  33703. onDisposeObservable: Observable<Scene>;
  33704. private _onDisposeObserver;
  33705. /** Sets a function to be executed when this scene is disposed. */
  33706. onDispose: () => void;
  33707. /**
  33708. * An event triggered before rendering the scene (right after animations and physics)
  33709. */
  33710. onBeforeRenderObservable: Observable<Scene>;
  33711. private _onBeforeRenderObserver;
  33712. /** Sets a function to be executed before rendering this scene */
  33713. beforeRender: Nullable<() => void>;
  33714. /**
  33715. * An event triggered after rendering the scene
  33716. */
  33717. onAfterRenderObservable: Observable<Scene>;
  33718. /**
  33719. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33720. */
  33721. onAfterRenderCameraObservable: Observable<Camera>;
  33722. private _onAfterRenderObserver;
  33723. /** Sets a function to be executed after rendering this scene */
  33724. afterRender: Nullable<() => void>;
  33725. /**
  33726. * An event triggered before animating the scene
  33727. */
  33728. onBeforeAnimationsObservable: Observable<Scene>;
  33729. /**
  33730. * An event triggered after animations processing
  33731. */
  33732. onAfterAnimationsObservable: Observable<Scene>;
  33733. /**
  33734. * An event triggered before draw calls are ready to be sent
  33735. */
  33736. onBeforeDrawPhaseObservable: Observable<Scene>;
  33737. /**
  33738. * An event triggered after draw calls have been sent
  33739. */
  33740. onAfterDrawPhaseObservable: Observable<Scene>;
  33741. /**
  33742. * An event triggered when the scene is ready
  33743. */
  33744. onReadyObservable: Observable<Scene>;
  33745. /**
  33746. * An event triggered before rendering a camera
  33747. */
  33748. onBeforeCameraRenderObservable: Observable<Camera>;
  33749. private _onBeforeCameraRenderObserver;
  33750. /** Sets a function to be executed before rendering a camera*/
  33751. beforeCameraRender: () => void;
  33752. /**
  33753. * An event triggered after rendering a camera
  33754. */
  33755. onAfterCameraRenderObservable: Observable<Camera>;
  33756. private _onAfterCameraRenderObserver;
  33757. /** Sets a function to be executed after rendering a camera*/
  33758. afterCameraRender: () => void;
  33759. /**
  33760. * An event triggered when active meshes evaluation is about to start
  33761. */
  33762. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33763. /**
  33764. * An event triggered when active meshes evaluation is done
  33765. */
  33766. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33767. /**
  33768. * An event triggered when particles rendering is about to start
  33769. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33770. */
  33771. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33772. /**
  33773. * An event triggered when particles rendering is done
  33774. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33775. */
  33776. onAfterParticlesRenderingObservable: Observable<Scene>;
  33777. /**
  33778. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33779. */
  33780. onDataLoadedObservable: Observable<Scene>;
  33781. /**
  33782. * An event triggered when a camera is created
  33783. */
  33784. onNewCameraAddedObservable: Observable<Camera>;
  33785. /**
  33786. * An event triggered when a camera is removed
  33787. */
  33788. onCameraRemovedObservable: Observable<Camera>;
  33789. /**
  33790. * An event triggered when a light is created
  33791. */
  33792. onNewLightAddedObservable: Observable<Light>;
  33793. /**
  33794. * An event triggered when a light is removed
  33795. */
  33796. onLightRemovedObservable: Observable<Light>;
  33797. /**
  33798. * An event triggered when a geometry is created
  33799. */
  33800. onNewGeometryAddedObservable: Observable<Geometry>;
  33801. /**
  33802. * An event triggered when a geometry is removed
  33803. */
  33804. onGeometryRemovedObservable: Observable<Geometry>;
  33805. /**
  33806. * An event triggered when a transform node is created
  33807. */
  33808. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33809. /**
  33810. * An event triggered when a transform node is removed
  33811. */
  33812. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33813. /**
  33814. * An event triggered when a mesh is created
  33815. */
  33816. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33817. /**
  33818. * An event triggered when a mesh is removed
  33819. */
  33820. onMeshRemovedObservable: Observable<AbstractMesh>;
  33821. /**
  33822. * An event triggered when a skeleton is created
  33823. */
  33824. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33825. /**
  33826. * An event triggered when a skeleton is removed
  33827. */
  33828. onSkeletonRemovedObservable: Observable<Skeleton>;
  33829. /**
  33830. * An event triggered when a material is created
  33831. */
  33832. onNewMaterialAddedObservable: Observable<Material>;
  33833. /**
  33834. * An event triggered when a material is removed
  33835. */
  33836. onMaterialRemovedObservable: Observable<Material>;
  33837. /**
  33838. * An event triggered when a texture is created
  33839. */
  33840. onNewTextureAddedObservable: Observable<BaseTexture>;
  33841. /**
  33842. * An event triggered when a texture is removed
  33843. */
  33844. onTextureRemovedObservable: Observable<BaseTexture>;
  33845. /**
  33846. * An event triggered when render targets are about to be rendered
  33847. * Can happen multiple times per frame.
  33848. */
  33849. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33850. /**
  33851. * An event triggered when render targets were rendered.
  33852. * Can happen multiple times per frame.
  33853. */
  33854. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33855. /**
  33856. * An event triggered before calculating deterministic simulation step
  33857. */
  33858. onBeforeStepObservable: Observable<Scene>;
  33859. /**
  33860. * An event triggered after calculating deterministic simulation step
  33861. */
  33862. onAfterStepObservable: Observable<Scene>;
  33863. /**
  33864. * An event triggered when the activeCamera property is updated
  33865. */
  33866. onActiveCameraChanged: Observable<Scene>;
  33867. /**
  33868. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33869. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33870. * 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)
  33871. */
  33872. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33873. /**
  33874. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33875. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33876. * 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)
  33877. */
  33878. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33879. /**
  33880. * This Observable will when a mesh has been imported into the scene.
  33881. */
  33882. onMeshImportedObservable: Observable<AbstractMesh>;
  33883. /**
  33884. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33885. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33886. */
  33887. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33888. /** @hidden */
  33889. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33890. /**
  33891. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33892. */
  33893. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33894. /**
  33895. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33896. */
  33897. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33898. /**
  33899. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33900. */
  33901. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33902. /** Callback called when a pointer move is detected */
  33903. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33904. /** Callback called when a pointer down is detected */
  33905. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33906. /** Callback called when a pointer up is detected */
  33907. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33908. /** Callback called when a pointer pick is detected */
  33909. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33910. /**
  33911. * 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).
  33912. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33913. */
  33914. onPrePointerObservable: Observable<PointerInfoPre>;
  33915. /**
  33916. * Observable event triggered each time an input event is received from the rendering canvas
  33917. */
  33918. onPointerObservable: Observable<PointerInfo>;
  33919. /**
  33920. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33921. */
  33922. readonly unTranslatedPointer: Vector2;
  33923. /**
  33924. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33925. */
  33926. static DragMovementThreshold: number;
  33927. /**
  33928. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33929. */
  33930. static LongPressDelay: number;
  33931. /**
  33932. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33933. */
  33934. static DoubleClickDelay: number;
  33935. /** If you need to check double click without raising a single click at first click, enable this flag */
  33936. static ExclusiveDoubleClickMode: boolean;
  33937. /** @hidden */
  33938. _mirroredCameraPosition: Nullable<Vector3>;
  33939. /**
  33940. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33941. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33942. */
  33943. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33944. /**
  33945. * Observable event triggered each time an keyboard event is received from the hosting window
  33946. */
  33947. onKeyboardObservable: Observable<KeyboardInfo>;
  33948. private _useRightHandedSystem;
  33949. /**
  33950. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33951. */
  33952. useRightHandedSystem: boolean;
  33953. private _timeAccumulator;
  33954. private _currentStepId;
  33955. private _currentInternalStep;
  33956. /**
  33957. * Sets the step Id used by deterministic lock step
  33958. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33959. * @param newStepId defines the step Id
  33960. */
  33961. setStepId(newStepId: number): void;
  33962. /**
  33963. * Gets the step Id used by deterministic lock step
  33964. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33965. * @returns the step Id
  33966. */
  33967. getStepId(): number;
  33968. /**
  33969. * Gets the internal step used by deterministic lock step
  33970. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33971. * @returns the internal step
  33972. */
  33973. getInternalStep(): number;
  33974. private _fogEnabled;
  33975. /**
  33976. * Gets or sets a boolean indicating if fog is enabled on this scene
  33977. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33978. * (Default is true)
  33979. */
  33980. fogEnabled: boolean;
  33981. private _fogMode;
  33982. /**
  33983. * Gets or sets the fog mode to use
  33984. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33985. * | mode | value |
  33986. * | --- | --- |
  33987. * | FOGMODE_NONE | 0 |
  33988. * | FOGMODE_EXP | 1 |
  33989. * | FOGMODE_EXP2 | 2 |
  33990. * | FOGMODE_LINEAR | 3 |
  33991. */
  33992. fogMode: number;
  33993. /**
  33994. * Gets or sets the fog color to use
  33995. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33996. * (Default is Color3(0.2, 0.2, 0.3))
  33997. */
  33998. fogColor: Color3;
  33999. /**
  34000. * Gets or sets the fog density to use
  34001. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34002. * (Default is 0.1)
  34003. */
  34004. fogDensity: number;
  34005. /**
  34006. * Gets or sets the fog start distance to use
  34007. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34008. * (Default is 0)
  34009. */
  34010. fogStart: number;
  34011. /**
  34012. * Gets or sets the fog end distance to use
  34013. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34014. * (Default is 1000)
  34015. */
  34016. fogEnd: number;
  34017. private _shadowsEnabled;
  34018. /**
  34019. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34020. */
  34021. shadowsEnabled: boolean;
  34022. private _lightsEnabled;
  34023. /**
  34024. * Gets or sets a boolean indicating if lights are enabled on this scene
  34025. */
  34026. lightsEnabled: boolean;
  34027. /** All of the active cameras added to this scene. */
  34028. activeCameras: Camera[];
  34029. /** @hidden */
  34030. _activeCamera: Nullable<Camera>;
  34031. /** Gets or sets the current active camera */
  34032. activeCamera: Nullable<Camera>;
  34033. private _defaultMaterial;
  34034. /** The default material used on meshes when no material is affected */
  34035. /** The default material used on meshes when no material is affected */
  34036. defaultMaterial: Material;
  34037. private _texturesEnabled;
  34038. /**
  34039. * Gets or sets a boolean indicating if textures are enabled on this scene
  34040. */
  34041. texturesEnabled: boolean;
  34042. /**
  34043. * Gets or sets a boolean indicating if particles are enabled on this scene
  34044. */
  34045. particlesEnabled: boolean;
  34046. /**
  34047. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34048. */
  34049. spritesEnabled: boolean;
  34050. private _skeletonsEnabled;
  34051. /**
  34052. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34053. */
  34054. skeletonsEnabled: boolean;
  34055. /**
  34056. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34057. */
  34058. lensFlaresEnabled: boolean;
  34059. /**
  34060. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34061. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34062. */
  34063. collisionsEnabled: boolean;
  34064. private _collisionCoordinator;
  34065. /** @hidden */
  34066. readonly collisionCoordinator: ICollisionCoordinator;
  34067. /**
  34068. * Defines the gravity applied to this scene (used only for collisions)
  34069. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34070. */
  34071. gravity: Vector3;
  34072. /**
  34073. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34074. */
  34075. postProcessesEnabled: boolean;
  34076. /**
  34077. * The list of postprocesses added to the scene
  34078. */
  34079. postProcesses: PostProcess[];
  34080. /**
  34081. * Gets the current postprocess manager
  34082. */
  34083. postProcessManager: PostProcessManager;
  34084. /**
  34085. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34086. */
  34087. renderTargetsEnabled: boolean;
  34088. /**
  34089. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34090. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34091. */
  34092. dumpNextRenderTargets: boolean;
  34093. /**
  34094. * The list of user defined render targets added to the scene
  34095. */
  34096. customRenderTargets: RenderTargetTexture[];
  34097. /**
  34098. * Defines if texture loading must be delayed
  34099. * If true, textures will only be loaded when they need to be rendered
  34100. */
  34101. useDelayedTextureLoading: boolean;
  34102. /**
  34103. * Gets the list of meshes imported to the scene through SceneLoader
  34104. */
  34105. importedMeshesFiles: String[];
  34106. /**
  34107. * Gets or sets a boolean indicating if probes are enabled on this scene
  34108. */
  34109. probesEnabled: boolean;
  34110. /**
  34111. * Gets or sets the current offline provider to use to store scene data
  34112. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34113. */
  34114. offlineProvider: IOfflineProvider;
  34115. /**
  34116. * Gets or sets the action manager associated with the scene
  34117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34118. */
  34119. actionManager: AbstractActionManager;
  34120. private _meshesForIntersections;
  34121. /**
  34122. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34123. */
  34124. proceduralTexturesEnabled: boolean;
  34125. private _engine;
  34126. private _totalVertices;
  34127. /** @hidden */
  34128. _activeIndices: PerfCounter;
  34129. /** @hidden */
  34130. _activeParticles: PerfCounter;
  34131. /** @hidden */
  34132. _activeBones: PerfCounter;
  34133. private _animationRatio;
  34134. /** @hidden */
  34135. _animationTimeLast: number;
  34136. /** @hidden */
  34137. _animationTime: number;
  34138. /**
  34139. * Gets or sets a general scale for animation speed
  34140. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34141. */
  34142. animationTimeScale: number;
  34143. /** @hidden */
  34144. _cachedMaterial: Nullable<Material>;
  34145. /** @hidden */
  34146. _cachedEffect: Nullable<Effect>;
  34147. /** @hidden */
  34148. _cachedVisibility: Nullable<number>;
  34149. private _renderId;
  34150. private _frameId;
  34151. private _executeWhenReadyTimeoutId;
  34152. private _intermediateRendering;
  34153. private _viewUpdateFlag;
  34154. private _projectionUpdateFlag;
  34155. /** @hidden */
  34156. _toBeDisposed: Nullable<IDisposable>[];
  34157. private _activeRequests;
  34158. /** @hidden */
  34159. _pendingData: any[];
  34160. private _isDisposed;
  34161. /**
  34162. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34163. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34164. */
  34165. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34166. private _activeMeshes;
  34167. private _processedMaterials;
  34168. private _renderTargets;
  34169. /** @hidden */
  34170. _activeParticleSystems: SmartArray<IParticleSystem>;
  34171. private _activeSkeletons;
  34172. private _softwareSkinnedMeshes;
  34173. private _renderingManager;
  34174. /** @hidden */
  34175. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34176. private _transformMatrix;
  34177. private _sceneUbo;
  34178. /** @hidden */
  34179. _viewMatrix: Matrix;
  34180. private _projectionMatrix;
  34181. /** @hidden */
  34182. _forcedViewPosition: Nullable<Vector3>;
  34183. /** @hidden */
  34184. _frustumPlanes: Plane[];
  34185. /**
  34186. * Gets the list of frustum planes (built from the active camera)
  34187. */
  34188. readonly frustumPlanes: Plane[];
  34189. /**
  34190. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34191. * This is useful if there are more lights that the maximum simulteanous authorized
  34192. */
  34193. requireLightSorting: boolean;
  34194. /** @hidden */
  34195. readonly useMaterialMeshMap: boolean;
  34196. /** @hidden */
  34197. readonly useClonedMeshhMap: boolean;
  34198. private _externalData;
  34199. private _uid;
  34200. /**
  34201. * @hidden
  34202. * Backing store of defined scene components.
  34203. */
  34204. _components: ISceneComponent[];
  34205. /**
  34206. * @hidden
  34207. * Backing store of defined scene components.
  34208. */
  34209. _serializableComponents: ISceneSerializableComponent[];
  34210. /**
  34211. * List of components to register on the next registration step.
  34212. */
  34213. private _transientComponents;
  34214. /**
  34215. * Registers the transient components if needed.
  34216. */
  34217. private _registerTransientComponents;
  34218. /**
  34219. * @hidden
  34220. * Add a component to the scene.
  34221. * Note that the ccomponent could be registered on th next frame if this is called after
  34222. * the register component stage.
  34223. * @param component Defines the component to add to the scene
  34224. */
  34225. _addComponent(component: ISceneComponent): void;
  34226. /**
  34227. * @hidden
  34228. * Gets a component from the scene.
  34229. * @param name defines the name of the component to retrieve
  34230. * @returns the component or null if not present
  34231. */
  34232. _getComponent(name: string): Nullable<ISceneComponent>;
  34233. /**
  34234. * @hidden
  34235. * Defines the actions happening before camera updates.
  34236. */
  34237. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34238. /**
  34239. * @hidden
  34240. * Defines the actions happening before clear the canvas.
  34241. */
  34242. _beforeClearStage: Stage<SimpleStageAction>;
  34243. /**
  34244. * @hidden
  34245. * Defines the actions when collecting render targets for the frame.
  34246. */
  34247. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34248. /**
  34249. * @hidden
  34250. * Defines the actions happening for one camera in the frame.
  34251. */
  34252. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34253. /**
  34254. * @hidden
  34255. * Defines the actions happening during the per mesh ready checks.
  34256. */
  34257. _isReadyForMeshStage: Stage<MeshStageAction>;
  34258. /**
  34259. * @hidden
  34260. * Defines the actions happening before evaluate active mesh checks.
  34261. */
  34262. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34263. /**
  34264. * @hidden
  34265. * Defines the actions happening during the evaluate sub mesh checks.
  34266. */
  34267. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34268. /**
  34269. * @hidden
  34270. * Defines the actions happening during the active mesh stage.
  34271. */
  34272. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34273. /**
  34274. * @hidden
  34275. * Defines the actions happening during the per camera render target step.
  34276. */
  34277. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34278. /**
  34279. * @hidden
  34280. * Defines the actions happening just before the active camera is drawing.
  34281. */
  34282. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34283. /**
  34284. * @hidden
  34285. * Defines the actions happening just before a render target is drawing.
  34286. */
  34287. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34288. /**
  34289. * @hidden
  34290. * Defines the actions happening just before a rendering group is drawing.
  34291. */
  34292. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34293. /**
  34294. * @hidden
  34295. * Defines the actions happening just before a mesh is drawing.
  34296. */
  34297. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34298. /**
  34299. * @hidden
  34300. * Defines the actions happening just after a mesh has been drawn.
  34301. */
  34302. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34303. /**
  34304. * @hidden
  34305. * Defines the actions happening just after a rendering group has been drawn.
  34306. */
  34307. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34308. /**
  34309. * @hidden
  34310. * Defines the actions happening just after the active camera has been drawn.
  34311. */
  34312. _afterCameraDrawStage: Stage<CameraStageAction>;
  34313. /**
  34314. * @hidden
  34315. * Defines the actions happening just after a render target has been drawn.
  34316. */
  34317. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34318. /**
  34319. * @hidden
  34320. * Defines the actions happening just after rendering all cameras and computing intersections.
  34321. */
  34322. _afterRenderStage: Stage<SimpleStageAction>;
  34323. /**
  34324. * @hidden
  34325. * Defines the actions happening when a pointer move event happens.
  34326. */
  34327. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34328. /**
  34329. * @hidden
  34330. * Defines the actions happening when a pointer down event happens.
  34331. */
  34332. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34333. /**
  34334. * @hidden
  34335. * Defines the actions happening when a pointer up event happens.
  34336. */
  34337. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34338. /**
  34339. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34340. */
  34341. private geometriesByUniqueId;
  34342. /**
  34343. * Creates a new Scene
  34344. * @param engine defines the engine to use to render this scene
  34345. * @param options defines the scene options
  34346. */
  34347. constructor(engine: Engine, options?: SceneOptions);
  34348. /**
  34349. * Gets a string idenfifying the name of the class
  34350. * @returns "Scene" string
  34351. */
  34352. getClassName(): string;
  34353. private _defaultMeshCandidates;
  34354. /**
  34355. * @hidden
  34356. */
  34357. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34358. private _defaultSubMeshCandidates;
  34359. /**
  34360. * @hidden
  34361. */
  34362. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34363. /**
  34364. * Sets the default candidate providers for the scene.
  34365. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34366. * and getCollidingSubMeshCandidates to their default function
  34367. */
  34368. setDefaultCandidateProviders(): void;
  34369. /**
  34370. * Gets the mesh that is currently under the pointer
  34371. */
  34372. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34373. /**
  34374. * Gets or sets the current on-screen X position of the pointer
  34375. */
  34376. pointerX: number;
  34377. /**
  34378. * Gets or sets the current on-screen Y position of the pointer
  34379. */
  34380. pointerY: number;
  34381. /**
  34382. * Gets the cached material (ie. the latest rendered one)
  34383. * @returns the cached material
  34384. */
  34385. getCachedMaterial(): Nullable<Material>;
  34386. /**
  34387. * Gets the cached effect (ie. the latest rendered one)
  34388. * @returns the cached effect
  34389. */
  34390. getCachedEffect(): Nullable<Effect>;
  34391. /**
  34392. * Gets the cached visibility state (ie. the latest rendered one)
  34393. * @returns the cached visibility state
  34394. */
  34395. getCachedVisibility(): Nullable<number>;
  34396. /**
  34397. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34398. * @param material defines the current material
  34399. * @param effect defines the current effect
  34400. * @param visibility defines the current visibility state
  34401. * @returns true if one parameter is not cached
  34402. */
  34403. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34404. /**
  34405. * Gets the engine associated with the scene
  34406. * @returns an Engine
  34407. */
  34408. getEngine(): Engine;
  34409. /**
  34410. * Gets the total number of vertices rendered per frame
  34411. * @returns the total number of vertices rendered per frame
  34412. */
  34413. getTotalVertices(): number;
  34414. /**
  34415. * Gets the performance counter for total vertices
  34416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34417. */
  34418. readonly totalVerticesPerfCounter: PerfCounter;
  34419. /**
  34420. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34421. * @returns the total number of active indices rendered per frame
  34422. */
  34423. getActiveIndices(): number;
  34424. /**
  34425. * Gets the performance counter for active indices
  34426. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34427. */
  34428. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34429. /**
  34430. * Gets the total number of active particles rendered per frame
  34431. * @returns the total number of active particles rendered per frame
  34432. */
  34433. getActiveParticles(): number;
  34434. /**
  34435. * Gets the performance counter for active particles
  34436. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34437. */
  34438. readonly activeParticlesPerfCounter: PerfCounter;
  34439. /**
  34440. * Gets the total number of active bones rendered per frame
  34441. * @returns the total number of active bones rendered per frame
  34442. */
  34443. getActiveBones(): number;
  34444. /**
  34445. * Gets the performance counter for active bones
  34446. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34447. */
  34448. readonly activeBonesPerfCounter: PerfCounter;
  34449. /**
  34450. * Gets the array of active meshes
  34451. * @returns an array of AbstractMesh
  34452. */
  34453. getActiveMeshes(): SmartArray<AbstractMesh>;
  34454. /**
  34455. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34456. * @returns a number
  34457. */
  34458. getAnimationRatio(): number;
  34459. /**
  34460. * Gets an unique Id for the current render phase
  34461. * @returns a number
  34462. */
  34463. getRenderId(): number;
  34464. /**
  34465. * Gets an unique Id for the current frame
  34466. * @returns a number
  34467. */
  34468. getFrameId(): number;
  34469. /** Call this function if you want to manually increment the render Id*/
  34470. incrementRenderId(): void;
  34471. private _createUbo;
  34472. /**
  34473. * Use this method to simulate a pointer move on a mesh
  34474. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34475. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34476. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34477. * @returns the current scene
  34478. */
  34479. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34480. /**
  34481. * Use this method to simulate a pointer down on a mesh
  34482. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34483. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34484. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34485. * @returns the current scene
  34486. */
  34487. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34488. /**
  34489. * Use this method to simulate a pointer up on a mesh
  34490. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34491. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34492. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34493. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34494. * @returns the current scene
  34495. */
  34496. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34497. /**
  34498. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34499. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34500. * @returns true if the pointer was captured
  34501. */
  34502. isPointerCaptured(pointerId?: number): boolean;
  34503. /**
  34504. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34505. * @param attachUp defines if you want to attach events to pointerup
  34506. * @param attachDown defines if you want to attach events to pointerdown
  34507. * @param attachMove defines if you want to attach events to pointermove
  34508. */
  34509. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34510. /** Detaches all event handlers*/
  34511. detachControl(): void;
  34512. /**
  34513. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34514. * Delay loaded resources are not taking in account
  34515. * @return true if all required resources are ready
  34516. */
  34517. isReady(): boolean;
  34518. /** Resets all cached information relative to material (including effect and visibility) */
  34519. resetCachedMaterial(): void;
  34520. /**
  34521. * Registers a function to be called before every frame render
  34522. * @param func defines the function to register
  34523. */
  34524. registerBeforeRender(func: () => void): void;
  34525. /**
  34526. * Unregisters a function called before every frame render
  34527. * @param func defines the function to unregister
  34528. */
  34529. unregisterBeforeRender(func: () => void): void;
  34530. /**
  34531. * Registers a function to be called after every frame render
  34532. * @param func defines the function to register
  34533. */
  34534. registerAfterRender(func: () => void): void;
  34535. /**
  34536. * Unregisters a function called after every frame render
  34537. * @param func defines the function to unregister
  34538. */
  34539. unregisterAfterRender(func: () => void): void;
  34540. private _executeOnceBeforeRender;
  34541. /**
  34542. * The provided function will run before render once and will be disposed afterwards.
  34543. * A timeout delay can be provided so that the function will be executed in N ms.
  34544. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34545. * @param func The function to be executed.
  34546. * @param timeout optional delay in ms
  34547. */
  34548. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34549. /** @hidden */
  34550. _addPendingData(data: any): void;
  34551. /** @hidden */
  34552. _removePendingData(data: any): void;
  34553. /**
  34554. * Returns the number of items waiting to be loaded
  34555. * @returns the number of items waiting to be loaded
  34556. */
  34557. getWaitingItemsCount(): number;
  34558. /**
  34559. * Returns a boolean indicating if the scene is still loading data
  34560. */
  34561. readonly isLoading: boolean;
  34562. /**
  34563. * Registers a function to be executed when the scene is ready
  34564. * @param {Function} func - the function to be executed
  34565. */
  34566. executeWhenReady(func: () => void): void;
  34567. /**
  34568. * Returns a promise that resolves when the scene is ready
  34569. * @returns A promise that resolves when the scene is ready
  34570. */
  34571. whenReadyAsync(): Promise<void>;
  34572. /** @hidden */
  34573. _checkIsReady(): void;
  34574. /**
  34575. * Gets all animatable attached to the scene
  34576. */
  34577. readonly animatables: Animatable[];
  34578. /**
  34579. * Resets the last animation time frame.
  34580. * Useful to override when animations start running when loading a scene for the first time.
  34581. */
  34582. resetLastAnimationTimeFrame(): void;
  34583. /**
  34584. * Gets the current view matrix
  34585. * @returns a Matrix
  34586. */
  34587. getViewMatrix(): Matrix;
  34588. /**
  34589. * Gets the current projection matrix
  34590. * @returns a Matrix
  34591. */
  34592. getProjectionMatrix(): Matrix;
  34593. /**
  34594. * Gets the current transform matrix
  34595. * @returns a Matrix made of View * Projection
  34596. */
  34597. getTransformMatrix(): Matrix;
  34598. /**
  34599. * Sets the current transform matrix
  34600. * @param viewL defines the View matrix to use
  34601. * @param projectionL defines the Projection matrix to use
  34602. * @param viewR defines the right View matrix to use (if provided)
  34603. * @param projectionR defines the right Projection matrix to use (if provided)
  34604. */
  34605. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34606. /**
  34607. * Gets the uniform buffer used to store scene data
  34608. * @returns a UniformBuffer
  34609. */
  34610. getSceneUniformBuffer(): UniformBuffer;
  34611. /**
  34612. * Gets an unique (relatively to the current scene) Id
  34613. * @returns an unique number for the scene
  34614. */
  34615. getUniqueId(): number;
  34616. /**
  34617. * Add a mesh to the list of scene's meshes
  34618. * @param newMesh defines the mesh to add
  34619. * @param recursive if all child meshes should also be added to the scene
  34620. */
  34621. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34622. /**
  34623. * Remove a mesh for the list of scene's meshes
  34624. * @param toRemove defines the mesh to remove
  34625. * @param recursive if all child meshes should also be removed from the scene
  34626. * @returns the index where the mesh was in the mesh list
  34627. */
  34628. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34629. /**
  34630. * Add a transform node to the list of scene's transform nodes
  34631. * @param newTransformNode defines the transform node to add
  34632. */
  34633. addTransformNode(newTransformNode: TransformNode): void;
  34634. /**
  34635. * Remove a transform node for the list of scene's transform nodes
  34636. * @param toRemove defines the transform node to remove
  34637. * @returns the index where the transform node was in the transform node list
  34638. */
  34639. removeTransformNode(toRemove: TransformNode): number;
  34640. /**
  34641. * Remove a skeleton for the list of scene's skeletons
  34642. * @param toRemove defines the skeleton to remove
  34643. * @returns the index where the skeleton was in the skeleton list
  34644. */
  34645. removeSkeleton(toRemove: Skeleton): number;
  34646. /**
  34647. * Remove a morph target for the list of scene's morph targets
  34648. * @param toRemove defines the morph target to remove
  34649. * @returns the index where the morph target was in the morph target list
  34650. */
  34651. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34652. /**
  34653. * Remove a light for the list of scene's lights
  34654. * @param toRemove defines the light to remove
  34655. * @returns the index where the light was in the light list
  34656. */
  34657. removeLight(toRemove: Light): number;
  34658. /**
  34659. * Remove a camera for the list of scene's cameras
  34660. * @param toRemove defines the camera to remove
  34661. * @returns the index where the camera was in the camera list
  34662. */
  34663. removeCamera(toRemove: Camera): number;
  34664. /**
  34665. * Remove a particle system for the list of scene's particle systems
  34666. * @param toRemove defines the particle system to remove
  34667. * @returns the index where the particle system was in the particle system list
  34668. */
  34669. removeParticleSystem(toRemove: IParticleSystem): number;
  34670. /**
  34671. * Remove a animation for the list of scene's animations
  34672. * @param toRemove defines the animation to remove
  34673. * @returns the index where the animation was in the animation list
  34674. */
  34675. removeAnimation(toRemove: Animation): number;
  34676. /**
  34677. * Will stop the animation of the given target
  34678. * @param target - the target
  34679. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34680. * @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)
  34681. */
  34682. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34683. /**
  34684. * Removes the given animation group from this scene.
  34685. * @param toRemove The animation group to remove
  34686. * @returns The index of the removed animation group
  34687. */
  34688. removeAnimationGroup(toRemove: AnimationGroup): number;
  34689. /**
  34690. * Removes the given multi-material from this scene.
  34691. * @param toRemove The multi-material to remove
  34692. * @returns The index of the removed multi-material
  34693. */
  34694. removeMultiMaterial(toRemove: MultiMaterial): number;
  34695. /**
  34696. * Removes the given material from this scene.
  34697. * @param toRemove The material to remove
  34698. * @returns The index of the removed material
  34699. */
  34700. removeMaterial(toRemove: Material): number;
  34701. /**
  34702. * Removes the given action manager from this scene.
  34703. * @param toRemove The action manager to remove
  34704. * @returns The index of the removed action manager
  34705. */
  34706. removeActionManager(toRemove: AbstractActionManager): number;
  34707. /**
  34708. * Removes the given texture from this scene.
  34709. * @param toRemove The texture to remove
  34710. * @returns The index of the removed texture
  34711. */
  34712. removeTexture(toRemove: BaseTexture): number;
  34713. /**
  34714. * Adds the given light to this scene
  34715. * @param newLight The light to add
  34716. */
  34717. addLight(newLight: Light): void;
  34718. /**
  34719. * Sorts the list list based on light priorities
  34720. */
  34721. sortLightsByPriority(): void;
  34722. /**
  34723. * Adds the given camera to this scene
  34724. * @param newCamera The camera to add
  34725. */
  34726. addCamera(newCamera: Camera): void;
  34727. /**
  34728. * Adds the given skeleton to this scene
  34729. * @param newSkeleton The skeleton to add
  34730. */
  34731. addSkeleton(newSkeleton: Skeleton): void;
  34732. /**
  34733. * Adds the given particle system to this scene
  34734. * @param newParticleSystem The particle system to add
  34735. */
  34736. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34737. /**
  34738. * Adds the given animation to this scene
  34739. * @param newAnimation The animation to add
  34740. */
  34741. addAnimation(newAnimation: Animation): void;
  34742. /**
  34743. * Adds the given animation group to this scene.
  34744. * @param newAnimationGroup The animation group to add
  34745. */
  34746. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34747. /**
  34748. * Adds the given multi-material to this scene
  34749. * @param newMultiMaterial The multi-material to add
  34750. */
  34751. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34752. /**
  34753. * Adds the given material to this scene
  34754. * @param newMaterial The material to add
  34755. */
  34756. addMaterial(newMaterial: Material): void;
  34757. /**
  34758. * Adds the given morph target to this scene
  34759. * @param newMorphTargetManager The morph target to add
  34760. */
  34761. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34762. /**
  34763. * Adds the given geometry to this scene
  34764. * @param newGeometry The geometry to add
  34765. */
  34766. addGeometry(newGeometry: Geometry): void;
  34767. /**
  34768. * Adds the given action manager to this scene
  34769. * @param newActionManager The action manager to add
  34770. */
  34771. addActionManager(newActionManager: AbstractActionManager): void;
  34772. /**
  34773. * Adds the given texture to this scene.
  34774. * @param newTexture The texture to add
  34775. */
  34776. addTexture(newTexture: BaseTexture): void;
  34777. /**
  34778. * Switch active camera
  34779. * @param newCamera defines the new active camera
  34780. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34781. */
  34782. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34783. /**
  34784. * sets the active camera of the scene using its ID
  34785. * @param id defines the camera's ID
  34786. * @return the new active camera or null if none found.
  34787. */
  34788. setActiveCameraByID(id: string): Nullable<Camera>;
  34789. /**
  34790. * sets the active camera of the scene using its name
  34791. * @param name defines the camera's name
  34792. * @returns the new active camera or null if none found.
  34793. */
  34794. setActiveCameraByName(name: string): Nullable<Camera>;
  34795. /**
  34796. * get an animation group using its name
  34797. * @param name defines the material's name
  34798. * @return the animation group or null if none found.
  34799. */
  34800. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34801. /**
  34802. * Get a material using its unique id
  34803. * @param uniqueId defines the material's unique id
  34804. * @return the material or null if none found.
  34805. */
  34806. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34807. /**
  34808. * get a material using its id
  34809. * @param id defines the material's ID
  34810. * @return the material or null if none found.
  34811. */
  34812. getMaterialByID(id: string): Nullable<Material>;
  34813. /**
  34814. * Gets a the last added material using a given id
  34815. * @param id defines the material's ID
  34816. * @return the last material with the given id or null if none found.
  34817. */
  34818. getLastMaterialByID(id: string): Nullable<Material>;
  34819. /**
  34820. * Gets a material using its name
  34821. * @param name defines the material's name
  34822. * @return the material or null if none found.
  34823. */
  34824. getMaterialByName(name: string): Nullable<Material>;
  34825. /**
  34826. * Get a texture using its unique id
  34827. * @param uniqueId defines the texture's unique id
  34828. * @return the texture or null if none found.
  34829. */
  34830. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34831. /**
  34832. * Gets a camera using its id
  34833. * @param id defines the id to look for
  34834. * @returns the camera or null if not found
  34835. */
  34836. getCameraByID(id: string): Nullable<Camera>;
  34837. /**
  34838. * Gets a camera using its unique id
  34839. * @param uniqueId defines the unique id to look for
  34840. * @returns the camera or null if not found
  34841. */
  34842. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34843. /**
  34844. * Gets a camera using its name
  34845. * @param name defines the camera's name
  34846. * @return the camera or null if none found.
  34847. */
  34848. getCameraByName(name: string): Nullable<Camera>;
  34849. /**
  34850. * Gets a bone using its id
  34851. * @param id defines the bone's id
  34852. * @return the bone or null if not found
  34853. */
  34854. getBoneByID(id: string): Nullable<Bone>;
  34855. /**
  34856. * Gets a bone using its id
  34857. * @param name defines the bone's name
  34858. * @return the bone or null if not found
  34859. */
  34860. getBoneByName(name: string): Nullable<Bone>;
  34861. /**
  34862. * Gets a light node using its name
  34863. * @param name defines the the light's name
  34864. * @return the light or null if none found.
  34865. */
  34866. getLightByName(name: string): Nullable<Light>;
  34867. /**
  34868. * Gets a light node using its id
  34869. * @param id defines the light's id
  34870. * @return the light or null if none found.
  34871. */
  34872. getLightByID(id: string): Nullable<Light>;
  34873. /**
  34874. * Gets a light node using its scene-generated unique ID
  34875. * @param uniqueId defines the light's unique id
  34876. * @return the light or null if none found.
  34877. */
  34878. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34879. /**
  34880. * Gets a particle system by id
  34881. * @param id defines the particle system id
  34882. * @return the corresponding system or null if none found
  34883. */
  34884. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34885. /**
  34886. * Gets a geometry using its ID
  34887. * @param id defines the geometry's id
  34888. * @return the geometry or null if none found.
  34889. */
  34890. getGeometryByID(id: string): Nullable<Geometry>;
  34891. private _getGeometryByUniqueID;
  34892. /**
  34893. * Add a new geometry to this scene
  34894. * @param geometry defines the geometry to be added to the scene.
  34895. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34896. * @return a boolean defining if the geometry was added or not
  34897. */
  34898. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34899. /**
  34900. * Removes an existing geometry
  34901. * @param geometry defines the geometry to be removed from the scene
  34902. * @return a boolean defining if the geometry was removed or not
  34903. */
  34904. removeGeometry(geometry: Geometry): boolean;
  34905. /**
  34906. * Gets the list of geometries attached to the scene
  34907. * @returns an array of Geometry
  34908. */
  34909. getGeometries(): Geometry[];
  34910. /**
  34911. * Gets the first added mesh found of a given ID
  34912. * @param id defines the id to search for
  34913. * @return the mesh found or null if not found at all
  34914. */
  34915. getMeshByID(id: string): Nullable<AbstractMesh>;
  34916. /**
  34917. * Gets a list of meshes using their id
  34918. * @param id defines the id to search for
  34919. * @returns a list of meshes
  34920. */
  34921. getMeshesByID(id: string): Array<AbstractMesh>;
  34922. /**
  34923. * Gets the first added transform node found of a given ID
  34924. * @param id defines the id to search for
  34925. * @return the found transform node or null if not found at all.
  34926. */
  34927. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34928. /**
  34929. * Gets a transform node with its auto-generated unique id
  34930. * @param uniqueId efines the unique id to search for
  34931. * @return the found transform node or null if not found at all.
  34932. */
  34933. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34934. /**
  34935. * Gets a list of transform nodes using their id
  34936. * @param id defines the id to search for
  34937. * @returns a list of transform nodes
  34938. */
  34939. getTransformNodesByID(id: string): Array<TransformNode>;
  34940. /**
  34941. * Gets a mesh with its auto-generated unique id
  34942. * @param uniqueId defines the unique id to search for
  34943. * @return the found mesh or null if not found at all.
  34944. */
  34945. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34946. /**
  34947. * Gets a the last added mesh using a given id
  34948. * @param id defines the id to search for
  34949. * @return the found mesh or null if not found at all.
  34950. */
  34951. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34952. /**
  34953. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34954. * @param id defines the id to search for
  34955. * @return the found node or null if not found at all
  34956. */
  34957. getLastEntryByID(id: string): Nullable<Node>;
  34958. /**
  34959. * Gets a node (Mesh, Camera, Light) using a given id
  34960. * @param id defines the id to search for
  34961. * @return the found node or null if not found at all
  34962. */
  34963. getNodeByID(id: string): Nullable<Node>;
  34964. /**
  34965. * Gets a node (Mesh, Camera, Light) using a given name
  34966. * @param name defines the name to search for
  34967. * @return the found node or null if not found at all.
  34968. */
  34969. getNodeByName(name: string): Nullable<Node>;
  34970. /**
  34971. * Gets a mesh using a given name
  34972. * @param name defines the name to search for
  34973. * @return the found mesh or null if not found at all.
  34974. */
  34975. getMeshByName(name: string): Nullable<AbstractMesh>;
  34976. /**
  34977. * Gets a transform node using a given name
  34978. * @param name defines the name to search for
  34979. * @return the found transform node or null if not found at all.
  34980. */
  34981. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34982. /**
  34983. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34984. * @param id defines the id to search for
  34985. * @return the found skeleton or null if not found at all.
  34986. */
  34987. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34988. /**
  34989. * Gets a skeleton using a given auto generated unique id
  34990. * @param uniqueId defines the unique id to search for
  34991. * @return the found skeleton or null if not found at all.
  34992. */
  34993. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34994. /**
  34995. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34996. * @param id defines the id to search for
  34997. * @return the found skeleton or null if not found at all.
  34998. */
  34999. getSkeletonById(id: string): Nullable<Skeleton>;
  35000. /**
  35001. * Gets a skeleton using a given name
  35002. * @param name defines the name to search for
  35003. * @return the found skeleton or null if not found at all.
  35004. */
  35005. getSkeletonByName(name: string): Nullable<Skeleton>;
  35006. /**
  35007. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35008. * @param id defines the id to search for
  35009. * @return the found morph target manager or null if not found at all.
  35010. */
  35011. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35012. /**
  35013. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35014. * @param id defines the id to search for
  35015. * @return the found morph target or null if not found at all.
  35016. */
  35017. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35018. /**
  35019. * Gets a boolean indicating if the given mesh is active
  35020. * @param mesh defines the mesh to look for
  35021. * @returns true if the mesh is in the active list
  35022. */
  35023. isActiveMesh(mesh: AbstractMesh): boolean;
  35024. /**
  35025. * Return a unique id as a string which can serve as an identifier for the scene
  35026. */
  35027. readonly uid: string;
  35028. /**
  35029. * Add an externaly attached data from its key.
  35030. * This method call will fail and return false, if such key already exists.
  35031. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35032. * @param key the unique key that identifies the data
  35033. * @param data the data object to associate to the key for this Engine instance
  35034. * @return true if no such key were already present and the data was added successfully, false otherwise
  35035. */
  35036. addExternalData<T>(key: string, data: T): boolean;
  35037. /**
  35038. * Get an externaly attached data from its key
  35039. * @param key the unique key that identifies the data
  35040. * @return the associated data, if present (can be null), or undefined if not present
  35041. */
  35042. getExternalData<T>(key: string): Nullable<T>;
  35043. /**
  35044. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35045. * @param key the unique key that identifies the data
  35046. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35047. * @return the associated data, can be null if the factory returned null.
  35048. */
  35049. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35050. /**
  35051. * Remove an externaly attached data from the Engine instance
  35052. * @param key the unique key that identifies the data
  35053. * @return true if the data was successfully removed, false if it doesn't exist
  35054. */
  35055. removeExternalData(key: string): boolean;
  35056. private _evaluateSubMesh;
  35057. /**
  35058. * Clear the processed materials smart array preventing retention point in material dispose.
  35059. */
  35060. freeProcessedMaterials(): void;
  35061. private _preventFreeActiveMeshesAndRenderingGroups;
  35062. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35063. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35064. * when disposing several meshes in a row or a hierarchy of meshes.
  35065. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35066. */
  35067. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35068. /**
  35069. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35070. */
  35071. freeActiveMeshes(): void;
  35072. /**
  35073. * Clear the info related to rendering groups preventing retention points during dispose.
  35074. */
  35075. freeRenderingGroups(): void;
  35076. /** @hidden */
  35077. _isInIntermediateRendering(): boolean;
  35078. /**
  35079. * Lambda returning the list of potentially active meshes.
  35080. */
  35081. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35082. /**
  35083. * Lambda returning the list of potentially active sub meshes.
  35084. */
  35085. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35086. /**
  35087. * Lambda returning the list of potentially intersecting sub meshes.
  35088. */
  35089. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35090. /**
  35091. * Lambda returning the list of potentially colliding sub meshes.
  35092. */
  35093. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35094. private _activeMeshesFrozen;
  35095. /**
  35096. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35097. * @returns the current scene
  35098. */
  35099. freezeActiveMeshes(): Scene;
  35100. /**
  35101. * Use this function to restart evaluating active meshes on every frame
  35102. * @returns the current scene
  35103. */
  35104. unfreezeActiveMeshes(): Scene;
  35105. private _evaluateActiveMeshes;
  35106. private _activeMesh;
  35107. /**
  35108. * Update the transform matrix to update from the current active camera
  35109. * @param force defines a boolean used to force the update even if cache is up to date
  35110. */
  35111. updateTransformMatrix(force?: boolean): void;
  35112. private _bindFrameBuffer;
  35113. /** @hidden */
  35114. _allowPostProcessClearColor: boolean;
  35115. /** @hidden */
  35116. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35117. private _processSubCameras;
  35118. private _checkIntersections;
  35119. /** @hidden */
  35120. _advancePhysicsEngineStep(step: number): void;
  35121. /**
  35122. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35123. */
  35124. getDeterministicFrameTime: () => number;
  35125. /** @hidden */
  35126. _animate(): void;
  35127. /** Execute all animations (for a frame) */
  35128. animate(): void;
  35129. /**
  35130. * Render the scene
  35131. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35132. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35133. */
  35134. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35135. /**
  35136. * Freeze all materials
  35137. * A frozen material will not be updatable but should be faster to render
  35138. */
  35139. freezeMaterials(): void;
  35140. /**
  35141. * Unfreeze all materials
  35142. * A frozen material will not be updatable but should be faster to render
  35143. */
  35144. unfreezeMaterials(): void;
  35145. /**
  35146. * Releases all held ressources
  35147. */
  35148. dispose(): void;
  35149. /**
  35150. * Gets if the scene is already disposed
  35151. */
  35152. readonly isDisposed: boolean;
  35153. /**
  35154. * Call this function to reduce memory footprint of the scene.
  35155. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35156. */
  35157. clearCachedVertexData(): void;
  35158. /**
  35159. * This function will remove the local cached buffer data from texture.
  35160. * It will save memory but will prevent the texture from being rebuilt
  35161. */
  35162. cleanCachedTextureBuffer(): void;
  35163. /**
  35164. * Get the world extend vectors with an optional filter
  35165. *
  35166. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35167. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35168. */
  35169. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35170. min: Vector3;
  35171. max: Vector3;
  35172. };
  35173. /**
  35174. * Creates a ray that can be used to pick in the scene
  35175. * @param x defines the x coordinate of the origin (on-screen)
  35176. * @param y defines the y coordinate of the origin (on-screen)
  35177. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35178. * @param camera defines the camera to use for the picking
  35179. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35180. * @returns a Ray
  35181. */
  35182. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35183. /**
  35184. * Creates a ray that can be used to pick in the scene
  35185. * @param x defines the x coordinate of the origin (on-screen)
  35186. * @param y defines the y coordinate of the origin (on-screen)
  35187. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35188. * @param result defines the ray where to store the picking ray
  35189. * @param camera defines the camera to use for the picking
  35190. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35191. * @returns the current scene
  35192. */
  35193. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35194. /**
  35195. * Creates a ray that can be used to pick in the scene
  35196. * @param x defines the x coordinate of the origin (on-screen)
  35197. * @param y defines the y coordinate of the origin (on-screen)
  35198. * @param camera defines the camera to use for the picking
  35199. * @returns a Ray
  35200. */
  35201. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35202. /**
  35203. * Creates a ray that can be used to pick in the scene
  35204. * @param x defines the x coordinate of the origin (on-screen)
  35205. * @param y defines the y coordinate of the origin (on-screen)
  35206. * @param result defines the ray where to store the picking ray
  35207. * @param camera defines the camera to use for the picking
  35208. * @returns the current scene
  35209. */
  35210. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35211. /** Launch a ray to try to pick a mesh in the scene
  35212. * @param x position on screen
  35213. * @param y position on screen
  35214. * @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
  35215. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35216. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35217. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35218. * @returns a PickingInfo
  35219. */
  35220. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35221. /** Use the given ray to pick a mesh in the scene
  35222. * @param ray The ray to use to pick meshes
  35223. * @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
  35224. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35225. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35226. * @returns a PickingInfo
  35227. */
  35228. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35229. /**
  35230. * Launch a ray to try to pick a mesh in the scene
  35231. * @param x X position on screen
  35232. * @param y Y position on screen
  35233. * @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
  35234. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35235. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35236. * @returns an array of PickingInfo
  35237. */
  35238. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35239. /**
  35240. * Launch a ray to try to pick a mesh in the scene
  35241. * @param ray Ray to use
  35242. * @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
  35243. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35244. * @returns an array of PickingInfo
  35245. */
  35246. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35247. /**
  35248. * Force the value of meshUnderPointer
  35249. * @param mesh defines the mesh to use
  35250. */
  35251. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35252. /**
  35253. * Gets the mesh under the pointer
  35254. * @returns a Mesh or null if no mesh is under the pointer
  35255. */
  35256. getPointerOverMesh(): Nullable<AbstractMesh>;
  35257. /** @hidden */
  35258. _rebuildGeometries(): void;
  35259. /** @hidden */
  35260. _rebuildTextures(): void;
  35261. private _getByTags;
  35262. /**
  35263. * Get a list of meshes by tags
  35264. * @param tagsQuery defines the tags query to use
  35265. * @param forEach defines a predicate used to filter results
  35266. * @returns an array of Mesh
  35267. */
  35268. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35269. /**
  35270. * Get a list of cameras by tags
  35271. * @param tagsQuery defines the tags query to use
  35272. * @param forEach defines a predicate used to filter results
  35273. * @returns an array of Camera
  35274. */
  35275. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35276. /**
  35277. * Get a list of lights by tags
  35278. * @param tagsQuery defines the tags query to use
  35279. * @param forEach defines a predicate used to filter results
  35280. * @returns an array of Light
  35281. */
  35282. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35283. /**
  35284. * Get a list of materials by tags
  35285. * @param tagsQuery defines the tags query to use
  35286. * @param forEach defines a predicate used to filter results
  35287. * @returns an array of Material
  35288. */
  35289. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35290. /**
  35291. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35292. * This allowed control for front to back rendering or reversly depending of the special needs.
  35293. *
  35294. * @param renderingGroupId The rendering group id corresponding to its index
  35295. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35296. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35297. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35298. */
  35299. 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;
  35300. /**
  35301. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35302. *
  35303. * @param renderingGroupId The rendering group id corresponding to its index
  35304. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35305. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35306. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35307. */
  35308. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35309. /**
  35310. * Gets the current auto clear configuration for one rendering group of the rendering
  35311. * manager.
  35312. * @param index the rendering group index to get the information for
  35313. * @returns The auto clear setup for the requested rendering group
  35314. */
  35315. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35316. private _blockMaterialDirtyMechanism;
  35317. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35318. blockMaterialDirtyMechanism: boolean;
  35319. /**
  35320. * Will flag all materials as dirty to trigger new shader compilation
  35321. * @param flag defines the flag used to specify which material part must be marked as dirty
  35322. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35323. */
  35324. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35325. /** @hidden */
  35326. _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;
  35327. /** @hidden */
  35328. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35329. }
  35330. }
  35331. declare module "babylonjs/assetContainer" {
  35332. import { AbstractScene } from "babylonjs/abstractScene";
  35333. import { Scene } from "babylonjs/scene";
  35334. import { Mesh } from "babylonjs/Meshes/mesh";
  35335. /**
  35336. * Set of assets to keep when moving a scene into an asset container.
  35337. */
  35338. export class KeepAssets extends AbstractScene {
  35339. }
  35340. /**
  35341. * Container with a set of assets that can be added or removed from a scene.
  35342. */
  35343. export class AssetContainer extends AbstractScene {
  35344. /**
  35345. * The scene the AssetContainer belongs to.
  35346. */
  35347. scene: Scene;
  35348. /**
  35349. * Instantiates an AssetContainer.
  35350. * @param scene The scene the AssetContainer belongs to.
  35351. */
  35352. constructor(scene: Scene);
  35353. /**
  35354. * Adds all the assets from the container to the scene.
  35355. */
  35356. addAllToScene(): void;
  35357. /**
  35358. * Removes all the assets in the container from the scene
  35359. */
  35360. removeAllFromScene(): void;
  35361. /**
  35362. * Disposes all the assets in the container
  35363. */
  35364. dispose(): void;
  35365. private _moveAssets;
  35366. /**
  35367. * Removes all the assets contained in the scene and adds them to the container.
  35368. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35369. */
  35370. moveAllFromScene(keepAssets?: KeepAssets): void;
  35371. /**
  35372. * 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.
  35373. * @returns the root mesh
  35374. */
  35375. createRootMesh(): Mesh;
  35376. }
  35377. }
  35378. declare module "babylonjs/abstractScene" {
  35379. import { Scene } from "babylonjs/scene";
  35380. import { Nullable } from "babylonjs/types";
  35381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35382. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35383. import { Geometry } from "babylonjs/Meshes/geometry";
  35384. import { Skeleton } from "babylonjs/Bones/skeleton";
  35385. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35386. import { AssetContainer } from "babylonjs/assetContainer";
  35387. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35388. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35390. import { Material } from "babylonjs/Materials/material";
  35391. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35392. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35393. import { Camera } from "babylonjs/Cameras/camera";
  35394. import { Light } from "babylonjs/Lights/light";
  35395. import { Node } from "babylonjs/node";
  35396. import { Animation } from "babylonjs/Animations/animation";
  35397. /**
  35398. * Defines how the parser contract is defined.
  35399. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35400. */
  35401. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35402. /**
  35403. * Defines how the individual parser contract is defined.
  35404. * These parser can parse an individual asset
  35405. */
  35406. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35407. /**
  35408. * Base class of the scene acting as a container for the different elements composing a scene.
  35409. * This class is dynamically extended by the different components of the scene increasing
  35410. * flexibility and reducing coupling
  35411. */
  35412. export abstract class AbstractScene {
  35413. /**
  35414. * Stores the list of available parsers in the application.
  35415. */
  35416. private static _BabylonFileParsers;
  35417. /**
  35418. * Stores the list of available individual parsers in the application.
  35419. */
  35420. private static _IndividualBabylonFileParsers;
  35421. /**
  35422. * Adds a parser in the list of available ones
  35423. * @param name Defines the name of the parser
  35424. * @param parser Defines the parser to add
  35425. */
  35426. static AddParser(name: string, parser: BabylonFileParser): void;
  35427. /**
  35428. * Gets a general parser from the list of avaialble ones
  35429. * @param name Defines the name of the parser
  35430. * @returns the requested parser or null
  35431. */
  35432. static GetParser(name: string): Nullable<BabylonFileParser>;
  35433. /**
  35434. * Adds n individual parser in the list of available ones
  35435. * @param name Defines the name of the parser
  35436. * @param parser Defines the parser to add
  35437. */
  35438. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35439. /**
  35440. * Gets an individual parser from the list of avaialble ones
  35441. * @param name Defines the name of the parser
  35442. * @returns the requested parser or null
  35443. */
  35444. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35445. /**
  35446. * Parser json data and populate both a scene and its associated container object
  35447. * @param jsonData Defines the data to parse
  35448. * @param scene Defines the scene to parse the data for
  35449. * @param container Defines the container attached to the parsing sequence
  35450. * @param rootUrl Defines the root url of the data
  35451. */
  35452. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35453. /**
  35454. * Gets the list of root nodes (ie. nodes with no parent)
  35455. */
  35456. rootNodes: Node[];
  35457. /** All of the cameras added to this scene
  35458. * @see http://doc.babylonjs.com/babylon101/cameras
  35459. */
  35460. cameras: Camera[];
  35461. /**
  35462. * All of the lights added to this scene
  35463. * @see http://doc.babylonjs.com/babylon101/lights
  35464. */
  35465. lights: Light[];
  35466. /**
  35467. * All of the (abstract) meshes added to this scene
  35468. */
  35469. meshes: AbstractMesh[];
  35470. /**
  35471. * The list of skeletons added to the scene
  35472. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35473. */
  35474. skeletons: Skeleton[];
  35475. /**
  35476. * All of the particle systems added to this scene
  35477. * @see http://doc.babylonjs.com/babylon101/particles
  35478. */
  35479. particleSystems: IParticleSystem[];
  35480. /**
  35481. * Gets a list of Animations associated with the scene
  35482. */
  35483. animations: Animation[];
  35484. /**
  35485. * All of the animation groups added to this scene
  35486. * @see http://doc.babylonjs.com/how_to/group
  35487. */
  35488. animationGroups: AnimationGroup[];
  35489. /**
  35490. * All of the multi-materials added to this scene
  35491. * @see http://doc.babylonjs.com/how_to/multi_materials
  35492. */
  35493. multiMaterials: MultiMaterial[];
  35494. /**
  35495. * All of the materials added to this scene
  35496. * In the context of a Scene, it is not supposed to be modified manually.
  35497. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35498. * Note also that the order of the Material wihin the array is not significant and might change.
  35499. * @see http://doc.babylonjs.com/babylon101/materials
  35500. */
  35501. materials: Material[];
  35502. /**
  35503. * The list of morph target managers added to the scene
  35504. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35505. */
  35506. morphTargetManagers: MorphTargetManager[];
  35507. /**
  35508. * The list of geometries used in the scene.
  35509. */
  35510. geometries: Geometry[];
  35511. /**
  35512. * All of the tranform nodes added to this scene
  35513. * In the context of a Scene, it is not supposed to be modified manually.
  35514. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35515. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35516. * @see http://doc.babylonjs.com/how_to/transformnode
  35517. */
  35518. transformNodes: TransformNode[];
  35519. /**
  35520. * ActionManagers available on the scene.
  35521. */
  35522. actionManagers: AbstractActionManager[];
  35523. /**
  35524. * Textures to keep.
  35525. */
  35526. textures: BaseTexture[];
  35527. /**
  35528. * Environment texture for the scene
  35529. */
  35530. environmentTexture: Nullable<BaseTexture>;
  35531. }
  35532. }
  35533. declare module "babylonjs/Audio/sound" {
  35534. import { Observable } from "babylonjs/Misc/observable";
  35535. import { Vector3 } from "babylonjs/Maths/math.vector";
  35536. import { Nullable } from "babylonjs/types";
  35537. import { Scene } from "babylonjs/scene";
  35538. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35539. /**
  35540. * Interface used to define options for Sound class
  35541. */
  35542. export interface ISoundOptions {
  35543. /**
  35544. * Does the sound autoplay once loaded.
  35545. */
  35546. autoplay?: boolean;
  35547. /**
  35548. * Does the sound loop after it finishes playing once.
  35549. */
  35550. loop?: boolean;
  35551. /**
  35552. * Sound's volume
  35553. */
  35554. volume?: number;
  35555. /**
  35556. * Is it a spatial sound?
  35557. */
  35558. spatialSound?: boolean;
  35559. /**
  35560. * Maximum distance to hear that sound
  35561. */
  35562. maxDistance?: number;
  35563. /**
  35564. * Uses user defined attenuation function
  35565. */
  35566. useCustomAttenuation?: boolean;
  35567. /**
  35568. * Define the roll off factor of spatial sounds.
  35569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35570. */
  35571. rolloffFactor?: number;
  35572. /**
  35573. * Define the reference distance the sound should be heard perfectly.
  35574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35575. */
  35576. refDistance?: number;
  35577. /**
  35578. * Define the distance attenuation model the sound will follow.
  35579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35580. */
  35581. distanceModel?: string;
  35582. /**
  35583. * Defines the playback speed (1 by default)
  35584. */
  35585. playbackRate?: number;
  35586. /**
  35587. * Defines if the sound is from a streaming source
  35588. */
  35589. streaming?: boolean;
  35590. /**
  35591. * Defines an optional length (in seconds) inside the sound file
  35592. */
  35593. length?: number;
  35594. /**
  35595. * Defines an optional offset (in seconds) inside the sound file
  35596. */
  35597. offset?: number;
  35598. /**
  35599. * If true, URLs will not be required to state the audio file codec to use.
  35600. */
  35601. skipCodecCheck?: boolean;
  35602. }
  35603. /**
  35604. * Defines a sound that can be played in the application.
  35605. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35607. */
  35608. export class Sound {
  35609. /**
  35610. * The name of the sound in the scene.
  35611. */
  35612. name: string;
  35613. /**
  35614. * Does the sound autoplay once loaded.
  35615. */
  35616. autoplay: boolean;
  35617. /**
  35618. * Does the sound loop after it finishes playing once.
  35619. */
  35620. loop: boolean;
  35621. /**
  35622. * Does the sound use a custom attenuation curve to simulate the falloff
  35623. * happening when the source gets further away from the camera.
  35624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35625. */
  35626. useCustomAttenuation: boolean;
  35627. /**
  35628. * The sound track id this sound belongs to.
  35629. */
  35630. soundTrackId: number;
  35631. /**
  35632. * Is this sound currently played.
  35633. */
  35634. isPlaying: boolean;
  35635. /**
  35636. * Is this sound currently paused.
  35637. */
  35638. isPaused: boolean;
  35639. /**
  35640. * Does this sound enables spatial sound.
  35641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35642. */
  35643. spatialSound: boolean;
  35644. /**
  35645. * Define the reference distance the sound should be heard perfectly.
  35646. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35647. */
  35648. refDistance: number;
  35649. /**
  35650. * Define the roll off factor of spatial sounds.
  35651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35652. */
  35653. rolloffFactor: number;
  35654. /**
  35655. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35657. */
  35658. maxDistance: number;
  35659. /**
  35660. * Define the distance attenuation model the sound will follow.
  35661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35662. */
  35663. distanceModel: string;
  35664. /**
  35665. * @hidden
  35666. * Back Compat
  35667. **/
  35668. onended: () => any;
  35669. /**
  35670. * Observable event when the current playing sound finishes.
  35671. */
  35672. onEndedObservable: Observable<Sound>;
  35673. private _panningModel;
  35674. private _playbackRate;
  35675. private _streaming;
  35676. private _startTime;
  35677. private _startOffset;
  35678. private _position;
  35679. /** @hidden */
  35680. _positionInEmitterSpace: boolean;
  35681. private _localDirection;
  35682. private _volume;
  35683. private _isReadyToPlay;
  35684. private _isDirectional;
  35685. private _readyToPlayCallback;
  35686. private _audioBuffer;
  35687. private _soundSource;
  35688. private _streamingSource;
  35689. private _soundPanner;
  35690. private _soundGain;
  35691. private _inputAudioNode;
  35692. private _outputAudioNode;
  35693. private _coneInnerAngle;
  35694. private _coneOuterAngle;
  35695. private _coneOuterGain;
  35696. private _scene;
  35697. private _connectedTransformNode;
  35698. private _customAttenuationFunction;
  35699. private _registerFunc;
  35700. private _isOutputConnected;
  35701. private _htmlAudioElement;
  35702. private _urlType;
  35703. private _length?;
  35704. private _offset?;
  35705. /** @hidden */
  35706. static _SceneComponentInitialization: (scene: Scene) => void;
  35707. /**
  35708. * Create a sound and attach it to a scene
  35709. * @param name Name of your sound
  35710. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35711. * @param scene defines the scene the sound belongs to
  35712. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35713. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35714. */
  35715. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35716. /**
  35717. * Release the sound and its associated resources
  35718. */
  35719. dispose(): void;
  35720. /**
  35721. * Gets if the sounds is ready to be played or not.
  35722. * @returns true if ready, otherwise false
  35723. */
  35724. isReady(): boolean;
  35725. private _soundLoaded;
  35726. /**
  35727. * Sets the data of the sound from an audiobuffer
  35728. * @param audioBuffer The audioBuffer containing the data
  35729. */
  35730. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35731. /**
  35732. * Updates the current sounds options such as maxdistance, loop...
  35733. * @param options A JSON object containing values named as the object properties
  35734. */
  35735. updateOptions(options: ISoundOptions): void;
  35736. private _createSpatialParameters;
  35737. private _updateSpatialParameters;
  35738. /**
  35739. * Switch the panning model to HRTF:
  35740. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35742. */
  35743. switchPanningModelToHRTF(): void;
  35744. /**
  35745. * Switch the panning model to Equal Power:
  35746. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35748. */
  35749. switchPanningModelToEqualPower(): void;
  35750. private _switchPanningModel;
  35751. /**
  35752. * Connect this sound to a sound track audio node like gain...
  35753. * @param soundTrackAudioNode the sound track audio node to connect to
  35754. */
  35755. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35756. /**
  35757. * Transform this sound into a directional source
  35758. * @param coneInnerAngle Size of the inner cone in degree
  35759. * @param coneOuterAngle Size of the outer cone in degree
  35760. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35761. */
  35762. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35763. /**
  35764. * Gets or sets the inner angle for the directional cone.
  35765. */
  35766. /**
  35767. * Gets or sets the inner angle for the directional cone.
  35768. */
  35769. directionalConeInnerAngle: number;
  35770. /**
  35771. * Gets or sets the outer angle for the directional cone.
  35772. */
  35773. /**
  35774. * Gets or sets the outer angle for the directional cone.
  35775. */
  35776. directionalConeOuterAngle: number;
  35777. /**
  35778. * Sets the position of the emitter if spatial sound is enabled
  35779. * @param newPosition Defines the new posisiton
  35780. */
  35781. setPosition(newPosition: Vector3): void;
  35782. /**
  35783. * Sets the local direction of the emitter if spatial sound is enabled
  35784. * @param newLocalDirection Defines the new local direction
  35785. */
  35786. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35787. private _updateDirection;
  35788. /** @hidden */
  35789. updateDistanceFromListener(): void;
  35790. /**
  35791. * Sets a new custom attenuation function for the sound.
  35792. * @param callback Defines the function used for the attenuation
  35793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35794. */
  35795. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35796. /**
  35797. * Play the sound
  35798. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35799. * @param offset (optional) Start the sound at a specific time in seconds
  35800. * @param length (optional) Sound duration (in seconds)
  35801. */
  35802. play(time?: number, offset?: number, length?: number): void;
  35803. private _onended;
  35804. /**
  35805. * Stop the sound
  35806. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35807. */
  35808. stop(time?: number): void;
  35809. /**
  35810. * Put the sound in pause
  35811. */
  35812. pause(): void;
  35813. /**
  35814. * Sets a dedicated volume for this sounds
  35815. * @param newVolume Define the new volume of the sound
  35816. * @param time Define time for gradual change to new volume
  35817. */
  35818. setVolume(newVolume: number, time?: number): void;
  35819. /**
  35820. * Set the sound play back rate
  35821. * @param newPlaybackRate Define the playback rate the sound should be played at
  35822. */
  35823. setPlaybackRate(newPlaybackRate: number): void;
  35824. /**
  35825. * Gets the volume of the sound.
  35826. * @returns the volume of the sound
  35827. */
  35828. getVolume(): number;
  35829. /**
  35830. * Attach the sound to a dedicated mesh
  35831. * @param transformNode The transform node to connect the sound with
  35832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35833. */
  35834. attachToMesh(transformNode: TransformNode): void;
  35835. /**
  35836. * Detach the sound from the previously attached mesh
  35837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35838. */
  35839. detachFromMesh(): void;
  35840. private _onRegisterAfterWorldMatrixUpdate;
  35841. /**
  35842. * Clone the current sound in the scene.
  35843. * @returns the new sound clone
  35844. */
  35845. clone(): Nullable<Sound>;
  35846. /**
  35847. * Gets the current underlying audio buffer containing the data
  35848. * @returns the audio buffer
  35849. */
  35850. getAudioBuffer(): Nullable<AudioBuffer>;
  35851. /**
  35852. * Serializes the Sound in a JSON representation
  35853. * @returns the JSON representation of the sound
  35854. */
  35855. serialize(): any;
  35856. /**
  35857. * Parse a JSON representation of a sound to innstantiate in a given scene
  35858. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35859. * @param scene Define the scene the new parsed sound should be created in
  35860. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35861. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35862. * @returns the newly parsed sound
  35863. */
  35864. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35865. }
  35866. }
  35867. declare module "babylonjs/Actions/directAudioActions" {
  35868. import { Action } from "babylonjs/Actions/action";
  35869. import { Condition } from "babylonjs/Actions/condition";
  35870. import { Sound } from "babylonjs/Audio/sound";
  35871. /**
  35872. * This defines an action helpful to play a defined sound on a triggered action.
  35873. */
  35874. export class PlaySoundAction extends Action {
  35875. private _sound;
  35876. /**
  35877. * Instantiate the action
  35878. * @param triggerOptions defines the trigger options
  35879. * @param sound defines the sound to play
  35880. * @param condition defines the trigger related conditions
  35881. */
  35882. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35883. /** @hidden */
  35884. _prepare(): void;
  35885. /**
  35886. * Execute the action and play the sound.
  35887. */
  35888. execute(): void;
  35889. /**
  35890. * Serializes the actions and its related information.
  35891. * @param parent defines the object to serialize in
  35892. * @returns the serialized object
  35893. */
  35894. serialize(parent: any): any;
  35895. }
  35896. /**
  35897. * This defines an action helpful to stop a defined sound on a triggered action.
  35898. */
  35899. export class StopSoundAction extends Action {
  35900. private _sound;
  35901. /**
  35902. * Instantiate the action
  35903. * @param triggerOptions defines the trigger options
  35904. * @param sound defines the sound to stop
  35905. * @param condition defines the trigger related conditions
  35906. */
  35907. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35908. /** @hidden */
  35909. _prepare(): void;
  35910. /**
  35911. * Execute the action and stop the sound.
  35912. */
  35913. execute(): void;
  35914. /**
  35915. * Serializes the actions and its related information.
  35916. * @param parent defines the object to serialize in
  35917. * @returns the serialized object
  35918. */
  35919. serialize(parent: any): any;
  35920. }
  35921. }
  35922. declare module "babylonjs/Actions/interpolateValueAction" {
  35923. import { Action } from "babylonjs/Actions/action";
  35924. import { Condition } from "babylonjs/Actions/condition";
  35925. import { Observable } from "babylonjs/Misc/observable";
  35926. /**
  35927. * This defines an action responsible to change the value of a property
  35928. * by interpolating between its current value and the newly set one once triggered.
  35929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35930. */
  35931. export class InterpolateValueAction extends Action {
  35932. /**
  35933. * Defines the path of the property where the value should be interpolated
  35934. */
  35935. propertyPath: string;
  35936. /**
  35937. * Defines the target value at the end of the interpolation.
  35938. */
  35939. value: any;
  35940. /**
  35941. * Defines the time it will take for the property to interpolate to the value.
  35942. */
  35943. duration: number;
  35944. /**
  35945. * Defines if the other scene animations should be stopped when the action has been triggered
  35946. */
  35947. stopOtherAnimations?: boolean;
  35948. /**
  35949. * Defines a callback raised once the interpolation animation has been done.
  35950. */
  35951. onInterpolationDone?: () => void;
  35952. /**
  35953. * Observable triggered once the interpolation animation has been done.
  35954. */
  35955. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35956. private _target;
  35957. private _effectiveTarget;
  35958. private _property;
  35959. /**
  35960. * Instantiate the action
  35961. * @param triggerOptions defines the trigger options
  35962. * @param target defines the object containing the value to interpolate
  35963. * @param propertyPath defines the path to the property in the target object
  35964. * @param value defines the target value at the end of the interpolation
  35965. * @param duration deines the time it will take for the property to interpolate to the value.
  35966. * @param condition defines the trigger related conditions
  35967. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35968. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35969. */
  35970. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35971. /** @hidden */
  35972. _prepare(): void;
  35973. /**
  35974. * Execute the action starts the value interpolation.
  35975. */
  35976. execute(): void;
  35977. /**
  35978. * Serializes the actions and its related information.
  35979. * @param parent defines the object to serialize in
  35980. * @returns the serialized object
  35981. */
  35982. serialize(parent: any): any;
  35983. }
  35984. }
  35985. declare module "babylonjs/Actions/index" {
  35986. export * from "babylonjs/Actions/action";
  35987. export * from "babylonjs/Actions/actionEvent";
  35988. export * from "babylonjs/Actions/actionManager";
  35989. export * from "babylonjs/Actions/condition";
  35990. export * from "babylonjs/Actions/directActions";
  35991. export * from "babylonjs/Actions/directAudioActions";
  35992. export * from "babylonjs/Actions/interpolateValueAction";
  35993. }
  35994. declare module "babylonjs/Animations/index" {
  35995. export * from "babylonjs/Animations/animatable";
  35996. export * from "babylonjs/Animations/animation";
  35997. export * from "babylonjs/Animations/animationGroup";
  35998. export * from "babylonjs/Animations/animationPropertiesOverride";
  35999. export * from "babylonjs/Animations/easing";
  36000. export * from "babylonjs/Animations/runtimeAnimation";
  36001. export * from "babylonjs/Animations/animationEvent";
  36002. export * from "babylonjs/Animations/animationGroup";
  36003. export * from "babylonjs/Animations/animationKey";
  36004. export * from "babylonjs/Animations/animationRange";
  36005. export * from "babylonjs/Animations/animatable.interface";
  36006. }
  36007. declare module "babylonjs/Audio/soundTrack" {
  36008. import { Sound } from "babylonjs/Audio/sound";
  36009. import { Analyser } from "babylonjs/Audio/analyser";
  36010. import { Scene } from "babylonjs/scene";
  36011. /**
  36012. * Options allowed during the creation of a sound track.
  36013. */
  36014. export interface ISoundTrackOptions {
  36015. /**
  36016. * The volume the sound track should take during creation
  36017. */
  36018. volume?: number;
  36019. /**
  36020. * Define if the sound track is the main sound track of the scene
  36021. */
  36022. mainTrack?: boolean;
  36023. }
  36024. /**
  36025. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36026. * It will be also used in a future release to apply effects on a specific track.
  36027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36028. */
  36029. export class SoundTrack {
  36030. /**
  36031. * The unique identifier of the sound track in the scene.
  36032. */
  36033. id: number;
  36034. /**
  36035. * The list of sounds included in the sound track.
  36036. */
  36037. soundCollection: Array<Sound>;
  36038. private _outputAudioNode;
  36039. private _scene;
  36040. private _isMainTrack;
  36041. private _connectedAnalyser;
  36042. private _options;
  36043. private _isInitialized;
  36044. /**
  36045. * Creates a new sound track.
  36046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36047. * @param scene Define the scene the sound track belongs to
  36048. * @param options
  36049. */
  36050. constructor(scene: Scene, options?: ISoundTrackOptions);
  36051. private _initializeSoundTrackAudioGraph;
  36052. /**
  36053. * Release the sound track and its associated resources
  36054. */
  36055. dispose(): void;
  36056. /**
  36057. * Adds a sound to this sound track
  36058. * @param sound define the cound to add
  36059. * @ignoreNaming
  36060. */
  36061. AddSound(sound: Sound): void;
  36062. /**
  36063. * Removes a sound to this sound track
  36064. * @param sound define the cound to remove
  36065. * @ignoreNaming
  36066. */
  36067. RemoveSound(sound: Sound): void;
  36068. /**
  36069. * Set a global volume for the full sound track.
  36070. * @param newVolume Define the new volume of the sound track
  36071. */
  36072. setVolume(newVolume: number): void;
  36073. /**
  36074. * Switch the panning model to HRTF:
  36075. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36077. */
  36078. switchPanningModelToHRTF(): void;
  36079. /**
  36080. * Switch the panning model to Equal Power:
  36081. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36083. */
  36084. switchPanningModelToEqualPower(): void;
  36085. /**
  36086. * Connect the sound track to an audio analyser allowing some amazing
  36087. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36089. * @param analyser The analyser to connect to the engine
  36090. */
  36091. connectToAnalyser(analyser: Analyser): void;
  36092. }
  36093. }
  36094. declare module "babylonjs/Audio/audioSceneComponent" {
  36095. import { Sound } from "babylonjs/Audio/sound";
  36096. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36097. import { Nullable } from "babylonjs/types";
  36098. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36099. import { Scene } from "babylonjs/scene";
  36100. import { AbstractScene } from "babylonjs/abstractScene";
  36101. module "babylonjs/abstractScene" {
  36102. interface AbstractScene {
  36103. /**
  36104. * The list of sounds used in the scene.
  36105. */
  36106. sounds: Nullable<Array<Sound>>;
  36107. }
  36108. }
  36109. module "babylonjs/scene" {
  36110. interface Scene {
  36111. /**
  36112. * @hidden
  36113. * Backing field
  36114. */
  36115. _mainSoundTrack: SoundTrack;
  36116. /**
  36117. * The main sound track played by the scene.
  36118. * It cotains your primary collection of sounds.
  36119. */
  36120. mainSoundTrack: SoundTrack;
  36121. /**
  36122. * The list of sound tracks added to the scene
  36123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36124. */
  36125. soundTracks: Nullable<Array<SoundTrack>>;
  36126. /**
  36127. * Gets a sound using a given name
  36128. * @param name defines the name to search for
  36129. * @return the found sound or null if not found at all.
  36130. */
  36131. getSoundByName(name: string): Nullable<Sound>;
  36132. /**
  36133. * Gets or sets if audio support is enabled
  36134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36135. */
  36136. audioEnabled: boolean;
  36137. /**
  36138. * Gets or sets if audio will be output to headphones
  36139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36140. */
  36141. headphone: boolean;
  36142. }
  36143. }
  36144. /**
  36145. * Defines the sound scene component responsible to manage any sounds
  36146. * in a given scene.
  36147. */
  36148. export class AudioSceneComponent implements ISceneSerializableComponent {
  36149. /**
  36150. * The component name helpfull to identify the component in the list of scene components.
  36151. */
  36152. readonly name: string;
  36153. /**
  36154. * The scene the component belongs to.
  36155. */
  36156. scene: Scene;
  36157. private _audioEnabled;
  36158. /**
  36159. * Gets whether audio is enabled or not.
  36160. * Please use related enable/disable method to switch state.
  36161. */
  36162. readonly audioEnabled: boolean;
  36163. private _headphone;
  36164. /**
  36165. * Gets whether audio is outputing to headphone or not.
  36166. * Please use the according Switch methods to change output.
  36167. */
  36168. readonly headphone: boolean;
  36169. /**
  36170. * Creates a new instance of the component for the given scene
  36171. * @param scene Defines the scene to register the component in
  36172. */
  36173. constructor(scene: Scene);
  36174. /**
  36175. * Registers the component in a given scene
  36176. */
  36177. register(): void;
  36178. /**
  36179. * Rebuilds the elements related to this component in case of
  36180. * context lost for instance.
  36181. */
  36182. rebuild(): void;
  36183. /**
  36184. * Serializes the component data to the specified json object
  36185. * @param serializationObject The object to serialize to
  36186. */
  36187. serialize(serializationObject: any): void;
  36188. /**
  36189. * Adds all the elements from the container to the scene
  36190. * @param container the container holding the elements
  36191. */
  36192. addFromContainer(container: AbstractScene): void;
  36193. /**
  36194. * Removes all the elements in the container from the scene
  36195. * @param container contains the elements to remove
  36196. * @param dispose if the removed element should be disposed (default: false)
  36197. */
  36198. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36199. /**
  36200. * Disposes the component and the associated ressources.
  36201. */
  36202. dispose(): void;
  36203. /**
  36204. * Disables audio in the associated scene.
  36205. */
  36206. disableAudio(): void;
  36207. /**
  36208. * Enables audio in the associated scene.
  36209. */
  36210. enableAudio(): void;
  36211. /**
  36212. * Switch audio to headphone output.
  36213. */
  36214. switchAudioModeForHeadphones(): void;
  36215. /**
  36216. * Switch audio to normal speakers.
  36217. */
  36218. switchAudioModeForNormalSpeakers(): void;
  36219. private _afterRender;
  36220. }
  36221. }
  36222. declare module "babylonjs/Audio/weightedsound" {
  36223. import { Sound } from "babylonjs/Audio/sound";
  36224. /**
  36225. * Wraps one or more Sound objects and selects one with random weight for playback.
  36226. */
  36227. export class WeightedSound {
  36228. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36229. loop: boolean;
  36230. private _coneInnerAngle;
  36231. private _coneOuterAngle;
  36232. private _volume;
  36233. /** A Sound is currently playing. */
  36234. isPlaying: boolean;
  36235. /** A Sound is currently paused. */
  36236. isPaused: boolean;
  36237. private _sounds;
  36238. private _weights;
  36239. private _currentIndex?;
  36240. /**
  36241. * Creates a new WeightedSound from the list of sounds given.
  36242. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36243. * @param sounds Array of Sounds that will be selected from.
  36244. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36245. */
  36246. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36247. /**
  36248. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36249. */
  36250. /**
  36251. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36252. */
  36253. directionalConeInnerAngle: number;
  36254. /**
  36255. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36256. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36257. */
  36258. /**
  36259. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36260. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36261. */
  36262. directionalConeOuterAngle: number;
  36263. /**
  36264. * Playback volume.
  36265. */
  36266. /**
  36267. * Playback volume.
  36268. */
  36269. volume: number;
  36270. private _onended;
  36271. /**
  36272. * Suspend playback
  36273. */
  36274. pause(): void;
  36275. /**
  36276. * Stop playback
  36277. */
  36278. stop(): void;
  36279. /**
  36280. * Start playback.
  36281. * @param startOffset Position the clip head at a specific time in seconds.
  36282. */
  36283. play(startOffset?: number): void;
  36284. }
  36285. }
  36286. declare module "babylonjs/Audio/index" {
  36287. export * from "babylonjs/Audio/analyser";
  36288. export * from "babylonjs/Audio/audioEngine";
  36289. export * from "babylonjs/Audio/audioSceneComponent";
  36290. export * from "babylonjs/Audio/sound";
  36291. export * from "babylonjs/Audio/soundTrack";
  36292. export * from "babylonjs/Audio/weightedsound";
  36293. }
  36294. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36295. import { Behavior } from "babylonjs/Behaviors/behavior";
  36296. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36297. import { BackEase } from "babylonjs/Animations/easing";
  36298. /**
  36299. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36300. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36301. */
  36302. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36303. /**
  36304. * Gets the name of the behavior.
  36305. */
  36306. readonly name: string;
  36307. /**
  36308. * The easing function used by animations
  36309. */
  36310. static EasingFunction: BackEase;
  36311. /**
  36312. * The easing mode used by animations
  36313. */
  36314. static EasingMode: number;
  36315. /**
  36316. * The duration of the animation, in milliseconds
  36317. */
  36318. transitionDuration: number;
  36319. /**
  36320. * Length of the distance animated by the transition when lower radius is reached
  36321. */
  36322. lowerRadiusTransitionRange: number;
  36323. /**
  36324. * Length of the distance animated by the transition when upper radius is reached
  36325. */
  36326. upperRadiusTransitionRange: number;
  36327. private _autoTransitionRange;
  36328. /**
  36329. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36330. */
  36331. /**
  36332. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36333. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36334. */
  36335. autoTransitionRange: boolean;
  36336. private _attachedCamera;
  36337. private _onAfterCheckInputsObserver;
  36338. private _onMeshTargetChangedObserver;
  36339. /**
  36340. * Initializes the behavior.
  36341. */
  36342. init(): void;
  36343. /**
  36344. * Attaches the behavior to its arc rotate camera.
  36345. * @param camera Defines the camera to attach the behavior to
  36346. */
  36347. attach(camera: ArcRotateCamera): void;
  36348. /**
  36349. * Detaches the behavior from its current arc rotate camera.
  36350. */
  36351. detach(): void;
  36352. private _radiusIsAnimating;
  36353. private _radiusBounceTransition;
  36354. private _animatables;
  36355. private _cachedWheelPrecision;
  36356. /**
  36357. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36358. * @param radiusLimit The limit to check against.
  36359. * @return Bool to indicate if at limit.
  36360. */
  36361. private _isRadiusAtLimit;
  36362. /**
  36363. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36364. * @param radiusDelta The delta by which to animate to. Can be negative.
  36365. */
  36366. private _applyBoundRadiusAnimation;
  36367. /**
  36368. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36369. */
  36370. protected _clearAnimationLocks(): void;
  36371. /**
  36372. * Stops and removes all animations that have been applied to the camera
  36373. */
  36374. stopAllAnimations(): void;
  36375. }
  36376. }
  36377. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36378. import { Behavior } from "babylonjs/Behaviors/behavior";
  36379. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36380. import { ExponentialEase } from "babylonjs/Animations/easing";
  36381. import { Nullable } from "babylonjs/types";
  36382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36383. import { Vector3 } from "babylonjs/Maths/math.vector";
  36384. /**
  36385. * 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.
  36386. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36387. */
  36388. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36389. /**
  36390. * Gets the name of the behavior.
  36391. */
  36392. readonly name: string;
  36393. private _mode;
  36394. private _radiusScale;
  36395. private _positionScale;
  36396. private _defaultElevation;
  36397. private _elevationReturnTime;
  36398. private _elevationReturnWaitTime;
  36399. private _zoomStopsAnimation;
  36400. private _framingTime;
  36401. /**
  36402. * The easing function used by animations
  36403. */
  36404. static EasingFunction: ExponentialEase;
  36405. /**
  36406. * The easing mode used by animations
  36407. */
  36408. static EasingMode: number;
  36409. /**
  36410. * Sets the current mode used by the behavior
  36411. */
  36412. /**
  36413. * Gets current mode used by the behavior.
  36414. */
  36415. mode: number;
  36416. /**
  36417. * Sets the scale applied to the radius (1 by default)
  36418. */
  36419. /**
  36420. * Gets the scale applied to the radius
  36421. */
  36422. radiusScale: number;
  36423. /**
  36424. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36425. */
  36426. /**
  36427. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36428. */
  36429. positionScale: number;
  36430. /**
  36431. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36432. * behaviour is triggered, in radians.
  36433. */
  36434. /**
  36435. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36436. * behaviour is triggered, in radians.
  36437. */
  36438. defaultElevation: number;
  36439. /**
  36440. * Sets the time (in milliseconds) taken to return to the default beta position.
  36441. * Negative value indicates camera should not return to default.
  36442. */
  36443. /**
  36444. * Gets the time (in milliseconds) taken to return to the default beta position.
  36445. * Negative value indicates camera should not return to default.
  36446. */
  36447. elevationReturnTime: number;
  36448. /**
  36449. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36450. */
  36451. /**
  36452. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36453. */
  36454. elevationReturnWaitTime: number;
  36455. /**
  36456. * Sets the flag that indicates if user zooming should stop animation.
  36457. */
  36458. /**
  36459. * Gets the flag that indicates if user zooming should stop animation.
  36460. */
  36461. zoomStopsAnimation: boolean;
  36462. /**
  36463. * Sets the transition time when framing the mesh, in milliseconds
  36464. */
  36465. /**
  36466. * Gets the transition time when framing the mesh, in milliseconds
  36467. */
  36468. framingTime: number;
  36469. /**
  36470. * Define if the behavior should automatically change the configured
  36471. * camera limits and sensibilities.
  36472. */
  36473. autoCorrectCameraLimitsAndSensibility: boolean;
  36474. private _onPrePointerObservableObserver;
  36475. private _onAfterCheckInputsObserver;
  36476. private _onMeshTargetChangedObserver;
  36477. private _attachedCamera;
  36478. private _isPointerDown;
  36479. private _lastInteractionTime;
  36480. /**
  36481. * Initializes the behavior.
  36482. */
  36483. init(): void;
  36484. /**
  36485. * Attaches the behavior to its arc rotate camera.
  36486. * @param camera Defines the camera to attach the behavior to
  36487. */
  36488. attach(camera: ArcRotateCamera): void;
  36489. /**
  36490. * Detaches the behavior from its current arc rotate camera.
  36491. */
  36492. detach(): void;
  36493. private _animatables;
  36494. private _betaIsAnimating;
  36495. private _betaTransition;
  36496. private _radiusTransition;
  36497. private _vectorTransition;
  36498. /**
  36499. * Targets the given mesh and updates zoom level accordingly.
  36500. * @param mesh The mesh to target.
  36501. * @param radius Optional. If a cached radius position already exists, overrides default.
  36502. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36503. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36504. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36505. */
  36506. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36507. /**
  36508. * Targets the given mesh with its children and updates zoom level accordingly.
  36509. * @param mesh The mesh to target.
  36510. * @param radius Optional. If a cached radius position already exists, overrides default.
  36511. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36512. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36513. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36514. */
  36515. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36516. /**
  36517. * Targets the given meshes with their children and updates zoom level accordingly.
  36518. * @param meshes The mesh to target.
  36519. * @param radius Optional. If a cached radius position already exists, overrides default.
  36520. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36521. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36522. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36523. */
  36524. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36525. /**
  36526. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36527. * @param minimumWorld Determines the smaller position of the bounding box extend
  36528. * @param maximumWorld Determines the bigger position of the bounding box extend
  36529. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36530. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36531. */
  36532. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36533. /**
  36534. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36535. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36536. * frustum width.
  36537. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36538. * to fully enclose the mesh in the viewing frustum.
  36539. */
  36540. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36541. /**
  36542. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36543. * is automatically returned to its default position (expected to be above ground plane).
  36544. */
  36545. private _maintainCameraAboveGround;
  36546. /**
  36547. * Returns the frustum slope based on the canvas ratio and camera FOV
  36548. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36549. */
  36550. private _getFrustumSlope;
  36551. /**
  36552. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36553. */
  36554. private _clearAnimationLocks;
  36555. /**
  36556. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36557. */
  36558. private _applyUserInteraction;
  36559. /**
  36560. * Stops and removes all animations that have been applied to the camera
  36561. */
  36562. stopAllAnimations(): void;
  36563. /**
  36564. * Gets a value indicating if the user is moving the camera
  36565. */
  36566. readonly isUserIsMoving: boolean;
  36567. /**
  36568. * The camera can move all the way towards the mesh.
  36569. */
  36570. static IgnoreBoundsSizeMode: number;
  36571. /**
  36572. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36573. */
  36574. static FitFrustumSidesMode: number;
  36575. }
  36576. }
  36577. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36578. import { Nullable } from "babylonjs/types";
  36579. import { Camera } from "babylonjs/Cameras/camera";
  36580. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36581. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36582. /**
  36583. * Base class for Camera Pointer Inputs.
  36584. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36585. * for example usage.
  36586. */
  36587. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36588. /**
  36589. * Defines the camera the input is attached to.
  36590. */
  36591. abstract camera: Camera;
  36592. /**
  36593. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36594. */
  36595. protected _altKey: boolean;
  36596. protected _ctrlKey: boolean;
  36597. protected _metaKey: boolean;
  36598. protected _shiftKey: boolean;
  36599. /**
  36600. * Which mouse buttons were pressed at time of last mouse event.
  36601. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36602. */
  36603. protected _buttonsPressed: number;
  36604. /**
  36605. * Defines the buttons associated with the input to handle camera move.
  36606. */
  36607. buttons: number[];
  36608. /**
  36609. * Attach the input controls to a specific dom element to get the input from.
  36610. * @param element Defines the element the controls should be listened from
  36611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36612. */
  36613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36614. /**
  36615. * Detach the current controls from the specified dom element.
  36616. * @param element Defines the element to stop listening the inputs from
  36617. */
  36618. detachControl(element: Nullable<HTMLElement>): void;
  36619. /**
  36620. * Gets the class name of the current input.
  36621. * @returns the class name
  36622. */
  36623. getClassName(): string;
  36624. /**
  36625. * Get the friendly name associated with the input class.
  36626. * @returns the input friendly name
  36627. */
  36628. getSimpleName(): string;
  36629. /**
  36630. * Called on pointer POINTERDOUBLETAP event.
  36631. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36632. */
  36633. protected onDoubleTap(type: string): void;
  36634. /**
  36635. * Called on pointer POINTERMOVE event if only a single touch is active.
  36636. * Override this method to provide functionality.
  36637. */
  36638. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36639. /**
  36640. * Called on pointer POINTERMOVE event if multiple touches are active.
  36641. * Override this method to provide functionality.
  36642. */
  36643. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36644. /**
  36645. * Called on JS contextmenu event.
  36646. * Override this method to provide functionality.
  36647. */
  36648. protected onContextMenu(evt: PointerEvent): void;
  36649. /**
  36650. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36651. * press.
  36652. * Override this method to provide functionality.
  36653. */
  36654. protected onButtonDown(evt: PointerEvent): void;
  36655. /**
  36656. * Called each time a new POINTERUP event occurs. Ie, for each button
  36657. * release.
  36658. * Override this method to provide functionality.
  36659. */
  36660. protected onButtonUp(evt: PointerEvent): void;
  36661. /**
  36662. * Called when window becomes inactive.
  36663. * Override this method to provide functionality.
  36664. */
  36665. protected onLostFocus(): void;
  36666. private _pointerInput;
  36667. private _observer;
  36668. private _onLostFocus;
  36669. private pointA;
  36670. private pointB;
  36671. }
  36672. }
  36673. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36674. import { Nullable } from "babylonjs/types";
  36675. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36676. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36677. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36678. /**
  36679. * Manage the pointers inputs to control an arc rotate camera.
  36680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36681. */
  36682. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36683. /**
  36684. * Defines the camera the input is attached to.
  36685. */
  36686. camera: ArcRotateCamera;
  36687. /**
  36688. * Gets the class name of the current input.
  36689. * @returns the class name
  36690. */
  36691. getClassName(): string;
  36692. /**
  36693. * Defines the buttons associated with the input to handle camera move.
  36694. */
  36695. buttons: number[];
  36696. /**
  36697. * Defines the pointer angular sensibility along the X axis or how fast is
  36698. * the camera rotating.
  36699. */
  36700. angularSensibilityX: number;
  36701. /**
  36702. * Defines the pointer angular sensibility along the Y axis or how fast is
  36703. * the camera rotating.
  36704. */
  36705. angularSensibilityY: number;
  36706. /**
  36707. * Defines the pointer pinch precision or how fast is the camera zooming.
  36708. */
  36709. pinchPrecision: number;
  36710. /**
  36711. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36712. * from 0.
  36713. * It defines the percentage of current camera.radius to use as delta when
  36714. * pinch zoom is used.
  36715. */
  36716. pinchDeltaPercentage: number;
  36717. /**
  36718. * Defines the pointer panning sensibility or how fast is the camera moving.
  36719. */
  36720. panningSensibility: number;
  36721. /**
  36722. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36723. */
  36724. multiTouchPanning: boolean;
  36725. /**
  36726. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36727. * zoom (pinch) through multitouch.
  36728. */
  36729. multiTouchPanAndZoom: boolean;
  36730. /**
  36731. * Revers pinch action direction.
  36732. */
  36733. pinchInwards: boolean;
  36734. private _isPanClick;
  36735. private _twoFingerActivityCount;
  36736. private _isPinching;
  36737. /**
  36738. * Called on pointer POINTERMOVE event if only a single touch is active.
  36739. */
  36740. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36741. /**
  36742. * Called on pointer POINTERDOUBLETAP event.
  36743. */
  36744. protected onDoubleTap(type: string): void;
  36745. /**
  36746. * Called on pointer POINTERMOVE event if multiple touches are active.
  36747. */
  36748. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36749. /**
  36750. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36751. * press.
  36752. */
  36753. protected onButtonDown(evt: PointerEvent): void;
  36754. /**
  36755. * Called each time a new POINTERUP event occurs. Ie, for each button
  36756. * release.
  36757. */
  36758. protected onButtonUp(evt: PointerEvent): void;
  36759. /**
  36760. * Called when window becomes inactive.
  36761. */
  36762. protected onLostFocus(): void;
  36763. }
  36764. }
  36765. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36766. import { Nullable } from "babylonjs/types";
  36767. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36768. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36769. /**
  36770. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36772. */
  36773. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36774. /**
  36775. * Defines the camera the input is attached to.
  36776. */
  36777. camera: ArcRotateCamera;
  36778. /**
  36779. * Defines the list of key codes associated with the up action (increase alpha)
  36780. */
  36781. keysUp: number[];
  36782. /**
  36783. * Defines the list of key codes associated with the down action (decrease alpha)
  36784. */
  36785. keysDown: number[];
  36786. /**
  36787. * Defines the list of key codes associated with the left action (increase beta)
  36788. */
  36789. keysLeft: number[];
  36790. /**
  36791. * Defines the list of key codes associated with the right action (decrease beta)
  36792. */
  36793. keysRight: number[];
  36794. /**
  36795. * Defines the list of key codes associated with the reset action.
  36796. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36797. */
  36798. keysReset: number[];
  36799. /**
  36800. * Defines the panning sensibility of the inputs.
  36801. * (How fast is the camera paning)
  36802. */
  36803. panningSensibility: number;
  36804. /**
  36805. * Defines the zooming sensibility of the inputs.
  36806. * (How fast is the camera zooming)
  36807. */
  36808. zoomingSensibility: number;
  36809. /**
  36810. * Defines wether maintaining the alt key down switch the movement mode from
  36811. * orientation to zoom.
  36812. */
  36813. useAltToZoom: boolean;
  36814. /**
  36815. * Rotation speed of the camera
  36816. */
  36817. angularSpeed: number;
  36818. private _keys;
  36819. private _ctrlPressed;
  36820. private _altPressed;
  36821. private _onCanvasBlurObserver;
  36822. private _onKeyboardObserver;
  36823. private _engine;
  36824. private _scene;
  36825. /**
  36826. * Attach the input controls to a specific dom element to get the input from.
  36827. * @param element Defines the element the controls should be listened from
  36828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36829. */
  36830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36831. /**
  36832. * Detach the current controls from the specified dom element.
  36833. * @param element Defines the element to stop listening the inputs from
  36834. */
  36835. detachControl(element: Nullable<HTMLElement>): void;
  36836. /**
  36837. * Update the current camera state depending on the inputs that have been used this frame.
  36838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36839. */
  36840. checkInputs(): void;
  36841. /**
  36842. * Gets the class name of the current intput.
  36843. * @returns the class name
  36844. */
  36845. getClassName(): string;
  36846. /**
  36847. * Get the friendly name associated with the input class.
  36848. * @returns the input friendly name
  36849. */
  36850. getSimpleName(): string;
  36851. }
  36852. }
  36853. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36854. import { Nullable } from "babylonjs/types";
  36855. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36856. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36857. /**
  36858. * Manage the mouse wheel inputs to control an arc rotate camera.
  36859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36860. */
  36861. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36862. /**
  36863. * Defines the camera the input is attached to.
  36864. */
  36865. camera: ArcRotateCamera;
  36866. /**
  36867. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36868. */
  36869. wheelPrecision: number;
  36870. /**
  36871. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36872. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36873. */
  36874. wheelDeltaPercentage: number;
  36875. private _wheel;
  36876. private _observer;
  36877. private computeDeltaFromMouseWheelLegacyEvent;
  36878. /**
  36879. * Attach the input controls to a specific dom element to get the input from.
  36880. * @param element Defines the element the controls should be listened from
  36881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36882. */
  36883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36884. /**
  36885. * Detach the current controls from the specified dom element.
  36886. * @param element Defines the element to stop listening the inputs from
  36887. */
  36888. detachControl(element: Nullable<HTMLElement>): void;
  36889. /**
  36890. * Gets the class name of the current intput.
  36891. * @returns the class name
  36892. */
  36893. getClassName(): string;
  36894. /**
  36895. * Get the friendly name associated with the input class.
  36896. * @returns the input friendly name
  36897. */
  36898. getSimpleName(): string;
  36899. }
  36900. }
  36901. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36902. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36903. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36904. /**
  36905. * Default Inputs manager for the ArcRotateCamera.
  36906. * It groups all the default supported inputs for ease of use.
  36907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36908. */
  36909. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36910. /**
  36911. * Instantiates a new ArcRotateCameraInputsManager.
  36912. * @param camera Defines the camera the inputs belong to
  36913. */
  36914. constructor(camera: ArcRotateCamera);
  36915. /**
  36916. * Add mouse wheel input support to the input manager.
  36917. * @returns the current input manager
  36918. */
  36919. addMouseWheel(): ArcRotateCameraInputsManager;
  36920. /**
  36921. * Add pointers input support to the input manager.
  36922. * @returns the current input manager
  36923. */
  36924. addPointers(): ArcRotateCameraInputsManager;
  36925. /**
  36926. * Add keyboard input support to the input manager.
  36927. * @returns the current input manager
  36928. */
  36929. addKeyboard(): ArcRotateCameraInputsManager;
  36930. }
  36931. }
  36932. declare module "babylonjs/Cameras/arcRotateCamera" {
  36933. import { Observable } from "babylonjs/Misc/observable";
  36934. import { Nullable } from "babylonjs/types";
  36935. import { Scene } from "babylonjs/scene";
  36936. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36938. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36939. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36940. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36941. import { Camera } from "babylonjs/Cameras/camera";
  36942. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36943. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36944. import { Collider } from "babylonjs/Collisions/collider";
  36945. /**
  36946. * This represents an orbital type of camera.
  36947. *
  36948. * 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.
  36949. * 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.
  36950. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36951. */
  36952. export class ArcRotateCamera extends TargetCamera {
  36953. /**
  36954. * Defines the rotation angle of the camera along the longitudinal axis.
  36955. */
  36956. alpha: number;
  36957. /**
  36958. * Defines the rotation angle of the camera along the latitudinal axis.
  36959. */
  36960. beta: number;
  36961. /**
  36962. * Defines the radius of the camera from it s target point.
  36963. */
  36964. radius: number;
  36965. protected _target: Vector3;
  36966. protected _targetHost: Nullable<AbstractMesh>;
  36967. /**
  36968. * Defines the target point of the camera.
  36969. * The camera looks towards it form the radius distance.
  36970. */
  36971. target: Vector3;
  36972. /**
  36973. * Define the current local position of the camera in the scene
  36974. */
  36975. position: Vector3;
  36976. protected _upVector: Vector3;
  36977. protected _upToYMatrix: Matrix;
  36978. protected _YToUpMatrix: Matrix;
  36979. /**
  36980. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36981. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36982. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36983. */
  36984. upVector: Vector3;
  36985. /**
  36986. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36987. */
  36988. setMatUp(): void;
  36989. /**
  36990. * Current inertia value on the longitudinal axis.
  36991. * The bigger this number the longer it will take for the camera to stop.
  36992. */
  36993. inertialAlphaOffset: number;
  36994. /**
  36995. * Current inertia value on the latitudinal axis.
  36996. * The bigger this number the longer it will take for the camera to stop.
  36997. */
  36998. inertialBetaOffset: number;
  36999. /**
  37000. * Current inertia value on the radius axis.
  37001. * The bigger this number the longer it will take for the camera to stop.
  37002. */
  37003. inertialRadiusOffset: number;
  37004. /**
  37005. * Minimum allowed angle on the longitudinal axis.
  37006. * This can help limiting how the Camera is able to move in the scene.
  37007. */
  37008. lowerAlphaLimit: Nullable<number>;
  37009. /**
  37010. * Maximum allowed angle on the longitudinal axis.
  37011. * This can help limiting how the Camera is able to move in the scene.
  37012. */
  37013. upperAlphaLimit: Nullable<number>;
  37014. /**
  37015. * Minimum allowed angle on the latitudinal axis.
  37016. * This can help limiting how the Camera is able to move in the scene.
  37017. */
  37018. lowerBetaLimit: number;
  37019. /**
  37020. * Maximum allowed angle on the latitudinal axis.
  37021. * This can help limiting how the Camera is able to move in the scene.
  37022. */
  37023. upperBetaLimit: number;
  37024. /**
  37025. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37026. * This can help limiting how the Camera is able to move in the scene.
  37027. */
  37028. lowerRadiusLimit: Nullable<number>;
  37029. /**
  37030. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37031. * This can help limiting how the Camera is able to move in the scene.
  37032. */
  37033. upperRadiusLimit: Nullable<number>;
  37034. /**
  37035. * Defines the current inertia value used during panning of the camera along the X axis.
  37036. */
  37037. inertialPanningX: number;
  37038. /**
  37039. * Defines the current inertia value used during panning of the camera along the Y axis.
  37040. */
  37041. inertialPanningY: number;
  37042. /**
  37043. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37044. * Basically if your fingers moves away from more than this distance you will be considered
  37045. * in pinch mode.
  37046. */
  37047. pinchToPanMaxDistance: number;
  37048. /**
  37049. * Defines the maximum distance the camera can pan.
  37050. * This could help keeping the cammera always in your scene.
  37051. */
  37052. panningDistanceLimit: Nullable<number>;
  37053. /**
  37054. * Defines the target of the camera before paning.
  37055. */
  37056. panningOriginTarget: Vector3;
  37057. /**
  37058. * Defines the value of the inertia used during panning.
  37059. * 0 would mean stop inertia and one would mean no decelleration at all.
  37060. */
  37061. panningInertia: number;
  37062. /**
  37063. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37064. */
  37065. angularSensibilityX: number;
  37066. /**
  37067. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37068. */
  37069. angularSensibilityY: number;
  37070. /**
  37071. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37072. */
  37073. pinchPrecision: number;
  37074. /**
  37075. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37076. * It will be used instead of pinchDeltaPrecision if different from 0.
  37077. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37078. */
  37079. pinchDeltaPercentage: number;
  37080. /**
  37081. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37082. */
  37083. panningSensibility: number;
  37084. /**
  37085. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37086. */
  37087. keysUp: number[];
  37088. /**
  37089. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37090. */
  37091. keysDown: number[];
  37092. /**
  37093. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37094. */
  37095. keysLeft: number[];
  37096. /**
  37097. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37098. */
  37099. keysRight: number[];
  37100. /**
  37101. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37102. */
  37103. wheelPrecision: number;
  37104. /**
  37105. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37106. * It will be used instead of pinchDeltaPrecision if different from 0.
  37107. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37108. */
  37109. wheelDeltaPercentage: number;
  37110. /**
  37111. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37112. */
  37113. zoomOnFactor: number;
  37114. /**
  37115. * Defines a screen offset for the camera position.
  37116. */
  37117. targetScreenOffset: Vector2;
  37118. /**
  37119. * Allows the camera to be completely reversed.
  37120. * If false the camera can not arrive upside down.
  37121. */
  37122. allowUpsideDown: boolean;
  37123. /**
  37124. * Define if double tap/click is used to restore the previously saved state of the camera.
  37125. */
  37126. useInputToRestoreState: boolean;
  37127. /** @hidden */
  37128. _viewMatrix: Matrix;
  37129. /** @hidden */
  37130. _useCtrlForPanning: boolean;
  37131. /** @hidden */
  37132. _panningMouseButton: number;
  37133. /**
  37134. * Defines the input associated to the camera.
  37135. */
  37136. inputs: ArcRotateCameraInputsManager;
  37137. /** @hidden */
  37138. _reset: () => void;
  37139. /**
  37140. * Defines the allowed panning axis.
  37141. */
  37142. panningAxis: Vector3;
  37143. protected _localDirection: Vector3;
  37144. protected _transformedDirection: Vector3;
  37145. private _bouncingBehavior;
  37146. /**
  37147. * Gets the bouncing behavior of the camera if it has been enabled.
  37148. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37149. */
  37150. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37151. /**
  37152. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37153. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37154. */
  37155. useBouncingBehavior: boolean;
  37156. private _framingBehavior;
  37157. /**
  37158. * Gets the framing behavior of the camera if it has been enabled.
  37159. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37160. */
  37161. readonly framingBehavior: Nullable<FramingBehavior>;
  37162. /**
  37163. * Defines if the framing behavior of the camera is enabled on the camera.
  37164. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37165. */
  37166. useFramingBehavior: boolean;
  37167. private _autoRotationBehavior;
  37168. /**
  37169. * Gets the auto rotation behavior of the camera if it has been enabled.
  37170. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37171. */
  37172. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37173. /**
  37174. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37175. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37176. */
  37177. useAutoRotationBehavior: boolean;
  37178. /**
  37179. * Observable triggered when the mesh target has been changed on the camera.
  37180. */
  37181. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37182. /**
  37183. * Event raised when the camera is colliding with a mesh.
  37184. */
  37185. onCollide: (collidedMesh: AbstractMesh) => void;
  37186. /**
  37187. * Defines whether the camera should check collision with the objects oh the scene.
  37188. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37189. */
  37190. checkCollisions: boolean;
  37191. /**
  37192. * Defines the collision radius of the camera.
  37193. * This simulates a sphere around the camera.
  37194. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37195. */
  37196. collisionRadius: Vector3;
  37197. protected _collider: Collider;
  37198. protected _previousPosition: Vector3;
  37199. protected _collisionVelocity: Vector3;
  37200. protected _newPosition: Vector3;
  37201. protected _previousAlpha: number;
  37202. protected _previousBeta: number;
  37203. protected _previousRadius: number;
  37204. protected _collisionTriggered: boolean;
  37205. protected _targetBoundingCenter: Nullable<Vector3>;
  37206. private _computationVector;
  37207. /**
  37208. * Instantiates a new ArcRotateCamera in a given scene
  37209. * @param name Defines the name of the camera
  37210. * @param alpha Defines the camera rotation along the logitudinal axis
  37211. * @param beta Defines the camera rotation along the latitudinal axis
  37212. * @param radius Defines the camera distance from its target
  37213. * @param target Defines the camera target
  37214. * @param scene Defines the scene the camera belongs to
  37215. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37216. */
  37217. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37218. /** @hidden */
  37219. _initCache(): void;
  37220. /** @hidden */
  37221. _updateCache(ignoreParentClass?: boolean): void;
  37222. protected _getTargetPosition(): Vector3;
  37223. private _storedAlpha;
  37224. private _storedBeta;
  37225. private _storedRadius;
  37226. private _storedTarget;
  37227. /**
  37228. * Stores the current state of the camera (alpha, beta, radius and target)
  37229. * @returns the camera itself
  37230. */
  37231. storeState(): Camera;
  37232. /**
  37233. * @hidden
  37234. * Restored camera state. You must call storeState() first
  37235. */
  37236. _restoreStateValues(): boolean;
  37237. /** @hidden */
  37238. _isSynchronizedViewMatrix(): boolean;
  37239. /**
  37240. * Attached controls to the current camera.
  37241. * @param element Defines the element the controls should be listened from
  37242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37243. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37244. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37245. */
  37246. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37247. /**
  37248. * Detach the current controls from the camera.
  37249. * The camera will stop reacting to inputs.
  37250. * @param element Defines the element to stop listening the inputs from
  37251. */
  37252. detachControl(element: HTMLElement): void;
  37253. /** @hidden */
  37254. _checkInputs(): void;
  37255. protected _checkLimits(): void;
  37256. /**
  37257. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37258. */
  37259. rebuildAnglesAndRadius(): void;
  37260. /**
  37261. * Use a position to define the current camera related information like aplha, beta and radius
  37262. * @param position Defines the position to set the camera at
  37263. */
  37264. setPosition(position: Vector3): void;
  37265. /**
  37266. * Defines the target the camera should look at.
  37267. * This will automatically adapt alpha beta and radius to fit within the new target.
  37268. * @param target Defines the new target as a Vector or a mesh
  37269. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37270. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37271. */
  37272. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37273. /** @hidden */
  37274. _getViewMatrix(): Matrix;
  37275. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37276. /**
  37277. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37278. * @param meshes Defines the mesh to zoom on
  37279. * @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)
  37280. */
  37281. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37282. /**
  37283. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37284. * The target will be changed but the radius
  37285. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37286. * @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)
  37287. */
  37288. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37289. min: Vector3;
  37290. max: Vector3;
  37291. distance: number;
  37292. }, doNotUpdateMaxZ?: boolean): void;
  37293. /**
  37294. * @override
  37295. * Override Camera.createRigCamera
  37296. */
  37297. createRigCamera(name: string, cameraIndex: number): Camera;
  37298. /**
  37299. * @hidden
  37300. * @override
  37301. * Override Camera._updateRigCameras
  37302. */
  37303. _updateRigCameras(): void;
  37304. /**
  37305. * Destroy the camera and release the current resources hold by it.
  37306. */
  37307. dispose(): void;
  37308. /**
  37309. * Gets the current object class name.
  37310. * @return the class name
  37311. */
  37312. getClassName(): string;
  37313. }
  37314. }
  37315. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37316. import { Behavior } from "babylonjs/Behaviors/behavior";
  37317. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37318. /**
  37319. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37320. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37321. */
  37322. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37323. /**
  37324. * Gets the name of the behavior.
  37325. */
  37326. readonly name: string;
  37327. private _zoomStopsAnimation;
  37328. private _idleRotationSpeed;
  37329. private _idleRotationWaitTime;
  37330. private _idleRotationSpinupTime;
  37331. /**
  37332. * Sets the flag that indicates if user zooming should stop animation.
  37333. */
  37334. /**
  37335. * Gets the flag that indicates if user zooming should stop animation.
  37336. */
  37337. zoomStopsAnimation: boolean;
  37338. /**
  37339. * Sets the default speed at which the camera rotates around the model.
  37340. */
  37341. /**
  37342. * Gets the default speed at which the camera rotates around the model.
  37343. */
  37344. idleRotationSpeed: number;
  37345. /**
  37346. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37347. */
  37348. /**
  37349. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37350. */
  37351. idleRotationWaitTime: number;
  37352. /**
  37353. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37354. */
  37355. /**
  37356. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37357. */
  37358. idleRotationSpinupTime: number;
  37359. /**
  37360. * Gets a value indicating if the camera is currently rotating because of this behavior
  37361. */
  37362. readonly rotationInProgress: boolean;
  37363. private _onPrePointerObservableObserver;
  37364. private _onAfterCheckInputsObserver;
  37365. private _attachedCamera;
  37366. private _isPointerDown;
  37367. private _lastFrameTime;
  37368. private _lastInteractionTime;
  37369. private _cameraRotationSpeed;
  37370. /**
  37371. * Initializes the behavior.
  37372. */
  37373. init(): void;
  37374. /**
  37375. * Attaches the behavior to its arc rotate camera.
  37376. * @param camera Defines the camera to attach the behavior to
  37377. */
  37378. attach(camera: ArcRotateCamera): void;
  37379. /**
  37380. * Detaches the behavior from its current arc rotate camera.
  37381. */
  37382. detach(): void;
  37383. /**
  37384. * Returns true if user is scrolling.
  37385. * @return true if user is scrolling.
  37386. */
  37387. private _userIsZooming;
  37388. private _lastFrameRadius;
  37389. private _shouldAnimationStopForInteraction;
  37390. /**
  37391. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37392. */
  37393. private _applyUserInteraction;
  37394. private _userIsMoving;
  37395. }
  37396. }
  37397. declare module "babylonjs/Behaviors/Cameras/index" {
  37398. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37399. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37400. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37401. }
  37402. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37403. import { Mesh } from "babylonjs/Meshes/mesh";
  37404. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37405. import { Behavior } from "babylonjs/Behaviors/behavior";
  37406. /**
  37407. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37408. */
  37409. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37410. private ui;
  37411. /**
  37412. * The name of the behavior
  37413. */
  37414. name: string;
  37415. /**
  37416. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37417. */
  37418. distanceAwayFromFace: number;
  37419. /**
  37420. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37421. */
  37422. distanceAwayFromBottomOfFace: number;
  37423. private _faceVectors;
  37424. private _target;
  37425. private _scene;
  37426. private _onRenderObserver;
  37427. private _tmpMatrix;
  37428. private _tmpVector;
  37429. /**
  37430. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37431. * @param ui The transform node that should be attched to the mesh
  37432. */
  37433. constructor(ui: TransformNode);
  37434. /**
  37435. * Initializes the behavior
  37436. */
  37437. init(): void;
  37438. private _closestFace;
  37439. private _zeroVector;
  37440. private _lookAtTmpMatrix;
  37441. private _lookAtToRef;
  37442. /**
  37443. * Attaches the AttachToBoxBehavior to the passed in mesh
  37444. * @param target The mesh that the specified node will be attached to
  37445. */
  37446. attach(target: Mesh): void;
  37447. /**
  37448. * Detaches the behavior from the mesh
  37449. */
  37450. detach(): void;
  37451. }
  37452. }
  37453. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37454. import { Behavior } from "babylonjs/Behaviors/behavior";
  37455. import { Mesh } from "babylonjs/Meshes/mesh";
  37456. /**
  37457. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37458. */
  37459. export class FadeInOutBehavior implements Behavior<Mesh> {
  37460. /**
  37461. * Time in milliseconds to delay before fading in (Default: 0)
  37462. */
  37463. delay: number;
  37464. /**
  37465. * Time in milliseconds for the mesh to fade in (Default: 300)
  37466. */
  37467. fadeInTime: number;
  37468. private _millisecondsPerFrame;
  37469. private _hovered;
  37470. private _hoverValue;
  37471. private _ownerNode;
  37472. /**
  37473. * Instatiates the FadeInOutBehavior
  37474. */
  37475. constructor();
  37476. /**
  37477. * The name of the behavior
  37478. */
  37479. readonly name: string;
  37480. /**
  37481. * Initializes the behavior
  37482. */
  37483. init(): void;
  37484. /**
  37485. * Attaches the fade behavior on the passed in mesh
  37486. * @param ownerNode The mesh that will be faded in/out once attached
  37487. */
  37488. attach(ownerNode: Mesh): void;
  37489. /**
  37490. * Detaches the behavior from the mesh
  37491. */
  37492. detach(): void;
  37493. /**
  37494. * Triggers the mesh to begin fading in or out
  37495. * @param value if the object should fade in or out (true to fade in)
  37496. */
  37497. fadeIn(value: boolean): void;
  37498. private _update;
  37499. private _setAllVisibility;
  37500. }
  37501. }
  37502. declare module "babylonjs/Misc/pivotTools" {
  37503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37504. /**
  37505. * Class containing a set of static utilities functions for managing Pivots
  37506. * @hidden
  37507. */
  37508. export class PivotTools {
  37509. private static _PivotCached;
  37510. private static _OldPivotPoint;
  37511. private static _PivotTranslation;
  37512. private static _PivotTmpVector;
  37513. /** @hidden */
  37514. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37515. /** @hidden */
  37516. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37517. }
  37518. }
  37519. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37520. import { Scene } from "babylonjs/scene";
  37521. import { Vector4 } from "babylonjs/Maths/math.vector";
  37522. import { Mesh } from "babylonjs/Meshes/mesh";
  37523. import { Nullable } from "babylonjs/types";
  37524. import { Plane } from "babylonjs/Maths/math.plane";
  37525. /**
  37526. * Class containing static functions to help procedurally build meshes
  37527. */
  37528. export class PlaneBuilder {
  37529. /**
  37530. * Creates a plane mesh
  37531. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37532. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37533. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37537. * @param name defines the name of the mesh
  37538. * @param options defines the options used to create the mesh
  37539. * @param scene defines the hosting scene
  37540. * @returns the plane mesh
  37541. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37542. */
  37543. static CreatePlane(name: string, options: {
  37544. size?: number;
  37545. width?: number;
  37546. height?: number;
  37547. sideOrientation?: number;
  37548. frontUVs?: Vector4;
  37549. backUVs?: Vector4;
  37550. updatable?: boolean;
  37551. sourcePlane?: Plane;
  37552. }, scene?: Nullable<Scene>): Mesh;
  37553. }
  37554. }
  37555. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37556. import { Behavior } from "babylonjs/Behaviors/behavior";
  37557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37558. import { Observable } from "babylonjs/Misc/observable";
  37559. import { Vector3 } from "babylonjs/Maths/math.vector";
  37560. import { Ray } from "babylonjs/Culling/ray";
  37561. import "babylonjs/Meshes/Builders/planeBuilder";
  37562. /**
  37563. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37564. */
  37565. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37566. private static _AnyMouseID;
  37567. /**
  37568. * Abstract mesh the behavior is set on
  37569. */
  37570. attachedNode: AbstractMesh;
  37571. private _dragPlane;
  37572. private _scene;
  37573. private _pointerObserver;
  37574. private _beforeRenderObserver;
  37575. private static _planeScene;
  37576. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37577. /**
  37578. * 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)
  37579. */
  37580. maxDragAngle: number;
  37581. /**
  37582. * @hidden
  37583. */
  37584. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37585. /**
  37586. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37587. */
  37588. currentDraggingPointerID: number;
  37589. /**
  37590. * The last position where the pointer hit the drag plane in world space
  37591. */
  37592. lastDragPosition: Vector3;
  37593. /**
  37594. * If the behavior is currently in a dragging state
  37595. */
  37596. dragging: boolean;
  37597. /**
  37598. * 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)
  37599. */
  37600. dragDeltaRatio: number;
  37601. /**
  37602. * If the drag plane orientation should be updated during the dragging (Default: true)
  37603. */
  37604. updateDragPlane: boolean;
  37605. private _debugMode;
  37606. private _moving;
  37607. /**
  37608. * Fires each time the attached mesh is dragged with the pointer
  37609. * * delta between last drag position and current drag position in world space
  37610. * * dragDistance along the drag axis
  37611. * * dragPlaneNormal normal of the current drag plane used during the drag
  37612. * * dragPlanePoint in world space where the drag intersects the drag plane
  37613. */
  37614. onDragObservable: Observable<{
  37615. delta: Vector3;
  37616. dragPlanePoint: Vector3;
  37617. dragPlaneNormal: Vector3;
  37618. dragDistance: number;
  37619. pointerId: number;
  37620. }>;
  37621. /**
  37622. * Fires each time a drag begins (eg. mouse down on mesh)
  37623. */
  37624. onDragStartObservable: Observable<{
  37625. dragPlanePoint: Vector3;
  37626. pointerId: number;
  37627. }>;
  37628. /**
  37629. * Fires each time a drag ends (eg. mouse release after drag)
  37630. */
  37631. onDragEndObservable: Observable<{
  37632. dragPlanePoint: Vector3;
  37633. pointerId: number;
  37634. }>;
  37635. /**
  37636. * If the attached mesh should be moved when dragged
  37637. */
  37638. moveAttached: boolean;
  37639. /**
  37640. * If the drag behavior will react to drag events (Default: true)
  37641. */
  37642. enabled: boolean;
  37643. /**
  37644. * If pointer events should start and release the drag (Default: true)
  37645. */
  37646. startAndReleaseDragOnPointerEvents: boolean;
  37647. /**
  37648. * If camera controls should be detached during the drag
  37649. */
  37650. detachCameraControls: boolean;
  37651. /**
  37652. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37653. */
  37654. useObjectOrienationForDragging: boolean;
  37655. private _options;
  37656. /**
  37657. * Creates a pointer drag behavior that can be attached to a mesh
  37658. * @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)
  37659. */
  37660. constructor(options?: {
  37661. dragAxis?: Vector3;
  37662. dragPlaneNormal?: Vector3;
  37663. });
  37664. /**
  37665. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37666. */
  37667. validateDrag: (targetPosition: Vector3) => boolean;
  37668. /**
  37669. * The name of the behavior
  37670. */
  37671. readonly name: string;
  37672. /**
  37673. * Initializes the behavior
  37674. */
  37675. init(): void;
  37676. private _tmpVector;
  37677. private _alternatePickedPoint;
  37678. private _worldDragAxis;
  37679. private _targetPosition;
  37680. private _attachedElement;
  37681. /**
  37682. * Attaches the drag behavior the passed in mesh
  37683. * @param ownerNode The mesh that will be dragged around once attached
  37684. */
  37685. attach(ownerNode: AbstractMesh): void;
  37686. /**
  37687. * Force relase the drag action by code.
  37688. */
  37689. releaseDrag(): void;
  37690. private _startDragRay;
  37691. private _lastPointerRay;
  37692. /**
  37693. * Simulates the start of a pointer drag event on the behavior
  37694. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37695. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37696. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37697. */
  37698. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37699. private _startDrag;
  37700. private _dragDelta;
  37701. private _moveDrag;
  37702. private _pickWithRayOnDragPlane;
  37703. private _pointA;
  37704. private _pointB;
  37705. private _pointC;
  37706. private _lineA;
  37707. private _lineB;
  37708. private _localAxis;
  37709. private _lookAt;
  37710. private _updateDragPlanePosition;
  37711. /**
  37712. * Detaches the behavior from the mesh
  37713. */
  37714. detach(): void;
  37715. }
  37716. }
  37717. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37718. import { Mesh } from "babylonjs/Meshes/mesh";
  37719. import { Behavior } from "babylonjs/Behaviors/behavior";
  37720. /**
  37721. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37722. */
  37723. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37724. private _dragBehaviorA;
  37725. private _dragBehaviorB;
  37726. private _startDistance;
  37727. private _initialScale;
  37728. private _targetScale;
  37729. private _ownerNode;
  37730. private _sceneRenderObserver;
  37731. /**
  37732. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37733. */
  37734. constructor();
  37735. /**
  37736. * The name of the behavior
  37737. */
  37738. readonly name: string;
  37739. /**
  37740. * Initializes the behavior
  37741. */
  37742. init(): void;
  37743. private _getCurrentDistance;
  37744. /**
  37745. * Attaches the scale behavior the passed in mesh
  37746. * @param ownerNode The mesh that will be scaled around once attached
  37747. */
  37748. attach(ownerNode: Mesh): void;
  37749. /**
  37750. * Detaches the behavior from the mesh
  37751. */
  37752. detach(): void;
  37753. }
  37754. }
  37755. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37756. import { Behavior } from "babylonjs/Behaviors/behavior";
  37757. import { Mesh } from "babylonjs/Meshes/mesh";
  37758. import { Observable } from "babylonjs/Misc/observable";
  37759. /**
  37760. * 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
  37761. */
  37762. export class SixDofDragBehavior implements Behavior<Mesh> {
  37763. private static _virtualScene;
  37764. private _ownerNode;
  37765. private _sceneRenderObserver;
  37766. private _scene;
  37767. private _targetPosition;
  37768. private _virtualOriginMesh;
  37769. private _virtualDragMesh;
  37770. private _pointerObserver;
  37771. private _moving;
  37772. private _startingOrientation;
  37773. /**
  37774. * 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)
  37775. */
  37776. private zDragFactor;
  37777. /**
  37778. * If the object should rotate to face the drag origin
  37779. */
  37780. rotateDraggedObject: boolean;
  37781. /**
  37782. * If the behavior is currently in a dragging state
  37783. */
  37784. dragging: boolean;
  37785. /**
  37786. * 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)
  37787. */
  37788. dragDeltaRatio: number;
  37789. /**
  37790. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37791. */
  37792. currentDraggingPointerID: number;
  37793. /**
  37794. * If camera controls should be detached during the drag
  37795. */
  37796. detachCameraControls: boolean;
  37797. /**
  37798. * Fires each time a drag starts
  37799. */
  37800. onDragStartObservable: Observable<{}>;
  37801. /**
  37802. * Fires each time a drag ends (eg. mouse release after drag)
  37803. */
  37804. onDragEndObservable: Observable<{}>;
  37805. /**
  37806. * 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
  37807. */
  37808. constructor();
  37809. /**
  37810. * The name of the behavior
  37811. */
  37812. readonly name: string;
  37813. /**
  37814. * Initializes the behavior
  37815. */
  37816. init(): void;
  37817. /**
  37818. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37819. */
  37820. private readonly _pointerCamera;
  37821. /**
  37822. * Attaches the scale behavior the passed in mesh
  37823. * @param ownerNode The mesh that will be scaled around once attached
  37824. */
  37825. attach(ownerNode: Mesh): void;
  37826. /**
  37827. * Detaches the behavior from the mesh
  37828. */
  37829. detach(): void;
  37830. }
  37831. }
  37832. declare module "babylonjs/Behaviors/Meshes/index" {
  37833. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37834. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37835. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37836. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37837. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37838. }
  37839. declare module "babylonjs/Behaviors/index" {
  37840. export * from "babylonjs/Behaviors/behavior";
  37841. export * from "babylonjs/Behaviors/Cameras/index";
  37842. export * from "babylonjs/Behaviors/Meshes/index";
  37843. }
  37844. declare module "babylonjs/Bones/boneIKController" {
  37845. import { Bone } from "babylonjs/Bones/bone";
  37846. import { Vector3 } from "babylonjs/Maths/math.vector";
  37847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37848. import { Nullable } from "babylonjs/types";
  37849. /**
  37850. * Class used to apply inverse kinematics to bones
  37851. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37852. */
  37853. export class BoneIKController {
  37854. private static _tmpVecs;
  37855. private static _tmpQuat;
  37856. private static _tmpMats;
  37857. /**
  37858. * Gets or sets the target mesh
  37859. */
  37860. targetMesh: AbstractMesh;
  37861. /** Gets or sets the mesh used as pole */
  37862. poleTargetMesh: AbstractMesh;
  37863. /**
  37864. * Gets or sets the bone used as pole
  37865. */
  37866. poleTargetBone: Nullable<Bone>;
  37867. /**
  37868. * Gets or sets the target position
  37869. */
  37870. targetPosition: Vector3;
  37871. /**
  37872. * Gets or sets the pole target position
  37873. */
  37874. poleTargetPosition: Vector3;
  37875. /**
  37876. * Gets or sets the pole target local offset
  37877. */
  37878. poleTargetLocalOffset: Vector3;
  37879. /**
  37880. * Gets or sets the pole angle
  37881. */
  37882. poleAngle: number;
  37883. /**
  37884. * Gets or sets the mesh associated with the controller
  37885. */
  37886. mesh: AbstractMesh;
  37887. /**
  37888. * 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)
  37889. */
  37890. slerpAmount: number;
  37891. private _bone1Quat;
  37892. private _bone1Mat;
  37893. private _bone2Ang;
  37894. private _bone1;
  37895. private _bone2;
  37896. private _bone1Length;
  37897. private _bone2Length;
  37898. private _maxAngle;
  37899. private _maxReach;
  37900. private _rightHandedSystem;
  37901. private _bendAxis;
  37902. private _slerping;
  37903. private _adjustRoll;
  37904. /**
  37905. * Gets or sets maximum allowed angle
  37906. */
  37907. maxAngle: number;
  37908. /**
  37909. * Creates a new BoneIKController
  37910. * @param mesh defines the mesh to control
  37911. * @param bone defines the bone to control
  37912. * @param options defines options to set up the controller
  37913. */
  37914. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37915. targetMesh?: AbstractMesh;
  37916. poleTargetMesh?: AbstractMesh;
  37917. poleTargetBone?: Bone;
  37918. poleTargetLocalOffset?: Vector3;
  37919. poleAngle?: number;
  37920. bendAxis?: Vector3;
  37921. maxAngle?: number;
  37922. slerpAmount?: number;
  37923. });
  37924. private _setMaxAngle;
  37925. /**
  37926. * Force the controller to update the bones
  37927. */
  37928. update(): void;
  37929. }
  37930. }
  37931. declare module "babylonjs/Bones/boneLookController" {
  37932. import { Vector3 } from "babylonjs/Maths/math.vector";
  37933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37934. import { Bone } from "babylonjs/Bones/bone";
  37935. import { Space } from "babylonjs/Maths/math.axis";
  37936. /**
  37937. * Class used to make a bone look toward a point in space
  37938. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37939. */
  37940. export class BoneLookController {
  37941. private static _tmpVecs;
  37942. private static _tmpQuat;
  37943. private static _tmpMats;
  37944. /**
  37945. * The target Vector3 that the bone will look at
  37946. */
  37947. target: Vector3;
  37948. /**
  37949. * The mesh that the bone is attached to
  37950. */
  37951. mesh: AbstractMesh;
  37952. /**
  37953. * The bone that will be looking to the target
  37954. */
  37955. bone: Bone;
  37956. /**
  37957. * The up axis of the coordinate system that is used when the bone is rotated
  37958. */
  37959. upAxis: Vector3;
  37960. /**
  37961. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37962. */
  37963. upAxisSpace: Space;
  37964. /**
  37965. * Used to make an adjustment to the yaw of the bone
  37966. */
  37967. adjustYaw: number;
  37968. /**
  37969. * Used to make an adjustment to the pitch of the bone
  37970. */
  37971. adjustPitch: number;
  37972. /**
  37973. * Used to make an adjustment to the roll of the bone
  37974. */
  37975. adjustRoll: number;
  37976. /**
  37977. * 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)
  37978. */
  37979. slerpAmount: number;
  37980. private _minYaw;
  37981. private _maxYaw;
  37982. private _minPitch;
  37983. private _maxPitch;
  37984. private _minYawSin;
  37985. private _minYawCos;
  37986. private _maxYawSin;
  37987. private _maxYawCos;
  37988. private _midYawConstraint;
  37989. private _minPitchTan;
  37990. private _maxPitchTan;
  37991. private _boneQuat;
  37992. private _slerping;
  37993. private _transformYawPitch;
  37994. private _transformYawPitchInv;
  37995. private _firstFrameSkipped;
  37996. private _yawRange;
  37997. private _fowardAxis;
  37998. /**
  37999. * Gets or sets the minimum yaw angle that the bone can look to
  38000. */
  38001. minYaw: number;
  38002. /**
  38003. * Gets or sets the maximum yaw angle that the bone can look to
  38004. */
  38005. maxYaw: number;
  38006. /**
  38007. * Gets or sets the minimum pitch angle that the bone can look to
  38008. */
  38009. minPitch: number;
  38010. /**
  38011. * Gets or sets the maximum pitch angle that the bone can look to
  38012. */
  38013. maxPitch: number;
  38014. /**
  38015. * Create a BoneLookController
  38016. * @param mesh the mesh that the bone belongs to
  38017. * @param bone the bone that will be looking to the target
  38018. * @param target the target Vector3 to look at
  38019. * @param options optional settings:
  38020. * * maxYaw: the maximum angle the bone will yaw to
  38021. * * minYaw: the minimum angle the bone will yaw to
  38022. * * maxPitch: the maximum angle the bone will pitch to
  38023. * * minPitch: the minimum angle the bone will yaw to
  38024. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38025. * * upAxis: the up axis of the coordinate system
  38026. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38027. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38028. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38029. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38030. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38031. * * adjustRoll: used to make an adjustment to the roll of the bone
  38032. **/
  38033. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38034. maxYaw?: number;
  38035. minYaw?: number;
  38036. maxPitch?: number;
  38037. minPitch?: number;
  38038. slerpAmount?: number;
  38039. upAxis?: Vector3;
  38040. upAxisSpace?: Space;
  38041. yawAxis?: Vector3;
  38042. pitchAxis?: Vector3;
  38043. adjustYaw?: number;
  38044. adjustPitch?: number;
  38045. adjustRoll?: number;
  38046. });
  38047. /**
  38048. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38049. */
  38050. update(): void;
  38051. private _getAngleDiff;
  38052. private _getAngleBetween;
  38053. private _isAngleBetween;
  38054. }
  38055. }
  38056. declare module "babylonjs/Bones/index" {
  38057. export * from "babylonjs/Bones/bone";
  38058. export * from "babylonjs/Bones/boneIKController";
  38059. export * from "babylonjs/Bones/boneLookController";
  38060. export * from "babylonjs/Bones/skeleton";
  38061. }
  38062. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38063. import { Nullable } from "babylonjs/types";
  38064. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38065. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38066. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38067. /**
  38068. * Manage the gamepad inputs to control an arc rotate camera.
  38069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38070. */
  38071. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38072. /**
  38073. * Defines the camera the input is attached to.
  38074. */
  38075. camera: ArcRotateCamera;
  38076. /**
  38077. * Defines the gamepad the input is gathering event from.
  38078. */
  38079. gamepad: Nullable<Gamepad>;
  38080. /**
  38081. * Defines the gamepad rotation sensiblity.
  38082. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38083. */
  38084. gamepadRotationSensibility: number;
  38085. /**
  38086. * Defines the gamepad move sensiblity.
  38087. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38088. */
  38089. gamepadMoveSensibility: number;
  38090. private _onGamepadConnectedObserver;
  38091. private _onGamepadDisconnectedObserver;
  38092. /**
  38093. * Attach the input controls to a specific dom element to get the input from.
  38094. * @param element Defines the element the controls should be listened from
  38095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38096. */
  38097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38098. /**
  38099. * Detach the current controls from the specified dom element.
  38100. * @param element Defines the element to stop listening the inputs from
  38101. */
  38102. detachControl(element: Nullable<HTMLElement>): void;
  38103. /**
  38104. * Update the current camera state depending on the inputs that have been used this frame.
  38105. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38106. */
  38107. checkInputs(): void;
  38108. /**
  38109. * Gets the class name of the current intput.
  38110. * @returns the class name
  38111. */
  38112. getClassName(): string;
  38113. /**
  38114. * Get the friendly name associated with the input class.
  38115. * @returns the input friendly name
  38116. */
  38117. getSimpleName(): string;
  38118. }
  38119. }
  38120. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38121. import { Nullable } from "babylonjs/types";
  38122. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38123. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38124. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38125. interface ArcRotateCameraInputsManager {
  38126. /**
  38127. * Add orientation input support to the input manager.
  38128. * @returns the current input manager
  38129. */
  38130. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38131. }
  38132. }
  38133. /**
  38134. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38136. */
  38137. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38138. /**
  38139. * Defines the camera the input is attached to.
  38140. */
  38141. camera: ArcRotateCamera;
  38142. /**
  38143. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38144. */
  38145. alphaCorrection: number;
  38146. /**
  38147. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38148. */
  38149. gammaCorrection: number;
  38150. private _alpha;
  38151. private _gamma;
  38152. private _dirty;
  38153. private _deviceOrientationHandler;
  38154. /**
  38155. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38156. */
  38157. constructor();
  38158. /**
  38159. * Attach the input controls to a specific dom element to get the input from.
  38160. * @param element Defines the element the controls should be listened from
  38161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38162. */
  38163. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38164. /** @hidden */
  38165. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38166. /**
  38167. * Update the current camera state depending on the inputs that have been used this frame.
  38168. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38169. */
  38170. checkInputs(): void;
  38171. /**
  38172. * Detach the current controls from the specified dom element.
  38173. * @param element Defines the element to stop listening the inputs from
  38174. */
  38175. detachControl(element: Nullable<HTMLElement>): void;
  38176. /**
  38177. * Gets the class name of the current intput.
  38178. * @returns the class name
  38179. */
  38180. getClassName(): string;
  38181. /**
  38182. * Get the friendly name associated with the input class.
  38183. * @returns the input friendly name
  38184. */
  38185. getSimpleName(): string;
  38186. }
  38187. }
  38188. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38189. import { Nullable } from "babylonjs/types";
  38190. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38191. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38192. /**
  38193. * Listen to mouse events to control the camera.
  38194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38195. */
  38196. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38197. /**
  38198. * Defines the camera the input is attached to.
  38199. */
  38200. camera: FlyCamera;
  38201. /**
  38202. * Defines if touch is enabled. (Default is true.)
  38203. */
  38204. touchEnabled: boolean;
  38205. /**
  38206. * Defines the buttons associated with the input to handle camera rotation.
  38207. */
  38208. buttons: number[];
  38209. /**
  38210. * Assign buttons for Yaw control.
  38211. */
  38212. buttonsYaw: number[];
  38213. /**
  38214. * Assign buttons for Pitch control.
  38215. */
  38216. buttonsPitch: number[];
  38217. /**
  38218. * Assign buttons for Roll control.
  38219. */
  38220. buttonsRoll: number[];
  38221. /**
  38222. * Detect if any button is being pressed while mouse is moved.
  38223. * -1 = Mouse locked.
  38224. * 0 = Left button.
  38225. * 1 = Middle Button.
  38226. * 2 = Right Button.
  38227. */
  38228. activeButton: number;
  38229. /**
  38230. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38231. * Higher values reduce its sensitivity.
  38232. */
  38233. angularSensibility: number;
  38234. private _mousemoveCallback;
  38235. private _observer;
  38236. private _rollObserver;
  38237. private previousPosition;
  38238. private noPreventDefault;
  38239. private element;
  38240. /**
  38241. * Listen to mouse events to control the camera.
  38242. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38244. */
  38245. constructor(touchEnabled?: boolean);
  38246. /**
  38247. * Attach the mouse control to the HTML DOM element.
  38248. * @param element Defines the element that listens to the input events.
  38249. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38250. */
  38251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38252. /**
  38253. * Detach the current controls from the specified dom element.
  38254. * @param element Defines the element to stop listening the inputs from
  38255. */
  38256. detachControl(element: Nullable<HTMLElement>): void;
  38257. /**
  38258. * Gets the class name of the current input.
  38259. * @returns the class name.
  38260. */
  38261. getClassName(): string;
  38262. /**
  38263. * Get the friendly name associated with the input class.
  38264. * @returns the input's friendly name.
  38265. */
  38266. getSimpleName(): string;
  38267. private _pointerInput;
  38268. private _onMouseMove;
  38269. /**
  38270. * Rotate camera by mouse offset.
  38271. */
  38272. private rotateCamera;
  38273. }
  38274. }
  38275. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38276. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38277. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38278. /**
  38279. * Default Inputs manager for the FlyCamera.
  38280. * It groups all the default supported inputs for ease of use.
  38281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38282. */
  38283. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38284. /**
  38285. * Instantiates a new FlyCameraInputsManager.
  38286. * @param camera Defines the camera the inputs belong to.
  38287. */
  38288. constructor(camera: FlyCamera);
  38289. /**
  38290. * Add keyboard input support to the input manager.
  38291. * @returns the new FlyCameraKeyboardMoveInput().
  38292. */
  38293. addKeyboard(): FlyCameraInputsManager;
  38294. /**
  38295. * Add mouse input support to the input manager.
  38296. * @param touchEnabled Enable touch screen support.
  38297. * @returns the new FlyCameraMouseInput().
  38298. */
  38299. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38300. }
  38301. }
  38302. declare module "babylonjs/Cameras/flyCamera" {
  38303. import { Scene } from "babylonjs/scene";
  38304. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38306. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38307. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38308. /**
  38309. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38310. * such as in a 3D Space Shooter or a Flight Simulator.
  38311. */
  38312. export class FlyCamera extends TargetCamera {
  38313. /**
  38314. * Define the collision ellipsoid of the camera.
  38315. * This is helpful for simulating a camera body, like a player's body.
  38316. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38317. */
  38318. ellipsoid: Vector3;
  38319. /**
  38320. * Define an offset for the position of the ellipsoid around the camera.
  38321. * This can be helpful if the camera is attached away from the player's body center,
  38322. * such as at its head.
  38323. */
  38324. ellipsoidOffset: Vector3;
  38325. /**
  38326. * Enable or disable collisions of the camera with the rest of the scene objects.
  38327. */
  38328. checkCollisions: boolean;
  38329. /**
  38330. * Enable or disable gravity on the camera.
  38331. */
  38332. applyGravity: boolean;
  38333. /**
  38334. * Define the current direction the camera is moving to.
  38335. */
  38336. cameraDirection: Vector3;
  38337. /**
  38338. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38339. * This overrides and empties cameraRotation.
  38340. */
  38341. rotationQuaternion: Quaternion;
  38342. /**
  38343. * Track Roll to maintain the wanted Rolling when looking around.
  38344. */
  38345. _trackRoll: number;
  38346. /**
  38347. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38348. */
  38349. rollCorrect: number;
  38350. /**
  38351. * Mimic a banked turn, Rolling the camera when Yawing.
  38352. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38353. */
  38354. bankedTurn: boolean;
  38355. /**
  38356. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38357. */
  38358. bankedTurnLimit: number;
  38359. /**
  38360. * Value of 0 disables the banked Roll.
  38361. * Value of 1 is equal to the Yaw angle in radians.
  38362. */
  38363. bankedTurnMultiplier: number;
  38364. /**
  38365. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38366. */
  38367. inputs: FlyCameraInputsManager;
  38368. /**
  38369. * Gets the input sensibility for mouse input.
  38370. * Higher values reduce sensitivity.
  38371. */
  38372. /**
  38373. * Sets the input sensibility for a mouse input.
  38374. * Higher values reduce sensitivity.
  38375. */
  38376. angularSensibility: number;
  38377. /**
  38378. * Get the keys for camera movement forward.
  38379. */
  38380. /**
  38381. * Set the keys for camera movement forward.
  38382. */
  38383. keysForward: number[];
  38384. /**
  38385. * Get the keys for camera movement backward.
  38386. */
  38387. keysBackward: number[];
  38388. /**
  38389. * Get the keys for camera movement up.
  38390. */
  38391. /**
  38392. * Set the keys for camera movement up.
  38393. */
  38394. keysUp: number[];
  38395. /**
  38396. * Get the keys for camera movement down.
  38397. */
  38398. /**
  38399. * Set the keys for camera movement down.
  38400. */
  38401. keysDown: number[];
  38402. /**
  38403. * Get the keys for camera movement left.
  38404. */
  38405. /**
  38406. * Set the keys for camera movement left.
  38407. */
  38408. keysLeft: number[];
  38409. /**
  38410. * Set the keys for camera movement right.
  38411. */
  38412. /**
  38413. * Set the keys for camera movement right.
  38414. */
  38415. keysRight: number[];
  38416. /**
  38417. * Event raised when the camera collides with a mesh in the scene.
  38418. */
  38419. onCollide: (collidedMesh: AbstractMesh) => void;
  38420. private _collider;
  38421. private _needMoveForGravity;
  38422. private _oldPosition;
  38423. private _diffPosition;
  38424. private _newPosition;
  38425. /** @hidden */
  38426. _localDirection: Vector3;
  38427. /** @hidden */
  38428. _transformedDirection: Vector3;
  38429. /**
  38430. * Instantiates a FlyCamera.
  38431. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38432. * such as in a 3D Space Shooter or a Flight Simulator.
  38433. * @param name Define the name of the camera in the scene.
  38434. * @param position Define the starting position of the camera in the scene.
  38435. * @param scene Define the scene the camera belongs to.
  38436. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38437. */
  38438. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38439. /**
  38440. * Attach a control to the HTML DOM element.
  38441. * @param element Defines the element that listens to the input events.
  38442. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38443. */
  38444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38445. /**
  38446. * Detach a control from the HTML DOM element.
  38447. * The camera will stop reacting to that input.
  38448. * @param element Defines the element that listens to the input events.
  38449. */
  38450. detachControl(element: HTMLElement): void;
  38451. private _collisionMask;
  38452. /**
  38453. * Get the mask that the camera ignores in collision events.
  38454. */
  38455. /**
  38456. * Set the mask that the camera ignores in collision events.
  38457. */
  38458. collisionMask: number;
  38459. /** @hidden */
  38460. _collideWithWorld(displacement: Vector3): void;
  38461. /** @hidden */
  38462. private _onCollisionPositionChange;
  38463. /** @hidden */
  38464. _checkInputs(): void;
  38465. /** @hidden */
  38466. _decideIfNeedsToMove(): boolean;
  38467. /** @hidden */
  38468. _updatePosition(): void;
  38469. /**
  38470. * Restore the Roll to its target value at the rate specified.
  38471. * @param rate - Higher means slower restoring.
  38472. * @hidden
  38473. */
  38474. restoreRoll(rate: number): void;
  38475. /**
  38476. * Destroy the camera and release the current resources held by it.
  38477. */
  38478. dispose(): void;
  38479. /**
  38480. * Get the current object class name.
  38481. * @returns the class name.
  38482. */
  38483. getClassName(): string;
  38484. }
  38485. }
  38486. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38487. import { Nullable } from "babylonjs/types";
  38488. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38489. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38490. /**
  38491. * Listen to keyboard events to control the camera.
  38492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38493. */
  38494. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38495. /**
  38496. * Defines the camera the input is attached to.
  38497. */
  38498. camera: FlyCamera;
  38499. /**
  38500. * The list of keyboard keys used to control the forward move of the camera.
  38501. */
  38502. keysForward: number[];
  38503. /**
  38504. * The list of keyboard keys used to control the backward move of the camera.
  38505. */
  38506. keysBackward: number[];
  38507. /**
  38508. * The list of keyboard keys used to control the forward move of the camera.
  38509. */
  38510. keysUp: number[];
  38511. /**
  38512. * The list of keyboard keys used to control the backward move of the camera.
  38513. */
  38514. keysDown: number[];
  38515. /**
  38516. * The list of keyboard keys used to control the right strafe move of the camera.
  38517. */
  38518. keysRight: number[];
  38519. /**
  38520. * The list of keyboard keys used to control the left strafe move of the camera.
  38521. */
  38522. keysLeft: number[];
  38523. private _keys;
  38524. private _onCanvasBlurObserver;
  38525. private _onKeyboardObserver;
  38526. private _engine;
  38527. private _scene;
  38528. /**
  38529. * Attach the input controls to a specific dom element to get the input from.
  38530. * @param element Defines the element the controls should be listened from
  38531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38532. */
  38533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38534. /**
  38535. * Detach the current controls from the specified dom element.
  38536. * @param element Defines the element to stop listening the inputs from
  38537. */
  38538. detachControl(element: Nullable<HTMLElement>): void;
  38539. /**
  38540. * Gets the class name of the current intput.
  38541. * @returns the class name
  38542. */
  38543. getClassName(): string;
  38544. /** @hidden */
  38545. _onLostFocus(e: FocusEvent): void;
  38546. /**
  38547. * Get the friendly name associated with the input class.
  38548. * @returns the input friendly name
  38549. */
  38550. getSimpleName(): string;
  38551. /**
  38552. * Update the current camera state depending on the inputs that have been used this frame.
  38553. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38554. */
  38555. checkInputs(): void;
  38556. }
  38557. }
  38558. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38559. import { Nullable } from "babylonjs/types";
  38560. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38561. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38562. /**
  38563. * Manage the mouse wheel inputs to control a follow camera.
  38564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38565. */
  38566. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38567. /**
  38568. * Defines the camera the input is attached to.
  38569. */
  38570. camera: FollowCamera;
  38571. /**
  38572. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38573. */
  38574. axisControlRadius: boolean;
  38575. /**
  38576. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38577. */
  38578. axisControlHeight: boolean;
  38579. /**
  38580. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38581. */
  38582. axisControlRotation: boolean;
  38583. /**
  38584. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38585. * relation to mouseWheel events.
  38586. */
  38587. wheelPrecision: number;
  38588. /**
  38589. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38590. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38591. */
  38592. wheelDeltaPercentage: number;
  38593. private _wheel;
  38594. private _observer;
  38595. /**
  38596. * Attach the input controls to a specific dom element to get the input from.
  38597. * @param element Defines the element the controls should be listened from
  38598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38599. */
  38600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38601. /**
  38602. * Detach the current controls from the specified dom element.
  38603. * @param element Defines the element to stop listening the inputs from
  38604. */
  38605. detachControl(element: Nullable<HTMLElement>): void;
  38606. /**
  38607. * Gets the class name of the current intput.
  38608. * @returns the class name
  38609. */
  38610. getClassName(): string;
  38611. /**
  38612. * Get the friendly name associated with the input class.
  38613. * @returns the input friendly name
  38614. */
  38615. getSimpleName(): string;
  38616. }
  38617. }
  38618. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38619. import { Nullable } from "babylonjs/types";
  38620. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38621. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38622. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38623. /**
  38624. * Manage the pointers inputs to control an follow camera.
  38625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38626. */
  38627. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38628. /**
  38629. * Defines the camera the input is attached to.
  38630. */
  38631. camera: FollowCamera;
  38632. /**
  38633. * Gets the class name of the current input.
  38634. * @returns the class name
  38635. */
  38636. getClassName(): string;
  38637. /**
  38638. * Defines the pointer angular sensibility along the X axis or how fast is
  38639. * the camera rotating.
  38640. * A negative number will reverse the axis direction.
  38641. */
  38642. angularSensibilityX: number;
  38643. /**
  38644. * Defines the pointer angular sensibility along the Y axis or how fast is
  38645. * the camera rotating.
  38646. * A negative number will reverse the axis direction.
  38647. */
  38648. angularSensibilityY: number;
  38649. /**
  38650. * Defines the pointer pinch precision or how fast is the camera zooming.
  38651. * A negative number will reverse the axis direction.
  38652. */
  38653. pinchPrecision: number;
  38654. /**
  38655. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38656. * from 0.
  38657. * It defines the percentage of current camera.radius to use as delta when
  38658. * pinch zoom is used.
  38659. */
  38660. pinchDeltaPercentage: number;
  38661. /**
  38662. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38663. */
  38664. axisXControlRadius: boolean;
  38665. /**
  38666. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38667. */
  38668. axisXControlHeight: boolean;
  38669. /**
  38670. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38671. */
  38672. axisXControlRotation: boolean;
  38673. /**
  38674. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38675. */
  38676. axisYControlRadius: boolean;
  38677. /**
  38678. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38679. */
  38680. axisYControlHeight: boolean;
  38681. /**
  38682. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38683. */
  38684. axisYControlRotation: boolean;
  38685. /**
  38686. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38687. */
  38688. axisPinchControlRadius: boolean;
  38689. /**
  38690. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38691. */
  38692. axisPinchControlHeight: boolean;
  38693. /**
  38694. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38695. */
  38696. axisPinchControlRotation: boolean;
  38697. /**
  38698. * Log error messages if basic misconfiguration has occurred.
  38699. */
  38700. warningEnable: boolean;
  38701. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38702. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38703. private _warningCounter;
  38704. private _warning;
  38705. }
  38706. }
  38707. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38708. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38709. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38710. /**
  38711. * Default Inputs manager for the FollowCamera.
  38712. * It groups all the default supported inputs for ease of use.
  38713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38714. */
  38715. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38716. /**
  38717. * Instantiates a new FollowCameraInputsManager.
  38718. * @param camera Defines the camera the inputs belong to
  38719. */
  38720. constructor(camera: FollowCamera);
  38721. /**
  38722. * Add keyboard input support to the input manager.
  38723. * @returns the current input manager
  38724. */
  38725. addKeyboard(): FollowCameraInputsManager;
  38726. /**
  38727. * Add mouse wheel input support to the input manager.
  38728. * @returns the current input manager
  38729. */
  38730. addMouseWheel(): FollowCameraInputsManager;
  38731. /**
  38732. * Add pointers input support to the input manager.
  38733. * @returns the current input manager
  38734. */
  38735. addPointers(): FollowCameraInputsManager;
  38736. /**
  38737. * Add orientation input support to the input manager.
  38738. * @returns the current input manager
  38739. */
  38740. addVRDeviceOrientation(): FollowCameraInputsManager;
  38741. }
  38742. }
  38743. declare module "babylonjs/Cameras/followCamera" {
  38744. import { Nullable } from "babylonjs/types";
  38745. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38746. import { Scene } from "babylonjs/scene";
  38747. import { Vector3 } from "babylonjs/Maths/math.vector";
  38748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38749. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38750. /**
  38751. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38752. * an arc rotate version arcFollowCamera are available.
  38753. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38754. */
  38755. export class FollowCamera extends TargetCamera {
  38756. /**
  38757. * Distance the follow camera should follow an object at
  38758. */
  38759. radius: number;
  38760. /**
  38761. * Minimum allowed distance of the camera to the axis of rotation
  38762. * (The camera can not get closer).
  38763. * This can help limiting how the Camera is able to move in the scene.
  38764. */
  38765. lowerRadiusLimit: Nullable<number>;
  38766. /**
  38767. * Maximum allowed distance of the camera to the axis of rotation
  38768. * (The camera can not get further).
  38769. * This can help limiting how the Camera is able to move in the scene.
  38770. */
  38771. upperRadiusLimit: Nullable<number>;
  38772. /**
  38773. * Define a rotation offset between the camera and the object it follows
  38774. */
  38775. rotationOffset: number;
  38776. /**
  38777. * Minimum allowed angle to camera position relative to target object.
  38778. * This can help limiting how the Camera is able to move in the scene.
  38779. */
  38780. lowerRotationOffsetLimit: Nullable<number>;
  38781. /**
  38782. * Maximum allowed angle to camera position relative to target object.
  38783. * This can help limiting how the Camera is able to move in the scene.
  38784. */
  38785. upperRotationOffsetLimit: Nullable<number>;
  38786. /**
  38787. * Define a height offset between the camera and the object it follows.
  38788. * It can help following an object from the top (like a car chaing a plane)
  38789. */
  38790. heightOffset: number;
  38791. /**
  38792. * Minimum allowed height of camera position relative to target object.
  38793. * This can help limiting how the Camera is able to move in the scene.
  38794. */
  38795. lowerHeightOffsetLimit: Nullable<number>;
  38796. /**
  38797. * Maximum allowed height of camera position relative to target object.
  38798. * This can help limiting how the Camera is able to move in the scene.
  38799. */
  38800. upperHeightOffsetLimit: Nullable<number>;
  38801. /**
  38802. * Define how fast the camera can accelerate to follow it s target.
  38803. */
  38804. cameraAcceleration: number;
  38805. /**
  38806. * Define the speed limit of the camera following an object.
  38807. */
  38808. maxCameraSpeed: number;
  38809. /**
  38810. * Define the target of the camera.
  38811. */
  38812. lockedTarget: Nullable<AbstractMesh>;
  38813. /**
  38814. * Defines the input associated with the camera.
  38815. */
  38816. inputs: FollowCameraInputsManager;
  38817. /**
  38818. * Instantiates the follow camera.
  38819. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38820. * @param name Define the name of the camera in the scene
  38821. * @param position Define the position of the camera
  38822. * @param scene Define the scene the camera belong to
  38823. * @param lockedTarget Define the target of the camera
  38824. */
  38825. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38826. private _follow;
  38827. /**
  38828. * Attached controls to the current camera.
  38829. * @param element Defines the element the controls should be listened from
  38830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38831. */
  38832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38833. /**
  38834. * Detach the current controls from the camera.
  38835. * The camera will stop reacting to inputs.
  38836. * @param element Defines the element to stop listening the inputs from
  38837. */
  38838. detachControl(element: HTMLElement): void;
  38839. /** @hidden */
  38840. _checkInputs(): void;
  38841. private _checkLimits;
  38842. /**
  38843. * Gets the camera class name.
  38844. * @returns the class name
  38845. */
  38846. getClassName(): string;
  38847. }
  38848. /**
  38849. * Arc Rotate version of the follow camera.
  38850. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38851. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38852. */
  38853. export class ArcFollowCamera extends TargetCamera {
  38854. /** The longitudinal angle of the camera */
  38855. alpha: number;
  38856. /** The latitudinal angle of the camera */
  38857. beta: number;
  38858. /** The radius of the camera from its target */
  38859. radius: number;
  38860. /** Define the camera target (the messh it should follow) */
  38861. target: Nullable<AbstractMesh>;
  38862. private _cartesianCoordinates;
  38863. /**
  38864. * Instantiates a new ArcFollowCamera
  38865. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38866. * @param name Define the name of the camera
  38867. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38868. * @param beta Define the rotation angle of the camera around the elevation axis
  38869. * @param radius Define the radius of the camera from its target point
  38870. * @param target Define the target of the camera
  38871. * @param scene Define the scene the camera belongs to
  38872. */
  38873. constructor(name: string,
  38874. /** The longitudinal angle of the camera */
  38875. alpha: number,
  38876. /** The latitudinal angle of the camera */
  38877. beta: number,
  38878. /** The radius of the camera from its target */
  38879. radius: number,
  38880. /** Define the camera target (the messh it should follow) */
  38881. target: Nullable<AbstractMesh>, scene: Scene);
  38882. private _follow;
  38883. /** @hidden */
  38884. _checkInputs(): void;
  38885. /**
  38886. * Returns the class name of the object.
  38887. * It is mostly used internally for serialization purposes.
  38888. */
  38889. getClassName(): string;
  38890. }
  38891. }
  38892. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38893. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38894. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38895. import { Nullable } from "babylonjs/types";
  38896. /**
  38897. * Manage the keyboard inputs to control the movement of a follow camera.
  38898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38899. */
  38900. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38901. /**
  38902. * Defines the camera the input is attached to.
  38903. */
  38904. camera: FollowCamera;
  38905. /**
  38906. * Defines the list of key codes associated with the up action (increase heightOffset)
  38907. */
  38908. keysHeightOffsetIncr: number[];
  38909. /**
  38910. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38911. */
  38912. keysHeightOffsetDecr: number[];
  38913. /**
  38914. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38915. */
  38916. keysHeightOffsetModifierAlt: boolean;
  38917. /**
  38918. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38919. */
  38920. keysHeightOffsetModifierCtrl: boolean;
  38921. /**
  38922. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38923. */
  38924. keysHeightOffsetModifierShift: boolean;
  38925. /**
  38926. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38927. */
  38928. keysRotationOffsetIncr: number[];
  38929. /**
  38930. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38931. */
  38932. keysRotationOffsetDecr: number[];
  38933. /**
  38934. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38935. */
  38936. keysRotationOffsetModifierAlt: boolean;
  38937. /**
  38938. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38939. */
  38940. keysRotationOffsetModifierCtrl: boolean;
  38941. /**
  38942. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38943. */
  38944. keysRotationOffsetModifierShift: boolean;
  38945. /**
  38946. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38947. */
  38948. keysRadiusIncr: number[];
  38949. /**
  38950. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38951. */
  38952. keysRadiusDecr: number[];
  38953. /**
  38954. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38955. */
  38956. keysRadiusModifierAlt: boolean;
  38957. /**
  38958. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38959. */
  38960. keysRadiusModifierCtrl: boolean;
  38961. /**
  38962. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38963. */
  38964. keysRadiusModifierShift: boolean;
  38965. /**
  38966. * Defines the rate of change of heightOffset.
  38967. */
  38968. heightSensibility: number;
  38969. /**
  38970. * Defines the rate of change of rotationOffset.
  38971. */
  38972. rotationSensibility: number;
  38973. /**
  38974. * Defines the rate of change of radius.
  38975. */
  38976. radiusSensibility: number;
  38977. private _keys;
  38978. private _ctrlPressed;
  38979. private _altPressed;
  38980. private _shiftPressed;
  38981. private _onCanvasBlurObserver;
  38982. private _onKeyboardObserver;
  38983. private _engine;
  38984. private _scene;
  38985. /**
  38986. * Attach the input controls to a specific dom element to get the input from.
  38987. * @param element Defines the element the controls should be listened from
  38988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38989. */
  38990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38991. /**
  38992. * Detach the current controls from the specified dom element.
  38993. * @param element Defines the element to stop listening the inputs from
  38994. */
  38995. detachControl(element: Nullable<HTMLElement>): void;
  38996. /**
  38997. * Update the current camera state depending on the inputs that have been used this frame.
  38998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38999. */
  39000. checkInputs(): void;
  39001. /**
  39002. * Gets the class name of the current input.
  39003. * @returns the class name
  39004. */
  39005. getClassName(): string;
  39006. /**
  39007. * Get the friendly name associated with the input class.
  39008. * @returns the input friendly name
  39009. */
  39010. getSimpleName(): string;
  39011. /**
  39012. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39013. * allow modification of the heightOffset value.
  39014. */
  39015. private _modifierHeightOffset;
  39016. /**
  39017. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39018. * allow modification of the rotationOffset value.
  39019. */
  39020. private _modifierRotationOffset;
  39021. /**
  39022. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39023. * allow modification of the radius value.
  39024. */
  39025. private _modifierRadius;
  39026. }
  39027. }
  39028. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39029. import { Nullable } from "babylonjs/types";
  39030. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39031. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39032. import { Observable } from "babylonjs/Misc/observable";
  39033. module "babylonjs/Cameras/freeCameraInputsManager" {
  39034. interface FreeCameraInputsManager {
  39035. /**
  39036. * @hidden
  39037. */
  39038. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39039. /**
  39040. * Add orientation input support to the input manager.
  39041. * @returns the current input manager
  39042. */
  39043. addDeviceOrientation(): FreeCameraInputsManager;
  39044. }
  39045. }
  39046. /**
  39047. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39048. * Screen rotation is taken into account.
  39049. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39050. */
  39051. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39052. private _camera;
  39053. private _screenOrientationAngle;
  39054. private _constantTranform;
  39055. private _screenQuaternion;
  39056. private _alpha;
  39057. private _beta;
  39058. private _gamma;
  39059. /**
  39060. * Can be used to detect if a device orientation sensor is availible on a device
  39061. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39062. * @returns a promise that will resolve on orientation change
  39063. */
  39064. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39065. /**
  39066. * @hidden
  39067. */
  39068. _onDeviceOrientationChangedObservable: Observable<void>;
  39069. /**
  39070. * Instantiates a new input
  39071. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39072. */
  39073. constructor();
  39074. /**
  39075. * Define the camera controlled by the input.
  39076. */
  39077. camera: FreeCamera;
  39078. /**
  39079. * Attach the input controls to a specific dom element to get the input from.
  39080. * @param element Defines the element the controls should be listened from
  39081. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39082. */
  39083. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39084. private _orientationChanged;
  39085. private _deviceOrientation;
  39086. /**
  39087. * Detach the current controls from the specified dom element.
  39088. * @param element Defines the element to stop listening the inputs from
  39089. */
  39090. detachControl(element: Nullable<HTMLElement>): void;
  39091. /**
  39092. * Update the current camera state depending on the inputs that have been used this frame.
  39093. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39094. */
  39095. checkInputs(): void;
  39096. /**
  39097. * Gets the class name of the current intput.
  39098. * @returns the class name
  39099. */
  39100. getClassName(): string;
  39101. /**
  39102. * Get the friendly name associated with the input class.
  39103. * @returns the input friendly name
  39104. */
  39105. getSimpleName(): string;
  39106. }
  39107. }
  39108. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39109. import { Nullable } from "babylonjs/types";
  39110. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39111. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39112. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39113. /**
  39114. * Manage the gamepad inputs to control a free camera.
  39115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39116. */
  39117. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39118. /**
  39119. * Define the camera the input is attached to.
  39120. */
  39121. camera: FreeCamera;
  39122. /**
  39123. * Define the Gamepad controlling the input
  39124. */
  39125. gamepad: Nullable<Gamepad>;
  39126. /**
  39127. * Defines the gamepad rotation sensiblity.
  39128. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39129. */
  39130. gamepadAngularSensibility: number;
  39131. /**
  39132. * Defines the gamepad move sensiblity.
  39133. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39134. */
  39135. gamepadMoveSensibility: number;
  39136. private _onGamepadConnectedObserver;
  39137. private _onGamepadDisconnectedObserver;
  39138. private _cameraTransform;
  39139. private _deltaTransform;
  39140. private _vector3;
  39141. private _vector2;
  39142. /**
  39143. * Attach the input controls to a specific dom element to get the input from.
  39144. * @param element Defines the element the controls should be listened from
  39145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39146. */
  39147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39148. /**
  39149. * Detach the current controls from the specified dom element.
  39150. * @param element Defines the element to stop listening the inputs from
  39151. */
  39152. detachControl(element: Nullable<HTMLElement>): void;
  39153. /**
  39154. * Update the current camera state depending on the inputs that have been used this frame.
  39155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39156. */
  39157. checkInputs(): void;
  39158. /**
  39159. * Gets the class name of the current intput.
  39160. * @returns the class name
  39161. */
  39162. getClassName(): string;
  39163. /**
  39164. * Get the friendly name associated with the input class.
  39165. * @returns the input friendly name
  39166. */
  39167. getSimpleName(): string;
  39168. }
  39169. }
  39170. declare module "babylonjs/Misc/virtualJoystick" {
  39171. import { Nullable } from "babylonjs/types";
  39172. import { Vector3 } from "babylonjs/Maths/math.vector";
  39173. /**
  39174. * Defines the potential axis of a Joystick
  39175. */
  39176. export enum JoystickAxis {
  39177. /** X axis */
  39178. X = 0,
  39179. /** Y axis */
  39180. Y = 1,
  39181. /** Z axis */
  39182. Z = 2
  39183. }
  39184. /**
  39185. * Class used to define virtual joystick (used in touch mode)
  39186. */
  39187. export class VirtualJoystick {
  39188. /**
  39189. * Gets or sets a boolean indicating that left and right values must be inverted
  39190. */
  39191. reverseLeftRight: boolean;
  39192. /**
  39193. * Gets or sets a boolean indicating that up and down values must be inverted
  39194. */
  39195. reverseUpDown: boolean;
  39196. /**
  39197. * Gets the offset value for the position (ie. the change of the position value)
  39198. */
  39199. deltaPosition: Vector3;
  39200. /**
  39201. * Gets a boolean indicating if the virtual joystick was pressed
  39202. */
  39203. pressed: boolean;
  39204. /**
  39205. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39206. */
  39207. static Canvas: Nullable<HTMLCanvasElement>;
  39208. private static _globalJoystickIndex;
  39209. private static vjCanvasContext;
  39210. private static vjCanvasWidth;
  39211. private static vjCanvasHeight;
  39212. private static halfWidth;
  39213. private _action;
  39214. private _axisTargetedByLeftAndRight;
  39215. private _axisTargetedByUpAndDown;
  39216. private _joystickSensibility;
  39217. private _inversedSensibility;
  39218. private _joystickPointerID;
  39219. private _joystickColor;
  39220. private _joystickPointerPos;
  39221. private _joystickPreviousPointerPos;
  39222. private _joystickPointerStartPos;
  39223. private _deltaJoystickVector;
  39224. private _leftJoystick;
  39225. private _touches;
  39226. private _onPointerDownHandlerRef;
  39227. private _onPointerMoveHandlerRef;
  39228. private _onPointerUpHandlerRef;
  39229. private _onResize;
  39230. /**
  39231. * Creates a new virtual joystick
  39232. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39233. */
  39234. constructor(leftJoystick?: boolean);
  39235. /**
  39236. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39237. * @param newJoystickSensibility defines the new sensibility
  39238. */
  39239. setJoystickSensibility(newJoystickSensibility: number): void;
  39240. private _onPointerDown;
  39241. private _onPointerMove;
  39242. private _onPointerUp;
  39243. /**
  39244. * Change the color of the virtual joystick
  39245. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39246. */
  39247. setJoystickColor(newColor: string): void;
  39248. /**
  39249. * Defines a callback to call when the joystick is touched
  39250. * @param action defines the callback
  39251. */
  39252. setActionOnTouch(action: () => any): void;
  39253. /**
  39254. * Defines which axis you'd like to control for left & right
  39255. * @param axis defines the axis to use
  39256. */
  39257. setAxisForLeftRight(axis: JoystickAxis): void;
  39258. /**
  39259. * Defines which axis you'd like to control for up & down
  39260. * @param axis defines the axis to use
  39261. */
  39262. setAxisForUpDown(axis: JoystickAxis): void;
  39263. private _drawVirtualJoystick;
  39264. /**
  39265. * Release internal HTML canvas
  39266. */
  39267. releaseCanvas(): void;
  39268. }
  39269. }
  39270. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39271. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39272. import { Nullable } from "babylonjs/types";
  39273. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39274. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39275. module "babylonjs/Cameras/freeCameraInputsManager" {
  39276. interface FreeCameraInputsManager {
  39277. /**
  39278. * Add virtual joystick input support to the input manager.
  39279. * @returns the current input manager
  39280. */
  39281. addVirtualJoystick(): FreeCameraInputsManager;
  39282. }
  39283. }
  39284. /**
  39285. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39286. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39287. */
  39288. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39289. /**
  39290. * Defines the camera the input is attached to.
  39291. */
  39292. camera: FreeCamera;
  39293. private _leftjoystick;
  39294. private _rightjoystick;
  39295. /**
  39296. * Gets the left stick of the virtual joystick.
  39297. * @returns The virtual Joystick
  39298. */
  39299. getLeftJoystick(): VirtualJoystick;
  39300. /**
  39301. * Gets the right stick of the virtual joystick.
  39302. * @returns The virtual Joystick
  39303. */
  39304. getRightJoystick(): VirtualJoystick;
  39305. /**
  39306. * Update the current camera state depending on the inputs that have been used this frame.
  39307. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39308. */
  39309. checkInputs(): void;
  39310. /**
  39311. * Attach the input controls to a specific dom element to get the input from.
  39312. * @param element Defines the element the controls should be listened from
  39313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39314. */
  39315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39316. /**
  39317. * Detach the current controls from the specified dom element.
  39318. * @param element Defines the element to stop listening the inputs from
  39319. */
  39320. detachControl(element: Nullable<HTMLElement>): void;
  39321. /**
  39322. * Gets the class name of the current intput.
  39323. * @returns the class name
  39324. */
  39325. getClassName(): string;
  39326. /**
  39327. * Get the friendly name associated with the input class.
  39328. * @returns the input friendly name
  39329. */
  39330. getSimpleName(): string;
  39331. }
  39332. }
  39333. declare module "babylonjs/Cameras/Inputs/index" {
  39334. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39335. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39336. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39337. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39338. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39339. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39340. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39341. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39342. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39343. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39344. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39345. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39346. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39347. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39348. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39349. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39350. }
  39351. declare module "babylonjs/Cameras/touchCamera" {
  39352. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39353. import { Scene } from "babylonjs/scene";
  39354. import { Vector3 } from "babylonjs/Maths/math.vector";
  39355. /**
  39356. * This represents a FPS type of camera controlled by touch.
  39357. * This is like a universal camera minus the Gamepad controls.
  39358. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39359. */
  39360. export class TouchCamera extends FreeCamera {
  39361. /**
  39362. * Defines the touch sensibility for rotation.
  39363. * The higher the faster.
  39364. */
  39365. touchAngularSensibility: number;
  39366. /**
  39367. * Defines the touch sensibility for move.
  39368. * The higher the faster.
  39369. */
  39370. touchMoveSensibility: number;
  39371. /**
  39372. * Instantiates a new touch camera.
  39373. * This represents a FPS type of camera controlled by touch.
  39374. * This is like a universal camera minus the Gamepad controls.
  39375. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39376. * @param name Define the name of the camera in the scene
  39377. * @param position Define the start position of the camera in the scene
  39378. * @param scene Define the scene the camera belongs to
  39379. */
  39380. constructor(name: string, position: Vector3, scene: Scene);
  39381. /**
  39382. * Gets the current object class name.
  39383. * @return the class name
  39384. */
  39385. getClassName(): string;
  39386. /** @hidden */
  39387. _setupInputs(): void;
  39388. }
  39389. }
  39390. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39391. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39392. import { Scene } from "babylonjs/scene";
  39393. import { Vector3 } from "babylonjs/Maths/math.vector";
  39394. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39395. import { Axis } from "babylonjs/Maths/math.axis";
  39396. /**
  39397. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39398. * being tilted forward or back and left or right.
  39399. */
  39400. export class DeviceOrientationCamera extends FreeCamera {
  39401. private _initialQuaternion;
  39402. private _quaternionCache;
  39403. private _tmpDragQuaternion;
  39404. /**
  39405. * Creates a new device orientation camera
  39406. * @param name The name of the camera
  39407. * @param position The start position camera
  39408. * @param scene The scene the camera belongs to
  39409. */
  39410. constructor(name: string, position: Vector3, scene: Scene);
  39411. /**
  39412. * @hidden
  39413. * Disabled pointer input on first orientation sensor update (Default: true)
  39414. */
  39415. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39416. private _dragFactor;
  39417. /**
  39418. * Enabled turning on the y axis when the orientation sensor is active
  39419. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39420. */
  39421. enableHorizontalDragging(dragFactor?: number): void;
  39422. /**
  39423. * Gets the current instance class name ("DeviceOrientationCamera").
  39424. * This helps avoiding instanceof at run time.
  39425. * @returns the class name
  39426. */
  39427. getClassName(): string;
  39428. /**
  39429. * @hidden
  39430. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39431. */
  39432. _checkInputs(): void;
  39433. /**
  39434. * Reset the camera to its default orientation on the specified axis only.
  39435. * @param axis The axis to reset
  39436. */
  39437. resetToCurrentRotation(axis?: Axis): void;
  39438. }
  39439. }
  39440. declare module "babylonjs/Gamepads/xboxGamepad" {
  39441. import { Observable } from "babylonjs/Misc/observable";
  39442. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39443. /**
  39444. * Defines supported buttons for XBox360 compatible gamepads
  39445. */
  39446. export enum Xbox360Button {
  39447. /** A */
  39448. A = 0,
  39449. /** B */
  39450. B = 1,
  39451. /** X */
  39452. X = 2,
  39453. /** Y */
  39454. Y = 3,
  39455. /** Start */
  39456. Start = 4,
  39457. /** Back */
  39458. Back = 5,
  39459. /** Left button */
  39460. LB = 6,
  39461. /** Right button */
  39462. RB = 7,
  39463. /** Left stick */
  39464. LeftStick = 8,
  39465. /** Right stick */
  39466. RightStick = 9
  39467. }
  39468. /** Defines values for XBox360 DPad */
  39469. export enum Xbox360Dpad {
  39470. /** Up */
  39471. Up = 0,
  39472. /** Down */
  39473. Down = 1,
  39474. /** Left */
  39475. Left = 2,
  39476. /** Right */
  39477. Right = 3
  39478. }
  39479. /**
  39480. * Defines a XBox360 gamepad
  39481. */
  39482. export class Xbox360Pad extends Gamepad {
  39483. private _leftTrigger;
  39484. private _rightTrigger;
  39485. private _onlefttriggerchanged;
  39486. private _onrighttriggerchanged;
  39487. private _onbuttondown;
  39488. private _onbuttonup;
  39489. private _ondpaddown;
  39490. private _ondpadup;
  39491. /** Observable raised when a button is pressed */
  39492. onButtonDownObservable: Observable<Xbox360Button>;
  39493. /** Observable raised when a button is released */
  39494. onButtonUpObservable: Observable<Xbox360Button>;
  39495. /** Observable raised when a pad is pressed */
  39496. onPadDownObservable: Observable<Xbox360Dpad>;
  39497. /** Observable raised when a pad is released */
  39498. onPadUpObservable: Observable<Xbox360Dpad>;
  39499. private _buttonA;
  39500. private _buttonB;
  39501. private _buttonX;
  39502. private _buttonY;
  39503. private _buttonBack;
  39504. private _buttonStart;
  39505. private _buttonLB;
  39506. private _buttonRB;
  39507. private _buttonLeftStick;
  39508. private _buttonRightStick;
  39509. private _dPadUp;
  39510. private _dPadDown;
  39511. private _dPadLeft;
  39512. private _dPadRight;
  39513. private _isXboxOnePad;
  39514. /**
  39515. * Creates a new XBox360 gamepad object
  39516. * @param id defines the id of this gamepad
  39517. * @param index defines its index
  39518. * @param gamepad defines the internal HTML gamepad object
  39519. * @param xboxOne defines if it is a XBox One gamepad
  39520. */
  39521. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39522. /**
  39523. * Defines the callback to call when left trigger is pressed
  39524. * @param callback defines the callback to use
  39525. */
  39526. onlefttriggerchanged(callback: (value: number) => void): void;
  39527. /**
  39528. * Defines the callback to call when right trigger is pressed
  39529. * @param callback defines the callback to use
  39530. */
  39531. onrighttriggerchanged(callback: (value: number) => void): void;
  39532. /**
  39533. * Gets the left trigger value
  39534. */
  39535. /**
  39536. * Sets the left trigger value
  39537. */
  39538. leftTrigger: number;
  39539. /**
  39540. * Gets the right trigger value
  39541. */
  39542. /**
  39543. * Sets the right trigger value
  39544. */
  39545. rightTrigger: number;
  39546. /**
  39547. * Defines the callback to call when a button is pressed
  39548. * @param callback defines the callback to use
  39549. */
  39550. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39551. /**
  39552. * Defines the callback to call when a button is released
  39553. * @param callback defines the callback to use
  39554. */
  39555. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39556. /**
  39557. * Defines the callback to call when a pad is pressed
  39558. * @param callback defines the callback to use
  39559. */
  39560. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39561. /**
  39562. * Defines the callback to call when a pad is released
  39563. * @param callback defines the callback to use
  39564. */
  39565. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39566. private _setButtonValue;
  39567. private _setDPadValue;
  39568. /**
  39569. * Gets the value of the `A` button
  39570. */
  39571. /**
  39572. * Sets the value of the `A` button
  39573. */
  39574. buttonA: number;
  39575. /**
  39576. * Gets the value of the `B` button
  39577. */
  39578. /**
  39579. * Sets the value of the `B` button
  39580. */
  39581. buttonB: number;
  39582. /**
  39583. * Gets the value of the `X` button
  39584. */
  39585. /**
  39586. * Sets the value of the `X` button
  39587. */
  39588. buttonX: number;
  39589. /**
  39590. * Gets the value of the `Y` button
  39591. */
  39592. /**
  39593. * Sets the value of the `Y` button
  39594. */
  39595. buttonY: number;
  39596. /**
  39597. * Gets the value of the `Start` button
  39598. */
  39599. /**
  39600. * Sets the value of the `Start` button
  39601. */
  39602. buttonStart: number;
  39603. /**
  39604. * Gets the value of the `Back` button
  39605. */
  39606. /**
  39607. * Sets the value of the `Back` button
  39608. */
  39609. buttonBack: number;
  39610. /**
  39611. * Gets the value of the `Left` button
  39612. */
  39613. /**
  39614. * Sets the value of the `Left` button
  39615. */
  39616. buttonLB: number;
  39617. /**
  39618. * Gets the value of the `Right` button
  39619. */
  39620. /**
  39621. * Sets the value of the `Right` button
  39622. */
  39623. buttonRB: number;
  39624. /**
  39625. * Gets the value of the Left joystick
  39626. */
  39627. /**
  39628. * Sets the value of the Left joystick
  39629. */
  39630. buttonLeftStick: number;
  39631. /**
  39632. * Gets the value of the Right joystick
  39633. */
  39634. /**
  39635. * Sets the value of the Right joystick
  39636. */
  39637. buttonRightStick: number;
  39638. /**
  39639. * Gets the value of D-pad up
  39640. */
  39641. /**
  39642. * Sets the value of D-pad up
  39643. */
  39644. dPadUp: number;
  39645. /**
  39646. * Gets the value of D-pad down
  39647. */
  39648. /**
  39649. * Sets the value of D-pad down
  39650. */
  39651. dPadDown: number;
  39652. /**
  39653. * Gets the value of D-pad left
  39654. */
  39655. /**
  39656. * Sets the value of D-pad left
  39657. */
  39658. dPadLeft: number;
  39659. /**
  39660. * Gets the value of D-pad right
  39661. */
  39662. /**
  39663. * Sets the value of D-pad right
  39664. */
  39665. dPadRight: number;
  39666. /**
  39667. * Force the gamepad to synchronize with device values
  39668. */
  39669. update(): void;
  39670. /**
  39671. * Disposes the gamepad
  39672. */
  39673. dispose(): void;
  39674. }
  39675. }
  39676. declare module "babylonjs/Gamepads/gamepadManager" {
  39677. import { Observable } from "babylonjs/Misc/observable";
  39678. import { Nullable } from "babylonjs/types";
  39679. import { Scene } from "babylonjs/scene";
  39680. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39681. /**
  39682. * Manager for handling gamepads
  39683. */
  39684. export class GamepadManager {
  39685. private _scene?;
  39686. private _babylonGamepads;
  39687. private _oneGamepadConnected;
  39688. /** @hidden */
  39689. _isMonitoring: boolean;
  39690. private _gamepadEventSupported;
  39691. private _gamepadSupport;
  39692. /**
  39693. * observable to be triggered when the gamepad controller has been connected
  39694. */
  39695. onGamepadConnectedObservable: Observable<Gamepad>;
  39696. /**
  39697. * observable to be triggered when the gamepad controller has been disconnected
  39698. */
  39699. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39700. private _onGamepadConnectedEvent;
  39701. private _onGamepadDisconnectedEvent;
  39702. /**
  39703. * Initializes the gamepad manager
  39704. * @param _scene BabylonJS scene
  39705. */
  39706. constructor(_scene?: Scene | undefined);
  39707. /**
  39708. * The gamepads in the game pad manager
  39709. */
  39710. readonly gamepads: Gamepad[];
  39711. /**
  39712. * Get the gamepad controllers based on type
  39713. * @param type The type of gamepad controller
  39714. * @returns Nullable gamepad
  39715. */
  39716. getGamepadByType(type?: number): Nullable<Gamepad>;
  39717. /**
  39718. * Disposes the gamepad manager
  39719. */
  39720. dispose(): void;
  39721. private _addNewGamepad;
  39722. private _startMonitoringGamepads;
  39723. private _stopMonitoringGamepads;
  39724. /** @hidden */
  39725. _checkGamepadsStatus(): void;
  39726. private _updateGamepadObjects;
  39727. }
  39728. }
  39729. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39730. import { Nullable } from "babylonjs/types";
  39731. import { Scene } from "babylonjs/scene";
  39732. import { ISceneComponent } from "babylonjs/sceneComponent";
  39733. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39734. module "babylonjs/scene" {
  39735. interface Scene {
  39736. /** @hidden */
  39737. _gamepadManager: Nullable<GamepadManager>;
  39738. /**
  39739. * Gets the gamepad manager associated with the scene
  39740. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39741. */
  39742. gamepadManager: GamepadManager;
  39743. }
  39744. }
  39745. module "babylonjs/Cameras/freeCameraInputsManager" {
  39746. /**
  39747. * Interface representing a free camera inputs manager
  39748. */
  39749. interface FreeCameraInputsManager {
  39750. /**
  39751. * Adds gamepad input support to the FreeCameraInputsManager.
  39752. * @returns the FreeCameraInputsManager
  39753. */
  39754. addGamepad(): FreeCameraInputsManager;
  39755. }
  39756. }
  39757. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39758. /**
  39759. * Interface representing an arc rotate camera inputs manager
  39760. */
  39761. interface ArcRotateCameraInputsManager {
  39762. /**
  39763. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39764. * @returns the camera inputs manager
  39765. */
  39766. addGamepad(): ArcRotateCameraInputsManager;
  39767. }
  39768. }
  39769. /**
  39770. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39771. */
  39772. export class GamepadSystemSceneComponent implements ISceneComponent {
  39773. /**
  39774. * The component name helpfull to identify the component in the list of scene components.
  39775. */
  39776. readonly name: string;
  39777. /**
  39778. * The scene the component belongs to.
  39779. */
  39780. scene: Scene;
  39781. /**
  39782. * Creates a new instance of the component for the given scene
  39783. * @param scene Defines the scene to register the component in
  39784. */
  39785. constructor(scene: Scene);
  39786. /**
  39787. * Registers the component in a given scene
  39788. */
  39789. register(): void;
  39790. /**
  39791. * Rebuilds the elements related to this component in case of
  39792. * context lost for instance.
  39793. */
  39794. rebuild(): void;
  39795. /**
  39796. * Disposes the component and the associated ressources
  39797. */
  39798. dispose(): void;
  39799. private _beforeCameraUpdate;
  39800. }
  39801. }
  39802. declare module "babylonjs/Cameras/universalCamera" {
  39803. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39804. import { Scene } from "babylonjs/scene";
  39805. import { Vector3 } from "babylonjs/Maths/math.vector";
  39806. import "babylonjs/Gamepads/gamepadSceneComponent";
  39807. /**
  39808. * 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,
  39809. * which still works and will still be found in many Playgrounds.
  39810. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39811. */
  39812. export class UniversalCamera extends TouchCamera {
  39813. /**
  39814. * Defines the gamepad rotation sensiblity.
  39815. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39816. */
  39817. gamepadAngularSensibility: number;
  39818. /**
  39819. * Defines the gamepad move sensiblity.
  39820. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39821. */
  39822. gamepadMoveSensibility: number;
  39823. /**
  39824. * 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,
  39825. * which still works and will still be found in many Playgrounds.
  39826. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39827. * @param name Define the name of the camera in the scene
  39828. * @param position Define the start position of the camera in the scene
  39829. * @param scene Define the scene the camera belongs to
  39830. */
  39831. constructor(name: string, position: Vector3, scene: Scene);
  39832. /**
  39833. * Gets the current object class name.
  39834. * @return the class name
  39835. */
  39836. getClassName(): string;
  39837. }
  39838. }
  39839. declare module "babylonjs/Cameras/gamepadCamera" {
  39840. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39841. import { Scene } from "babylonjs/scene";
  39842. import { Vector3 } from "babylonjs/Maths/math.vector";
  39843. /**
  39844. * This represents a FPS type of camera. This is only here for back compat purpose.
  39845. * Please use the UniversalCamera instead as both are identical.
  39846. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39847. */
  39848. export class GamepadCamera extends UniversalCamera {
  39849. /**
  39850. * Instantiates a new Gamepad Camera
  39851. * This represents a FPS type of camera. This is only here for back compat purpose.
  39852. * Please use the UniversalCamera instead as both are identical.
  39853. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39854. * @param name Define the name of the camera in the scene
  39855. * @param position Define the start position of the camera in the scene
  39856. * @param scene Define the scene the camera belongs to
  39857. */
  39858. constructor(name: string, position: Vector3, scene: Scene);
  39859. /**
  39860. * Gets the current object class name.
  39861. * @return the class name
  39862. */
  39863. getClassName(): string;
  39864. }
  39865. }
  39866. declare module "babylonjs/Shaders/pass.fragment" {
  39867. /** @hidden */
  39868. export var passPixelShader: {
  39869. name: string;
  39870. shader: string;
  39871. };
  39872. }
  39873. declare module "babylonjs/Shaders/passCube.fragment" {
  39874. /** @hidden */
  39875. export var passCubePixelShader: {
  39876. name: string;
  39877. shader: string;
  39878. };
  39879. }
  39880. declare module "babylonjs/PostProcesses/passPostProcess" {
  39881. import { Nullable } from "babylonjs/types";
  39882. import { Camera } from "babylonjs/Cameras/camera";
  39883. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39884. import { Engine } from "babylonjs/Engines/engine";
  39885. import "babylonjs/Shaders/pass.fragment";
  39886. import "babylonjs/Shaders/passCube.fragment";
  39887. /**
  39888. * PassPostProcess which produces an output the same as it's input
  39889. */
  39890. export class PassPostProcess extends PostProcess {
  39891. /**
  39892. * Creates the PassPostProcess
  39893. * @param name The name of the effect.
  39894. * @param options The required width/height ratio to downsize to before computing the render pass.
  39895. * @param camera The camera to apply the render pass to.
  39896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39897. * @param engine The engine which the post process will be applied. (default: current engine)
  39898. * @param reusable If the post process can be reused on the same frame. (default: false)
  39899. * @param textureType The type of texture to be used when performing the post processing.
  39900. * @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)
  39901. */
  39902. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39903. }
  39904. /**
  39905. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39906. */
  39907. export class PassCubePostProcess extends PostProcess {
  39908. private _face;
  39909. /**
  39910. * Gets or sets the cube face to display.
  39911. * * 0 is +X
  39912. * * 1 is -X
  39913. * * 2 is +Y
  39914. * * 3 is -Y
  39915. * * 4 is +Z
  39916. * * 5 is -Z
  39917. */
  39918. face: number;
  39919. /**
  39920. * Creates the PassCubePostProcess
  39921. * @param name The name of the effect.
  39922. * @param options The required width/height ratio to downsize to before computing the render pass.
  39923. * @param camera The camera to apply the render pass to.
  39924. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39925. * @param engine The engine which the post process will be applied. (default: current engine)
  39926. * @param reusable If the post process can be reused on the same frame. (default: false)
  39927. * @param textureType The type of texture to be used when performing the post processing.
  39928. * @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)
  39929. */
  39930. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39931. }
  39932. }
  39933. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39934. /** @hidden */
  39935. export var anaglyphPixelShader: {
  39936. name: string;
  39937. shader: string;
  39938. };
  39939. }
  39940. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39941. import { Engine } from "babylonjs/Engines/engine";
  39942. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39943. import { Camera } from "babylonjs/Cameras/camera";
  39944. import "babylonjs/Shaders/anaglyph.fragment";
  39945. /**
  39946. * Postprocess used to generate anaglyphic rendering
  39947. */
  39948. export class AnaglyphPostProcess extends PostProcess {
  39949. private _passedProcess;
  39950. /**
  39951. * Creates a new AnaglyphPostProcess
  39952. * @param name defines postprocess name
  39953. * @param options defines creation options or target ratio scale
  39954. * @param rigCameras defines cameras using this postprocess
  39955. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39956. * @param engine defines hosting engine
  39957. * @param reusable defines if the postprocess will be reused multiple times per frame
  39958. */
  39959. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39960. }
  39961. }
  39962. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39963. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39964. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39965. import { Scene } from "babylonjs/scene";
  39966. import { Vector3 } from "babylonjs/Maths/math.vector";
  39967. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39968. /**
  39969. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39970. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39971. */
  39972. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39973. /**
  39974. * Creates a new AnaglyphArcRotateCamera
  39975. * @param name defines camera name
  39976. * @param alpha defines alpha angle (in radians)
  39977. * @param beta defines beta angle (in radians)
  39978. * @param radius defines radius
  39979. * @param target defines camera target
  39980. * @param interaxialDistance defines distance between each color axis
  39981. * @param scene defines the hosting scene
  39982. */
  39983. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39984. /**
  39985. * Gets camera class name
  39986. * @returns AnaglyphArcRotateCamera
  39987. */
  39988. getClassName(): string;
  39989. }
  39990. }
  39991. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39992. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39993. import { Scene } from "babylonjs/scene";
  39994. import { Vector3 } from "babylonjs/Maths/math.vector";
  39995. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39996. /**
  39997. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39998. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39999. */
  40000. export class AnaglyphFreeCamera extends FreeCamera {
  40001. /**
  40002. * Creates a new AnaglyphFreeCamera
  40003. * @param name defines camera name
  40004. * @param position defines initial position
  40005. * @param interaxialDistance defines distance between each color axis
  40006. * @param scene defines the hosting scene
  40007. */
  40008. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40009. /**
  40010. * Gets camera class name
  40011. * @returns AnaglyphFreeCamera
  40012. */
  40013. getClassName(): string;
  40014. }
  40015. }
  40016. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40017. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40018. import { Scene } from "babylonjs/scene";
  40019. import { Vector3 } from "babylonjs/Maths/math.vector";
  40020. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40021. /**
  40022. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40023. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40024. */
  40025. export class AnaglyphGamepadCamera extends GamepadCamera {
  40026. /**
  40027. * Creates a new AnaglyphGamepadCamera
  40028. * @param name defines camera name
  40029. * @param position defines initial position
  40030. * @param interaxialDistance defines distance between each color axis
  40031. * @param scene defines the hosting scene
  40032. */
  40033. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40034. /**
  40035. * Gets camera class name
  40036. * @returns AnaglyphGamepadCamera
  40037. */
  40038. getClassName(): string;
  40039. }
  40040. }
  40041. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40042. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40043. import { Scene } from "babylonjs/scene";
  40044. import { Vector3 } from "babylonjs/Maths/math.vector";
  40045. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40046. /**
  40047. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40048. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40049. */
  40050. export class AnaglyphUniversalCamera extends UniversalCamera {
  40051. /**
  40052. * Creates a new AnaglyphUniversalCamera
  40053. * @param name defines camera name
  40054. * @param position defines initial position
  40055. * @param interaxialDistance defines distance between each color axis
  40056. * @param scene defines the hosting scene
  40057. */
  40058. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40059. /**
  40060. * Gets camera class name
  40061. * @returns AnaglyphUniversalCamera
  40062. */
  40063. getClassName(): string;
  40064. }
  40065. }
  40066. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40067. /** @hidden */
  40068. export var stereoscopicInterlacePixelShader: {
  40069. name: string;
  40070. shader: string;
  40071. };
  40072. }
  40073. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40074. import { Camera } from "babylonjs/Cameras/camera";
  40075. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40076. import { Engine } from "babylonjs/Engines/engine";
  40077. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40078. /**
  40079. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40080. */
  40081. export class StereoscopicInterlacePostProcess extends PostProcess {
  40082. private _stepSize;
  40083. private _passedProcess;
  40084. /**
  40085. * Initializes a StereoscopicInterlacePostProcess
  40086. * @param name The name of the effect.
  40087. * @param rigCameras The rig cameras to be appled to the post process
  40088. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40090. * @param engine The engine which the post process will be applied. (default: current engine)
  40091. * @param reusable If the post process can be reused on the same frame. (default: false)
  40092. */
  40093. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40094. }
  40095. }
  40096. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40097. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40098. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40099. import { Scene } from "babylonjs/scene";
  40100. import { Vector3 } from "babylonjs/Maths/math.vector";
  40101. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40102. /**
  40103. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40104. * @see http://doc.babylonjs.com/features/cameras
  40105. */
  40106. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40107. /**
  40108. * Creates a new StereoscopicArcRotateCamera
  40109. * @param name defines camera name
  40110. * @param alpha defines alpha angle (in radians)
  40111. * @param beta defines beta angle (in radians)
  40112. * @param radius defines radius
  40113. * @param target defines camera target
  40114. * @param interaxialDistance defines distance between each color axis
  40115. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40116. * @param scene defines the hosting scene
  40117. */
  40118. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40119. /**
  40120. * Gets camera class name
  40121. * @returns StereoscopicArcRotateCamera
  40122. */
  40123. getClassName(): string;
  40124. }
  40125. }
  40126. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40127. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40128. import { Scene } from "babylonjs/scene";
  40129. import { Vector3 } from "babylonjs/Maths/math.vector";
  40130. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40131. /**
  40132. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40133. * @see http://doc.babylonjs.com/features/cameras
  40134. */
  40135. export class StereoscopicFreeCamera extends FreeCamera {
  40136. /**
  40137. * Creates a new StereoscopicFreeCamera
  40138. * @param name defines camera name
  40139. * @param position defines initial position
  40140. * @param interaxialDistance defines distance between each color axis
  40141. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40142. * @param scene defines the hosting scene
  40143. */
  40144. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40145. /**
  40146. * Gets camera class name
  40147. * @returns StereoscopicFreeCamera
  40148. */
  40149. getClassName(): string;
  40150. }
  40151. }
  40152. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40153. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40154. import { Scene } from "babylonjs/scene";
  40155. import { Vector3 } from "babylonjs/Maths/math.vector";
  40156. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40157. /**
  40158. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40159. * @see http://doc.babylonjs.com/features/cameras
  40160. */
  40161. export class StereoscopicGamepadCamera extends GamepadCamera {
  40162. /**
  40163. * Creates a new StereoscopicGamepadCamera
  40164. * @param name defines camera name
  40165. * @param position defines initial position
  40166. * @param interaxialDistance defines distance between each color axis
  40167. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40168. * @param scene defines the hosting scene
  40169. */
  40170. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40171. /**
  40172. * Gets camera class name
  40173. * @returns StereoscopicGamepadCamera
  40174. */
  40175. getClassName(): string;
  40176. }
  40177. }
  40178. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40179. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40180. import { Scene } from "babylonjs/scene";
  40181. import { Vector3 } from "babylonjs/Maths/math.vector";
  40182. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40183. /**
  40184. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40185. * @see http://doc.babylonjs.com/features/cameras
  40186. */
  40187. export class StereoscopicUniversalCamera extends UniversalCamera {
  40188. /**
  40189. * Creates a new StereoscopicUniversalCamera
  40190. * @param name defines camera name
  40191. * @param position defines initial position
  40192. * @param interaxialDistance defines distance between each color axis
  40193. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40194. * @param scene defines the hosting scene
  40195. */
  40196. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40197. /**
  40198. * Gets camera class name
  40199. * @returns StereoscopicUniversalCamera
  40200. */
  40201. getClassName(): string;
  40202. }
  40203. }
  40204. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40205. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40206. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40207. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40208. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40209. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40210. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40211. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40212. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40213. }
  40214. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40215. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40216. import { Scene } from "babylonjs/scene";
  40217. import { Vector3 } from "babylonjs/Maths/math.vector";
  40218. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40219. /**
  40220. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40221. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40222. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40223. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40224. */
  40225. export class VirtualJoysticksCamera extends FreeCamera {
  40226. /**
  40227. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40228. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40229. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40230. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40231. * @param name Define the name of the camera in the scene
  40232. * @param position Define the start position of the camera in the scene
  40233. * @param scene Define the scene the camera belongs to
  40234. */
  40235. constructor(name: string, position: Vector3, scene: Scene);
  40236. /**
  40237. * Gets the current object class name.
  40238. * @return the class name
  40239. */
  40240. getClassName(): string;
  40241. }
  40242. }
  40243. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40244. import { Matrix } from "babylonjs/Maths/math.vector";
  40245. /**
  40246. * This represents all the required metrics to create a VR camera.
  40247. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40248. */
  40249. export class VRCameraMetrics {
  40250. /**
  40251. * Define the horizontal resolution off the screen.
  40252. */
  40253. hResolution: number;
  40254. /**
  40255. * Define the vertical resolution off the screen.
  40256. */
  40257. vResolution: number;
  40258. /**
  40259. * Define the horizontal screen size.
  40260. */
  40261. hScreenSize: number;
  40262. /**
  40263. * Define the vertical screen size.
  40264. */
  40265. vScreenSize: number;
  40266. /**
  40267. * Define the vertical screen center position.
  40268. */
  40269. vScreenCenter: number;
  40270. /**
  40271. * Define the distance of the eyes to the screen.
  40272. */
  40273. eyeToScreenDistance: number;
  40274. /**
  40275. * Define the distance between both lenses
  40276. */
  40277. lensSeparationDistance: number;
  40278. /**
  40279. * Define the distance between both viewer's eyes.
  40280. */
  40281. interpupillaryDistance: number;
  40282. /**
  40283. * Define the distortion factor of the VR postprocess.
  40284. * Please, touch with care.
  40285. */
  40286. distortionK: number[];
  40287. /**
  40288. * Define the chromatic aberration correction factors for the VR post process.
  40289. */
  40290. chromaAbCorrection: number[];
  40291. /**
  40292. * Define the scale factor of the post process.
  40293. * The smaller the better but the slower.
  40294. */
  40295. postProcessScaleFactor: number;
  40296. /**
  40297. * Define an offset for the lens center.
  40298. */
  40299. lensCenterOffset: number;
  40300. /**
  40301. * Define if the current vr camera should compensate the distortion of the lense or not.
  40302. */
  40303. compensateDistortion: boolean;
  40304. /**
  40305. * Defines if multiview should be enabled when rendering (Default: false)
  40306. */
  40307. multiviewEnabled: boolean;
  40308. /**
  40309. * Gets the rendering aspect ratio based on the provided resolutions.
  40310. */
  40311. readonly aspectRatio: number;
  40312. /**
  40313. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40314. */
  40315. readonly aspectRatioFov: number;
  40316. /**
  40317. * @hidden
  40318. */
  40319. readonly leftHMatrix: Matrix;
  40320. /**
  40321. * @hidden
  40322. */
  40323. readonly rightHMatrix: Matrix;
  40324. /**
  40325. * @hidden
  40326. */
  40327. readonly leftPreViewMatrix: Matrix;
  40328. /**
  40329. * @hidden
  40330. */
  40331. readonly rightPreViewMatrix: Matrix;
  40332. /**
  40333. * Get the default VRMetrics based on the most generic setup.
  40334. * @returns the default vr metrics
  40335. */
  40336. static GetDefault(): VRCameraMetrics;
  40337. }
  40338. }
  40339. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40340. /** @hidden */
  40341. export var vrDistortionCorrectionPixelShader: {
  40342. name: string;
  40343. shader: string;
  40344. };
  40345. }
  40346. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40347. import { Camera } from "babylonjs/Cameras/camera";
  40348. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40349. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40350. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40351. /**
  40352. * VRDistortionCorrectionPostProcess used for mobile VR
  40353. */
  40354. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40355. private _isRightEye;
  40356. private _distortionFactors;
  40357. private _postProcessScaleFactor;
  40358. private _lensCenterOffset;
  40359. private _scaleIn;
  40360. private _scaleFactor;
  40361. private _lensCenter;
  40362. /**
  40363. * Initializes the VRDistortionCorrectionPostProcess
  40364. * @param name The name of the effect.
  40365. * @param camera The camera to apply the render pass to.
  40366. * @param isRightEye If this is for the right eye distortion
  40367. * @param vrMetrics All the required metrics for the VR camera
  40368. */
  40369. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40370. }
  40371. }
  40372. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40373. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40374. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40375. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40376. import { Scene } from "babylonjs/scene";
  40377. import { Vector3 } from "babylonjs/Maths/math.vector";
  40378. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40379. import "babylonjs/Cameras/RigModes/vrRigMode";
  40380. /**
  40381. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40382. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40383. */
  40384. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40385. /**
  40386. * Creates a new VRDeviceOrientationArcRotateCamera
  40387. * @param name defines camera name
  40388. * @param alpha defines the camera rotation along the logitudinal axis
  40389. * @param beta defines the camera rotation along the latitudinal axis
  40390. * @param radius defines the camera distance from its target
  40391. * @param target defines the camera target
  40392. * @param scene defines the scene the camera belongs to
  40393. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40394. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40395. */
  40396. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40397. /**
  40398. * Gets camera class name
  40399. * @returns VRDeviceOrientationArcRotateCamera
  40400. */
  40401. getClassName(): string;
  40402. }
  40403. }
  40404. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40405. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40406. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40407. import { Scene } from "babylonjs/scene";
  40408. import { Vector3 } from "babylonjs/Maths/math.vector";
  40409. import "babylonjs/Cameras/RigModes/vrRigMode";
  40410. /**
  40411. * Camera used to simulate VR rendering (based on FreeCamera)
  40412. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40413. */
  40414. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40415. /**
  40416. * Creates a new VRDeviceOrientationFreeCamera
  40417. * @param name defines camera name
  40418. * @param position defines the start position of the camera
  40419. * @param scene defines the scene the camera belongs to
  40420. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40421. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40422. */
  40423. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40424. /**
  40425. * Gets camera class name
  40426. * @returns VRDeviceOrientationFreeCamera
  40427. */
  40428. getClassName(): string;
  40429. }
  40430. }
  40431. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40432. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40433. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40434. import { Scene } from "babylonjs/scene";
  40435. import { Vector3 } from "babylonjs/Maths/math.vector";
  40436. import "babylonjs/Gamepads/gamepadSceneComponent";
  40437. /**
  40438. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40439. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40440. */
  40441. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40442. /**
  40443. * Creates a new VRDeviceOrientationGamepadCamera
  40444. * @param name defines camera name
  40445. * @param position defines the start position of the camera
  40446. * @param scene defines the scene the camera belongs to
  40447. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40448. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40449. */
  40450. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40451. /**
  40452. * Gets camera class name
  40453. * @returns VRDeviceOrientationGamepadCamera
  40454. */
  40455. getClassName(): string;
  40456. }
  40457. }
  40458. declare module "babylonjs/Materials/pushMaterial" {
  40459. import { Nullable } from "babylonjs/types";
  40460. import { Scene } from "babylonjs/scene";
  40461. import { Matrix } from "babylonjs/Maths/math.vector";
  40462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40463. import { Mesh } from "babylonjs/Meshes/mesh";
  40464. import { Material } from "babylonjs/Materials/material";
  40465. import { Effect } from "babylonjs/Materials/effect";
  40466. /**
  40467. * Base class of materials working in push mode in babylon JS
  40468. * @hidden
  40469. */
  40470. export class PushMaterial extends Material {
  40471. protected _activeEffect: Effect;
  40472. protected _normalMatrix: Matrix;
  40473. /**
  40474. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40475. * This means that the material can keep using a previous shader while a new one is being compiled.
  40476. * This is mostly used when shader parallel compilation is supported (true by default)
  40477. */
  40478. allowShaderHotSwapping: boolean;
  40479. constructor(name: string, scene: Scene);
  40480. getEffect(): Effect;
  40481. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40482. /**
  40483. * Binds the given world matrix to the active effect
  40484. *
  40485. * @param world the matrix to bind
  40486. */
  40487. bindOnlyWorldMatrix(world: Matrix): void;
  40488. /**
  40489. * Binds the given normal matrix to the active effect
  40490. *
  40491. * @param normalMatrix the matrix to bind
  40492. */
  40493. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40494. bind(world: Matrix, mesh?: Mesh): void;
  40495. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40496. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40497. }
  40498. }
  40499. declare module "babylonjs/Materials/materialFlags" {
  40500. /**
  40501. * This groups all the flags used to control the materials channel.
  40502. */
  40503. export class MaterialFlags {
  40504. private static _DiffuseTextureEnabled;
  40505. /**
  40506. * Are diffuse textures enabled in the application.
  40507. */
  40508. static DiffuseTextureEnabled: boolean;
  40509. private static _AmbientTextureEnabled;
  40510. /**
  40511. * Are ambient textures enabled in the application.
  40512. */
  40513. static AmbientTextureEnabled: boolean;
  40514. private static _OpacityTextureEnabled;
  40515. /**
  40516. * Are opacity textures enabled in the application.
  40517. */
  40518. static OpacityTextureEnabled: boolean;
  40519. private static _ReflectionTextureEnabled;
  40520. /**
  40521. * Are reflection textures enabled in the application.
  40522. */
  40523. static ReflectionTextureEnabled: boolean;
  40524. private static _EmissiveTextureEnabled;
  40525. /**
  40526. * Are emissive textures enabled in the application.
  40527. */
  40528. static EmissiveTextureEnabled: boolean;
  40529. private static _SpecularTextureEnabled;
  40530. /**
  40531. * Are specular textures enabled in the application.
  40532. */
  40533. static SpecularTextureEnabled: boolean;
  40534. private static _BumpTextureEnabled;
  40535. /**
  40536. * Are bump textures enabled in the application.
  40537. */
  40538. static BumpTextureEnabled: boolean;
  40539. private static _LightmapTextureEnabled;
  40540. /**
  40541. * Are lightmap textures enabled in the application.
  40542. */
  40543. static LightmapTextureEnabled: boolean;
  40544. private static _RefractionTextureEnabled;
  40545. /**
  40546. * Are refraction textures enabled in the application.
  40547. */
  40548. static RefractionTextureEnabled: boolean;
  40549. private static _ColorGradingTextureEnabled;
  40550. /**
  40551. * Are color grading textures enabled in the application.
  40552. */
  40553. static ColorGradingTextureEnabled: boolean;
  40554. private static _FresnelEnabled;
  40555. /**
  40556. * Are fresnels enabled in the application.
  40557. */
  40558. static FresnelEnabled: boolean;
  40559. private static _ClearCoatTextureEnabled;
  40560. /**
  40561. * Are clear coat textures enabled in the application.
  40562. */
  40563. static ClearCoatTextureEnabled: boolean;
  40564. private static _ClearCoatBumpTextureEnabled;
  40565. /**
  40566. * Are clear coat bump textures enabled in the application.
  40567. */
  40568. static ClearCoatBumpTextureEnabled: boolean;
  40569. private static _ClearCoatTintTextureEnabled;
  40570. /**
  40571. * Are clear coat tint textures enabled in the application.
  40572. */
  40573. static ClearCoatTintTextureEnabled: boolean;
  40574. private static _SheenTextureEnabled;
  40575. /**
  40576. * Are sheen textures enabled in the application.
  40577. */
  40578. static SheenTextureEnabled: boolean;
  40579. private static _AnisotropicTextureEnabled;
  40580. /**
  40581. * Are anisotropic textures enabled in the application.
  40582. */
  40583. static AnisotropicTextureEnabled: boolean;
  40584. private static _ThicknessTextureEnabled;
  40585. /**
  40586. * Are thickness textures enabled in the application.
  40587. */
  40588. static ThicknessTextureEnabled: boolean;
  40589. }
  40590. }
  40591. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40592. /** @hidden */
  40593. export var defaultFragmentDeclaration: {
  40594. name: string;
  40595. shader: string;
  40596. };
  40597. }
  40598. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40599. /** @hidden */
  40600. export var defaultUboDeclaration: {
  40601. name: string;
  40602. shader: string;
  40603. };
  40604. }
  40605. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40606. /** @hidden */
  40607. export var lightFragmentDeclaration: {
  40608. name: string;
  40609. shader: string;
  40610. };
  40611. }
  40612. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40613. /** @hidden */
  40614. export var lightUboDeclaration: {
  40615. name: string;
  40616. shader: string;
  40617. };
  40618. }
  40619. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40620. /** @hidden */
  40621. export var lightsFragmentFunctions: {
  40622. name: string;
  40623. shader: string;
  40624. };
  40625. }
  40626. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40627. /** @hidden */
  40628. export var shadowsFragmentFunctions: {
  40629. name: string;
  40630. shader: string;
  40631. };
  40632. }
  40633. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40634. /** @hidden */
  40635. export var fresnelFunction: {
  40636. name: string;
  40637. shader: string;
  40638. };
  40639. }
  40640. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40641. /** @hidden */
  40642. export var reflectionFunction: {
  40643. name: string;
  40644. shader: string;
  40645. };
  40646. }
  40647. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40648. /** @hidden */
  40649. export var bumpFragmentFunctions: {
  40650. name: string;
  40651. shader: string;
  40652. };
  40653. }
  40654. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40655. /** @hidden */
  40656. export var logDepthDeclaration: {
  40657. name: string;
  40658. shader: string;
  40659. };
  40660. }
  40661. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40662. /** @hidden */
  40663. export var bumpFragment: {
  40664. name: string;
  40665. shader: string;
  40666. };
  40667. }
  40668. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40669. /** @hidden */
  40670. export var depthPrePass: {
  40671. name: string;
  40672. shader: string;
  40673. };
  40674. }
  40675. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40676. /** @hidden */
  40677. export var lightFragment: {
  40678. name: string;
  40679. shader: string;
  40680. };
  40681. }
  40682. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40683. /** @hidden */
  40684. export var logDepthFragment: {
  40685. name: string;
  40686. shader: string;
  40687. };
  40688. }
  40689. declare module "babylonjs/Shaders/default.fragment" {
  40690. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40691. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40692. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40693. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40694. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40695. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40696. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40697. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40698. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40699. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40700. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40701. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40702. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40703. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40704. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40705. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40706. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40707. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40708. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40709. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40710. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40711. /** @hidden */
  40712. export var defaultPixelShader: {
  40713. name: string;
  40714. shader: string;
  40715. };
  40716. }
  40717. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40718. /** @hidden */
  40719. export var defaultVertexDeclaration: {
  40720. name: string;
  40721. shader: string;
  40722. };
  40723. }
  40724. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40725. /** @hidden */
  40726. export var bumpVertexDeclaration: {
  40727. name: string;
  40728. shader: string;
  40729. };
  40730. }
  40731. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40732. /** @hidden */
  40733. export var bumpVertex: {
  40734. name: string;
  40735. shader: string;
  40736. };
  40737. }
  40738. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40739. /** @hidden */
  40740. export var fogVertex: {
  40741. name: string;
  40742. shader: string;
  40743. };
  40744. }
  40745. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40746. /** @hidden */
  40747. export var shadowsVertex: {
  40748. name: string;
  40749. shader: string;
  40750. };
  40751. }
  40752. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40753. /** @hidden */
  40754. export var pointCloudVertex: {
  40755. name: string;
  40756. shader: string;
  40757. };
  40758. }
  40759. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40760. /** @hidden */
  40761. export var logDepthVertex: {
  40762. name: string;
  40763. shader: string;
  40764. };
  40765. }
  40766. declare module "babylonjs/Shaders/default.vertex" {
  40767. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40768. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40769. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40770. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40771. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40772. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40773. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40774. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40775. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40776. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40777. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40778. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40779. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40780. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40781. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40782. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40783. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40784. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40785. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40786. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40787. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40788. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40789. /** @hidden */
  40790. export var defaultVertexShader: {
  40791. name: string;
  40792. shader: string;
  40793. };
  40794. }
  40795. declare module "babylonjs/Materials/standardMaterial" {
  40796. import { SmartArray } from "babylonjs/Misc/smartArray";
  40797. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40798. import { Nullable } from "babylonjs/types";
  40799. import { Scene } from "babylonjs/scene";
  40800. import { Matrix } from "babylonjs/Maths/math.vector";
  40801. import { Color3 } from "babylonjs/Maths/math.color";
  40802. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40804. import { Mesh } from "babylonjs/Meshes/mesh";
  40805. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40806. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40807. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40808. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40809. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40811. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40812. import "babylonjs/Shaders/default.fragment";
  40813. import "babylonjs/Shaders/default.vertex";
  40814. /** @hidden */
  40815. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40816. MAINUV1: boolean;
  40817. MAINUV2: boolean;
  40818. DIFFUSE: boolean;
  40819. DIFFUSEDIRECTUV: number;
  40820. AMBIENT: boolean;
  40821. AMBIENTDIRECTUV: number;
  40822. OPACITY: boolean;
  40823. OPACITYDIRECTUV: number;
  40824. OPACITYRGB: boolean;
  40825. REFLECTION: boolean;
  40826. EMISSIVE: boolean;
  40827. EMISSIVEDIRECTUV: number;
  40828. SPECULAR: boolean;
  40829. SPECULARDIRECTUV: number;
  40830. BUMP: boolean;
  40831. BUMPDIRECTUV: number;
  40832. PARALLAX: boolean;
  40833. PARALLAXOCCLUSION: boolean;
  40834. SPECULAROVERALPHA: boolean;
  40835. CLIPPLANE: boolean;
  40836. CLIPPLANE2: boolean;
  40837. CLIPPLANE3: boolean;
  40838. CLIPPLANE4: boolean;
  40839. ALPHATEST: boolean;
  40840. DEPTHPREPASS: boolean;
  40841. ALPHAFROMDIFFUSE: boolean;
  40842. POINTSIZE: boolean;
  40843. FOG: boolean;
  40844. SPECULARTERM: boolean;
  40845. DIFFUSEFRESNEL: boolean;
  40846. OPACITYFRESNEL: boolean;
  40847. REFLECTIONFRESNEL: boolean;
  40848. REFRACTIONFRESNEL: boolean;
  40849. EMISSIVEFRESNEL: boolean;
  40850. FRESNEL: boolean;
  40851. NORMAL: boolean;
  40852. UV1: boolean;
  40853. UV2: boolean;
  40854. VERTEXCOLOR: boolean;
  40855. VERTEXALPHA: boolean;
  40856. NUM_BONE_INFLUENCERS: number;
  40857. BonesPerMesh: number;
  40858. BONETEXTURE: boolean;
  40859. INSTANCES: boolean;
  40860. GLOSSINESS: boolean;
  40861. ROUGHNESS: boolean;
  40862. EMISSIVEASILLUMINATION: boolean;
  40863. LINKEMISSIVEWITHDIFFUSE: boolean;
  40864. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40865. LIGHTMAP: boolean;
  40866. LIGHTMAPDIRECTUV: number;
  40867. OBJECTSPACE_NORMALMAP: boolean;
  40868. USELIGHTMAPASSHADOWMAP: boolean;
  40869. REFLECTIONMAP_3D: boolean;
  40870. REFLECTIONMAP_SPHERICAL: boolean;
  40871. REFLECTIONMAP_PLANAR: boolean;
  40872. REFLECTIONMAP_CUBIC: boolean;
  40873. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40874. REFLECTIONMAP_PROJECTION: boolean;
  40875. REFLECTIONMAP_SKYBOX: boolean;
  40876. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40877. REFLECTIONMAP_EXPLICIT: boolean;
  40878. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40879. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40880. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40881. INVERTCUBICMAP: boolean;
  40882. LOGARITHMICDEPTH: boolean;
  40883. REFRACTION: boolean;
  40884. REFRACTIONMAP_3D: boolean;
  40885. REFLECTIONOVERALPHA: boolean;
  40886. TWOSIDEDLIGHTING: boolean;
  40887. SHADOWFLOAT: boolean;
  40888. MORPHTARGETS: boolean;
  40889. MORPHTARGETS_NORMAL: boolean;
  40890. MORPHTARGETS_TANGENT: boolean;
  40891. MORPHTARGETS_UV: boolean;
  40892. NUM_MORPH_INFLUENCERS: number;
  40893. NONUNIFORMSCALING: boolean;
  40894. PREMULTIPLYALPHA: boolean;
  40895. IMAGEPROCESSING: boolean;
  40896. VIGNETTE: boolean;
  40897. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40898. VIGNETTEBLENDMODEOPAQUE: boolean;
  40899. TONEMAPPING: boolean;
  40900. TONEMAPPING_ACES: boolean;
  40901. CONTRAST: boolean;
  40902. COLORCURVES: boolean;
  40903. COLORGRADING: boolean;
  40904. COLORGRADING3D: boolean;
  40905. SAMPLER3DGREENDEPTH: boolean;
  40906. SAMPLER3DBGRMAP: boolean;
  40907. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40908. MULTIVIEW: boolean;
  40909. /**
  40910. * If the reflection texture on this material is in linear color space
  40911. * @hidden
  40912. */
  40913. IS_REFLECTION_LINEAR: boolean;
  40914. /**
  40915. * If the refraction texture on this material is in linear color space
  40916. * @hidden
  40917. */
  40918. IS_REFRACTION_LINEAR: boolean;
  40919. EXPOSURE: boolean;
  40920. constructor();
  40921. setReflectionMode(modeToEnable: string): void;
  40922. }
  40923. /**
  40924. * This is the default material used in Babylon. It is the best trade off between quality
  40925. * and performances.
  40926. * @see http://doc.babylonjs.com/babylon101/materials
  40927. */
  40928. export class StandardMaterial extends PushMaterial {
  40929. private _diffuseTexture;
  40930. /**
  40931. * The basic texture of the material as viewed under a light.
  40932. */
  40933. diffuseTexture: Nullable<BaseTexture>;
  40934. private _ambientTexture;
  40935. /**
  40936. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40937. */
  40938. ambientTexture: Nullable<BaseTexture>;
  40939. private _opacityTexture;
  40940. /**
  40941. * Define the transparency of the material from a texture.
  40942. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40943. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40944. */
  40945. opacityTexture: Nullable<BaseTexture>;
  40946. private _reflectionTexture;
  40947. /**
  40948. * Define the texture used to display the reflection.
  40949. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40950. */
  40951. reflectionTexture: Nullable<BaseTexture>;
  40952. private _emissiveTexture;
  40953. /**
  40954. * Define texture of the material as if self lit.
  40955. * This will be mixed in the final result even in the absence of light.
  40956. */
  40957. emissiveTexture: Nullable<BaseTexture>;
  40958. private _specularTexture;
  40959. /**
  40960. * Define how the color and intensity of the highlight given by the light in the material.
  40961. */
  40962. specularTexture: Nullable<BaseTexture>;
  40963. private _bumpTexture;
  40964. /**
  40965. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40966. * 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.
  40967. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40968. */
  40969. bumpTexture: Nullable<BaseTexture>;
  40970. private _lightmapTexture;
  40971. /**
  40972. * Complex lighting can be computationally expensive to compute at runtime.
  40973. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40974. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40975. */
  40976. lightmapTexture: Nullable<BaseTexture>;
  40977. private _refractionTexture;
  40978. /**
  40979. * Define the texture used to display the refraction.
  40980. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40981. */
  40982. refractionTexture: Nullable<BaseTexture>;
  40983. /**
  40984. * The color of the material lit by the environmental background lighting.
  40985. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40986. */
  40987. ambientColor: Color3;
  40988. /**
  40989. * The basic color of the material as viewed under a light.
  40990. */
  40991. diffuseColor: Color3;
  40992. /**
  40993. * Define how the color and intensity of the highlight given by the light in the material.
  40994. */
  40995. specularColor: Color3;
  40996. /**
  40997. * Define the color of the material as if self lit.
  40998. * This will be mixed in the final result even in the absence of light.
  40999. */
  41000. emissiveColor: Color3;
  41001. /**
  41002. * Defines how sharp are the highlights in the material.
  41003. * The bigger the value the sharper giving a more glossy feeling to the result.
  41004. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41005. */
  41006. specularPower: number;
  41007. private _useAlphaFromDiffuseTexture;
  41008. /**
  41009. * Does the transparency come from the diffuse texture alpha channel.
  41010. */
  41011. useAlphaFromDiffuseTexture: boolean;
  41012. private _useEmissiveAsIllumination;
  41013. /**
  41014. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41015. */
  41016. useEmissiveAsIllumination: boolean;
  41017. private _linkEmissiveWithDiffuse;
  41018. /**
  41019. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41020. * the emissive level when the final color is close to one.
  41021. */
  41022. linkEmissiveWithDiffuse: boolean;
  41023. private _useSpecularOverAlpha;
  41024. /**
  41025. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41026. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41027. */
  41028. useSpecularOverAlpha: boolean;
  41029. private _useReflectionOverAlpha;
  41030. /**
  41031. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41032. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41033. */
  41034. useReflectionOverAlpha: boolean;
  41035. private _disableLighting;
  41036. /**
  41037. * Does lights from the scene impacts this material.
  41038. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41039. */
  41040. disableLighting: boolean;
  41041. private _useObjectSpaceNormalMap;
  41042. /**
  41043. * Allows using an object space normal map (instead of tangent space).
  41044. */
  41045. useObjectSpaceNormalMap: boolean;
  41046. private _useParallax;
  41047. /**
  41048. * Is parallax enabled or not.
  41049. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41050. */
  41051. useParallax: boolean;
  41052. private _useParallaxOcclusion;
  41053. /**
  41054. * Is parallax occlusion enabled or not.
  41055. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41056. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41057. */
  41058. useParallaxOcclusion: boolean;
  41059. /**
  41060. * 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.
  41061. */
  41062. parallaxScaleBias: number;
  41063. private _roughness;
  41064. /**
  41065. * Helps to define how blurry the reflections should appears in the material.
  41066. */
  41067. roughness: number;
  41068. /**
  41069. * In case of refraction, define the value of the index of refraction.
  41070. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41071. */
  41072. indexOfRefraction: number;
  41073. /**
  41074. * Invert the refraction texture alongside the y axis.
  41075. * It can be useful with procedural textures or probe for instance.
  41076. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41077. */
  41078. invertRefractionY: boolean;
  41079. /**
  41080. * Defines the alpha limits in alpha test mode.
  41081. */
  41082. alphaCutOff: number;
  41083. private _useLightmapAsShadowmap;
  41084. /**
  41085. * In case of light mapping, define whether the map contains light or shadow informations.
  41086. */
  41087. useLightmapAsShadowmap: boolean;
  41088. private _diffuseFresnelParameters;
  41089. /**
  41090. * Define the diffuse fresnel parameters of the material.
  41091. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41092. */
  41093. diffuseFresnelParameters: FresnelParameters;
  41094. private _opacityFresnelParameters;
  41095. /**
  41096. * Define the opacity fresnel parameters of the material.
  41097. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41098. */
  41099. opacityFresnelParameters: FresnelParameters;
  41100. private _reflectionFresnelParameters;
  41101. /**
  41102. * Define the reflection fresnel parameters of the material.
  41103. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41104. */
  41105. reflectionFresnelParameters: FresnelParameters;
  41106. private _refractionFresnelParameters;
  41107. /**
  41108. * Define the refraction fresnel parameters of the material.
  41109. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41110. */
  41111. refractionFresnelParameters: FresnelParameters;
  41112. private _emissiveFresnelParameters;
  41113. /**
  41114. * Define the emissive fresnel parameters of the material.
  41115. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41116. */
  41117. emissiveFresnelParameters: FresnelParameters;
  41118. private _useReflectionFresnelFromSpecular;
  41119. /**
  41120. * If true automatically deducts the fresnels values from the material specularity.
  41121. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41122. */
  41123. useReflectionFresnelFromSpecular: boolean;
  41124. private _useGlossinessFromSpecularMapAlpha;
  41125. /**
  41126. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41127. */
  41128. useGlossinessFromSpecularMapAlpha: boolean;
  41129. private _maxSimultaneousLights;
  41130. /**
  41131. * Defines the maximum number of lights that can be used in the material
  41132. */
  41133. maxSimultaneousLights: number;
  41134. private _invertNormalMapX;
  41135. /**
  41136. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41137. */
  41138. invertNormalMapX: boolean;
  41139. private _invertNormalMapY;
  41140. /**
  41141. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41142. */
  41143. invertNormalMapY: boolean;
  41144. private _twoSidedLighting;
  41145. /**
  41146. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41147. */
  41148. twoSidedLighting: boolean;
  41149. /**
  41150. * Default configuration related to image processing available in the standard Material.
  41151. */
  41152. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41153. /**
  41154. * Gets the image processing configuration used either in this material.
  41155. */
  41156. /**
  41157. * Sets the Default image processing configuration used either in the this material.
  41158. *
  41159. * If sets to null, the scene one is in use.
  41160. */
  41161. imageProcessingConfiguration: ImageProcessingConfiguration;
  41162. /**
  41163. * Keep track of the image processing observer to allow dispose and replace.
  41164. */
  41165. private _imageProcessingObserver;
  41166. /**
  41167. * Attaches a new image processing configuration to the Standard Material.
  41168. * @param configuration
  41169. */
  41170. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41171. /**
  41172. * Gets wether the color curves effect is enabled.
  41173. */
  41174. /**
  41175. * Sets wether the color curves effect is enabled.
  41176. */
  41177. cameraColorCurvesEnabled: boolean;
  41178. /**
  41179. * Gets wether the color grading effect is enabled.
  41180. */
  41181. /**
  41182. * Gets wether the color grading effect is enabled.
  41183. */
  41184. cameraColorGradingEnabled: boolean;
  41185. /**
  41186. * Gets wether tonemapping is enabled or not.
  41187. */
  41188. /**
  41189. * Sets wether tonemapping is enabled or not
  41190. */
  41191. cameraToneMappingEnabled: boolean;
  41192. /**
  41193. * The camera exposure used on this material.
  41194. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41195. * This corresponds to a photographic exposure.
  41196. */
  41197. /**
  41198. * The camera exposure used on this material.
  41199. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41200. * This corresponds to a photographic exposure.
  41201. */
  41202. cameraExposure: number;
  41203. /**
  41204. * Gets The camera contrast used on this material.
  41205. */
  41206. /**
  41207. * Sets The camera contrast used on this material.
  41208. */
  41209. cameraContrast: number;
  41210. /**
  41211. * Gets the Color Grading 2D Lookup Texture.
  41212. */
  41213. /**
  41214. * Sets the Color Grading 2D Lookup Texture.
  41215. */
  41216. cameraColorGradingTexture: Nullable<BaseTexture>;
  41217. /**
  41218. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41219. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41220. * 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;
  41221. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41222. */
  41223. /**
  41224. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41225. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41226. * 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;
  41227. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41228. */
  41229. cameraColorCurves: Nullable<ColorCurves>;
  41230. /**
  41231. * Custom callback helping to override the default shader used in the material.
  41232. */
  41233. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41234. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41235. protected _worldViewProjectionMatrix: Matrix;
  41236. protected _globalAmbientColor: Color3;
  41237. protected _useLogarithmicDepth: boolean;
  41238. /**
  41239. * Instantiates a new standard material.
  41240. * This is the default material used in Babylon. It is the best trade off between quality
  41241. * and performances.
  41242. * @see http://doc.babylonjs.com/babylon101/materials
  41243. * @param name Define the name of the material in the scene
  41244. * @param scene Define the scene the material belong to
  41245. */
  41246. constructor(name: string, scene: Scene);
  41247. /**
  41248. * Gets a boolean indicating that current material needs to register RTT
  41249. */
  41250. readonly hasRenderTargetTextures: boolean;
  41251. /**
  41252. * Gets the current class name of the material e.g. "StandardMaterial"
  41253. * Mainly use in serialization.
  41254. * @returns the class name
  41255. */
  41256. getClassName(): string;
  41257. /**
  41258. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41259. * You can try switching to logarithmic depth.
  41260. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41261. */
  41262. useLogarithmicDepth: boolean;
  41263. /**
  41264. * Specifies if the material will require alpha blending
  41265. * @returns a boolean specifying if alpha blending is needed
  41266. */
  41267. needAlphaBlending(): boolean;
  41268. /**
  41269. * Specifies if this material should be rendered in alpha test mode
  41270. * @returns a boolean specifying if an alpha test is needed.
  41271. */
  41272. needAlphaTesting(): boolean;
  41273. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41274. /**
  41275. * Get the texture used for alpha test purpose.
  41276. * @returns the diffuse texture in case of the standard material.
  41277. */
  41278. getAlphaTestTexture(): Nullable<BaseTexture>;
  41279. /**
  41280. * Get if the submesh is ready to be used and all its information available.
  41281. * Child classes can use it to update shaders
  41282. * @param mesh defines the mesh to check
  41283. * @param subMesh defines which submesh to check
  41284. * @param useInstances specifies that instances should be used
  41285. * @returns a boolean indicating that the submesh is ready or not
  41286. */
  41287. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41288. /**
  41289. * Builds the material UBO layouts.
  41290. * Used internally during the effect preparation.
  41291. */
  41292. buildUniformLayout(): void;
  41293. /**
  41294. * Unbinds the material from the mesh
  41295. */
  41296. unbind(): void;
  41297. /**
  41298. * Binds the submesh to this material by preparing the effect and shader to draw
  41299. * @param world defines the world transformation matrix
  41300. * @param mesh defines the mesh containing the submesh
  41301. * @param subMesh defines the submesh to bind the material to
  41302. */
  41303. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41304. /**
  41305. * Get the list of animatables in the material.
  41306. * @returns the list of animatables object used in the material
  41307. */
  41308. getAnimatables(): IAnimatable[];
  41309. /**
  41310. * Gets the active textures from the material
  41311. * @returns an array of textures
  41312. */
  41313. getActiveTextures(): BaseTexture[];
  41314. /**
  41315. * Specifies if the material uses a texture
  41316. * @param texture defines the texture to check against the material
  41317. * @returns a boolean specifying if the material uses the texture
  41318. */
  41319. hasTexture(texture: BaseTexture): boolean;
  41320. /**
  41321. * Disposes the material
  41322. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41323. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41324. */
  41325. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41326. /**
  41327. * Makes a duplicate of the material, and gives it a new name
  41328. * @param name defines the new name for the duplicated material
  41329. * @returns the cloned material
  41330. */
  41331. clone(name: string): StandardMaterial;
  41332. /**
  41333. * Serializes this material in a JSON representation
  41334. * @returns the serialized material object
  41335. */
  41336. serialize(): any;
  41337. /**
  41338. * Creates a standard material from parsed material data
  41339. * @param source defines the JSON representation of the material
  41340. * @param scene defines the hosting scene
  41341. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41342. * @returns a new standard material
  41343. */
  41344. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41345. /**
  41346. * Are diffuse textures enabled in the application.
  41347. */
  41348. static DiffuseTextureEnabled: boolean;
  41349. /**
  41350. * Are ambient textures enabled in the application.
  41351. */
  41352. static AmbientTextureEnabled: boolean;
  41353. /**
  41354. * Are opacity textures enabled in the application.
  41355. */
  41356. static OpacityTextureEnabled: boolean;
  41357. /**
  41358. * Are reflection textures enabled in the application.
  41359. */
  41360. static ReflectionTextureEnabled: boolean;
  41361. /**
  41362. * Are emissive textures enabled in the application.
  41363. */
  41364. static EmissiveTextureEnabled: boolean;
  41365. /**
  41366. * Are specular textures enabled in the application.
  41367. */
  41368. static SpecularTextureEnabled: boolean;
  41369. /**
  41370. * Are bump textures enabled in the application.
  41371. */
  41372. static BumpTextureEnabled: boolean;
  41373. /**
  41374. * Are lightmap textures enabled in the application.
  41375. */
  41376. static LightmapTextureEnabled: boolean;
  41377. /**
  41378. * Are refraction textures enabled in the application.
  41379. */
  41380. static RefractionTextureEnabled: boolean;
  41381. /**
  41382. * Are color grading textures enabled in the application.
  41383. */
  41384. static ColorGradingTextureEnabled: boolean;
  41385. /**
  41386. * Are fresnels enabled in the application.
  41387. */
  41388. static FresnelEnabled: boolean;
  41389. }
  41390. }
  41391. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41392. import { Scene } from "babylonjs/scene";
  41393. import { Texture } from "babylonjs/Materials/Textures/texture";
  41394. /**
  41395. * A class extending Texture allowing drawing on a texture
  41396. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41397. */
  41398. export class DynamicTexture extends Texture {
  41399. private _generateMipMaps;
  41400. private _canvas;
  41401. private _context;
  41402. private _engine;
  41403. /**
  41404. * Creates a DynamicTexture
  41405. * @param name defines the name of the texture
  41406. * @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
  41407. * @param scene defines the scene where you want the texture
  41408. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41409. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41410. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41411. */
  41412. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41413. /**
  41414. * Get the current class name of the texture useful for serialization or dynamic coding.
  41415. * @returns "DynamicTexture"
  41416. */
  41417. getClassName(): string;
  41418. /**
  41419. * Gets the current state of canRescale
  41420. */
  41421. readonly canRescale: boolean;
  41422. private _recreate;
  41423. /**
  41424. * Scales the texture
  41425. * @param ratio the scale factor to apply to both width and height
  41426. */
  41427. scale(ratio: number): void;
  41428. /**
  41429. * Resizes the texture
  41430. * @param width the new width
  41431. * @param height the new height
  41432. */
  41433. scaleTo(width: number, height: number): void;
  41434. /**
  41435. * Gets the context of the canvas used by the texture
  41436. * @returns the canvas context of the dynamic texture
  41437. */
  41438. getContext(): CanvasRenderingContext2D;
  41439. /**
  41440. * Clears the texture
  41441. */
  41442. clear(): void;
  41443. /**
  41444. * Updates the texture
  41445. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41446. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41447. */
  41448. update(invertY?: boolean, premulAlpha?: boolean): void;
  41449. /**
  41450. * Draws text onto the texture
  41451. * @param text defines the text to be drawn
  41452. * @param x defines the placement of the text from the left
  41453. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41454. * @param font defines the font to be used with font-style, font-size, font-name
  41455. * @param color defines the color used for the text
  41456. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41457. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41458. * @param update defines whether texture is immediately update (default is true)
  41459. */
  41460. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41461. /**
  41462. * Clones the texture
  41463. * @returns the clone of the texture.
  41464. */
  41465. clone(): DynamicTexture;
  41466. /**
  41467. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41468. * @returns a serialized dynamic texture object
  41469. */
  41470. serialize(): any;
  41471. /** @hidden */
  41472. _rebuild(): void;
  41473. }
  41474. }
  41475. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41476. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41477. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41478. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41479. /** @hidden */
  41480. export var imageProcessingPixelShader: {
  41481. name: string;
  41482. shader: string;
  41483. };
  41484. }
  41485. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41486. import { Nullable } from "babylonjs/types";
  41487. import { Color4 } from "babylonjs/Maths/math.color";
  41488. import { Camera } from "babylonjs/Cameras/camera";
  41489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41490. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41491. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41492. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41493. import { Engine } from "babylonjs/Engines/engine";
  41494. import "babylonjs/Shaders/imageProcessing.fragment";
  41495. import "babylonjs/Shaders/postprocess.vertex";
  41496. /**
  41497. * ImageProcessingPostProcess
  41498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41499. */
  41500. export class ImageProcessingPostProcess extends PostProcess {
  41501. /**
  41502. * Default configuration related to image processing available in the PBR Material.
  41503. */
  41504. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41505. /**
  41506. * Gets the image processing configuration used either in this material.
  41507. */
  41508. /**
  41509. * Sets the Default image processing configuration used either in the this material.
  41510. *
  41511. * If sets to null, the scene one is in use.
  41512. */
  41513. imageProcessingConfiguration: ImageProcessingConfiguration;
  41514. /**
  41515. * Keep track of the image processing observer to allow dispose and replace.
  41516. */
  41517. private _imageProcessingObserver;
  41518. /**
  41519. * Attaches a new image processing configuration to the PBR Material.
  41520. * @param configuration
  41521. */
  41522. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41523. /**
  41524. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41525. */
  41526. /**
  41527. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41528. */
  41529. colorCurves: Nullable<ColorCurves>;
  41530. /**
  41531. * Gets wether the color curves effect is enabled.
  41532. */
  41533. /**
  41534. * Sets wether the color curves effect is enabled.
  41535. */
  41536. colorCurvesEnabled: boolean;
  41537. /**
  41538. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41539. */
  41540. /**
  41541. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41542. */
  41543. colorGradingTexture: Nullable<BaseTexture>;
  41544. /**
  41545. * Gets wether the color grading effect is enabled.
  41546. */
  41547. /**
  41548. * Gets wether the color grading effect is enabled.
  41549. */
  41550. colorGradingEnabled: boolean;
  41551. /**
  41552. * Gets exposure used in the effect.
  41553. */
  41554. /**
  41555. * Sets exposure used in the effect.
  41556. */
  41557. exposure: number;
  41558. /**
  41559. * Gets wether tonemapping is enabled or not.
  41560. */
  41561. /**
  41562. * Sets wether tonemapping is enabled or not
  41563. */
  41564. toneMappingEnabled: boolean;
  41565. /**
  41566. * Gets the type of tone mapping effect.
  41567. */
  41568. /**
  41569. * Sets the type of tone mapping effect.
  41570. */
  41571. toneMappingType: number;
  41572. /**
  41573. * Gets contrast used in the effect.
  41574. */
  41575. /**
  41576. * Sets contrast used in the effect.
  41577. */
  41578. contrast: number;
  41579. /**
  41580. * Gets Vignette stretch size.
  41581. */
  41582. /**
  41583. * Sets Vignette stretch size.
  41584. */
  41585. vignetteStretch: number;
  41586. /**
  41587. * Gets Vignette centre X Offset.
  41588. */
  41589. /**
  41590. * Sets Vignette centre X Offset.
  41591. */
  41592. vignetteCentreX: number;
  41593. /**
  41594. * Gets Vignette centre Y Offset.
  41595. */
  41596. /**
  41597. * Sets Vignette centre Y Offset.
  41598. */
  41599. vignetteCentreY: number;
  41600. /**
  41601. * Gets Vignette weight or intensity of the vignette effect.
  41602. */
  41603. /**
  41604. * Sets Vignette weight or intensity of the vignette effect.
  41605. */
  41606. vignetteWeight: number;
  41607. /**
  41608. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41609. * if vignetteEnabled is set to true.
  41610. */
  41611. /**
  41612. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41613. * if vignetteEnabled is set to true.
  41614. */
  41615. vignetteColor: Color4;
  41616. /**
  41617. * Gets Camera field of view used by the Vignette effect.
  41618. */
  41619. /**
  41620. * Sets Camera field of view used by the Vignette effect.
  41621. */
  41622. vignetteCameraFov: number;
  41623. /**
  41624. * Gets the vignette blend mode allowing different kind of effect.
  41625. */
  41626. /**
  41627. * Sets the vignette blend mode allowing different kind of effect.
  41628. */
  41629. vignetteBlendMode: number;
  41630. /**
  41631. * Gets wether the vignette effect is enabled.
  41632. */
  41633. /**
  41634. * Sets wether the vignette effect is enabled.
  41635. */
  41636. vignetteEnabled: boolean;
  41637. private _fromLinearSpace;
  41638. /**
  41639. * Gets wether the input of the processing is in Gamma or Linear Space.
  41640. */
  41641. /**
  41642. * Sets wether the input of the processing is in Gamma or Linear Space.
  41643. */
  41644. fromLinearSpace: boolean;
  41645. /**
  41646. * Defines cache preventing GC.
  41647. */
  41648. private _defines;
  41649. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41650. /**
  41651. * "ImageProcessingPostProcess"
  41652. * @returns "ImageProcessingPostProcess"
  41653. */
  41654. getClassName(): string;
  41655. protected _updateParameters(): void;
  41656. dispose(camera?: Camera): void;
  41657. }
  41658. }
  41659. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41660. import { Scene } from "babylonjs/scene";
  41661. import { Color3 } from "babylonjs/Maths/math.color";
  41662. import { Mesh } from "babylonjs/Meshes/mesh";
  41663. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41664. import { Nullable } from "babylonjs/types";
  41665. /**
  41666. * Class containing static functions to help procedurally build meshes
  41667. */
  41668. export class GroundBuilder {
  41669. /**
  41670. * Creates a ground mesh
  41671. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41672. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41674. * @param name defines the name of the mesh
  41675. * @param options defines the options used to create the mesh
  41676. * @param scene defines the hosting scene
  41677. * @returns the ground mesh
  41678. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41679. */
  41680. static CreateGround(name: string, options: {
  41681. width?: number;
  41682. height?: number;
  41683. subdivisions?: number;
  41684. subdivisionsX?: number;
  41685. subdivisionsY?: number;
  41686. updatable?: boolean;
  41687. }, scene: any): Mesh;
  41688. /**
  41689. * Creates a tiled ground mesh
  41690. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41691. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41692. * * 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
  41693. * * 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
  41694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41695. * @param name defines the name of the mesh
  41696. * @param options defines the options used to create the mesh
  41697. * @param scene defines the hosting scene
  41698. * @returns the tiled ground mesh
  41699. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41700. */
  41701. static CreateTiledGround(name: string, options: {
  41702. xmin: number;
  41703. zmin: number;
  41704. xmax: number;
  41705. zmax: number;
  41706. subdivisions?: {
  41707. w: number;
  41708. h: number;
  41709. };
  41710. precision?: {
  41711. w: number;
  41712. h: number;
  41713. };
  41714. updatable?: boolean;
  41715. }, scene?: Nullable<Scene>): Mesh;
  41716. /**
  41717. * Creates a ground mesh from a height map
  41718. * * The parameter `url` sets the URL of the height map image resource.
  41719. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41720. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41721. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41722. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41723. * * 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.
  41724. * * 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).
  41725. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41727. * @param name defines the name of the mesh
  41728. * @param url defines the url to the height map
  41729. * @param options defines the options used to create the mesh
  41730. * @param scene defines the hosting scene
  41731. * @returns the ground mesh
  41732. * @see https://doc.babylonjs.com/babylon101/height_map
  41733. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41734. */
  41735. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41736. width?: number;
  41737. height?: number;
  41738. subdivisions?: number;
  41739. minHeight?: number;
  41740. maxHeight?: number;
  41741. colorFilter?: Color3;
  41742. alphaFilter?: number;
  41743. updatable?: boolean;
  41744. onReady?: (mesh: GroundMesh) => void;
  41745. }, scene?: Nullable<Scene>): GroundMesh;
  41746. }
  41747. }
  41748. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41749. import { Vector4 } from "babylonjs/Maths/math.vector";
  41750. import { Mesh } from "babylonjs/Meshes/mesh";
  41751. /**
  41752. * Class containing static functions to help procedurally build meshes
  41753. */
  41754. export class TorusBuilder {
  41755. /**
  41756. * Creates a torus mesh
  41757. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41758. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41759. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41763. * @param name defines the name of the mesh
  41764. * @param options defines the options used to create the mesh
  41765. * @param scene defines the hosting scene
  41766. * @returns the torus mesh
  41767. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41768. */
  41769. static CreateTorus(name: string, options: {
  41770. diameter?: number;
  41771. thickness?: number;
  41772. tessellation?: number;
  41773. updatable?: boolean;
  41774. sideOrientation?: number;
  41775. frontUVs?: Vector4;
  41776. backUVs?: Vector4;
  41777. }, scene: any): Mesh;
  41778. }
  41779. }
  41780. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41781. import { Vector4 } from "babylonjs/Maths/math.vector";
  41782. import { Color4 } from "babylonjs/Maths/math.color";
  41783. import { Mesh } from "babylonjs/Meshes/mesh";
  41784. /**
  41785. * Class containing static functions to help procedurally build meshes
  41786. */
  41787. export class CylinderBuilder {
  41788. /**
  41789. * Creates a cylinder or a cone mesh
  41790. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41791. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41792. * * 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.
  41793. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41794. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41795. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41796. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41797. * * 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).
  41798. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41799. * * 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).
  41800. * * 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
  41801. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41802. * * 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
  41803. * * 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.
  41804. * * If `enclose` is false, a ring surface is one element.
  41805. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41806. * * 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
  41807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41808. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41810. * @param name defines the name of the mesh
  41811. * @param options defines the options used to create the mesh
  41812. * @param scene defines the hosting scene
  41813. * @returns the cylinder mesh
  41814. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41815. */
  41816. static CreateCylinder(name: string, options: {
  41817. height?: number;
  41818. diameterTop?: number;
  41819. diameterBottom?: number;
  41820. diameter?: number;
  41821. tessellation?: number;
  41822. subdivisions?: number;
  41823. arc?: number;
  41824. faceColors?: Color4[];
  41825. faceUV?: Vector4[];
  41826. updatable?: boolean;
  41827. hasRings?: boolean;
  41828. enclose?: boolean;
  41829. cap?: number;
  41830. sideOrientation?: number;
  41831. frontUVs?: Vector4;
  41832. backUVs?: Vector4;
  41833. }, scene: any): Mesh;
  41834. }
  41835. }
  41836. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41837. import { Observable } from "babylonjs/Misc/observable";
  41838. import { Nullable } from "babylonjs/types";
  41839. import { Camera } from "babylonjs/Cameras/camera";
  41840. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41841. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41842. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41843. import { Scene } from "babylonjs/scene";
  41844. import { Vector3 } from "babylonjs/Maths/math.vector";
  41845. import { Color3 } from "babylonjs/Maths/math.color";
  41846. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41848. import { Mesh } from "babylonjs/Meshes/mesh";
  41849. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41850. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41851. import "babylonjs/Meshes/Builders/groundBuilder";
  41852. import "babylonjs/Meshes/Builders/torusBuilder";
  41853. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41854. import "babylonjs/Gamepads/gamepadSceneComponent";
  41855. import "babylonjs/Animations/animatable";
  41856. /**
  41857. * Options to modify the vr teleportation behavior.
  41858. */
  41859. export interface VRTeleportationOptions {
  41860. /**
  41861. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41862. */
  41863. floorMeshName?: string;
  41864. /**
  41865. * A list of meshes to be used as the teleportation floor. (default: empty)
  41866. */
  41867. floorMeshes?: Mesh[];
  41868. }
  41869. /**
  41870. * Options to modify the vr experience helper's behavior.
  41871. */
  41872. export interface VRExperienceHelperOptions extends WebVROptions {
  41873. /**
  41874. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41875. */
  41876. createDeviceOrientationCamera?: boolean;
  41877. /**
  41878. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41879. */
  41880. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41881. /**
  41882. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41883. */
  41884. laserToggle?: boolean;
  41885. /**
  41886. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41887. */
  41888. floorMeshes?: Mesh[];
  41889. /**
  41890. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41891. */
  41892. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41893. }
  41894. /**
  41895. * Event containing information after VR has been entered
  41896. */
  41897. export class OnAfterEnteringVRObservableEvent {
  41898. /**
  41899. * If entering vr was successful
  41900. */
  41901. success: boolean;
  41902. }
  41903. /**
  41904. * Helps to quickly add VR support to an existing scene.
  41905. * See http://doc.babylonjs.com/how_to/webvr_helper
  41906. */
  41907. export class VRExperienceHelper {
  41908. /** Options to modify the vr experience helper's behavior. */
  41909. webVROptions: VRExperienceHelperOptions;
  41910. private _scene;
  41911. private _position;
  41912. private _btnVR;
  41913. private _btnVRDisplayed;
  41914. private _webVRsupported;
  41915. private _webVRready;
  41916. private _webVRrequesting;
  41917. private _webVRpresenting;
  41918. private _hasEnteredVR;
  41919. private _fullscreenVRpresenting;
  41920. private _canvas;
  41921. private _webVRCamera;
  41922. private _vrDeviceOrientationCamera;
  41923. private _deviceOrientationCamera;
  41924. private _existingCamera;
  41925. private _onKeyDown;
  41926. private _onVrDisplayPresentChange;
  41927. private _onVRDisplayChanged;
  41928. private _onVRRequestPresentStart;
  41929. private _onVRRequestPresentComplete;
  41930. /**
  41931. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  41932. */
  41933. enableGazeEvenWhenNoPointerLock: boolean;
  41934. /**
  41935. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41936. */
  41937. exitVROnDoubleTap: boolean;
  41938. /**
  41939. * Observable raised right before entering VR.
  41940. */
  41941. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41942. /**
  41943. * Observable raised when entering VR has completed.
  41944. */
  41945. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41946. /**
  41947. * Observable raised when exiting VR.
  41948. */
  41949. onExitingVRObservable: Observable<VRExperienceHelper>;
  41950. /**
  41951. * Observable raised when controller mesh is loaded.
  41952. */
  41953. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41954. /** Return this.onEnteringVRObservable
  41955. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41956. */
  41957. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41958. /** Return this.onExitingVRObservable
  41959. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41960. */
  41961. readonly onExitingVR: Observable<VRExperienceHelper>;
  41962. /** Return this.onControllerMeshLoadedObservable
  41963. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41964. */
  41965. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41966. private _rayLength;
  41967. private _useCustomVRButton;
  41968. private _teleportationRequested;
  41969. private _teleportActive;
  41970. private _floorMeshName;
  41971. private _floorMeshesCollection;
  41972. private _rotationAllowed;
  41973. private _teleportBackwardsVector;
  41974. private _teleportationTarget;
  41975. private _isDefaultTeleportationTarget;
  41976. private _postProcessMove;
  41977. private _teleportationFillColor;
  41978. private _teleportationBorderColor;
  41979. private _rotationAngle;
  41980. private _haloCenter;
  41981. private _cameraGazer;
  41982. private _padSensibilityUp;
  41983. private _padSensibilityDown;
  41984. private _leftController;
  41985. private _rightController;
  41986. /**
  41987. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41988. */
  41989. onNewMeshSelected: Observable<AbstractMesh>;
  41990. /**
  41991. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41992. */
  41993. onNewMeshPicked: Observable<PickingInfo>;
  41994. private _circleEase;
  41995. /**
  41996. * Observable raised before camera teleportation
  41997. */
  41998. onBeforeCameraTeleport: Observable<Vector3>;
  41999. /**
  42000. * Observable raised after camera teleportation
  42001. */
  42002. onAfterCameraTeleport: Observable<Vector3>;
  42003. /**
  42004. * Observable raised when current selected mesh gets unselected
  42005. */
  42006. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42007. private _raySelectionPredicate;
  42008. /**
  42009. * To be optionaly changed by user to define custom ray selection
  42010. */
  42011. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42012. /**
  42013. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42014. */
  42015. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42016. /**
  42017. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42018. */
  42019. teleportationEnabled: boolean;
  42020. private _defaultHeight;
  42021. private _teleportationInitialized;
  42022. private _interactionsEnabled;
  42023. private _interactionsRequested;
  42024. private _displayGaze;
  42025. private _displayLaserPointer;
  42026. /**
  42027. * The mesh used to display where the user is going to teleport.
  42028. */
  42029. /**
  42030. * Sets the mesh to be used to display where the user is going to teleport.
  42031. */
  42032. teleportationTarget: Mesh;
  42033. /**
  42034. * 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
  42035. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42036. * See http://doc.babylonjs.com/resources/baking_transformations
  42037. */
  42038. gazeTrackerMesh: Mesh;
  42039. /**
  42040. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42041. */
  42042. updateGazeTrackerScale: boolean;
  42043. /**
  42044. * If the gaze trackers color should be updated when selecting meshes
  42045. */
  42046. updateGazeTrackerColor: boolean;
  42047. /**
  42048. * The gaze tracking mesh corresponding to the left controller
  42049. */
  42050. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42051. /**
  42052. * The gaze tracking mesh corresponding to the right controller
  42053. */
  42054. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42055. /**
  42056. * If the ray of the gaze should be displayed.
  42057. */
  42058. /**
  42059. * Sets if the ray of the gaze should be displayed.
  42060. */
  42061. displayGaze: boolean;
  42062. /**
  42063. * If the ray of the LaserPointer should be displayed.
  42064. */
  42065. /**
  42066. * Sets if the ray of the LaserPointer should be displayed.
  42067. */
  42068. displayLaserPointer: boolean;
  42069. /**
  42070. * The deviceOrientationCamera used as the camera when not in VR.
  42071. */
  42072. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42073. /**
  42074. * Based on the current WebVR support, returns the current VR camera used.
  42075. */
  42076. readonly currentVRCamera: Nullable<Camera>;
  42077. /**
  42078. * The webVRCamera which is used when in VR.
  42079. */
  42080. readonly webVRCamera: WebVRFreeCamera;
  42081. /**
  42082. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42083. */
  42084. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42085. /**
  42086. * The html button that is used to trigger entering into VR.
  42087. */
  42088. readonly vrButton: Nullable<HTMLButtonElement>;
  42089. private readonly _teleportationRequestInitiated;
  42090. /**
  42091. * Defines wether or not Pointer lock should be requested when switching to
  42092. * full screen.
  42093. */
  42094. requestPointerLockOnFullScreen: boolean;
  42095. /**
  42096. * Instantiates a VRExperienceHelper.
  42097. * Helps to quickly add VR support to an existing scene.
  42098. * @param scene The scene the VRExperienceHelper belongs to.
  42099. * @param webVROptions Options to modify the vr experience helper's behavior.
  42100. */
  42101. constructor(scene: Scene,
  42102. /** Options to modify the vr experience helper's behavior. */
  42103. webVROptions?: VRExperienceHelperOptions);
  42104. private _onDefaultMeshLoaded;
  42105. private _onResize;
  42106. private _onFullscreenChange;
  42107. /**
  42108. * Gets a value indicating if we are currently in VR mode.
  42109. */
  42110. readonly isInVRMode: boolean;
  42111. private onVrDisplayPresentChange;
  42112. private onVRDisplayChanged;
  42113. private moveButtonToBottomRight;
  42114. private displayVRButton;
  42115. private updateButtonVisibility;
  42116. private _cachedAngularSensibility;
  42117. /**
  42118. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42119. * Otherwise, will use the fullscreen API.
  42120. */
  42121. enterVR(): void;
  42122. /**
  42123. * Attempt to exit VR, or fullscreen.
  42124. */
  42125. exitVR(): void;
  42126. /**
  42127. * The position of the vr experience helper.
  42128. */
  42129. /**
  42130. * Sets the position of the vr experience helper.
  42131. */
  42132. position: Vector3;
  42133. /**
  42134. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42135. */
  42136. enableInteractions(): void;
  42137. private readonly _noControllerIsActive;
  42138. private beforeRender;
  42139. private _isTeleportationFloor;
  42140. /**
  42141. * Adds a floor mesh to be used for teleportation.
  42142. * @param floorMesh the mesh to be used for teleportation.
  42143. */
  42144. addFloorMesh(floorMesh: Mesh): void;
  42145. /**
  42146. * Removes a floor mesh from being used for teleportation.
  42147. * @param floorMesh the mesh to be removed.
  42148. */
  42149. removeFloorMesh(floorMesh: Mesh): void;
  42150. /**
  42151. * Enables interactions and teleportation using the VR controllers and gaze.
  42152. * @param vrTeleportationOptions options to modify teleportation behavior.
  42153. */
  42154. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42155. private _onNewGamepadConnected;
  42156. private _tryEnableInteractionOnController;
  42157. private _onNewGamepadDisconnected;
  42158. private _enableInteractionOnController;
  42159. private _checkTeleportWithRay;
  42160. private _checkRotate;
  42161. private _checkTeleportBackwards;
  42162. private _enableTeleportationOnController;
  42163. private _createTeleportationCircles;
  42164. private _displayTeleportationTarget;
  42165. private _hideTeleportationTarget;
  42166. private _rotateCamera;
  42167. private _moveTeleportationSelectorTo;
  42168. private _workingVector;
  42169. private _workingQuaternion;
  42170. private _workingMatrix;
  42171. /**
  42172. * Teleports the users feet to the desired location
  42173. * @param location The location where the user's feet should be placed
  42174. */
  42175. teleportCamera(location: Vector3): void;
  42176. private _convertNormalToDirectionOfRay;
  42177. private _castRayAndSelectObject;
  42178. private _notifySelectedMeshUnselected;
  42179. /**
  42180. * Sets the color of the laser ray from the vr controllers.
  42181. * @param color new color for the ray.
  42182. */
  42183. changeLaserColor(color: Color3): void;
  42184. /**
  42185. * Sets the color of the ray from the vr headsets gaze.
  42186. * @param color new color for the ray.
  42187. */
  42188. changeGazeColor(color: Color3): void;
  42189. /**
  42190. * Exits VR and disposes of the vr experience helper
  42191. */
  42192. dispose(): void;
  42193. /**
  42194. * Gets the name of the VRExperienceHelper class
  42195. * @returns "VRExperienceHelper"
  42196. */
  42197. getClassName(): string;
  42198. }
  42199. }
  42200. declare module "babylonjs/Cameras/VR/index" {
  42201. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42202. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42203. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42204. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42205. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42206. export * from "babylonjs/Cameras/VR/webVRCamera";
  42207. }
  42208. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42209. import { Observable } from "babylonjs/Misc/observable";
  42210. import { Nullable } from "babylonjs/types";
  42211. import { IDisposable, Scene } from "babylonjs/scene";
  42212. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42213. /**
  42214. * Manages an XRSession to work with Babylon's engine
  42215. * @see https://doc.babylonjs.com/how_to/webxr
  42216. */
  42217. export class WebXRSessionManager implements IDisposable {
  42218. private scene;
  42219. /**
  42220. * Fires every time a new xrFrame arrives which can be used to update the camera
  42221. */
  42222. onXRFrameObservable: Observable<any>;
  42223. /**
  42224. * Fires when the xr session is ended either by the device or manually done
  42225. */
  42226. onXRSessionEnded: Observable<any>;
  42227. /**
  42228. * Underlying xr session
  42229. */
  42230. session: XRSession;
  42231. /**
  42232. * Type of reference space used when creating the session
  42233. */
  42234. referenceSpace: XRReferenceSpace;
  42235. /** @hidden */
  42236. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42237. /**
  42238. * Current XR frame
  42239. */
  42240. currentFrame: Nullable<XRFrame>;
  42241. private _xrNavigator;
  42242. private baseLayer;
  42243. /**
  42244. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42245. * @param scene The scene which the session should be created for
  42246. */
  42247. constructor(scene: Scene);
  42248. /**
  42249. * Initializes the manager
  42250. * After initialization enterXR can be called to start an XR session
  42251. * @returns Promise which resolves after it is initialized
  42252. */
  42253. initializeAsync(): Promise<void>;
  42254. /**
  42255. * Initializes an xr session
  42256. * @param xrSessionMode mode to initialize
  42257. * @returns a promise which will resolve once the session has been initialized
  42258. */
  42259. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42260. /**
  42261. * Sets the reference space on the xr session
  42262. * @param referenceSpace space to set
  42263. * @returns a promise that will resolve once the reference space has been set
  42264. */
  42265. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42266. /**
  42267. * Updates the render state of the session
  42268. * @param state state to set
  42269. * @returns a promise that resolves once the render state has been updated
  42270. */
  42271. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42272. /**
  42273. * Starts rendering to the xr layer
  42274. * @returns a promise that will resolve once rendering has started
  42275. */
  42276. startRenderingToXRAsync(): Promise<void>;
  42277. /**
  42278. * Stops the xrSession and restores the renderloop
  42279. * @returns Promise which resolves after it exits XR
  42280. */
  42281. exitXRAsync(): Promise<unknown>;
  42282. /**
  42283. * Checks if a session would be supported for the creation options specified
  42284. * @param sessionMode session mode to check if supported eg. immersive-vr
  42285. * @returns true if supported
  42286. */
  42287. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42288. /**
  42289. * @hidden
  42290. * Converts the render layer of xrSession to a render target
  42291. * @param session session to create render target for
  42292. * @param scene scene the new render target should be created for
  42293. */
  42294. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42295. /**
  42296. * Disposes of the session manager
  42297. */
  42298. dispose(): void;
  42299. }
  42300. }
  42301. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42302. import { Scene } from "babylonjs/scene";
  42303. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42304. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42305. /**
  42306. * WebXR Camera which holds the views for the xrSession
  42307. * @see https://doc.babylonjs.com/how_to/webxr
  42308. */
  42309. export class WebXRCamera extends FreeCamera {
  42310. private static _TmpMatrix;
  42311. /**
  42312. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42313. * @param name the name of the camera
  42314. * @param scene the scene to add the camera to
  42315. */
  42316. constructor(name: string, scene: Scene);
  42317. private _updateNumberOfRigCameras;
  42318. /** @hidden */
  42319. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42320. /**
  42321. * Updates the cameras position from the current pose information of the XR session
  42322. * @param xrSessionManager the session containing pose information
  42323. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42324. */
  42325. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42326. }
  42327. }
  42328. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42329. import { Nullable } from "babylonjs/types";
  42330. import { IDisposable } from "babylonjs/scene";
  42331. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42332. /**
  42333. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42334. */
  42335. export class WebXRManagedOutputCanvas implements IDisposable {
  42336. private helper;
  42337. private _canvas;
  42338. /**
  42339. * xrpresent context of the canvas which can be used to display/mirror xr content
  42340. */
  42341. canvasContext: WebGLRenderingContext;
  42342. /**
  42343. * xr layer for the canvas
  42344. */
  42345. xrLayer: Nullable<XRWebGLLayer>;
  42346. /**
  42347. * Initializes the xr layer for the session
  42348. * @param xrSession xr session
  42349. * @returns a promise that will resolve once the XR Layer has been created
  42350. */
  42351. initializeXRLayerAsync(xrSession: any): any;
  42352. /**
  42353. * Initializes the canvas to be added/removed upon entering/exiting xr
  42354. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42355. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42356. */
  42357. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42358. /**
  42359. * Disposes of the object
  42360. */
  42361. dispose(): void;
  42362. private _setManagedOutputCanvas;
  42363. private _addCanvas;
  42364. private _removeCanvas;
  42365. }
  42366. }
  42367. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42368. import { Observable } from "babylonjs/Misc/observable";
  42369. import { IDisposable, Scene } from "babylonjs/scene";
  42370. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42372. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42373. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42374. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42375. /**
  42376. * States of the webXR experience
  42377. */
  42378. export enum WebXRState {
  42379. /**
  42380. * Transitioning to being in XR mode
  42381. */
  42382. ENTERING_XR = 0,
  42383. /**
  42384. * Transitioning to non XR mode
  42385. */
  42386. EXITING_XR = 1,
  42387. /**
  42388. * In XR mode and presenting
  42389. */
  42390. IN_XR = 2,
  42391. /**
  42392. * Not entered XR mode
  42393. */
  42394. NOT_IN_XR = 3
  42395. }
  42396. /**
  42397. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42398. * @see https://doc.babylonjs.com/how_to/webxr
  42399. */
  42400. export class WebXRExperienceHelper implements IDisposable {
  42401. private scene;
  42402. /**
  42403. * 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
  42404. */
  42405. container: AbstractMesh;
  42406. /**
  42407. * Camera used to render xr content
  42408. */
  42409. camera: WebXRCamera;
  42410. /**
  42411. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42412. */
  42413. state: WebXRState;
  42414. private _setState;
  42415. private static _TmpVector;
  42416. /**
  42417. * Fires when the state of the experience helper has changed
  42418. */
  42419. onStateChangedObservable: Observable<WebXRState>;
  42420. /** Session manager used to keep track of xr session */
  42421. sessionManager: WebXRSessionManager;
  42422. private _nonVRCamera;
  42423. private _originalSceneAutoClear;
  42424. private _supported;
  42425. /**
  42426. * Creates the experience helper
  42427. * @param scene the scene to attach the experience helper to
  42428. * @returns a promise for the experience helper
  42429. */
  42430. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42431. /**
  42432. * Creates a WebXRExperienceHelper
  42433. * @param scene The scene the helper should be created in
  42434. */
  42435. private constructor();
  42436. /**
  42437. * Exits XR mode and returns the scene to its original state
  42438. * @returns promise that resolves after xr mode has exited
  42439. */
  42440. exitXRAsync(): Promise<unknown>;
  42441. /**
  42442. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42443. * @param sessionCreationOptions options for the XR session
  42444. * @param referenceSpaceType frame of reference of the XR session
  42445. * @param outputCanvas the output canvas that will be used to enter XR mode
  42446. * @returns promise that resolves after xr mode has entered
  42447. */
  42448. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42449. /**
  42450. * Updates the global position of the camera by moving the camera's container
  42451. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42452. * @param position The desired global position of the camera
  42453. */
  42454. setPositionOfCameraUsingContainer(position: Vector3): void;
  42455. /**
  42456. * Rotates the xr camera by rotating the camera's container around the camera's position
  42457. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42458. * @param rotation the desired quaternion rotation to apply to the camera
  42459. */
  42460. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42461. /**
  42462. * Disposes of the experience helper
  42463. */
  42464. dispose(): void;
  42465. }
  42466. }
  42467. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42468. import { Nullable } from "babylonjs/types";
  42469. import { Observable } from "babylonjs/Misc/observable";
  42470. import { IDisposable, Scene } from "babylonjs/scene";
  42471. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42472. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42473. /**
  42474. * Button which can be used to enter a different mode of XR
  42475. */
  42476. export class WebXREnterExitUIButton {
  42477. /** button element */
  42478. element: HTMLElement;
  42479. /** XR initialization options for the button */
  42480. sessionMode: XRSessionMode;
  42481. /** Reference space type */
  42482. referenceSpaceType: XRReferenceSpaceType;
  42483. /**
  42484. * Creates a WebXREnterExitUIButton
  42485. * @param element button element
  42486. * @param sessionMode XR initialization session mode
  42487. * @param referenceSpaceType the type of reference space to be used
  42488. */
  42489. constructor(
  42490. /** button element */
  42491. element: HTMLElement,
  42492. /** XR initialization options for the button */
  42493. sessionMode: XRSessionMode,
  42494. /** Reference space type */
  42495. referenceSpaceType: XRReferenceSpaceType);
  42496. /**
  42497. * Overwritable function which can be used to update the button's visuals when the state changes
  42498. * @param activeButton the current active button in the UI
  42499. */
  42500. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42501. }
  42502. /**
  42503. * Options to create the webXR UI
  42504. */
  42505. export class WebXREnterExitUIOptions {
  42506. /**
  42507. * Context to enter xr with
  42508. */
  42509. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42510. /**
  42511. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42512. */
  42513. customButtons?: Array<WebXREnterExitUIButton>;
  42514. }
  42515. /**
  42516. * UI to allow the user to enter/exit XR mode
  42517. */
  42518. export class WebXREnterExitUI implements IDisposable {
  42519. private scene;
  42520. private _overlay;
  42521. private _buttons;
  42522. private _activeButton;
  42523. /**
  42524. * Fired every time the active button is changed.
  42525. *
  42526. * When xr is entered via a button that launches xr that button will be the callback parameter
  42527. *
  42528. * When exiting xr the callback parameter will be null)
  42529. */
  42530. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42531. /**
  42532. * Creates UI to allow the user to enter/exit XR mode
  42533. * @param scene the scene to add the ui to
  42534. * @param helper the xr experience helper to enter/exit xr with
  42535. * @param options options to configure the UI
  42536. * @returns the created ui
  42537. */
  42538. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42539. private constructor();
  42540. private _updateButtons;
  42541. /**
  42542. * Disposes of the object
  42543. */
  42544. dispose(): void;
  42545. }
  42546. }
  42547. declare module "babylonjs/Cameras/XR/webXRController" {
  42548. import { Nullable } from "babylonjs/types";
  42549. import { Observable } from "babylonjs/Misc/observable";
  42550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42551. import { Ray } from "babylonjs/Culling/ray";
  42552. import { Scene } from "babylonjs/scene";
  42553. /**
  42554. * Represents an XR input
  42555. */
  42556. export class WebXRController {
  42557. private scene;
  42558. /** The underlying input source for the controller */
  42559. inputSource: XRInputSource;
  42560. private parentContainer;
  42561. /**
  42562. * 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
  42563. */
  42564. grip?: AbstractMesh;
  42565. /**
  42566. * Pointer which can be used to select objects or attach a visible laser to
  42567. */
  42568. pointer: AbstractMesh;
  42569. /**
  42570. * Event that fires when the controller is removed/disposed
  42571. */
  42572. onDisposeObservable: Observable<{}>;
  42573. private _tmpMatrix;
  42574. private _tmpQuaternion;
  42575. private _tmpVector;
  42576. /**
  42577. * Creates the controller
  42578. * @see https://doc.babylonjs.com/how_to/webxr
  42579. * @param scene the scene which the controller should be associated to
  42580. * @param inputSource the underlying input source for the controller
  42581. * @param parentContainer parent that the controller meshes should be children of
  42582. */
  42583. constructor(scene: Scene,
  42584. /** The underlying input source for the controller */
  42585. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42586. /**
  42587. * Updates the controller pose based on the given XRFrame
  42588. * @param xrFrame xr frame to update the pose with
  42589. * @param referenceSpace reference space to use
  42590. */
  42591. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42592. /**
  42593. * Gets a world space ray coming from the controller
  42594. * @param result the resulting ray
  42595. */
  42596. getWorldPointerRayToRef(result: Ray): void;
  42597. /**
  42598. * Disposes of the object
  42599. */
  42600. dispose(): void;
  42601. }
  42602. }
  42603. declare module "babylonjs/Cameras/XR/webXRInput" {
  42604. import { Observable } from "babylonjs/Misc/observable";
  42605. import { IDisposable } from "babylonjs/scene";
  42606. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42607. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42608. /**
  42609. * XR input used to track XR inputs such as controllers/rays
  42610. */
  42611. export class WebXRInput implements IDisposable {
  42612. /**
  42613. * Base experience the input listens to
  42614. */
  42615. baseExperience: WebXRExperienceHelper;
  42616. /**
  42617. * XR controllers being tracked
  42618. */
  42619. controllers: Array<WebXRController>;
  42620. private _frameObserver;
  42621. private _stateObserver;
  42622. /**
  42623. * Event when a controller has been connected/added
  42624. */
  42625. onControllerAddedObservable: Observable<WebXRController>;
  42626. /**
  42627. * Event when a controller has been removed/disconnected
  42628. */
  42629. onControllerRemovedObservable: Observable<WebXRController>;
  42630. /**
  42631. * Initializes the WebXRInput
  42632. * @param baseExperience experience helper which the input should be created for
  42633. */
  42634. constructor(
  42635. /**
  42636. * Base experience the input listens to
  42637. */
  42638. baseExperience: WebXRExperienceHelper);
  42639. private _onInputSourcesChange;
  42640. private _addAndRemoveControllers;
  42641. /**
  42642. * Disposes of the object
  42643. */
  42644. dispose(): void;
  42645. }
  42646. }
  42647. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42649. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42650. /**
  42651. * Enables teleportation
  42652. */
  42653. export class WebXRControllerTeleportation {
  42654. private _teleportationFillColor;
  42655. private _teleportationBorderColor;
  42656. private _tmpRay;
  42657. private _tmpVector;
  42658. /**
  42659. * Creates a WebXRControllerTeleportation
  42660. * @param input input manager to add teleportation to
  42661. * @param floorMeshes floormeshes which can be teleported to
  42662. */
  42663. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42664. }
  42665. }
  42666. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42667. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42668. /**
  42669. * Handles pointer input automatically for the pointer of XR controllers
  42670. */
  42671. export class WebXRControllerPointerSelection {
  42672. private static _idCounter;
  42673. private _tmpRay;
  42674. /**
  42675. * Creates a WebXRControllerPointerSelection
  42676. * @param input input manager to setup pointer selection
  42677. */
  42678. constructor(input: WebXRInput);
  42679. private _convertNormalToDirectionOfRay;
  42680. private _updatePointerDistance;
  42681. }
  42682. }
  42683. declare module "babylonjs/Loading/sceneLoader" {
  42684. import { Observable } from "babylonjs/Misc/observable";
  42685. import { Nullable } from "babylonjs/types";
  42686. import { Scene } from "babylonjs/scene";
  42687. import { Engine } from "babylonjs/Engines/engine";
  42688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42689. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42690. import { AssetContainer } from "babylonjs/assetContainer";
  42691. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42692. import { Skeleton } from "babylonjs/Bones/skeleton";
  42693. /**
  42694. * Class used to represent data loading progression
  42695. */
  42696. export class SceneLoaderProgressEvent {
  42697. /** defines if data length to load can be evaluated */
  42698. readonly lengthComputable: boolean;
  42699. /** defines the loaded data length */
  42700. readonly loaded: number;
  42701. /** defines the data length to load */
  42702. readonly total: number;
  42703. /**
  42704. * Create a new progress event
  42705. * @param lengthComputable defines if data length to load can be evaluated
  42706. * @param loaded defines the loaded data length
  42707. * @param total defines the data length to load
  42708. */
  42709. constructor(
  42710. /** defines if data length to load can be evaluated */
  42711. lengthComputable: boolean,
  42712. /** defines the loaded data length */
  42713. loaded: number,
  42714. /** defines the data length to load */
  42715. total: number);
  42716. /**
  42717. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42718. * @param event defines the source event
  42719. * @returns a new SceneLoaderProgressEvent
  42720. */
  42721. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42722. }
  42723. /**
  42724. * Interface used by SceneLoader plugins to define supported file extensions
  42725. */
  42726. export interface ISceneLoaderPluginExtensions {
  42727. /**
  42728. * Defines the list of supported extensions
  42729. */
  42730. [extension: string]: {
  42731. isBinary: boolean;
  42732. };
  42733. }
  42734. /**
  42735. * Interface used by SceneLoader plugin factory
  42736. */
  42737. export interface ISceneLoaderPluginFactory {
  42738. /**
  42739. * Defines the name of the factory
  42740. */
  42741. name: string;
  42742. /**
  42743. * Function called to create a new plugin
  42744. * @return the new plugin
  42745. */
  42746. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42747. /**
  42748. * Boolean indicating if the plugin can direct load specific data
  42749. */
  42750. canDirectLoad?: (data: string) => boolean;
  42751. }
  42752. /**
  42753. * Interface used to define a SceneLoader plugin
  42754. */
  42755. export interface ISceneLoaderPlugin {
  42756. /**
  42757. * The friendly name of this plugin.
  42758. */
  42759. name: string;
  42760. /**
  42761. * The file extensions supported by this plugin.
  42762. */
  42763. extensions: string | ISceneLoaderPluginExtensions;
  42764. /**
  42765. * Import meshes into a scene.
  42766. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42767. * @param scene The scene to import into
  42768. * @param data The data to import
  42769. * @param rootUrl The root url for scene and resources
  42770. * @param meshes The meshes array to import into
  42771. * @param particleSystems The particle systems array to import into
  42772. * @param skeletons The skeletons array to import into
  42773. * @param onError The callback when import fails
  42774. * @returns True if successful or false otherwise
  42775. */
  42776. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42777. /**
  42778. * Load into a scene.
  42779. * @param scene The scene to load into
  42780. * @param data The data to import
  42781. * @param rootUrl The root url for scene and resources
  42782. * @param onError The callback when import fails
  42783. * @returns true if successful or false otherwise
  42784. */
  42785. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42786. /**
  42787. * The callback that returns true if the data can be directly loaded.
  42788. */
  42789. canDirectLoad?: (data: string) => boolean;
  42790. /**
  42791. * The callback that allows custom handling of the root url based on the response url.
  42792. */
  42793. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42794. /**
  42795. * Load into an asset container.
  42796. * @param scene The scene to load into
  42797. * @param data The data to import
  42798. * @param rootUrl The root url for scene and resources
  42799. * @param onError The callback when import fails
  42800. * @returns The loaded asset container
  42801. */
  42802. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42803. }
  42804. /**
  42805. * Interface used to define an async SceneLoader plugin
  42806. */
  42807. export interface ISceneLoaderPluginAsync {
  42808. /**
  42809. * The friendly name of this plugin.
  42810. */
  42811. name: string;
  42812. /**
  42813. * The file extensions supported by this plugin.
  42814. */
  42815. extensions: string | ISceneLoaderPluginExtensions;
  42816. /**
  42817. * Import meshes into a scene.
  42818. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42819. * @param scene The scene to import into
  42820. * @param data The data to import
  42821. * @param rootUrl The root url for scene and resources
  42822. * @param onProgress The callback when the load progresses
  42823. * @param fileName Defines the name of the file to load
  42824. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42825. */
  42826. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42827. meshes: AbstractMesh[];
  42828. particleSystems: IParticleSystem[];
  42829. skeletons: Skeleton[];
  42830. animationGroups: AnimationGroup[];
  42831. }>;
  42832. /**
  42833. * Load into a scene.
  42834. * @param scene The scene to load into
  42835. * @param data The data to import
  42836. * @param rootUrl The root url for scene and resources
  42837. * @param onProgress The callback when the load progresses
  42838. * @param fileName Defines the name of the file to load
  42839. * @returns Nothing
  42840. */
  42841. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42842. /**
  42843. * The callback that returns true if the data can be directly loaded.
  42844. */
  42845. canDirectLoad?: (data: string) => boolean;
  42846. /**
  42847. * The callback that allows custom handling of the root url based on the response url.
  42848. */
  42849. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42850. /**
  42851. * Load into an asset container.
  42852. * @param scene The scene to load into
  42853. * @param data The data to import
  42854. * @param rootUrl The root url for scene and resources
  42855. * @param onProgress The callback when the load progresses
  42856. * @param fileName Defines the name of the file to load
  42857. * @returns The loaded asset container
  42858. */
  42859. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42860. }
  42861. /**
  42862. * Class used to load scene from various file formats using registered plugins
  42863. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42864. */
  42865. export class SceneLoader {
  42866. /**
  42867. * No logging while loading
  42868. */
  42869. static readonly NO_LOGGING: number;
  42870. /**
  42871. * Minimal logging while loading
  42872. */
  42873. static readonly MINIMAL_LOGGING: number;
  42874. /**
  42875. * Summary logging while loading
  42876. */
  42877. static readonly SUMMARY_LOGGING: number;
  42878. /**
  42879. * Detailled logging while loading
  42880. */
  42881. static readonly DETAILED_LOGGING: number;
  42882. /**
  42883. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42884. */
  42885. static ForceFullSceneLoadingForIncremental: boolean;
  42886. /**
  42887. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42888. */
  42889. static ShowLoadingScreen: boolean;
  42890. /**
  42891. * Defines the current logging level (while loading the scene)
  42892. * @ignorenaming
  42893. */
  42894. static loggingLevel: number;
  42895. /**
  42896. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42897. */
  42898. static CleanBoneMatrixWeights: boolean;
  42899. /**
  42900. * Event raised when a plugin is used to load a scene
  42901. */
  42902. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42903. private static _registeredPlugins;
  42904. private static _getDefaultPlugin;
  42905. private static _getPluginForExtension;
  42906. private static _getPluginForDirectLoad;
  42907. private static _getPluginForFilename;
  42908. private static _getDirectLoad;
  42909. private static _loadData;
  42910. private static _getFileInfo;
  42911. /**
  42912. * Gets a plugin that can load the given extension
  42913. * @param extension defines the extension to load
  42914. * @returns a plugin or null if none works
  42915. */
  42916. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42917. /**
  42918. * Gets a boolean indicating that the given extension can be loaded
  42919. * @param extension defines the extension to load
  42920. * @returns true if the extension is supported
  42921. */
  42922. static IsPluginForExtensionAvailable(extension: string): boolean;
  42923. /**
  42924. * Adds a new plugin to the list of registered plugins
  42925. * @param plugin defines the plugin to add
  42926. */
  42927. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42928. /**
  42929. * Import meshes into a scene
  42930. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42931. * @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)
  42932. * @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)
  42933. * @param scene the instance of BABYLON.Scene to append to
  42934. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42935. * @param onProgress a callback with a progress event for each file being loaded
  42936. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42937. * @param pluginExtension the extension used to determine the plugin
  42938. * @returns The loaded plugin
  42939. */
  42940. 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>;
  42941. /**
  42942. * Import meshes into a scene
  42943. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42944. * @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)
  42945. * @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)
  42946. * @param scene the instance of BABYLON.Scene to append to
  42947. * @param onProgress a callback with a progress event for each file being loaded
  42948. * @param pluginExtension the extension used to determine the plugin
  42949. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42950. */
  42951. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42952. meshes: AbstractMesh[];
  42953. particleSystems: IParticleSystem[];
  42954. skeletons: Skeleton[];
  42955. animationGroups: AnimationGroup[];
  42956. }>;
  42957. /**
  42958. * Load a scene
  42959. * @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)
  42960. * @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)
  42961. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42962. * @param onSuccess a callback with the scene when import succeeds
  42963. * @param onProgress a callback with a progress event for each file being loaded
  42964. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42965. * @param pluginExtension the extension used to determine the plugin
  42966. * @returns The loaded plugin
  42967. */
  42968. 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>;
  42969. /**
  42970. * Load a scene
  42971. * @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)
  42972. * @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)
  42973. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42974. * @param onProgress a callback with a progress event for each file being loaded
  42975. * @param pluginExtension the extension used to determine the plugin
  42976. * @returns The loaded scene
  42977. */
  42978. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42979. /**
  42980. * Append a scene
  42981. * @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)
  42982. * @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)
  42983. * @param scene is the instance of BABYLON.Scene to append to
  42984. * @param onSuccess a callback with the scene when import succeeds
  42985. * @param onProgress a callback with a progress event for each file being loaded
  42986. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42987. * @param pluginExtension the extension used to determine the plugin
  42988. * @returns The loaded plugin
  42989. */
  42990. 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>;
  42991. /**
  42992. * Append a scene
  42993. * @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)
  42994. * @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)
  42995. * @param scene is the instance of BABYLON.Scene to append to
  42996. * @param onProgress a callback with a progress event for each file being loaded
  42997. * @param pluginExtension the extension used to determine the plugin
  42998. * @returns The given scene
  42999. */
  43000. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43001. /**
  43002. * Load a scene into an asset container
  43003. * @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)
  43004. * @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)
  43005. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43006. * @param onSuccess a callback with the scene when import succeeds
  43007. * @param onProgress a callback with a progress event for each file being loaded
  43008. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43009. * @param pluginExtension the extension used to determine the plugin
  43010. * @returns The loaded plugin
  43011. */
  43012. 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>;
  43013. /**
  43014. * Load a scene into an asset container
  43015. * @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)
  43016. * @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)
  43017. * @param scene is the instance of Scene to append to
  43018. * @param onProgress a callback with a progress event for each file being loaded
  43019. * @param pluginExtension the extension used to determine the plugin
  43020. * @returns The loaded asset container
  43021. */
  43022. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43023. }
  43024. }
  43025. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43026. import { Scene } from "babylonjs/scene";
  43027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43028. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43029. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43030. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43031. /**
  43032. * Generic Controller
  43033. */
  43034. export class GenericController extends WebVRController {
  43035. /**
  43036. * Base Url for the controller model.
  43037. */
  43038. static readonly MODEL_BASE_URL: string;
  43039. /**
  43040. * File name for the controller model.
  43041. */
  43042. static readonly MODEL_FILENAME: string;
  43043. /**
  43044. * Creates a new GenericController from a gamepad
  43045. * @param vrGamepad the gamepad that the controller should be created from
  43046. */
  43047. constructor(vrGamepad: any);
  43048. /**
  43049. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43050. * @param scene scene in which to add meshes
  43051. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43052. */
  43053. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43054. /**
  43055. * Called once for each button that changed state since the last frame
  43056. * @param buttonIdx Which button index changed
  43057. * @param state New state of the button
  43058. * @param changes Which properties on the state changed since last frame
  43059. */
  43060. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43061. }
  43062. }
  43063. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43064. import { Observable } from "babylonjs/Misc/observable";
  43065. import { Scene } from "babylonjs/scene";
  43066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43067. import { Ray } from "babylonjs/Culling/ray";
  43068. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43069. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43070. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43071. /**
  43072. * Defines the WindowsMotionController object that the state of the windows motion controller
  43073. */
  43074. export class WindowsMotionController extends WebVRController {
  43075. /**
  43076. * The base url used to load the left and right controller models
  43077. */
  43078. static MODEL_BASE_URL: string;
  43079. /**
  43080. * The name of the left controller model file
  43081. */
  43082. static MODEL_LEFT_FILENAME: string;
  43083. /**
  43084. * The name of the right controller model file
  43085. */
  43086. static MODEL_RIGHT_FILENAME: string;
  43087. /**
  43088. * The controller name prefix for this controller type
  43089. */
  43090. static readonly GAMEPAD_ID_PREFIX: string;
  43091. /**
  43092. * The controller id pattern for this controller type
  43093. */
  43094. private static readonly GAMEPAD_ID_PATTERN;
  43095. private _loadedMeshInfo;
  43096. private readonly _mapping;
  43097. /**
  43098. * Fired when the trackpad on this controller is clicked
  43099. */
  43100. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43101. /**
  43102. * Fired when the trackpad on this controller is modified
  43103. */
  43104. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43105. /**
  43106. * The current x and y values of this controller's trackpad
  43107. */
  43108. trackpad: StickValues;
  43109. /**
  43110. * Creates a new WindowsMotionController from a gamepad
  43111. * @param vrGamepad the gamepad that the controller should be created from
  43112. */
  43113. constructor(vrGamepad: any);
  43114. /**
  43115. * Fired when the trigger on this controller is modified
  43116. */
  43117. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43118. /**
  43119. * Fired when the menu button on this controller is modified
  43120. */
  43121. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43122. /**
  43123. * Fired when the grip button on this controller is modified
  43124. */
  43125. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43126. /**
  43127. * Fired when the thumbstick button on this controller is modified
  43128. */
  43129. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43130. /**
  43131. * Fired when the touchpad button on this controller is modified
  43132. */
  43133. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43134. /**
  43135. * Fired when the touchpad values on this controller are modified
  43136. */
  43137. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43138. private _updateTrackpad;
  43139. /**
  43140. * Called once per frame by the engine.
  43141. */
  43142. update(): void;
  43143. /**
  43144. * Called once for each button that changed state since the last frame
  43145. * @param buttonIdx Which button index changed
  43146. * @param state New state of the button
  43147. * @param changes Which properties on the state changed since last frame
  43148. */
  43149. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43150. /**
  43151. * Moves the buttons on the controller mesh based on their current state
  43152. * @param buttonName the name of the button to move
  43153. * @param buttonValue the value of the button which determines the buttons new position
  43154. */
  43155. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43156. /**
  43157. * Moves the axis on the controller mesh based on its current state
  43158. * @param axis the index of the axis
  43159. * @param axisValue the value of the axis which determines the meshes new position
  43160. * @hidden
  43161. */
  43162. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43163. /**
  43164. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43165. * @param scene scene in which to add meshes
  43166. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43167. */
  43168. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43169. /**
  43170. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43171. * can be transformed by button presses and axes values, based on this._mapping.
  43172. *
  43173. * @param scene scene in which the meshes exist
  43174. * @param meshes list of meshes that make up the controller model to process
  43175. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43176. */
  43177. private processModel;
  43178. private createMeshInfo;
  43179. /**
  43180. * Gets the ray of the controller in the direction the controller is pointing
  43181. * @param length the length the resulting ray should be
  43182. * @returns a ray in the direction the controller is pointing
  43183. */
  43184. getForwardRay(length?: number): Ray;
  43185. /**
  43186. * Disposes of the controller
  43187. */
  43188. dispose(): void;
  43189. }
  43190. }
  43191. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43192. import { Observable } from "babylonjs/Misc/observable";
  43193. import { Scene } from "babylonjs/scene";
  43194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43195. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43196. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43197. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43198. /**
  43199. * Oculus Touch Controller
  43200. */
  43201. export class OculusTouchController extends WebVRController {
  43202. /**
  43203. * Base Url for the controller model.
  43204. */
  43205. static MODEL_BASE_URL: string;
  43206. /**
  43207. * File name for the left controller model.
  43208. */
  43209. static MODEL_LEFT_FILENAME: string;
  43210. /**
  43211. * File name for the right controller model.
  43212. */
  43213. static MODEL_RIGHT_FILENAME: string;
  43214. /**
  43215. * Base Url for the Quest controller model.
  43216. */
  43217. static QUEST_MODEL_BASE_URL: string;
  43218. /**
  43219. * @hidden
  43220. * If the controllers are running on a device that needs the updated Quest controller models
  43221. */
  43222. static _IsQuest: boolean;
  43223. /**
  43224. * Fired when the secondary trigger on this controller is modified
  43225. */
  43226. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43227. /**
  43228. * Fired when the thumb rest on this controller is modified
  43229. */
  43230. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43231. /**
  43232. * Creates a new OculusTouchController from a gamepad
  43233. * @param vrGamepad the gamepad that the controller should be created from
  43234. */
  43235. constructor(vrGamepad: any);
  43236. /**
  43237. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43238. * @param scene scene in which to add meshes
  43239. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43240. */
  43241. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43242. /**
  43243. * Fired when the A button on this controller is modified
  43244. */
  43245. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43246. /**
  43247. * Fired when the B button on this controller is modified
  43248. */
  43249. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43250. /**
  43251. * Fired when the X button on this controller is modified
  43252. */
  43253. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43254. /**
  43255. * Fired when the Y button on this controller is modified
  43256. */
  43257. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43258. /**
  43259. * Called once for each button that changed state since the last frame
  43260. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43261. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43262. * 2) secondary trigger (same)
  43263. * 3) A (right) X (left), touch, pressed = value
  43264. * 4) B / Y
  43265. * 5) thumb rest
  43266. * @param buttonIdx Which button index changed
  43267. * @param state New state of the button
  43268. * @param changes Which properties on the state changed since last frame
  43269. */
  43270. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43271. }
  43272. }
  43273. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43274. import { Scene } from "babylonjs/scene";
  43275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43276. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43277. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43278. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43279. import { Observable } from "babylonjs/Misc/observable";
  43280. /**
  43281. * Vive Controller
  43282. */
  43283. export class ViveController extends WebVRController {
  43284. /**
  43285. * Base Url for the controller model.
  43286. */
  43287. static MODEL_BASE_URL: string;
  43288. /**
  43289. * File name for the controller model.
  43290. */
  43291. static MODEL_FILENAME: string;
  43292. /**
  43293. * Creates a new ViveController from a gamepad
  43294. * @param vrGamepad the gamepad that the controller should be created from
  43295. */
  43296. constructor(vrGamepad: any);
  43297. /**
  43298. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43299. * @param scene scene in which to add meshes
  43300. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43301. */
  43302. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43303. /**
  43304. * Fired when the left button on this controller is modified
  43305. */
  43306. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43307. /**
  43308. * Fired when the right button on this controller is modified
  43309. */
  43310. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43311. /**
  43312. * Fired when the menu button on this controller is modified
  43313. */
  43314. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43315. /**
  43316. * Called once for each button that changed state since the last frame
  43317. * Vive mapping:
  43318. * 0: touchpad
  43319. * 1: trigger
  43320. * 2: left AND right buttons
  43321. * 3: menu button
  43322. * @param buttonIdx Which button index changed
  43323. * @param state New state of the button
  43324. * @param changes Which properties on the state changed since last frame
  43325. */
  43326. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43327. }
  43328. }
  43329. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43330. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43331. /**
  43332. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43333. */
  43334. export class WebXRControllerModelLoader {
  43335. /**
  43336. * Creates the WebXRControllerModelLoader
  43337. * @param input xr input that creates the controllers
  43338. */
  43339. constructor(input: WebXRInput);
  43340. }
  43341. }
  43342. declare module "babylonjs/Cameras/XR/index" {
  43343. export * from "babylonjs/Cameras/XR/webXRCamera";
  43344. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43345. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43346. export * from "babylonjs/Cameras/XR/webXRInput";
  43347. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43348. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43349. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43350. export * from "babylonjs/Cameras/XR/webXRController";
  43351. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43352. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43353. }
  43354. declare module "babylonjs/Cameras/RigModes/index" {
  43355. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43356. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43357. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43358. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43359. }
  43360. declare module "babylonjs/Cameras/index" {
  43361. export * from "babylonjs/Cameras/Inputs/index";
  43362. export * from "babylonjs/Cameras/cameraInputsManager";
  43363. export * from "babylonjs/Cameras/camera";
  43364. export * from "babylonjs/Cameras/targetCamera";
  43365. export * from "babylonjs/Cameras/freeCamera";
  43366. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43367. export * from "babylonjs/Cameras/touchCamera";
  43368. export * from "babylonjs/Cameras/arcRotateCamera";
  43369. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43370. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43371. export * from "babylonjs/Cameras/flyCamera";
  43372. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43373. export * from "babylonjs/Cameras/followCamera";
  43374. export * from "babylonjs/Cameras/gamepadCamera";
  43375. export * from "babylonjs/Cameras/Stereoscopic/index";
  43376. export * from "babylonjs/Cameras/universalCamera";
  43377. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43378. export * from "babylonjs/Cameras/VR/index";
  43379. export * from "babylonjs/Cameras/XR/index";
  43380. export * from "babylonjs/Cameras/RigModes/index";
  43381. }
  43382. declare module "babylonjs/Collisions/index" {
  43383. export * from "babylonjs/Collisions/collider";
  43384. export * from "babylonjs/Collisions/collisionCoordinator";
  43385. export * from "babylonjs/Collisions/pickingInfo";
  43386. export * from "babylonjs/Collisions/intersectionInfo";
  43387. export * from "babylonjs/Collisions/meshCollisionData";
  43388. }
  43389. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43390. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43391. import { Vector3 } from "babylonjs/Maths/math.vector";
  43392. import { Ray } from "babylonjs/Culling/ray";
  43393. import { Plane } from "babylonjs/Maths/math.plane";
  43394. /**
  43395. * Contains an array of blocks representing the octree
  43396. */
  43397. export interface IOctreeContainer<T> {
  43398. /**
  43399. * Blocks within the octree
  43400. */
  43401. blocks: Array<OctreeBlock<T>>;
  43402. }
  43403. /**
  43404. * Class used to store a cell in an octree
  43405. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43406. */
  43407. export class OctreeBlock<T> {
  43408. /**
  43409. * Gets the content of the current block
  43410. */
  43411. entries: T[];
  43412. /**
  43413. * Gets the list of block children
  43414. */
  43415. blocks: Array<OctreeBlock<T>>;
  43416. private _depth;
  43417. private _maxDepth;
  43418. private _capacity;
  43419. private _minPoint;
  43420. private _maxPoint;
  43421. private _boundingVectors;
  43422. private _creationFunc;
  43423. /**
  43424. * Creates a new block
  43425. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43426. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43427. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43428. * @param depth defines the current depth of this block in the octree
  43429. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43430. * @param creationFunc defines a callback to call when an element is added to the block
  43431. */
  43432. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43433. /**
  43434. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43435. */
  43436. readonly capacity: number;
  43437. /**
  43438. * Gets the minimum vector (in world space) of the block's bounding box
  43439. */
  43440. readonly minPoint: Vector3;
  43441. /**
  43442. * Gets the maximum vector (in world space) of the block's bounding box
  43443. */
  43444. readonly maxPoint: Vector3;
  43445. /**
  43446. * Add a new element to this block
  43447. * @param entry defines the element to add
  43448. */
  43449. addEntry(entry: T): void;
  43450. /**
  43451. * Remove an element from this block
  43452. * @param entry defines the element to remove
  43453. */
  43454. removeEntry(entry: T): void;
  43455. /**
  43456. * Add an array of elements to this block
  43457. * @param entries defines the array of elements to add
  43458. */
  43459. addEntries(entries: T[]): void;
  43460. /**
  43461. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43462. * @param frustumPlanes defines the frustum planes to test
  43463. * @param selection defines the array to store current content if selection is positive
  43464. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43465. */
  43466. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43467. /**
  43468. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43469. * @param sphereCenter defines the bounding sphere center
  43470. * @param sphereRadius defines the bounding sphere radius
  43471. * @param selection defines the array to store current content if selection is positive
  43472. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43473. */
  43474. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43475. /**
  43476. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43477. * @param ray defines the ray to test with
  43478. * @param selection defines the array to store current content if selection is positive
  43479. */
  43480. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43481. /**
  43482. * Subdivide the content into child blocks (this block will then be empty)
  43483. */
  43484. createInnerBlocks(): void;
  43485. /**
  43486. * @hidden
  43487. */
  43488. 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;
  43489. }
  43490. }
  43491. declare module "babylonjs/Culling/Octrees/octree" {
  43492. import { SmartArray } from "babylonjs/Misc/smartArray";
  43493. import { Vector3 } from "babylonjs/Maths/math.vector";
  43494. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43496. import { Ray } from "babylonjs/Culling/ray";
  43497. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43498. import { Plane } from "babylonjs/Maths/math.plane";
  43499. /**
  43500. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43501. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43502. */
  43503. export class Octree<T> {
  43504. /** 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.) */
  43505. maxDepth: number;
  43506. /**
  43507. * Blocks within the octree containing objects
  43508. */
  43509. blocks: Array<OctreeBlock<T>>;
  43510. /**
  43511. * Content stored in the octree
  43512. */
  43513. dynamicContent: T[];
  43514. private _maxBlockCapacity;
  43515. private _selectionContent;
  43516. private _creationFunc;
  43517. /**
  43518. * Creates a octree
  43519. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43520. * @param creationFunc function to be used to instatiate the octree
  43521. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43522. * @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.)
  43523. */
  43524. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43525. /** 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.) */
  43526. maxDepth?: number);
  43527. /**
  43528. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43529. * @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);
  43530. * @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);
  43531. * @param entries meshes to be added to the octree blocks
  43532. */
  43533. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43534. /**
  43535. * Adds a mesh to the octree
  43536. * @param entry Mesh to add to the octree
  43537. */
  43538. addMesh(entry: T): void;
  43539. /**
  43540. * Remove an element from the octree
  43541. * @param entry defines the element to remove
  43542. */
  43543. removeMesh(entry: T): void;
  43544. /**
  43545. * Selects an array of meshes within the frustum
  43546. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43547. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43548. * @returns array of meshes within the frustum
  43549. */
  43550. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43551. /**
  43552. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43553. * @param sphereCenter defines the bounding sphere center
  43554. * @param sphereRadius defines the bounding sphere radius
  43555. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43556. * @returns an array of objects that intersect the sphere
  43557. */
  43558. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43559. /**
  43560. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43561. * @param ray defines the ray to test with
  43562. * @returns array of intersected objects
  43563. */
  43564. intersectsRay(ray: Ray): SmartArray<T>;
  43565. /**
  43566. * Adds a mesh into the octree block if it intersects the block
  43567. */
  43568. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43569. /**
  43570. * Adds a submesh into the octree block if it intersects the block
  43571. */
  43572. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43573. }
  43574. }
  43575. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43576. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43577. import { Scene } from "babylonjs/scene";
  43578. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43580. import { Ray } from "babylonjs/Culling/ray";
  43581. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43582. import { Collider } from "babylonjs/Collisions/collider";
  43583. module "babylonjs/scene" {
  43584. interface Scene {
  43585. /**
  43586. * @hidden
  43587. * Backing Filed
  43588. */
  43589. _selectionOctree: Octree<AbstractMesh>;
  43590. /**
  43591. * Gets the octree used to boost mesh selection (picking)
  43592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43593. */
  43594. selectionOctree: Octree<AbstractMesh>;
  43595. /**
  43596. * Creates or updates the octree used to boost selection (picking)
  43597. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43598. * @param maxCapacity defines the maximum capacity per leaf
  43599. * @param maxDepth defines the maximum depth of the octree
  43600. * @returns an octree of AbstractMesh
  43601. */
  43602. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43603. }
  43604. }
  43605. module "babylonjs/Meshes/abstractMesh" {
  43606. interface AbstractMesh {
  43607. /**
  43608. * @hidden
  43609. * Backing Field
  43610. */
  43611. _submeshesOctree: Octree<SubMesh>;
  43612. /**
  43613. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43614. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43615. * @param maxCapacity defines the maximum size of each block (64 by default)
  43616. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43617. * @returns the new octree
  43618. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43620. */
  43621. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43622. }
  43623. }
  43624. /**
  43625. * Defines the octree scene component responsible to manage any octrees
  43626. * in a given scene.
  43627. */
  43628. export class OctreeSceneComponent {
  43629. /**
  43630. * The component name help to identify the component in the list of scene components.
  43631. */
  43632. readonly name: string;
  43633. /**
  43634. * The scene the component belongs to.
  43635. */
  43636. scene: Scene;
  43637. /**
  43638. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43639. */
  43640. readonly checksIsEnabled: boolean;
  43641. /**
  43642. * Creates a new instance of the component for the given scene
  43643. * @param scene Defines the scene to register the component in
  43644. */
  43645. constructor(scene: Scene);
  43646. /**
  43647. * Registers the component in a given scene
  43648. */
  43649. register(): void;
  43650. /**
  43651. * Return the list of active meshes
  43652. * @returns the list of active meshes
  43653. */
  43654. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43655. /**
  43656. * Return the list of active sub meshes
  43657. * @param mesh The mesh to get the candidates sub meshes from
  43658. * @returns the list of active sub meshes
  43659. */
  43660. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43661. private _tempRay;
  43662. /**
  43663. * Return the list of sub meshes intersecting with a given local ray
  43664. * @param mesh defines the mesh to find the submesh for
  43665. * @param localRay defines the ray in local space
  43666. * @returns the list of intersecting sub meshes
  43667. */
  43668. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43669. /**
  43670. * Return the list of sub meshes colliding with a collider
  43671. * @param mesh defines the mesh to find the submesh for
  43672. * @param collider defines the collider to evaluate the collision against
  43673. * @returns the list of colliding sub meshes
  43674. */
  43675. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43676. /**
  43677. * Rebuilds the elements related to this component in case of
  43678. * context lost for instance.
  43679. */
  43680. rebuild(): void;
  43681. /**
  43682. * Disposes the component and the associated ressources.
  43683. */
  43684. dispose(): void;
  43685. }
  43686. }
  43687. declare module "babylonjs/Culling/Octrees/index" {
  43688. export * from "babylonjs/Culling/Octrees/octree";
  43689. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43690. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43691. }
  43692. declare module "babylonjs/Culling/index" {
  43693. export * from "babylonjs/Culling/boundingBox";
  43694. export * from "babylonjs/Culling/boundingInfo";
  43695. export * from "babylonjs/Culling/boundingSphere";
  43696. export * from "babylonjs/Culling/Octrees/index";
  43697. export * from "babylonjs/Culling/ray";
  43698. }
  43699. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43700. import { IDisposable, Scene } from "babylonjs/scene";
  43701. import { Nullable } from "babylonjs/types";
  43702. import { Observable } from "babylonjs/Misc/observable";
  43703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43704. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43705. import { Camera } from "babylonjs/Cameras/camera";
  43706. /**
  43707. * Renders a layer on top of an existing scene
  43708. */
  43709. export class UtilityLayerRenderer implements IDisposable {
  43710. /** the original scene that will be rendered on top of */
  43711. originalScene: Scene;
  43712. private _pointerCaptures;
  43713. private _lastPointerEvents;
  43714. private static _DefaultUtilityLayer;
  43715. private static _DefaultKeepDepthUtilityLayer;
  43716. private _sharedGizmoLight;
  43717. private _renderCamera;
  43718. /**
  43719. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43720. * @returns the camera that is used when rendering the utility layer
  43721. */
  43722. getRenderCamera(): Nullable<Camera>;
  43723. /**
  43724. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43725. * @param cam the camera that should be used when rendering the utility layer
  43726. */
  43727. setRenderCamera(cam: Nullable<Camera>): void;
  43728. /**
  43729. * @hidden
  43730. * Light which used by gizmos to get light shading
  43731. */
  43732. _getSharedGizmoLight(): HemisphericLight;
  43733. /**
  43734. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43735. */
  43736. pickUtilitySceneFirst: boolean;
  43737. /**
  43738. * 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)
  43739. */
  43740. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43741. /**
  43742. * 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)
  43743. */
  43744. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43745. /**
  43746. * The scene that is rendered on top of the original scene
  43747. */
  43748. utilityLayerScene: Scene;
  43749. /**
  43750. * If the utility layer should automatically be rendered on top of existing scene
  43751. */
  43752. shouldRender: boolean;
  43753. /**
  43754. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43755. */
  43756. onlyCheckPointerDownEvents: boolean;
  43757. /**
  43758. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43759. */
  43760. processAllEvents: boolean;
  43761. /**
  43762. * Observable raised when the pointer move from the utility layer scene to the main scene
  43763. */
  43764. onPointerOutObservable: Observable<number>;
  43765. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43766. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43767. private _afterRenderObserver;
  43768. private _sceneDisposeObserver;
  43769. private _originalPointerObserver;
  43770. /**
  43771. * Instantiates a UtilityLayerRenderer
  43772. * @param originalScene the original scene that will be rendered on top of
  43773. * @param handleEvents boolean indicating if the utility layer should handle events
  43774. */
  43775. constructor(
  43776. /** the original scene that will be rendered on top of */
  43777. originalScene: Scene, handleEvents?: boolean);
  43778. private _notifyObservers;
  43779. /**
  43780. * Renders the utility layers scene on top of the original scene
  43781. */
  43782. render(): void;
  43783. /**
  43784. * Disposes of the renderer
  43785. */
  43786. dispose(): void;
  43787. private _updateCamera;
  43788. }
  43789. }
  43790. declare module "babylonjs/Gizmos/gizmo" {
  43791. import { Nullable } from "babylonjs/types";
  43792. import { IDisposable } from "babylonjs/scene";
  43793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43794. import { Mesh } from "babylonjs/Meshes/mesh";
  43795. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43796. /**
  43797. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43798. */
  43799. export class Gizmo implements IDisposable {
  43800. /** The utility layer the gizmo will be added to */
  43801. gizmoLayer: UtilityLayerRenderer;
  43802. /**
  43803. * The root mesh of the gizmo
  43804. */
  43805. _rootMesh: Mesh;
  43806. private _attachedMesh;
  43807. /**
  43808. * Ratio for the scale of the gizmo (Default: 1)
  43809. */
  43810. scaleRatio: number;
  43811. /**
  43812. * If a custom mesh has been set (Default: false)
  43813. */
  43814. protected _customMeshSet: boolean;
  43815. /**
  43816. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43817. * * When set, interactions will be enabled
  43818. */
  43819. attachedMesh: Nullable<AbstractMesh>;
  43820. /**
  43821. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43822. * @param mesh The mesh to replace the default mesh of the gizmo
  43823. */
  43824. setCustomMesh(mesh: Mesh): void;
  43825. /**
  43826. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43827. */
  43828. updateGizmoRotationToMatchAttachedMesh: boolean;
  43829. /**
  43830. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43831. */
  43832. updateGizmoPositionToMatchAttachedMesh: boolean;
  43833. /**
  43834. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43835. */
  43836. updateScale: boolean;
  43837. protected _interactionsEnabled: boolean;
  43838. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43839. private _beforeRenderObserver;
  43840. private _tempVector;
  43841. /**
  43842. * Creates a gizmo
  43843. * @param gizmoLayer The utility layer the gizmo will be added to
  43844. */
  43845. constructor(
  43846. /** The utility layer the gizmo will be added to */
  43847. gizmoLayer?: UtilityLayerRenderer);
  43848. /**
  43849. * Updates the gizmo to match the attached mesh's position/rotation
  43850. */
  43851. protected _update(): void;
  43852. /**
  43853. * Disposes of the gizmo
  43854. */
  43855. dispose(): void;
  43856. }
  43857. }
  43858. declare module "babylonjs/Gizmos/planeDragGizmo" {
  43859. import { Observable } from "babylonjs/Misc/observable";
  43860. import { Nullable } from "babylonjs/types";
  43861. import { Vector3 } from "babylonjs/Maths/math.vector";
  43862. import { Color3 } from "babylonjs/Maths/math.color";
  43863. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43865. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43866. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43867. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43868. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43869. import { Scene } from "babylonjs/scene";
  43870. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43871. /**
  43872. * Single plane drag gizmo
  43873. */
  43874. export class PlaneDragGizmo extends Gizmo {
  43875. /**
  43876. * Drag behavior responsible for the gizmos dragging interactions
  43877. */
  43878. dragBehavior: PointerDragBehavior;
  43879. private _pointerObserver;
  43880. /**
  43881. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43882. */
  43883. snapDistance: number;
  43884. /**
  43885. * Event that fires each time the gizmo snaps to a new location.
  43886. * * snapDistance is the the change in distance
  43887. */
  43888. onSnapObservable: Observable<{
  43889. snapDistance: number;
  43890. }>;
  43891. private _plane;
  43892. private _coloredMaterial;
  43893. private _hoverMaterial;
  43894. private _isEnabled;
  43895. private _parent;
  43896. /** @hidden */
  43897. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43898. /** @hidden */
  43899. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43900. /**
  43901. * Creates a PlaneDragGizmo
  43902. * @param gizmoLayer The utility layer the gizmo will be added to
  43903. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43904. * @param color The color of the gizmo
  43905. */
  43906. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43907. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43908. /**
  43909. * If the gizmo is enabled
  43910. */
  43911. isEnabled: boolean;
  43912. /**
  43913. * Disposes of the gizmo
  43914. */
  43915. dispose(): void;
  43916. }
  43917. }
  43918. declare module "babylonjs/Gizmos/positionGizmo" {
  43919. import { Observable } from "babylonjs/Misc/observable";
  43920. import { Nullable } from "babylonjs/types";
  43921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43922. import { Mesh } from "babylonjs/Meshes/mesh";
  43923. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43924. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43925. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  43926. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43927. /**
  43928. * Gizmo that enables dragging a mesh along 3 axis
  43929. */
  43930. export class PositionGizmo extends Gizmo {
  43931. /**
  43932. * Internal gizmo used for interactions on the x axis
  43933. */
  43934. xGizmo: AxisDragGizmo;
  43935. /**
  43936. * Internal gizmo used for interactions on the y axis
  43937. */
  43938. yGizmo: AxisDragGizmo;
  43939. /**
  43940. * Internal gizmo used for interactions on the z axis
  43941. */
  43942. zGizmo: AxisDragGizmo;
  43943. /**
  43944. * Internal gizmo used for interactions on the yz plane
  43945. */
  43946. xPlaneGizmo: PlaneDragGizmo;
  43947. /**
  43948. * Internal gizmo used for interactions on the xz plane
  43949. */
  43950. yPlaneGizmo: PlaneDragGizmo;
  43951. /**
  43952. * Internal gizmo used for interactions on the xy plane
  43953. */
  43954. zPlaneGizmo: PlaneDragGizmo;
  43955. /**
  43956. * private variables
  43957. */
  43958. private _meshAttached;
  43959. private _updateGizmoRotationToMatchAttachedMesh;
  43960. private _snapDistance;
  43961. private _scaleRatio;
  43962. /** Fires an event when any of it's sub gizmos are dragged */
  43963. onDragStartObservable: Observable<unknown>;
  43964. /** Fires an event when any of it's sub gizmos are released from dragging */
  43965. onDragEndObservable: Observable<unknown>;
  43966. /**
  43967. * If set to true, planar drag is enabled
  43968. */
  43969. private _planarGizmoEnabled;
  43970. attachedMesh: Nullable<AbstractMesh>;
  43971. /**
  43972. * Creates a PositionGizmo
  43973. * @param gizmoLayer The utility layer the gizmo will be added to
  43974. */
  43975. constructor(gizmoLayer?: UtilityLayerRenderer);
  43976. /**
  43977. * If the planar drag gizmo is enabled
  43978. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43979. */
  43980. planarGizmoEnabled: boolean;
  43981. updateGizmoRotationToMatchAttachedMesh: boolean;
  43982. /**
  43983. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43984. */
  43985. snapDistance: number;
  43986. /**
  43987. * Ratio for the scale of the gizmo (Default: 1)
  43988. */
  43989. scaleRatio: number;
  43990. /**
  43991. * Disposes of the gizmo
  43992. */
  43993. dispose(): void;
  43994. /**
  43995. * CustomMeshes are not supported by this gizmo
  43996. * @param mesh The mesh to replace the default mesh of the gizmo
  43997. */
  43998. setCustomMesh(mesh: Mesh): void;
  43999. }
  44000. }
  44001. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44002. import { Observable } from "babylonjs/Misc/observable";
  44003. import { Nullable } from "babylonjs/types";
  44004. import { Vector3 } from "babylonjs/Maths/math.vector";
  44005. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44007. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44008. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44009. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44010. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44011. import { Scene } from "babylonjs/scene";
  44012. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44013. import { Color3 } from "babylonjs/Maths/math.color";
  44014. /**
  44015. * Single axis drag gizmo
  44016. */
  44017. export class AxisDragGizmo extends Gizmo {
  44018. /**
  44019. * Drag behavior responsible for the gizmos dragging interactions
  44020. */
  44021. dragBehavior: PointerDragBehavior;
  44022. private _pointerObserver;
  44023. /**
  44024. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44025. */
  44026. snapDistance: number;
  44027. /**
  44028. * Event that fires each time the gizmo snaps to a new location.
  44029. * * snapDistance is the the change in distance
  44030. */
  44031. onSnapObservable: Observable<{
  44032. snapDistance: number;
  44033. }>;
  44034. private _isEnabled;
  44035. private _parent;
  44036. private _arrow;
  44037. private _coloredMaterial;
  44038. private _hoverMaterial;
  44039. /** @hidden */
  44040. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44041. /** @hidden */
  44042. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44043. /**
  44044. * Creates an AxisDragGizmo
  44045. * @param gizmoLayer The utility layer the gizmo will be added to
  44046. * @param dragAxis The axis which the gizmo will be able to drag on
  44047. * @param color The color of the gizmo
  44048. */
  44049. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44050. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44051. /**
  44052. * If the gizmo is enabled
  44053. */
  44054. isEnabled: boolean;
  44055. /**
  44056. * Disposes of the gizmo
  44057. */
  44058. dispose(): void;
  44059. }
  44060. }
  44061. declare module "babylonjs/Debug/axesViewer" {
  44062. import { Vector3 } from "babylonjs/Maths/math.vector";
  44063. import { Nullable } from "babylonjs/types";
  44064. import { Scene } from "babylonjs/scene";
  44065. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44066. /**
  44067. * The Axes viewer will show 3 axes in a specific point in space
  44068. */
  44069. export class AxesViewer {
  44070. private _xAxis;
  44071. private _yAxis;
  44072. private _zAxis;
  44073. private _scaleLinesFactor;
  44074. private _instanced;
  44075. /**
  44076. * Gets the hosting scene
  44077. */
  44078. scene: Scene;
  44079. /**
  44080. * Gets or sets a number used to scale line length
  44081. */
  44082. scaleLines: number;
  44083. /** Gets the node hierarchy used to render x-axis */
  44084. readonly xAxis: TransformNode;
  44085. /** Gets the node hierarchy used to render y-axis */
  44086. readonly yAxis: TransformNode;
  44087. /** Gets the node hierarchy used to render z-axis */
  44088. readonly zAxis: TransformNode;
  44089. /**
  44090. * Creates a new AxesViewer
  44091. * @param scene defines the hosting scene
  44092. * @param scaleLines defines a number used to scale line length (1 by default)
  44093. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44094. * @param xAxis defines the node hierarchy used to render the x-axis
  44095. * @param yAxis defines the node hierarchy used to render the y-axis
  44096. * @param zAxis defines the node hierarchy used to render the z-axis
  44097. */
  44098. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44099. /**
  44100. * Force the viewer to update
  44101. * @param position defines the position of the viewer
  44102. * @param xaxis defines the x axis of the viewer
  44103. * @param yaxis defines the y axis of the viewer
  44104. * @param zaxis defines the z axis of the viewer
  44105. */
  44106. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44107. /**
  44108. * Creates an instance of this axes viewer.
  44109. * @returns a new axes viewer with instanced meshes
  44110. */
  44111. createInstance(): AxesViewer;
  44112. /** Releases resources */
  44113. dispose(): void;
  44114. private static _SetRenderingGroupId;
  44115. }
  44116. }
  44117. declare module "babylonjs/Debug/boneAxesViewer" {
  44118. import { Nullable } from "babylonjs/types";
  44119. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44120. import { Vector3 } from "babylonjs/Maths/math.vector";
  44121. import { Mesh } from "babylonjs/Meshes/mesh";
  44122. import { Bone } from "babylonjs/Bones/bone";
  44123. import { Scene } from "babylonjs/scene";
  44124. /**
  44125. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44126. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44127. */
  44128. export class BoneAxesViewer extends AxesViewer {
  44129. /**
  44130. * Gets or sets the target mesh where to display the axes viewer
  44131. */
  44132. mesh: Nullable<Mesh>;
  44133. /**
  44134. * Gets or sets the target bone where to display the axes viewer
  44135. */
  44136. bone: Nullable<Bone>;
  44137. /** Gets current position */
  44138. pos: Vector3;
  44139. /** Gets direction of X axis */
  44140. xaxis: Vector3;
  44141. /** Gets direction of Y axis */
  44142. yaxis: Vector3;
  44143. /** Gets direction of Z axis */
  44144. zaxis: Vector3;
  44145. /**
  44146. * Creates a new BoneAxesViewer
  44147. * @param scene defines the hosting scene
  44148. * @param bone defines the target bone
  44149. * @param mesh defines the target mesh
  44150. * @param scaleLines defines a scaling factor for line length (1 by default)
  44151. */
  44152. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44153. /**
  44154. * Force the viewer to update
  44155. */
  44156. update(): void;
  44157. /** Releases resources */
  44158. dispose(): void;
  44159. }
  44160. }
  44161. declare module "babylonjs/Debug/debugLayer" {
  44162. import { Scene } from "babylonjs/scene";
  44163. /**
  44164. * Interface used to define scene explorer extensibility option
  44165. */
  44166. export interface IExplorerExtensibilityOption {
  44167. /**
  44168. * Define the option label
  44169. */
  44170. label: string;
  44171. /**
  44172. * Defines the action to execute on click
  44173. */
  44174. action: (entity: any) => void;
  44175. }
  44176. /**
  44177. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44178. */
  44179. export interface IExplorerExtensibilityGroup {
  44180. /**
  44181. * Defines a predicate to test if a given type mut be extended
  44182. */
  44183. predicate: (entity: any) => boolean;
  44184. /**
  44185. * Gets the list of options added to a type
  44186. */
  44187. entries: IExplorerExtensibilityOption[];
  44188. }
  44189. /**
  44190. * Interface used to define the options to use to create the Inspector
  44191. */
  44192. export interface IInspectorOptions {
  44193. /**
  44194. * Display in overlay mode (default: false)
  44195. */
  44196. overlay?: boolean;
  44197. /**
  44198. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44199. */
  44200. globalRoot?: HTMLElement;
  44201. /**
  44202. * Display the Scene explorer
  44203. */
  44204. showExplorer?: boolean;
  44205. /**
  44206. * Display the property inspector
  44207. */
  44208. showInspector?: boolean;
  44209. /**
  44210. * Display in embed mode (both panes on the right)
  44211. */
  44212. embedMode?: boolean;
  44213. /**
  44214. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44215. */
  44216. handleResize?: boolean;
  44217. /**
  44218. * Allow the panes to popup (default: true)
  44219. */
  44220. enablePopup?: boolean;
  44221. /**
  44222. * Allow the panes to be closed by users (default: true)
  44223. */
  44224. enableClose?: boolean;
  44225. /**
  44226. * Optional list of extensibility entries
  44227. */
  44228. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44229. /**
  44230. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44231. */
  44232. inspectorURL?: string;
  44233. }
  44234. module "babylonjs/scene" {
  44235. interface Scene {
  44236. /**
  44237. * @hidden
  44238. * Backing field
  44239. */
  44240. _debugLayer: DebugLayer;
  44241. /**
  44242. * Gets the debug layer (aka Inspector) associated with the scene
  44243. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44244. */
  44245. debugLayer: DebugLayer;
  44246. }
  44247. }
  44248. /**
  44249. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44250. * what is happening in your scene
  44251. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44252. */
  44253. export class DebugLayer {
  44254. /**
  44255. * Define the url to get the inspector script from.
  44256. * By default it uses the babylonjs CDN.
  44257. * @ignoreNaming
  44258. */
  44259. static InspectorURL: string;
  44260. private _scene;
  44261. private BJSINSPECTOR;
  44262. private _onPropertyChangedObservable?;
  44263. /**
  44264. * Observable triggered when a property is changed through the inspector.
  44265. */
  44266. readonly onPropertyChangedObservable: any;
  44267. /**
  44268. * Instantiates a new debug layer.
  44269. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44270. * what is happening in your scene
  44271. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44272. * @param scene Defines the scene to inspect
  44273. */
  44274. constructor(scene: Scene);
  44275. /** Creates the inspector window. */
  44276. private _createInspector;
  44277. /**
  44278. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44279. * @param entity defines the entity to select
  44280. * @param lineContainerTitle defines the specific block to highlight
  44281. */
  44282. select(entity: any, lineContainerTitle?: string): void;
  44283. /** Get the inspector from bundle or global */
  44284. private _getGlobalInspector;
  44285. /**
  44286. * Get if the inspector is visible or not.
  44287. * @returns true if visible otherwise, false
  44288. */
  44289. isVisible(): boolean;
  44290. /**
  44291. * Hide the inspector and close its window.
  44292. */
  44293. hide(): void;
  44294. /**
  44295. * Launch the debugLayer.
  44296. * @param config Define the configuration of the inspector
  44297. * @return a promise fulfilled when the debug layer is visible
  44298. */
  44299. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44300. }
  44301. }
  44302. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44303. import { Nullable } from "babylonjs/types";
  44304. import { Scene } from "babylonjs/scene";
  44305. import { Vector4 } from "babylonjs/Maths/math.vector";
  44306. import { Color4 } from "babylonjs/Maths/math.color";
  44307. import { Mesh } from "babylonjs/Meshes/mesh";
  44308. /**
  44309. * Class containing static functions to help procedurally build meshes
  44310. */
  44311. export class BoxBuilder {
  44312. /**
  44313. * Creates a box mesh
  44314. * * The parameter `size` sets the size (float) of each box side (default 1)
  44315. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44316. * * 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)
  44317. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44321. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44322. * @param name defines the name of the mesh
  44323. * @param options defines the options used to create the mesh
  44324. * @param scene defines the hosting scene
  44325. * @returns the box mesh
  44326. */
  44327. static CreateBox(name: string, options: {
  44328. size?: number;
  44329. width?: number;
  44330. height?: number;
  44331. depth?: number;
  44332. faceUV?: Vector4[];
  44333. faceColors?: Color4[];
  44334. sideOrientation?: number;
  44335. frontUVs?: Vector4;
  44336. backUVs?: Vector4;
  44337. wrap?: boolean;
  44338. topBaseAt?: number;
  44339. bottomBaseAt?: number;
  44340. updatable?: boolean;
  44341. }, scene?: Nullable<Scene>): Mesh;
  44342. }
  44343. }
  44344. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44345. import { Vector4 } from "babylonjs/Maths/math.vector";
  44346. import { Mesh } from "babylonjs/Meshes/mesh";
  44347. /**
  44348. * Class containing static functions to help procedurally build meshes
  44349. */
  44350. export class SphereBuilder {
  44351. /**
  44352. * Creates a sphere mesh
  44353. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44354. * * 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`)
  44355. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44356. * * 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
  44357. * * 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)
  44358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44361. * @param name defines the name of the mesh
  44362. * @param options defines the options used to create the mesh
  44363. * @param scene defines the hosting scene
  44364. * @returns the sphere mesh
  44365. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44366. */
  44367. static CreateSphere(name: string, options: {
  44368. segments?: number;
  44369. diameter?: number;
  44370. diameterX?: number;
  44371. diameterY?: number;
  44372. diameterZ?: number;
  44373. arc?: number;
  44374. slice?: number;
  44375. sideOrientation?: number;
  44376. frontUVs?: Vector4;
  44377. backUVs?: Vector4;
  44378. updatable?: boolean;
  44379. }, scene: any): Mesh;
  44380. }
  44381. }
  44382. declare module "babylonjs/Debug/physicsViewer" {
  44383. import { Nullable } from "babylonjs/types";
  44384. import { Scene } from "babylonjs/scene";
  44385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44386. import { Mesh } from "babylonjs/Meshes/mesh";
  44387. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44388. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44389. /**
  44390. * Used to show the physics impostor around the specific mesh
  44391. */
  44392. export class PhysicsViewer {
  44393. /** @hidden */
  44394. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44395. /** @hidden */
  44396. protected _meshes: Array<Nullable<AbstractMesh>>;
  44397. /** @hidden */
  44398. protected _scene: Nullable<Scene>;
  44399. /** @hidden */
  44400. protected _numMeshes: number;
  44401. /** @hidden */
  44402. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44403. private _renderFunction;
  44404. private _utilityLayer;
  44405. private _debugBoxMesh;
  44406. private _debugSphereMesh;
  44407. private _debugCylinderMesh;
  44408. private _debugMaterial;
  44409. private _debugMeshMeshes;
  44410. /**
  44411. * Creates a new PhysicsViewer
  44412. * @param scene defines the hosting scene
  44413. */
  44414. constructor(scene: Scene);
  44415. /** @hidden */
  44416. protected _updateDebugMeshes(): void;
  44417. /**
  44418. * Renders a specified physic impostor
  44419. * @param impostor defines the impostor to render
  44420. * @param targetMesh defines the mesh represented by the impostor
  44421. * @returns the new debug mesh used to render the impostor
  44422. */
  44423. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44424. /**
  44425. * Hides a specified physic impostor
  44426. * @param impostor defines the impostor to hide
  44427. */
  44428. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44429. private _getDebugMaterial;
  44430. private _getDebugBoxMesh;
  44431. private _getDebugSphereMesh;
  44432. private _getDebugCylinderMesh;
  44433. private _getDebugMeshMesh;
  44434. private _getDebugMesh;
  44435. /** Releases all resources */
  44436. dispose(): void;
  44437. }
  44438. }
  44439. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44440. import { Vector3 } from "babylonjs/Maths/math.vector";
  44441. import { Color4 } from "babylonjs/Maths/math.color";
  44442. import { Nullable } from "babylonjs/types";
  44443. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44444. import { Scene } from "babylonjs/scene";
  44445. /**
  44446. * Class containing static functions to help procedurally build meshes
  44447. */
  44448. export class LinesBuilder {
  44449. /**
  44450. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44451. * * 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
  44452. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44453. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44454. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44455. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44456. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44457. * * 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
  44458. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44461. * @param name defines the name of the new line system
  44462. * @param options defines the options used to create the line system
  44463. * @param scene defines the hosting scene
  44464. * @returns a new line system mesh
  44465. */
  44466. static CreateLineSystem(name: string, options: {
  44467. lines: Vector3[][];
  44468. updatable?: boolean;
  44469. instance?: Nullable<LinesMesh>;
  44470. colors?: Nullable<Color4[][]>;
  44471. useVertexAlpha?: boolean;
  44472. }, scene: Nullable<Scene>): LinesMesh;
  44473. /**
  44474. * Creates a line mesh
  44475. * 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
  44476. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44477. * * The parameter `points` is an array successive Vector3
  44478. * * 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
  44479. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44480. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44481. * * When updating an instance, remember that only point positions can change, not the number of points
  44482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44483. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44484. * @param name defines the name of the new line system
  44485. * @param options defines the options used to create the line system
  44486. * @param scene defines the hosting scene
  44487. * @returns a new line mesh
  44488. */
  44489. static CreateLines(name: string, options: {
  44490. points: Vector3[];
  44491. updatable?: boolean;
  44492. instance?: Nullable<LinesMesh>;
  44493. colors?: Color4[];
  44494. useVertexAlpha?: boolean;
  44495. }, scene?: Nullable<Scene>): LinesMesh;
  44496. /**
  44497. * Creates a dashed line mesh
  44498. * * 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
  44499. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44500. * * The parameter `points` is an array successive Vector3
  44501. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44502. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44503. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44504. * * 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
  44505. * * When updating an instance, remember that only point positions can change, not the number of points
  44506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44507. * @param name defines the name of the mesh
  44508. * @param options defines the options used to create the mesh
  44509. * @param scene defines the hosting scene
  44510. * @returns the dashed line mesh
  44511. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44512. */
  44513. static CreateDashedLines(name: string, options: {
  44514. points: Vector3[];
  44515. dashSize?: number;
  44516. gapSize?: number;
  44517. dashNb?: number;
  44518. updatable?: boolean;
  44519. instance?: LinesMesh;
  44520. }, scene?: Nullable<Scene>): LinesMesh;
  44521. }
  44522. }
  44523. declare module "babylonjs/Debug/rayHelper" {
  44524. import { Nullable } from "babylonjs/types";
  44525. import { Ray } from "babylonjs/Culling/ray";
  44526. import { Vector3 } from "babylonjs/Maths/math.vector";
  44527. import { Color3 } from "babylonjs/Maths/math.color";
  44528. import { Scene } from "babylonjs/scene";
  44529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44530. import "babylonjs/Meshes/Builders/linesBuilder";
  44531. /**
  44532. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44533. * in order to better appreciate the issue one might have.
  44534. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44535. */
  44536. export class RayHelper {
  44537. /**
  44538. * Defines the ray we are currently tryin to visualize.
  44539. */
  44540. ray: Nullable<Ray>;
  44541. private _renderPoints;
  44542. private _renderLine;
  44543. private _renderFunction;
  44544. private _scene;
  44545. private _updateToMeshFunction;
  44546. private _attachedToMesh;
  44547. private _meshSpaceDirection;
  44548. private _meshSpaceOrigin;
  44549. /**
  44550. * Helper function to create a colored helper in a scene in one line.
  44551. * @param ray Defines the ray we are currently tryin to visualize
  44552. * @param scene Defines the scene the ray is used in
  44553. * @param color Defines the color we want to see the ray in
  44554. * @returns The newly created ray helper.
  44555. */
  44556. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44557. /**
  44558. * Instantiate a new ray helper.
  44559. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44560. * in order to better appreciate the issue one might have.
  44561. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44562. * @param ray Defines the ray we are currently tryin to visualize
  44563. */
  44564. constructor(ray: Ray);
  44565. /**
  44566. * Shows the ray we are willing to debug.
  44567. * @param scene Defines the scene the ray needs to be rendered in
  44568. * @param color Defines the color the ray needs to be rendered in
  44569. */
  44570. show(scene: Scene, color?: Color3): void;
  44571. /**
  44572. * Hides the ray we are debugging.
  44573. */
  44574. hide(): void;
  44575. private _render;
  44576. /**
  44577. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44578. * @param mesh Defines the mesh we want the helper attached to
  44579. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44580. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44581. * @param length Defines the length of the ray
  44582. */
  44583. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44584. /**
  44585. * Detach the ray helper from the mesh it has previously been attached to.
  44586. */
  44587. detachFromMesh(): void;
  44588. private _updateToMesh;
  44589. /**
  44590. * Dispose the helper and release its associated resources.
  44591. */
  44592. dispose(): void;
  44593. }
  44594. }
  44595. declare module "babylonjs/Debug/skeletonViewer" {
  44596. import { Color3 } from "babylonjs/Maths/math.color";
  44597. import { Scene } from "babylonjs/scene";
  44598. import { Nullable } from "babylonjs/types";
  44599. import { Skeleton } from "babylonjs/Bones/skeleton";
  44600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44601. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44602. /**
  44603. * Class used to render a debug view of a given skeleton
  44604. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44605. */
  44606. export class SkeletonViewer {
  44607. /** defines the skeleton to render */
  44608. skeleton: Skeleton;
  44609. /** defines the mesh attached to the skeleton */
  44610. mesh: AbstractMesh;
  44611. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44612. autoUpdateBonesMatrices: boolean;
  44613. /** defines the rendering group id to use with the viewer */
  44614. renderingGroupId: number;
  44615. /** Gets or sets the color used to render the skeleton */
  44616. color: Color3;
  44617. private _scene;
  44618. private _debugLines;
  44619. private _debugMesh;
  44620. private _isEnabled;
  44621. private _renderFunction;
  44622. private _utilityLayer;
  44623. /**
  44624. * Returns the mesh used to render the bones
  44625. */
  44626. readonly debugMesh: Nullable<LinesMesh>;
  44627. /**
  44628. * Creates a new SkeletonViewer
  44629. * @param skeleton defines the skeleton to render
  44630. * @param mesh defines the mesh attached to the skeleton
  44631. * @param scene defines the hosting scene
  44632. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44633. * @param renderingGroupId defines the rendering group id to use with the viewer
  44634. */
  44635. constructor(
  44636. /** defines the skeleton to render */
  44637. skeleton: Skeleton,
  44638. /** defines the mesh attached to the skeleton */
  44639. mesh: AbstractMesh, scene: Scene,
  44640. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44641. autoUpdateBonesMatrices?: boolean,
  44642. /** defines the rendering group id to use with the viewer */
  44643. renderingGroupId?: number);
  44644. /** Gets or sets a boolean indicating if the viewer is enabled */
  44645. isEnabled: boolean;
  44646. private _getBonePosition;
  44647. private _getLinesForBonesWithLength;
  44648. private _getLinesForBonesNoLength;
  44649. /** Update the viewer to sync with current skeleton state */
  44650. update(): void;
  44651. /** Release associated resources */
  44652. dispose(): void;
  44653. }
  44654. }
  44655. declare module "babylonjs/Debug/index" {
  44656. export * from "babylonjs/Debug/axesViewer";
  44657. export * from "babylonjs/Debug/boneAxesViewer";
  44658. export * from "babylonjs/Debug/debugLayer";
  44659. export * from "babylonjs/Debug/physicsViewer";
  44660. export * from "babylonjs/Debug/rayHelper";
  44661. export * from "babylonjs/Debug/skeletonViewer";
  44662. }
  44663. declare module "babylonjs/Engines/nullEngine" {
  44664. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44665. import { Scene } from "babylonjs/scene";
  44666. import { Engine } from "babylonjs/Engines/engine";
  44667. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44668. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44669. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44670. import { Effect } from "babylonjs/Materials/effect";
  44671. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44672. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44673. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  44674. /**
  44675. * Options to create the null engine
  44676. */
  44677. export class NullEngineOptions {
  44678. /**
  44679. * Render width (Default: 512)
  44680. */
  44681. renderWidth: number;
  44682. /**
  44683. * Render height (Default: 256)
  44684. */
  44685. renderHeight: number;
  44686. /**
  44687. * Texture size (Default: 512)
  44688. */
  44689. textureSize: number;
  44690. /**
  44691. * If delta time between frames should be constant
  44692. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44693. */
  44694. deterministicLockstep: boolean;
  44695. /**
  44696. * Maximum about of steps between frames (Default: 4)
  44697. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44698. */
  44699. lockstepMaxSteps: number;
  44700. }
  44701. /**
  44702. * The null engine class provides support for headless version of babylon.js.
  44703. * This can be used in server side scenario or for testing purposes
  44704. */
  44705. export class NullEngine extends Engine {
  44706. private _options;
  44707. /**
  44708. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44709. */
  44710. isDeterministicLockStep(): boolean;
  44711. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  44712. getLockstepMaxSteps(): number;
  44713. /**
  44714. * Sets hardware scaling, used to save performance if needed
  44715. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  44716. */
  44717. getHardwareScalingLevel(): number;
  44718. constructor(options?: NullEngineOptions);
  44719. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44720. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44721. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44722. getRenderWidth(useScreen?: boolean): number;
  44723. getRenderHeight(useScreen?: boolean): number;
  44724. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44725. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44726. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44727. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44728. bindSamplers(effect: Effect): void;
  44729. enableEffect(effect: Effect): void;
  44730. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44731. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44732. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44733. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44734. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44735. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44736. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44737. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44738. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44739. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44740. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44741. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44742. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44743. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44744. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44745. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44746. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44747. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44748. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44749. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44750. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44751. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44752. bindBuffers(vertexBuffers: {
  44753. [key: string]: VertexBuffer;
  44754. }, indexBuffer: DataBuffer, effect: Effect): void;
  44755. wipeCaches(bruteForce?: boolean): void;
  44756. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44757. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44758. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44759. /** @hidden */
  44760. _createTexture(): WebGLTexture;
  44761. /** @hidden */
  44762. _releaseTexture(texture: InternalTexture): void;
  44763. 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;
  44764. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44765. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44766. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44767. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44768. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44769. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44770. areAllEffectsReady(): boolean;
  44771. /**
  44772. * @hidden
  44773. * Get the current error code of the webGL context
  44774. * @returns the error code
  44775. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44776. */
  44777. getError(): number;
  44778. /** @hidden */
  44779. _getUnpackAlignement(): number;
  44780. /** @hidden */
  44781. _unpackFlipY(value: boolean): void;
  44782. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44783. /**
  44784. * Updates a dynamic vertex buffer.
  44785. * @param vertexBuffer the vertex buffer to update
  44786. * @param data the data used to update the vertex buffer
  44787. * @param byteOffset the byte offset of the data (optional)
  44788. * @param byteLength the byte length of the data (optional)
  44789. */
  44790. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44791. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44792. /** @hidden */
  44793. _bindTexture(channel: number, texture: InternalTexture): void;
  44794. /** @hidden */
  44795. _releaseBuffer(buffer: DataBuffer): boolean;
  44796. releaseEffects(): void;
  44797. displayLoadingUI(): void;
  44798. hideLoadingUI(): void;
  44799. /** @hidden */
  44800. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44801. /** @hidden */
  44802. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44803. /** @hidden */
  44804. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44805. /** @hidden */
  44806. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44807. }
  44808. }
  44809. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  44810. import { Nullable, int } from "babylonjs/types";
  44811. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  44812. /** @hidden */
  44813. export class _OcclusionDataStorage {
  44814. /** @hidden */
  44815. occlusionInternalRetryCounter: number;
  44816. /** @hidden */
  44817. isOcclusionQueryInProgress: boolean;
  44818. /** @hidden */
  44819. isOccluded: boolean;
  44820. /** @hidden */
  44821. occlusionRetryCount: number;
  44822. /** @hidden */
  44823. occlusionType: number;
  44824. /** @hidden */
  44825. occlusionQueryAlgorithmType: number;
  44826. }
  44827. module "babylonjs/Engines/engine" {
  44828. interface Engine {
  44829. /**
  44830. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44831. * @return the new query
  44832. */
  44833. createQuery(): WebGLQuery;
  44834. /**
  44835. * Delete and release a webGL query
  44836. * @param query defines the query to delete
  44837. * @return the current engine
  44838. */
  44839. deleteQuery(query: WebGLQuery): Engine;
  44840. /**
  44841. * Check if a given query has resolved and got its value
  44842. * @param query defines the query to check
  44843. * @returns true if the query got its value
  44844. */
  44845. isQueryResultAvailable(query: WebGLQuery): boolean;
  44846. /**
  44847. * Gets the value of a given query
  44848. * @param query defines the query to check
  44849. * @returns the value of the query
  44850. */
  44851. getQueryResult(query: WebGLQuery): number;
  44852. /**
  44853. * Initiates an occlusion query
  44854. * @param algorithmType defines the algorithm to use
  44855. * @param query defines the query to use
  44856. * @returns the current engine
  44857. * @see http://doc.babylonjs.com/features/occlusionquery
  44858. */
  44859. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44860. /**
  44861. * Ends an occlusion query
  44862. * @see http://doc.babylonjs.com/features/occlusionquery
  44863. * @param algorithmType defines the algorithm to use
  44864. * @returns the current engine
  44865. */
  44866. endOcclusionQuery(algorithmType: number): Engine;
  44867. /**
  44868. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44869. * Please note that only one query can be issued at a time
  44870. * @returns a time token used to track the time span
  44871. */
  44872. startTimeQuery(): Nullable<_TimeToken>;
  44873. /**
  44874. * Ends a time query
  44875. * @param token defines the token used to measure the time span
  44876. * @returns the time spent (in ns)
  44877. */
  44878. endTimeQuery(token: _TimeToken): int;
  44879. /** @hidden */
  44880. _currentNonTimestampToken: Nullable<_TimeToken>;
  44881. /** @hidden */
  44882. _createTimeQuery(): WebGLQuery;
  44883. /** @hidden */
  44884. _deleteTimeQuery(query: WebGLQuery): void;
  44885. /** @hidden */
  44886. _getGlAlgorithmType(algorithmType: number): number;
  44887. /** @hidden */
  44888. _getTimeQueryResult(query: WebGLQuery): any;
  44889. /** @hidden */
  44890. _getTimeQueryAvailability(query: WebGLQuery): any;
  44891. }
  44892. }
  44893. module "babylonjs/Meshes/abstractMesh" {
  44894. interface AbstractMesh {
  44895. /**
  44896. * Backing filed
  44897. * @hidden
  44898. */
  44899. __occlusionDataStorage: _OcclusionDataStorage;
  44900. /**
  44901. * Access property
  44902. * @hidden
  44903. */
  44904. _occlusionDataStorage: _OcclusionDataStorage;
  44905. /**
  44906. * 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.
  44907. * The default value is -1 which means don't break the query and wait till the result
  44908. * @see http://doc.babylonjs.com/features/occlusionquery
  44909. */
  44910. occlusionRetryCount: number;
  44911. /**
  44912. * 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:
  44913. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44914. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44915. * * 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.
  44916. * @see http://doc.babylonjs.com/features/occlusionquery
  44917. */
  44918. occlusionType: number;
  44919. /**
  44920. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44921. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44922. * * 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.
  44923. * @see http://doc.babylonjs.com/features/occlusionquery
  44924. */
  44925. occlusionQueryAlgorithmType: number;
  44926. /**
  44927. * 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
  44928. * @see http://doc.babylonjs.com/features/occlusionquery
  44929. */
  44930. isOccluded: boolean;
  44931. /**
  44932. * Flag to check the progress status of the query
  44933. * @see http://doc.babylonjs.com/features/occlusionquery
  44934. */
  44935. isOcclusionQueryInProgress: boolean;
  44936. }
  44937. }
  44938. }
  44939. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  44940. import { Nullable } from "babylonjs/types";
  44941. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44942. /** @hidden */
  44943. export var _forceTransformFeedbackToBundle: boolean;
  44944. module "babylonjs/Engines/engine" {
  44945. interface Engine {
  44946. /**
  44947. * Creates a webGL transform feedback object
  44948. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44949. * @returns the webGL transform feedback object
  44950. */
  44951. createTransformFeedback(): WebGLTransformFeedback;
  44952. /**
  44953. * Delete a webGL transform feedback object
  44954. * @param value defines the webGL transform feedback object to delete
  44955. */
  44956. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44957. /**
  44958. * Bind a webGL transform feedback object to the webgl context
  44959. * @param value defines the webGL transform feedback object to bind
  44960. */
  44961. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44962. /**
  44963. * Begins a transform feedback operation
  44964. * @param usePoints defines if points or triangles must be used
  44965. */
  44966. beginTransformFeedback(usePoints: boolean): void;
  44967. /**
  44968. * Ends a transform feedback operation
  44969. */
  44970. endTransformFeedback(): void;
  44971. /**
  44972. * Specify the varyings to use with transform feedback
  44973. * @param program defines the associated webGL program
  44974. * @param value defines the list of strings representing the varying names
  44975. */
  44976. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44977. /**
  44978. * Bind a webGL buffer for a transform feedback operation
  44979. * @param value defines the webGL buffer to bind
  44980. */
  44981. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44982. }
  44983. }
  44984. }
  44985. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  44986. import { Scene } from "babylonjs/scene";
  44987. import { Engine } from "babylonjs/Engines/engine";
  44988. import { Texture } from "babylonjs/Materials/Textures/texture";
  44989. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44990. import "babylonjs/Engines/Extensions/engine.multiRender";
  44991. /**
  44992. * Creation options of the multi render target texture.
  44993. */
  44994. export interface IMultiRenderTargetOptions {
  44995. /**
  44996. * Define if the texture needs to create mip maps after render.
  44997. */
  44998. generateMipMaps?: boolean;
  44999. /**
  45000. * Define the types of all the draw buffers we want to create
  45001. */
  45002. types?: number[];
  45003. /**
  45004. * Define the sampling modes of all the draw buffers we want to create
  45005. */
  45006. samplingModes?: number[];
  45007. /**
  45008. * Define if a depth buffer is required
  45009. */
  45010. generateDepthBuffer?: boolean;
  45011. /**
  45012. * Define if a stencil buffer is required
  45013. */
  45014. generateStencilBuffer?: boolean;
  45015. /**
  45016. * Define if a depth texture is required instead of a depth buffer
  45017. */
  45018. generateDepthTexture?: boolean;
  45019. /**
  45020. * Define the number of desired draw buffers
  45021. */
  45022. textureCount?: number;
  45023. /**
  45024. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45025. */
  45026. doNotChangeAspectRatio?: boolean;
  45027. /**
  45028. * Define the default type of the buffers we are creating
  45029. */
  45030. defaultType?: number;
  45031. }
  45032. /**
  45033. * A multi render target, like a render target provides the ability to render to a texture.
  45034. * Unlike the render target, it can render to several draw buffers in one draw.
  45035. * This is specially interesting in deferred rendering or for any effects requiring more than
  45036. * just one color from a single pass.
  45037. */
  45038. export class MultiRenderTarget extends RenderTargetTexture {
  45039. private _internalTextures;
  45040. private _textures;
  45041. private _multiRenderTargetOptions;
  45042. /**
  45043. * Get if draw buffers are currently supported by the used hardware and browser.
  45044. */
  45045. readonly isSupported: boolean;
  45046. /**
  45047. * Get the list of textures generated by the multi render target.
  45048. */
  45049. readonly textures: Texture[];
  45050. /**
  45051. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45052. */
  45053. readonly depthTexture: Texture;
  45054. /**
  45055. * Set the wrapping mode on U of all the textures we are rendering to.
  45056. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45057. */
  45058. wrapU: number;
  45059. /**
  45060. * Set the wrapping mode on V of all the textures we are rendering to.
  45061. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45062. */
  45063. wrapV: number;
  45064. /**
  45065. * Instantiate a new multi render target texture.
  45066. * A multi render target, like a render target provides the ability to render to a texture.
  45067. * Unlike the render target, it can render to several draw buffers in one draw.
  45068. * This is specially interesting in deferred rendering or for any effects requiring more than
  45069. * just one color from a single pass.
  45070. * @param name Define the name of the texture
  45071. * @param size Define the size of the buffers to render to
  45072. * @param count Define the number of target we are rendering into
  45073. * @param scene Define the scene the texture belongs to
  45074. * @param options Define the options used to create the multi render target
  45075. */
  45076. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45077. /** @hidden */
  45078. _rebuild(): void;
  45079. private _createInternalTextures;
  45080. private _createTextures;
  45081. /**
  45082. * Define the number of samples used if MSAA is enabled.
  45083. */
  45084. samples: number;
  45085. /**
  45086. * Resize all the textures in the multi render target.
  45087. * Be carrefull as it will recreate all the data in the new texture.
  45088. * @param size Define the new size
  45089. */
  45090. resize(size: any): void;
  45091. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45092. /**
  45093. * Dispose the render targets and their associated resources
  45094. */
  45095. dispose(): void;
  45096. /**
  45097. * Release all the underlying texture used as draw buffers.
  45098. */
  45099. releaseInternalTextures(): void;
  45100. }
  45101. }
  45102. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45103. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45104. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45105. import { Nullable } from "babylonjs/types";
  45106. module "babylonjs/Engines/engine" {
  45107. interface Engine {
  45108. /**
  45109. * Unbind a list of render target textures from the webGL context
  45110. * This is used only when drawBuffer extension or webGL2 are active
  45111. * @param textures defines the render target textures to unbind
  45112. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45113. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45114. */
  45115. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45116. /**
  45117. * Create a multi render target texture
  45118. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45119. * @param size defines the size of the texture
  45120. * @param options defines the creation options
  45121. * @returns the cube texture as an InternalTexture
  45122. */
  45123. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45124. /**
  45125. * Update the sample count for a given multiple render target texture
  45126. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45127. * @param textures defines the textures to update
  45128. * @param samples defines the sample count to set
  45129. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45130. */
  45131. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45132. }
  45133. }
  45134. }
  45135. declare module "babylonjs/Engines/Extensions/index" {
  45136. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45137. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45138. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45139. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45140. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45141. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45142. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45143. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45144. }
  45145. declare module "babylonjs/Engines/index" {
  45146. export * from "babylonjs/Engines/constants";
  45147. export * from "babylonjs/Engines/engine";
  45148. export * from "babylonjs/Engines/engineStore";
  45149. export * from "babylonjs/Engines/nullEngine";
  45150. export * from "babylonjs/Engines/Extensions/index";
  45151. export * from "babylonjs/Engines/IPipelineContext";
  45152. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45153. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45154. }
  45155. declare module "babylonjs/Events/clipboardEvents" {
  45156. /**
  45157. * Gather the list of clipboard event types as constants.
  45158. */
  45159. export class ClipboardEventTypes {
  45160. /**
  45161. * The clipboard event is fired when a copy command is active (pressed).
  45162. */
  45163. static readonly COPY: number;
  45164. /**
  45165. * The clipboard event is fired when a cut command is active (pressed).
  45166. */
  45167. static readonly CUT: number;
  45168. /**
  45169. * The clipboard event is fired when a paste command is active (pressed).
  45170. */
  45171. static readonly PASTE: number;
  45172. }
  45173. /**
  45174. * This class is used to store clipboard related info for the onClipboardObservable event.
  45175. */
  45176. export class ClipboardInfo {
  45177. /**
  45178. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45179. */
  45180. type: number;
  45181. /**
  45182. * Defines the related dom event
  45183. */
  45184. event: ClipboardEvent;
  45185. /**
  45186. *Creates an instance of ClipboardInfo.
  45187. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45188. * @param event Defines the related dom event
  45189. */
  45190. constructor(
  45191. /**
  45192. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45193. */
  45194. type: number,
  45195. /**
  45196. * Defines the related dom event
  45197. */
  45198. event: ClipboardEvent);
  45199. /**
  45200. * Get the clipboard event's type from the keycode.
  45201. * @param keyCode Defines the keyCode for the current keyboard event.
  45202. * @return {number}
  45203. */
  45204. static GetTypeFromCharacter(keyCode: number): number;
  45205. }
  45206. }
  45207. declare module "babylonjs/Events/index" {
  45208. export * from "babylonjs/Events/keyboardEvents";
  45209. export * from "babylonjs/Events/pointerEvents";
  45210. export * from "babylonjs/Events/clipboardEvents";
  45211. }
  45212. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45213. import { Scene } from "babylonjs/scene";
  45214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45215. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45216. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45217. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45218. /**
  45219. * Google Daydream controller
  45220. */
  45221. export class DaydreamController extends WebVRController {
  45222. /**
  45223. * Base Url for the controller model.
  45224. */
  45225. static MODEL_BASE_URL: string;
  45226. /**
  45227. * File name for the controller model.
  45228. */
  45229. static MODEL_FILENAME: string;
  45230. /**
  45231. * Gamepad Id prefix used to identify Daydream Controller.
  45232. */
  45233. static readonly GAMEPAD_ID_PREFIX: string;
  45234. /**
  45235. * Creates a new DaydreamController from a gamepad
  45236. * @param vrGamepad the gamepad that the controller should be created from
  45237. */
  45238. constructor(vrGamepad: any);
  45239. /**
  45240. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45241. * @param scene scene in which to add meshes
  45242. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45243. */
  45244. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45245. /**
  45246. * Called once for each button that changed state since the last frame
  45247. * @param buttonIdx Which button index changed
  45248. * @param state New state of the button
  45249. * @param changes Which properties on the state changed since last frame
  45250. */
  45251. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45252. }
  45253. }
  45254. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45255. import { Scene } from "babylonjs/scene";
  45256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45257. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45258. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45259. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45260. /**
  45261. * Gear VR Controller
  45262. */
  45263. export class GearVRController extends WebVRController {
  45264. /**
  45265. * Base Url for the controller model.
  45266. */
  45267. static MODEL_BASE_URL: string;
  45268. /**
  45269. * File name for the controller model.
  45270. */
  45271. static MODEL_FILENAME: string;
  45272. /**
  45273. * Gamepad Id prefix used to identify this controller.
  45274. */
  45275. static readonly GAMEPAD_ID_PREFIX: string;
  45276. private readonly _buttonIndexToObservableNameMap;
  45277. /**
  45278. * Creates a new GearVRController from a gamepad
  45279. * @param vrGamepad the gamepad that the controller should be created from
  45280. */
  45281. constructor(vrGamepad: any);
  45282. /**
  45283. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45284. * @param scene scene in which to add meshes
  45285. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45286. */
  45287. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45288. /**
  45289. * Called once for each button that changed state since the last frame
  45290. * @param buttonIdx Which button index changed
  45291. * @param state New state of the button
  45292. * @param changes Which properties on the state changed since last frame
  45293. */
  45294. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45295. }
  45296. }
  45297. declare module "babylonjs/Gamepads/Controllers/index" {
  45298. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45299. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45300. export * from "babylonjs/Gamepads/Controllers/genericController";
  45301. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45302. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45303. export * from "babylonjs/Gamepads/Controllers/viveController";
  45304. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45305. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45306. }
  45307. declare module "babylonjs/Gamepads/index" {
  45308. export * from "babylonjs/Gamepads/Controllers/index";
  45309. export * from "babylonjs/Gamepads/gamepad";
  45310. export * from "babylonjs/Gamepads/gamepadManager";
  45311. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45312. export * from "babylonjs/Gamepads/xboxGamepad";
  45313. }
  45314. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45315. import { Scene } from "babylonjs/scene";
  45316. import { Vector4 } from "babylonjs/Maths/math.vector";
  45317. import { Color4 } from "babylonjs/Maths/math.color";
  45318. import { Mesh } from "babylonjs/Meshes/mesh";
  45319. import { Nullable } from "babylonjs/types";
  45320. /**
  45321. * Class containing static functions to help procedurally build meshes
  45322. */
  45323. export class PolyhedronBuilder {
  45324. /**
  45325. * Creates a polyhedron mesh
  45326. * * 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
  45327. * * The parameter `size` (positive float, default 1) sets the polygon size
  45328. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45329. * * 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`
  45330. * * 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
  45331. * * 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)`)
  45332. * * 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
  45333. * * 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
  45334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45337. * @param name defines the name of the mesh
  45338. * @param options defines the options used to create the mesh
  45339. * @param scene defines the hosting scene
  45340. * @returns the polyhedron mesh
  45341. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45342. */
  45343. static CreatePolyhedron(name: string, options: {
  45344. type?: number;
  45345. size?: number;
  45346. sizeX?: number;
  45347. sizeY?: number;
  45348. sizeZ?: number;
  45349. custom?: any;
  45350. faceUV?: Vector4[];
  45351. faceColors?: Color4[];
  45352. flat?: boolean;
  45353. updatable?: boolean;
  45354. sideOrientation?: number;
  45355. frontUVs?: Vector4;
  45356. backUVs?: Vector4;
  45357. }, scene?: Nullable<Scene>): Mesh;
  45358. }
  45359. }
  45360. declare module "babylonjs/Gizmos/scaleGizmo" {
  45361. import { Observable } from "babylonjs/Misc/observable";
  45362. import { Nullable } from "babylonjs/types";
  45363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45364. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45365. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45366. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45367. /**
  45368. * Gizmo that enables scaling a mesh along 3 axis
  45369. */
  45370. export class ScaleGizmo extends Gizmo {
  45371. /**
  45372. * Internal gizmo used for interactions on the x axis
  45373. */
  45374. xGizmo: AxisScaleGizmo;
  45375. /**
  45376. * Internal gizmo used for interactions on the y axis
  45377. */
  45378. yGizmo: AxisScaleGizmo;
  45379. /**
  45380. * Internal gizmo used for interactions on the z axis
  45381. */
  45382. zGizmo: AxisScaleGizmo;
  45383. /**
  45384. * Internal gizmo used to scale all axis equally
  45385. */
  45386. uniformScaleGizmo: AxisScaleGizmo;
  45387. private _meshAttached;
  45388. private _updateGizmoRotationToMatchAttachedMesh;
  45389. private _snapDistance;
  45390. private _scaleRatio;
  45391. private _uniformScalingMesh;
  45392. private _octahedron;
  45393. /** Fires an event when any of it's sub gizmos are dragged */
  45394. onDragStartObservable: Observable<unknown>;
  45395. /** Fires an event when any of it's sub gizmos are released from dragging */
  45396. onDragEndObservable: Observable<unknown>;
  45397. attachedMesh: Nullable<AbstractMesh>;
  45398. /**
  45399. * Creates a ScaleGizmo
  45400. * @param gizmoLayer The utility layer the gizmo will be added to
  45401. */
  45402. constructor(gizmoLayer?: UtilityLayerRenderer);
  45403. updateGizmoRotationToMatchAttachedMesh: boolean;
  45404. /**
  45405. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45406. */
  45407. snapDistance: number;
  45408. /**
  45409. * Ratio for the scale of the gizmo (Default: 1)
  45410. */
  45411. scaleRatio: number;
  45412. /**
  45413. * Disposes of the gizmo
  45414. */
  45415. dispose(): void;
  45416. }
  45417. }
  45418. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45419. import { Observable } from "babylonjs/Misc/observable";
  45420. import { Nullable } from "babylonjs/types";
  45421. import { Vector3 } from "babylonjs/Maths/math.vector";
  45422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45423. import { Mesh } from "babylonjs/Meshes/mesh";
  45424. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45425. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45426. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45427. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45428. import { Color3 } from "babylonjs/Maths/math.color";
  45429. /**
  45430. * Single axis scale gizmo
  45431. */
  45432. export class AxisScaleGizmo extends Gizmo {
  45433. /**
  45434. * Drag behavior responsible for the gizmos dragging interactions
  45435. */
  45436. dragBehavior: PointerDragBehavior;
  45437. private _pointerObserver;
  45438. /**
  45439. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45440. */
  45441. snapDistance: number;
  45442. /**
  45443. * Event that fires each time the gizmo snaps to a new location.
  45444. * * snapDistance is the the change in distance
  45445. */
  45446. onSnapObservable: Observable<{
  45447. snapDistance: number;
  45448. }>;
  45449. /**
  45450. * If the scaling operation should be done on all axis (default: false)
  45451. */
  45452. uniformScaling: boolean;
  45453. private _isEnabled;
  45454. private _parent;
  45455. private _arrow;
  45456. private _coloredMaterial;
  45457. private _hoverMaterial;
  45458. /**
  45459. * Creates an AxisScaleGizmo
  45460. * @param gizmoLayer The utility layer the gizmo will be added to
  45461. * @param dragAxis The axis which the gizmo will be able to scale on
  45462. * @param color The color of the gizmo
  45463. */
  45464. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45465. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45466. /**
  45467. * If the gizmo is enabled
  45468. */
  45469. isEnabled: boolean;
  45470. /**
  45471. * Disposes of the gizmo
  45472. */
  45473. dispose(): void;
  45474. /**
  45475. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45476. * @param mesh The mesh to replace the default mesh of the gizmo
  45477. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45478. */
  45479. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45480. }
  45481. }
  45482. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45483. import { Observable } from "babylonjs/Misc/observable";
  45484. import { Nullable } from "babylonjs/types";
  45485. import { Vector3 } from "babylonjs/Maths/math.vector";
  45486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45487. import { Mesh } from "babylonjs/Meshes/mesh";
  45488. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45489. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45490. import { Color3 } from "babylonjs/Maths/math.color";
  45491. import "babylonjs/Meshes/Builders/boxBuilder";
  45492. /**
  45493. * Bounding box gizmo
  45494. */
  45495. export class BoundingBoxGizmo extends Gizmo {
  45496. private _lineBoundingBox;
  45497. private _rotateSpheresParent;
  45498. private _scaleBoxesParent;
  45499. private _boundingDimensions;
  45500. private _renderObserver;
  45501. private _pointerObserver;
  45502. private _scaleDragSpeed;
  45503. private _tmpQuaternion;
  45504. private _tmpVector;
  45505. private _tmpRotationMatrix;
  45506. /**
  45507. * 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)
  45508. */
  45509. ignoreChildren: boolean;
  45510. /**
  45511. * 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)
  45512. */
  45513. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45514. /**
  45515. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45516. */
  45517. rotationSphereSize: number;
  45518. /**
  45519. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45520. */
  45521. scaleBoxSize: number;
  45522. /**
  45523. * 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)
  45524. */
  45525. fixedDragMeshScreenSize: boolean;
  45526. /**
  45527. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45528. */
  45529. fixedDragMeshScreenSizeDistanceFactor: number;
  45530. /**
  45531. * Fired when a rotation sphere or scale box is dragged
  45532. */
  45533. onDragStartObservable: Observable<{}>;
  45534. /**
  45535. * Fired when a scale box is dragged
  45536. */
  45537. onScaleBoxDragObservable: Observable<{}>;
  45538. /**
  45539. * Fired when a scale box drag is ended
  45540. */
  45541. onScaleBoxDragEndObservable: Observable<{}>;
  45542. /**
  45543. * Fired when a rotation sphere is dragged
  45544. */
  45545. onRotationSphereDragObservable: Observable<{}>;
  45546. /**
  45547. * Fired when a rotation sphere drag is ended
  45548. */
  45549. onRotationSphereDragEndObservable: Observable<{}>;
  45550. /**
  45551. * 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)
  45552. */
  45553. scalePivot: Nullable<Vector3>;
  45554. /**
  45555. * Mesh used as a pivot to rotate the attached mesh
  45556. */
  45557. private _anchorMesh;
  45558. private _existingMeshScale;
  45559. private _dragMesh;
  45560. private pointerDragBehavior;
  45561. private coloredMaterial;
  45562. private hoverColoredMaterial;
  45563. /**
  45564. * Sets the color of the bounding box gizmo
  45565. * @param color the color to set
  45566. */
  45567. setColor(color: Color3): void;
  45568. /**
  45569. * Creates an BoundingBoxGizmo
  45570. * @param gizmoLayer The utility layer the gizmo will be added to
  45571. * @param color The color of the gizmo
  45572. */
  45573. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45574. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45575. private _selectNode;
  45576. /**
  45577. * Updates the bounding box information for the Gizmo
  45578. */
  45579. updateBoundingBox(): void;
  45580. private _updateRotationSpheres;
  45581. private _updateScaleBoxes;
  45582. /**
  45583. * Enables rotation on the specified axis and disables rotation on the others
  45584. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45585. */
  45586. setEnabledRotationAxis(axis: string): void;
  45587. /**
  45588. * Enables/disables scaling
  45589. * @param enable if scaling should be enabled
  45590. */
  45591. setEnabledScaling(enable: boolean): void;
  45592. private _updateDummy;
  45593. /**
  45594. * Enables a pointer drag behavior on the bounding box of the gizmo
  45595. */
  45596. enableDragBehavior(): void;
  45597. /**
  45598. * Disposes of the gizmo
  45599. */
  45600. dispose(): void;
  45601. /**
  45602. * 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)
  45603. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45604. * @returns the bounding box mesh with the passed in mesh as a child
  45605. */
  45606. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45607. /**
  45608. * CustomMeshes are not supported by this gizmo
  45609. * @param mesh The mesh to replace the default mesh of the gizmo
  45610. */
  45611. setCustomMesh(mesh: Mesh): void;
  45612. }
  45613. }
  45614. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45615. import { Observable } from "babylonjs/Misc/observable";
  45616. import { Nullable } from "babylonjs/types";
  45617. import { Vector3 } from "babylonjs/Maths/math.vector";
  45618. import { Color3 } from "babylonjs/Maths/math.color";
  45619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45620. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45621. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45622. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45623. import "babylonjs/Meshes/Builders/linesBuilder";
  45624. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45625. /**
  45626. * Single plane rotation gizmo
  45627. */
  45628. export class PlaneRotationGizmo extends Gizmo {
  45629. /**
  45630. * Drag behavior responsible for the gizmos dragging interactions
  45631. */
  45632. dragBehavior: PointerDragBehavior;
  45633. private _pointerObserver;
  45634. /**
  45635. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45636. */
  45637. snapDistance: number;
  45638. /**
  45639. * Event that fires each time the gizmo snaps to a new location.
  45640. * * snapDistance is the the change in distance
  45641. */
  45642. onSnapObservable: Observable<{
  45643. snapDistance: number;
  45644. }>;
  45645. private _isEnabled;
  45646. private _parent;
  45647. /**
  45648. * Creates a PlaneRotationGizmo
  45649. * @param gizmoLayer The utility layer the gizmo will be added to
  45650. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45651. * @param color The color of the gizmo
  45652. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45653. */
  45654. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45655. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45656. /**
  45657. * If the gizmo is enabled
  45658. */
  45659. isEnabled: boolean;
  45660. /**
  45661. * Disposes of the gizmo
  45662. */
  45663. dispose(): void;
  45664. }
  45665. }
  45666. declare module "babylonjs/Gizmos/rotationGizmo" {
  45667. import { Observable } from "babylonjs/Misc/observable";
  45668. import { Nullable } from "babylonjs/types";
  45669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45670. import { Mesh } from "babylonjs/Meshes/mesh";
  45671. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45672. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45673. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45674. /**
  45675. * Gizmo that enables rotating a mesh along 3 axis
  45676. */
  45677. export class RotationGizmo extends Gizmo {
  45678. /**
  45679. * Internal gizmo used for interactions on the x axis
  45680. */
  45681. xGizmo: PlaneRotationGizmo;
  45682. /**
  45683. * Internal gizmo used for interactions on the y axis
  45684. */
  45685. yGizmo: PlaneRotationGizmo;
  45686. /**
  45687. * Internal gizmo used for interactions on the z axis
  45688. */
  45689. zGizmo: PlaneRotationGizmo;
  45690. /** Fires an event when any of it's sub gizmos are dragged */
  45691. onDragStartObservable: Observable<unknown>;
  45692. /** Fires an event when any of it's sub gizmos are released from dragging */
  45693. onDragEndObservable: Observable<unknown>;
  45694. private _meshAttached;
  45695. attachedMesh: Nullable<AbstractMesh>;
  45696. /**
  45697. * Creates a RotationGizmo
  45698. * @param gizmoLayer The utility layer the gizmo will be added to
  45699. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45700. */
  45701. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45702. updateGizmoRotationToMatchAttachedMesh: boolean;
  45703. /**
  45704. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45705. */
  45706. snapDistance: number;
  45707. /**
  45708. * Ratio for the scale of the gizmo (Default: 1)
  45709. */
  45710. scaleRatio: number;
  45711. /**
  45712. * Disposes of the gizmo
  45713. */
  45714. dispose(): void;
  45715. /**
  45716. * CustomMeshes are not supported by this gizmo
  45717. * @param mesh The mesh to replace the default mesh of the gizmo
  45718. */
  45719. setCustomMesh(mesh: Mesh): void;
  45720. }
  45721. }
  45722. declare module "babylonjs/Gizmos/gizmoManager" {
  45723. import { Observable } from "babylonjs/Misc/observable";
  45724. import { Nullable } from "babylonjs/types";
  45725. import { Scene, IDisposable } from "babylonjs/scene";
  45726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45727. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45728. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45729. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45730. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45731. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45732. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45733. /**
  45734. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45735. */
  45736. export class GizmoManager implements IDisposable {
  45737. private scene;
  45738. /**
  45739. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45740. */
  45741. gizmos: {
  45742. positionGizmo: Nullable<PositionGizmo>;
  45743. rotationGizmo: Nullable<RotationGizmo>;
  45744. scaleGizmo: Nullable<ScaleGizmo>;
  45745. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45746. };
  45747. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45748. clearGizmoOnEmptyPointerEvent: boolean;
  45749. /** Fires an event when the manager is attached to a mesh */
  45750. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45751. private _gizmosEnabled;
  45752. private _pointerObserver;
  45753. private _attachedMesh;
  45754. private _boundingBoxColor;
  45755. private _defaultUtilityLayer;
  45756. private _defaultKeepDepthUtilityLayer;
  45757. /**
  45758. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45759. */
  45760. boundingBoxDragBehavior: SixDofDragBehavior;
  45761. /**
  45762. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45763. */
  45764. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45765. /**
  45766. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45767. */
  45768. usePointerToAttachGizmos: boolean;
  45769. /**
  45770. * Utility layer that the bounding box gizmo belongs to
  45771. */
  45772. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45773. /**
  45774. * Utility layer that all gizmos besides bounding box belong to
  45775. */
  45776. readonly utilityLayer: UtilityLayerRenderer;
  45777. /**
  45778. * Instatiates a gizmo manager
  45779. * @param scene the scene to overlay the gizmos on top of
  45780. */
  45781. constructor(scene: Scene);
  45782. /**
  45783. * Attaches a set of gizmos to the specified mesh
  45784. * @param mesh The mesh the gizmo's should be attached to
  45785. */
  45786. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45787. /**
  45788. * If the position gizmo is enabled
  45789. */
  45790. positionGizmoEnabled: boolean;
  45791. /**
  45792. * If the rotation gizmo is enabled
  45793. */
  45794. rotationGizmoEnabled: boolean;
  45795. /**
  45796. * If the scale gizmo is enabled
  45797. */
  45798. scaleGizmoEnabled: boolean;
  45799. /**
  45800. * If the boundingBox gizmo is enabled
  45801. */
  45802. boundingBoxGizmoEnabled: boolean;
  45803. /**
  45804. * Disposes of the gizmo manager
  45805. */
  45806. dispose(): void;
  45807. }
  45808. }
  45809. declare module "babylonjs/Lights/directionalLight" {
  45810. import { Camera } from "babylonjs/Cameras/camera";
  45811. import { Scene } from "babylonjs/scene";
  45812. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45814. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45815. import { Effect } from "babylonjs/Materials/effect";
  45816. /**
  45817. * A directional light is defined by a direction (what a surprise!).
  45818. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45819. * 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.
  45820. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45821. */
  45822. export class DirectionalLight extends ShadowLight {
  45823. private _shadowFrustumSize;
  45824. /**
  45825. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45826. */
  45827. /**
  45828. * Specifies a fix frustum size for the shadow generation.
  45829. */
  45830. shadowFrustumSize: number;
  45831. private _shadowOrthoScale;
  45832. /**
  45833. * Gets the shadow projection scale against the optimal computed one.
  45834. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45835. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45836. */
  45837. /**
  45838. * Sets the shadow projection scale against the optimal computed one.
  45839. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45840. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45841. */
  45842. shadowOrthoScale: number;
  45843. /**
  45844. * Automatically compute the projection matrix to best fit (including all the casters)
  45845. * on each frame.
  45846. */
  45847. autoUpdateExtends: boolean;
  45848. private _orthoLeft;
  45849. private _orthoRight;
  45850. private _orthoTop;
  45851. private _orthoBottom;
  45852. /**
  45853. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45854. * The directional light is emitted from everywhere in the given direction.
  45855. * It can cast shadows.
  45856. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45857. * @param name The friendly name of the light
  45858. * @param direction The direction of the light
  45859. * @param scene The scene the light belongs to
  45860. */
  45861. constructor(name: string, direction: Vector3, scene: Scene);
  45862. /**
  45863. * Returns the string "DirectionalLight".
  45864. * @return The class name
  45865. */
  45866. getClassName(): string;
  45867. /**
  45868. * Returns the integer 1.
  45869. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45870. */
  45871. getTypeID(): number;
  45872. /**
  45873. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45874. * Returns the DirectionalLight Shadow projection matrix.
  45875. */
  45876. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45877. /**
  45878. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45879. * Returns the DirectionalLight Shadow projection matrix.
  45880. */
  45881. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45882. /**
  45883. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45884. * Returns the DirectionalLight Shadow projection matrix.
  45885. */
  45886. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45887. protected _buildUniformLayout(): void;
  45888. /**
  45889. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45890. * @param effect The effect to update
  45891. * @param lightIndex The index of the light in the effect to update
  45892. * @returns The directional light
  45893. */
  45894. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45895. /**
  45896. * Gets the minZ used for shadow according to both the scene and the light.
  45897. *
  45898. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45899. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45900. * @param activeCamera The camera we are returning the min for
  45901. * @returns the depth min z
  45902. */
  45903. getDepthMinZ(activeCamera: Camera): number;
  45904. /**
  45905. * Gets the maxZ used for shadow according to both the scene and the light.
  45906. *
  45907. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45908. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45909. * @param activeCamera The camera we are returning the max for
  45910. * @returns the depth max z
  45911. */
  45912. getDepthMaxZ(activeCamera: Camera): number;
  45913. /**
  45914. * Prepares the list of defines specific to the light type.
  45915. * @param defines the list of defines
  45916. * @param lightIndex defines the index of the light for the effect
  45917. */
  45918. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45919. }
  45920. }
  45921. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45922. import { Mesh } from "babylonjs/Meshes/mesh";
  45923. /**
  45924. * Class containing static functions to help procedurally build meshes
  45925. */
  45926. export class HemisphereBuilder {
  45927. /**
  45928. * Creates a hemisphere mesh
  45929. * @param name defines the name of the mesh
  45930. * @param options defines the options used to create the mesh
  45931. * @param scene defines the hosting scene
  45932. * @returns the hemisphere mesh
  45933. */
  45934. static CreateHemisphere(name: string, options: {
  45935. segments?: number;
  45936. diameter?: number;
  45937. sideOrientation?: number;
  45938. }, scene: any): Mesh;
  45939. }
  45940. }
  45941. declare module "babylonjs/Lights/spotLight" {
  45942. import { Nullable } from "babylonjs/types";
  45943. import { Scene } from "babylonjs/scene";
  45944. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45946. import { Effect } from "babylonjs/Materials/effect";
  45947. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45948. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45949. /**
  45950. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45951. * These values define a cone of light starting from the position, emitting toward the direction.
  45952. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45953. * and the exponent defines the speed of the decay of the light with distance (reach).
  45954. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45955. */
  45956. export class SpotLight extends ShadowLight {
  45957. private _angle;
  45958. private _innerAngle;
  45959. private _cosHalfAngle;
  45960. private _lightAngleScale;
  45961. private _lightAngleOffset;
  45962. /**
  45963. * Gets the cone angle of the spot light in Radians.
  45964. */
  45965. /**
  45966. * Sets the cone angle of the spot light in Radians.
  45967. */
  45968. angle: number;
  45969. /**
  45970. * Only used in gltf falloff mode, this defines the angle where
  45971. * the directional falloff will start before cutting at angle which could be seen
  45972. * as outer angle.
  45973. */
  45974. /**
  45975. * Only used in gltf falloff mode, this defines the angle where
  45976. * the directional falloff will start before cutting at angle which could be seen
  45977. * as outer angle.
  45978. */
  45979. innerAngle: number;
  45980. private _shadowAngleScale;
  45981. /**
  45982. * Allows scaling the angle of the light for shadow generation only.
  45983. */
  45984. /**
  45985. * Allows scaling the angle of the light for shadow generation only.
  45986. */
  45987. shadowAngleScale: number;
  45988. /**
  45989. * The light decay speed with the distance from the emission spot.
  45990. */
  45991. exponent: number;
  45992. private _projectionTextureMatrix;
  45993. /**
  45994. * Allows reading the projecton texture
  45995. */
  45996. readonly projectionTextureMatrix: Matrix;
  45997. protected _projectionTextureLightNear: number;
  45998. /**
  45999. * Gets the near clip of the Spotlight for texture projection.
  46000. */
  46001. /**
  46002. * Sets the near clip of the Spotlight for texture projection.
  46003. */
  46004. projectionTextureLightNear: number;
  46005. protected _projectionTextureLightFar: number;
  46006. /**
  46007. * Gets the far clip of the Spotlight for texture projection.
  46008. */
  46009. /**
  46010. * Sets the far clip of the Spotlight for texture projection.
  46011. */
  46012. projectionTextureLightFar: number;
  46013. protected _projectionTextureUpDirection: Vector3;
  46014. /**
  46015. * Gets the Up vector of the Spotlight for texture projection.
  46016. */
  46017. /**
  46018. * Sets the Up vector of the Spotlight for texture projection.
  46019. */
  46020. projectionTextureUpDirection: Vector3;
  46021. private _projectionTexture;
  46022. /**
  46023. * Gets the projection texture of the light.
  46024. */
  46025. /**
  46026. * Sets the projection texture of the light.
  46027. */
  46028. projectionTexture: Nullable<BaseTexture>;
  46029. private _projectionTextureViewLightDirty;
  46030. private _projectionTextureProjectionLightDirty;
  46031. private _projectionTextureDirty;
  46032. private _projectionTextureViewTargetVector;
  46033. private _projectionTextureViewLightMatrix;
  46034. private _projectionTextureProjectionLightMatrix;
  46035. private _projectionTextureScalingMatrix;
  46036. /**
  46037. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46038. * It can cast shadows.
  46039. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46040. * @param name The light friendly name
  46041. * @param position The position of the spot light in the scene
  46042. * @param direction The direction of the light in the scene
  46043. * @param angle The cone angle of the light in Radians
  46044. * @param exponent The light decay speed with the distance from the emission spot
  46045. * @param scene The scene the lights belongs to
  46046. */
  46047. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46048. /**
  46049. * Returns the string "SpotLight".
  46050. * @returns the class name
  46051. */
  46052. getClassName(): string;
  46053. /**
  46054. * Returns the integer 2.
  46055. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46056. */
  46057. getTypeID(): number;
  46058. /**
  46059. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46060. */
  46061. protected _setDirection(value: Vector3): void;
  46062. /**
  46063. * Overrides the position setter to recompute the projection texture view light Matrix.
  46064. */
  46065. protected _setPosition(value: Vector3): void;
  46066. /**
  46067. * 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.
  46068. * Returns the SpotLight.
  46069. */
  46070. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46071. protected _computeProjectionTextureViewLightMatrix(): void;
  46072. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46073. /**
  46074. * Main function for light texture projection matrix computing.
  46075. */
  46076. protected _computeProjectionTextureMatrix(): void;
  46077. protected _buildUniformLayout(): void;
  46078. private _computeAngleValues;
  46079. /**
  46080. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46081. * @param effect The effect to update
  46082. * @param lightIndex The index of the light in the effect to update
  46083. * @returns The spot light
  46084. */
  46085. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46086. /**
  46087. * Disposes the light and the associated resources.
  46088. */
  46089. dispose(): void;
  46090. /**
  46091. * Prepares the list of defines specific to the light type.
  46092. * @param defines the list of defines
  46093. * @param lightIndex defines the index of the light for the effect
  46094. */
  46095. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46096. }
  46097. }
  46098. declare module "babylonjs/Gizmos/lightGizmo" {
  46099. import { Nullable } from "babylonjs/types";
  46100. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46101. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46102. import { Light } from "babylonjs/Lights/light";
  46103. /**
  46104. * Gizmo that enables viewing a light
  46105. */
  46106. export class LightGizmo extends Gizmo {
  46107. private _lightMesh;
  46108. private _material;
  46109. private cachedPosition;
  46110. private cachedForward;
  46111. /**
  46112. * Creates a LightGizmo
  46113. * @param gizmoLayer The utility layer the gizmo will be added to
  46114. */
  46115. constructor(gizmoLayer?: UtilityLayerRenderer);
  46116. private _light;
  46117. /**
  46118. * The light that the gizmo is attached to
  46119. */
  46120. light: Nullable<Light>;
  46121. /**
  46122. * @hidden
  46123. * Updates the gizmo to match the attached mesh's position/rotation
  46124. */
  46125. protected _update(): void;
  46126. private static _Scale;
  46127. /**
  46128. * Creates the lines for a light mesh
  46129. */
  46130. private static _createLightLines;
  46131. /**
  46132. * Disposes of the light gizmo
  46133. */
  46134. dispose(): void;
  46135. private static _CreateHemisphericLightMesh;
  46136. private static _CreatePointLightMesh;
  46137. private static _CreateSpotLightMesh;
  46138. private static _CreateDirectionalLightMesh;
  46139. }
  46140. }
  46141. declare module "babylonjs/Gizmos/index" {
  46142. export * from "babylonjs/Gizmos/axisDragGizmo";
  46143. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46144. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46145. export * from "babylonjs/Gizmos/gizmo";
  46146. export * from "babylonjs/Gizmos/gizmoManager";
  46147. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46148. export * from "babylonjs/Gizmos/positionGizmo";
  46149. export * from "babylonjs/Gizmos/rotationGizmo";
  46150. export * from "babylonjs/Gizmos/scaleGizmo";
  46151. export * from "babylonjs/Gizmos/lightGizmo";
  46152. export * from "babylonjs/Gizmos/planeDragGizmo";
  46153. }
  46154. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46155. /** @hidden */
  46156. export var backgroundFragmentDeclaration: {
  46157. name: string;
  46158. shader: string;
  46159. };
  46160. }
  46161. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46162. /** @hidden */
  46163. export var backgroundUboDeclaration: {
  46164. name: string;
  46165. shader: string;
  46166. };
  46167. }
  46168. declare module "babylonjs/Shaders/background.fragment" {
  46169. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46170. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46171. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46172. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46173. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46174. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46175. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46176. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46177. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46178. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46179. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46180. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46181. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46182. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46183. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46184. /** @hidden */
  46185. export var backgroundPixelShader: {
  46186. name: string;
  46187. shader: string;
  46188. };
  46189. }
  46190. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46191. /** @hidden */
  46192. export var backgroundVertexDeclaration: {
  46193. name: string;
  46194. shader: string;
  46195. };
  46196. }
  46197. declare module "babylonjs/Shaders/background.vertex" {
  46198. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46199. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46200. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46201. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46202. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46203. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46204. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46205. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46206. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46207. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46208. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46209. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46210. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46211. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46212. /** @hidden */
  46213. export var backgroundVertexShader: {
  46214. name: string;
  46215. shader: string;
  46216. };
  46217. }
  46218. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46219. import { Nullable, int, float } from "babylonjs/types";
  46220. import { Scene } from "babylonjs/scene";
  46221. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46222. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46224. import { Mesh } from "babylonjs/Meshes/mesh";
  46225. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46226. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46227. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46229. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46230. import { Color3 } from "babylonjs/Maths/math.color";
  46231. import "babylonjs/Shaders/background.fragment";
  46232. import "babylonjs/Shaders/background.vertex";
  46233. /**
  46234. * Background material used to create an efficient environement around your scene.
  46235. */
  46236. export class BackgroundMaterial extends PushMaterial {
  46237. /**
  46238. * Standard reflectance value at parallel view angle.
  46239. */
  46240. static StandardReflectance0: number;
  46241. /**
  46242. * Standard reflectance value at grazing angle.
  46243. */
  46244. static StandardReflectance90: number;
  46245. protected _primaryColor: Color3;
  46246. /**
  46247. * Key light Color (multiply against the environement texture)
  46248. */
  46249. primaryColor: Color3;
  46250. protected __perceptualColor: Nullable<Color3>;
  46251. /**
  46252. * Experimental Internal Use Only.
  46253. *
  46254. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46255. * This acts as a helper to set the primary color to a more "human friendly" value.
  46256. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46257. * output color as close as possible from the chosen value.
  46258. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46259. * part of lighting setup.)
  46260. */
  46261. _perceptualColor: Nullable<Color3>;
  46262. protected _primaryColorShadowLevel: float;
  46263. /**
  46264. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46265. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46266. */
  46267. primaryColorShadowLevel: float;
  46268. protected _primaryColorHighlightLevel: float;
  46269. /**
  46270. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46271. * The primary color is used at the level chosen to define what the white area would look.
  46272. */
  46273. primaryColorHighlightLevel: float;
  46274. protected _reflectionTexture: Nullable<BaseTexture>;
  46275. /**
  46276. * Reflection Texture used in the material.
  46277. * Should be author in a specific way for the best result (refer to the documentation).
  46278. */
  46279. reflectionTexture: Nullable<BaseTexture>;
  46280. protected _reflectionBlur: float;
  46281. /**
  46282. * Reflection Texture level of blur.
  46283. *
  46284. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46285. * texture twice.
  46286. */
  46287. reflectionBlur: float;
  46288. protected _diffuseTexture: Nullable<BaseTexture>;
  46289. /**
  46290. * Diffuse Texture used in the material.
  46291. * Should be author in a specific way for the best result (refer to the documentation).
  46292. */
  46293. diffuseTexture: Nullable<BaseTexture>;
  46294. protected _shadowLights: Nullable<IShadowLight[]>;
  46295. /**
  46296. * Specify the list of lights casting shadow on the material.
  46297. * All scene shadow lights will be included if null.
  46298. */
  46299. shadowLights: Nullable<IShadowLight[]>;
  46300. protected _shadowLevel: float;
  46301. /**
  46302. * Helps adjusting the shadow to a softer level if required.
  46303. * 0 means black shadows and 1 means no shadows.
  46304. */
  46305. shadowLevel: float;
  46306. protected _sceneCenter: Vector3;
  46307. /**
  46308. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46309. * It is usually zero but might be interesting to modify according to your setup.
  46310. */
  46311. sceneCenter: Vector3;
  46312. protected _opacityFresnel: boolean;
  46313. /**
  46314. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46315. * This helps ensuring a nice transition when the camera goes under the ground.
  46316. */
  46317. opacityFresnel: boolean;
  46318. protected _reflectionFresnel: boolean;
  46319. /**
  46320. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46321. * This helps adding a mirror texture on the ground.
  46322. */
  46323. reflectionFresnel: boolean;
  46324. protected _reflectionFalloffDistance: number;
  46325. /**
  46326. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46327. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46328. */
  46329. reflectionFalloffDistance: number;
  46330. protected _reflectionAmount: number;
  46331. /**
  46332. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46333. */
  46334. reflectionAmount: number;
  46335. protected _reflectionReflectance0: number;
  46336. /**
  46337. * This specifies the weight of the reflection at grazing angle.
  46338. */
  46339. reflectionReflectance0: number;
  46340. protected _reflectionReflectance90: number;
  46341. /**
  46342. * This specifies the weight of the reflection at a perpendicular point of view.
  46343. */
  46344. reflectionReflectance90: number;
  46345. /**
  46346. * Sets the reflection reflectance fresnel values according to the default standard
  46347. * empirically know to work well :-)
  46348. */
  46349. reflectionStandardFresnelWeight: number;
  46350. protected _useRGBColor: boolean;
  46351. /**
  46352. * Helps to directly use the maps channels instead of their level.
  46353. */
  46354. useRGBColor: boolean;
  46355. protected _enableNoise: boolean;
  46356. /**
  46357. * This helps reducing the banding effect that could occur on the background.
  46358. */
  46359. enableNoise: boolean;
  46360. /**
  46361. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46362. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46363. * Recommended to be keep at 1.0 except for special cases.
  46364. */
  46365. fovMultiplier: number;
  46366. private _fovMultiplier;
  46367. /**
  46368. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46369. */
  46370. useEquirectangularFOV: boolean;
  46371. private _maxSimultaneousLights;
  46372. /**
  46373. * Number of Simultaneous lights allowed on the material.
  46374. */
  46375. maxSimultaneousLights: int;
  46376. /**
  46377. * Default configuration related to image processing available in the Background Material.
  46378. */
  46379. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46380. /**
  46381. * Keep track of the image processing observer to allow dispose and replace.
  46382. */
  46383. private _imageProcessingObserver;
  46384. /**
  46385. * Attaches a new image processing configuration to the PBR Material.
  46386. * @param configuration (if null the scene configuration will be use)
  46387. */
  46388. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46389. /**
  46390. * Gets the image processing configuration used either in this material.
  46391. */
  46392. /**
  46393. * Sets the Default image processing configuration used either in the this material.
  46394. *
  46395. * If sets to null, the scene one is in use.
  46396. */
  46397. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46398. /**
  46399. * Gets wether the color curves effect is enabled.
  46400. */
  46401. /**
  46402. * Sets wether the color curves effect is enabled.
  46403. */
  46404. cameraColorCurvesEnabled: boolean;
  46405. /**
  46406. * Gets wether the color grading effect is enabled.
  46407. */
  46408. /**
  46409. * Gets wether the color grading effect is enabled.
  46410. */
  46411. cameraColorGradingEnabled: boolean;
  46412. /**
  46413. * Gets wether tonemapping is enabled or not.
  46414. */
  46415. /**
  46416. * Sets wether tonemapping is enabled or not
  46417. */
  46418. cameraToneMappingEnabled: boolean;
  46419. /**
  46420. * The camera exposure used on this material.
  46421. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46422. * This corresponds to a photographic exposure.
  46423. */
  46424. /**
  46425. * The camera exposure used on this material.
  46426. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46427. * This corresponds to a photographic exposure.
  46428. */
  46429. cameraExposure: float;
  46430. /**
  46431. * Gets The camera contrast used on this material.
  46432. */
  46433. /**
  46434. * Sets The camera contrast used on this material.
  46435. */
  46436. cameraContrast: float;
  46437. /**
  46438. * Gets the Color Grading 2D Lookup Texture.
  46439. */
  46440. /**
  46441. * Sets the Color Grading 2D Lookup Texture.
  46442. */
  46443. cameraColorGradingTexture: Nullable<BaseTexture>;
  46444. /**
  46445. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46446. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46447. * 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;
  46448. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46449. */
  46450. /**
  46451. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46452. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46453. * 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;
  46454. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46455. */
  46456. cameraColorCurves: Nullable<ColorCurves>;
  46457. /**
  46458. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46459. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46460. */
  46461. switchToBGR: boolean;
  46462. private _renderTargets;
  46463. private _reflectionControls;
  46464. private _white;
  46465. private _primaryShadowColor;
  46466. private _primaryHighlightColor;
  46467. /**
  46468. * Instantiates a Background Material in the given scene
  46469. * @param name The friendly name of the material
  46470. * @param scene The scene to add the material to
  46471. */
  46472. constructor(name: string, scene: Scene);
  46473. /**
  46474. * Gets a boolean indicating that current material needs to register RTT
  46475. */
  46476. readonly hasRenderTargetTextures: boolean;
  46477. /**
  46478. * The entire material has been created in order to prevent overdraw.
  46479. * @returns false
  46480. */
  46481. needAlphaTesting(): boolean;
  46482. /**
  46483. * The entire material has been created in order to prevent overdraw.
  46484. * @returns true if blending is enable
  46485. */
  46486. needAlphaBlending(): boolean;
  46487. /**
  46488. * Checks wether the material is ready to be rendered for a given mesh.
  46489. * @param mesh The mesh to render
  46490. * @param subMesh The submesh to check against
  46491. * @param useInstances Specify wether or not the material is used with instances
  46492. * @returns true if all the dependencies are ready (Textures, Effects...)
  46493. */
  46494. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46495. /**
  46496. * Compute the primary color according to the chosen perceptual color.
  46497. */
  46498. private _computePrimaryColorFromPerceptualColor;
  46499. /**
  46500. * Compute the highlights and shadow colors according to their chosen levels.
  46501. */
  46502. private _computePrimaryColors;
  46503. /**
  46504. * Build the uniform buffer used in the material.
  46505. */
  46506. buildUniformLayout(): void;
  46507. /**
  46508. * Unbind the material.
  46509. */
  46510. unbind(): void;
  46511. /**
  46512. * Bind only the world matrix to the material.
  46513. * @param world The world matrix to bind.
  46514. */
  46515. bindOnlyWorldMatrix(world: Matrix): void;
  46516. /**
  46517. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46518. * @param world The world matrix to bind.
  46519. * @param subMesh The submesh to bind for.
  46520. */
  46521. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46522. /**
  46523. * Dispose the material.
  46524. * @param forceDisposeEffect Force disposal of the associated effect.
  46525. * @param forceDisposeTextures Force disposal of the associated textures.
  46526. */
  46527. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46528. /**
  46529. * Clones the material.
  46530. * @param name The cloned name.
  46531. * @returns The cloned material.
  46532. */
  46533. clone(name: string): BackgroundMaterial;
  46534. /**
  46535. * Serializes the current material to its JSON representation.
  46536. * @returns The JSON representation.
  46537. */
  46538. serialize(): any;
  46539. /**
  46540. * Gets the class name of the material
  46541. * @returns "BackgroundMaterial"
  46542. */
  46543. getClassName(): string;
  46544. /**
  46545. * Parse a JSON input to create back a background material.
  46546. * @param source The JSON data to parse
  46547. * @param scene The scene to create the parsed material in
  46548. * @param rootUrl The root url of the assets the material depends upon
  46549. * @returns the instantiated BackgroundMaterial.
  46550. */
  46551. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46552. }
  46553. }
  46554. declare module "babylonjs/Helpers/environmentHelper" {
  46555. import { Observable } from "babylonjs/Misc/observable";
  46556. import { Nullable } from "babylonjs/types";
  46557. import { Scene } from "babylonjs/scene";
  46558. import { Vector3 } from "babylonjs/Maths/math.vector";
  46559. import { Color3 } from "babylonjs/Maths/math.color";
  46560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46561. import { Mesh } from "babylonjs/Meshes/mesh";
  46562. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46563. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46564. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46565. import "babylonjs/Meshes/Builders/planeBuilder";
  46566. import "babylonjs/Meshes/Builders/boxBuilder";
  46567. /**
  46568. * Represents the different options available during the creation of
  46569. * a Environment helper.
  46570. *
  46571. * This can control the default ground, skybox and image processing setup of your scene.
  46572. */
  46573. export interface IEnvironmentHelperOptions {
  46574. /**
  46575. * Specifies wether or not to create a ground.
  46576. * True by default.
  46577. */
  46578. createGround: boolean;
  46579. /**
  46580. * Specifies the ground size.
  46581. * 15 by default.
  46582. */
  46583. groundSize: number;
  46584. /**
  46585. * The texture used on the ground for the main color.
  46586. * Comes from the BabylonJS CDN by default.
  46587. *
  46588. * Remarks: Can be either a texture or a url.
  46589. */
  46590. groundTexture: string | BaseTexture;
  46591. /**
  46592. * The color mixed in the ground texture by default.
  46593. * BabylonJS clearColor by default.
  46594. */
  46595. groundColor: Color3;
  46596. /**
  46597. * Specifies the ground opacity.
  46598. * 1 by default.
  46599. */
  46600. groundOpacity: number;
  46601. /**
  46602. * Enables the ground to receive shadows.
  46603. * True by default.
  46604. */
  46605. enableGroundShadow: boolean;
  46606. /**
  46607. * Helps preventing the shadow to be fully black on the ground.
  46608. * 0.5 by default.
  46609. */
  46610. groundShadowLevel: number;
  46611. /**
  46612. * Creates a mirror texture attach to the ground.
  46613. * false by default.
  46614. */
  46615. enableGroundMirror: boolean;
  46616. /**
  46617. * Specifies the ground mirror size ratio.
  46618. * 0.3 by default as the default kernel is 64.
  46619. */
  46620. groundMirrorSizeRatio: number;
  46621. /**
  46622. * Specifies the ground mirror blur kernel size.
  46623. * 64 by default.
  46624. */
  46625. groundMirrorBlurKernel: number;
  46626. /**
  46627. * Specifies the ground mirror visibility amount.
  46628. * 1 by default
  46629. */
  46630. groundMirrorAmount: number;
  46631. /**
  46632. * Specifies the ground mirror reflectance weight.
  46633. * This uses the standard weight of the background material to setup the fresnel effect
  46634. * of the mirror.
  46635. * 1 by default.
  46636. */
  46637. groundMirrorFresnelWeight: number;
  46638. /**
  46639. * Specifies the ground mirror Falloff distance.
  46640. * This can helps reducing the size of the reflection.
  46641. * 0 by Default.
  46642. */
  46643. groundMirrorFallOffDistance: number;
  46644. /**
  46645. * Specifies the ground mirror texture type.
  46646. * Unsigned Int by Default.
  46647. */
  46648. groundMirrorTextureType: number;
  46649. /**
  46650. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46651. * the shown objects.
  46652. */
  46653. groundYBias: number;
  46654. /**
  46655. * Specifies wether or not to create a skybox.
  46656. * True by default.
  46657. */
  46658. createSkybox: boolean;
  46659. /**
  46660. * Specifies the skybox size.
  46661. * 20 by default.
  46662. */
  46663. skyboxSize: number;
  46664. /**
  46665. * The texture used on the skybox for the main color.
  46666. * Comes from the BabylonJS CDN by default.
  46667. *
  46668. * Remarks: Can be either a texture or a url.
  46669. */
  46670. skyboxTexture: string | BaseTexture;
  46671. /**
  46672. * The color mixed in the skybox texture by default.
  46673. * BabylonJS clearColor by default.
  46674. */
  46675. skyboxColor: Color3;
  46676. /**
  46677. * The background rotation around the Y axis of the scene.
  46678. * This helps aligning the key lights of your scene with the background.
  46679. * 0 by default.
  46680. */
  46681. backgroundYRotation: number;
  46682. /**
  46683. * Compute automatically the size of the elements to best fit with the scene.
  46684. */
  46685. sizeAuto: boolean;
  46686. /**
  46687. * Default position of the rootMesh if autoSize is not true.
  46688. */
  46689. rootPosition: Vector3;
  46690. /**
  46691. * Sets up the image processing in the scene.
  46692. * true by default.
  46693. */
  46694. setupImageProcessing: boolean;
  46695. /**
  46696. * The texture used as your environment texture in the scene.
  46697. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46698. *
  46699. * Remarks: Can be either a texture or a url.
  46700. */
  46701. environmentTexture: string | BaseTexture;
  46702. /**
  46703. * The value of the exposure to apply to the scene.
  46704. * 0.6 by default if setupImageProcessing is true.
  46705. */
  46706. cameraExposure: number;
  46707. /**
  46708. * The value of the contrast to apply to the scene.
  46709. * 1.6 by default if setupImageProcessing is true.
  46710. */
  46711. cameraContrast: number;
  46712. /**
  46713. * Specifies wether or not tonemapping should be enabled in the scene.
  46714. * true by default if setupImageProcessing is true.
  46715. */
  46716. toneMappingEnabled: boolean;
  46717. }
  46718. /**
  46719. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46720. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46721. * It also helps with the default setup of your imageProcessing configuration.
  46722. */
  46723. export class EnvironmentHelper {
  46724. /**
  46725. * Default ground texture URL.
  46726. */
  46727. private static _groundTextureCDNUrl;
  46728. /**
  46729. * Default skybox texture URL.
  46730. */
  46731. private static _skyboxTextureCDNUrl;
  46732. /**
  46733. * Default environment texture URL.
  46734. */
  46735. private static _environmentTextureCDNUrl;
  46736. /**
  46737. * Creates the default options for the helper.
  46738. */
  46739. private static _getDefaultOptions;
  46740. private _rootMesh;
  46741. /**
  46742. * Gets the root mesh created by the helper.
  46743. */
  46744. readonly rootMesh: Mesh;
  46745. private _skybox;
  46746. /**
  46747. * Gets the skybox created by the helper.
  46748. */
  46749. readonly skybox: Nullable<Mesh>;
  46750. private _skyboxTexture;
  46751. /**
  46752. * Gets the skybox texture created by the helper.
  46753. */
  46754. readonly skyboxTexture: Nullable<BaseTexture>;
  46755. private _skyboxMaterial;
  46756. /**
  46757. * Gets the skybox material created by the helper.
  46758. */
  46759. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46760. private _ground;
  46761. /**
  46762. * Gets the ground mesh created by the helper.
  46763. */
  46764. readonly ground: Nullable<Mesh>;
  46765. private _groundTexture;
  46766. /**
  46767. * Gets the ground texture created by the helper.
  46768. */
  46769. readonly groundTexture: Nullable<BaseTexture>;
  46770. private _groundMirror;
  46771. /**
  46772. * Gets the ground mirror created by the helper.
  46773. */
  46774. readonly groundMirror: Nullable<MirrorTexture>;
  46775. /**
  46776. * Gets the ground mirror render list to helps pushing the meshes
  46777. * you wish in the ground reflection.
  46778. */
  46779. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46780. private _groundMaterial;
  46781. /**
  46782. * Gets the ground material created by the helper.
  46783. */
  46784. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46785. /**
  46786. * Stores the creation options.
  46787. */
  46788. private readonly _scene;
  46789. private _options;
  46790. /**
  46791. * This observable will be notified with any error during the creation of the environment,
  46792. * mainly texture creation errors.
  46793. */
  46794. onErrorObservable: Observable<{
  46795. message?: string;
  46796. exception?: any;
  46797. }>;
  46798. /**
  46799. * constructor
  46800. * @param options Defines the options we want to customize the helper
  46801. * @param scene The scene to add the material to
  46802. */
  46803. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46804. /**
  46805. * Updates the background according to the new options
  46806. * @param options
  46807. */
  46808. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46809. /**
  46810. * Sets the primary color of all the available elements.
  46811. * @param color the main color to affect to the ground and the background
  46812. */
  46813. setMainColor(color: Color3): void;
  46814. /**
  46815. * Setup the image processing according to the specified options.
  46816. */
  46817. private _setupImageProcessing;
  46818. /**
  46819. * Setup the environment texture according to the specified options.
  46820. */
  46821. private _setupEnvironmentTexture;
  46822. /**
  46823. * Setup the background according to the specified options.
  46824. */
  46825. private _setupBackground;
  46826. /**
  46827. * Get the scene sizes according to the setup.
  46828. */
  46829. private _getSceneSize;
  46830. /**
  46831. * Setup the ground according to the specified options.
  46832. */
  46833. private _setupGround;
  46834. /**
  46835. * Setup the ground material according to the specified options.
  46836. */
  46837. private _setupGroundMaterial;
  46838. /**
  46839. * Setup the ground diffuse texture according to the specified options.
  46840. */
  46841. private _setupGroundDiffuseTexture;
  46842. /**
  46843. * Setup the ground mirror texture according to the specified options.
  46844. */
  46845. private _setupGroundMirrorTexture;
  46846. /**
  46847. * Setup the ground to receive the mirror texture.
  46848. */
  46849. private _setupMirrorInGroundMaterial;
  46850. /**
  46851. * Setup the skybox according to the specified options.
  46852. */
  46853. private _setupSkybox;
  46854. /**
  46855. * Setup the skybox material according to the specified options.
  46856. */
  46857. private _setupSkyboxMaterial;
  46858. /**
  46859. * Setup the skybox reflection texture according to the specified options.
  46860. */
  46861. private _setupSkyboxReflectionTexture;
  46862. private _errorHandler;
  46863. /**
  46864. * Dispose all the elements created by the Helper.
  46865. */
  46866. dispose(): void;
  46867. }
  46868. }
  46869. declare module "babylonjs/Helpers/photoDome" {
  46870. import { Observable } from "babylonjs/Misc/observable";
  46871. import { Nullable } from "babylonjs/types";
  46872. import { Scene } from "babylonjs/scene";
  46873. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46874. import { Mesh } from "babylonjs/Meshes/mesh";
  46875. import { Texture } from "babylonjs/Materials/Textures/texture";
  46876. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46877. import "babylonjs/Meshes/Builders/sphereBuilder";
  46878. /**
  46879. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46880. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46881. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46882. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46883. */
  46884. export class PhotoDome extends TransformNode {
  46885. /**
  46886. * Define the image as a Monoscopic panoramic 360 image.
  46887. */
  46888. static readonly MODE_MONOSCOPIC: number;
  46889. /**
  46890. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46891. */
  46892. static readonly MODE_TOPBOTTOM: number;
  46893. /**
  46894. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46895. */
  46896. static readonly MODE_SIDEBYSIDE: number;
  46897. private _useDirectMapping;
  46898. /**
  46899. * The texture being displayed on the sphere
  46900. */
  46901. protected _photoTexture: Texture;
  46902. /**
  46903. * Gets or sets the texture being displayed on the sphere
  46904. */
  46905. photoTexture: Texture;
  46906. /**
  46907. * Observable raised when an error occured while loading the 360 image
  46908. */
  46909. onLoadErrorObservable: Observable<string>;
  46910. /**
  46911. * The skybox material
  46912. */
  46913. protected _material: BackgroundMaterial;
  46914. /**
  46915. * The surface used for the skybox
  46916. */
  46917. protected _mesh: Mesh;
  46918. /**
  46919. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46920. * Also see the options.resolution property.
  46921. */
  46922. fovMultiplier: number;
  46923. private _imageMode;
  46924. /**
  46925. * Gets or set the current video mode for the video. It can be:
  46926. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46927. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46928. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46929. */
  46930. imageMode: number;
  46931. /**
  46932. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46933. * @param name Element's name, child elements will append suffixes for their own names.
  46934. * @param urlsOfPhoto defines the url of the photo to display
  46935. * @param options defines an object containing optional or exposed sub element properties
  46936. * @param onError defines a callback called when an error occured while loading the texture
  46937. */
  46938. constructor(name: string, urlOfPhoto: string, options: {
  46939. resolution?: number;
  46940. size?: number;
  46941. useDirectMapping?: boolean;
  46942. faceForward?: boolean;
  46943. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46944. private _onBeforeCameraRenderObserver;
  46945. private _changeImageMode;
  46946. /**
  46947. * Releases resources associated with this node.
  46948. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46949. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46950. */
  46951. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46952. }
  46953. }
  46954. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46955. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46956. /** @hidden */
  46957. export var rgbdDecodePixelShader: {
  46958. name: string;
  46959. shader: string;
  46960. };
  46961. }
  46962. declare module "babylonjs/Misc/brdfTextureTools" {
  46963. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46964. import { Scene } from "babylonjs/scene";
  46965. import "babylonjs/Shaders/rgbdDecode.fragment";
  46966. /**
  46967. * Class used to host texture specific utilities
  46968. */
  46969. export class BRDFTextureTools {
  46970. /**
  46971. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46972. * @param texture the texture to expand.
  46973. */
  46974. private static _ExpandDefaultBRDFTexture;
  46975. /**
  46976. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46977. * @param scene defines the hosting scene
  46978. * @returns the environment BRDF texture
  46979. */
  46980. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46981. private static _environmentBRDFBase64Texture;
  46982. }
  46983. }
  46984. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46985. import { Nullable } from "babylonjs/types";
  46986. import { Color3 } from "babylonjs/Maths/math.color";
  46987. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46988. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46989. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46990. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  46991. import { Engine } from "babylonjs/Engines/engine";
  46992. import { Scene } from "babylonjs/scene";
  46993. /**
  46994. * @hidden
  46995. */
  46996. export interface IMaterialClearCoatDefines {
  46997. CLEARCOAT: boolean;
  46998. CLEARCOAT_DEFAULTIOR: boolean;
  46999. CLEARCOAT_TEXTURE: boolean;
  47000. CLEARCOAT_TEXTUREDIRECTUV: number;
  47001. CLEARCOAT_BUMP: boolean;
  47002. CLEARCOAT_BUMPDIRECTUV: number;
  47003. CLEARCOAT_TINT: boolean;
  47004. CLEARCOAT_TINT_TEXTURE: boolean;
  47005. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47006. /** @hidden */
  47007. _areTexturesDirty: boolean;
  47008. }
  47009. /**
  47010. * Define the code related to the clear coat parameters of the pbr material.
  47011. */
  47012. export class PBRClearCoatConfiguration {
  47013. /**
  47014. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47015. * The default fits with a polyurethane material.
  47016. */
  47017. private static readonly _DefaultIndexOfRefraction;
  47018. private _isEnabled;
  47019. /**
  47020. * Defines if the clear coat is enabled in the material.
  47021. */
  47022. isEnabled: boolean;
  47023. /**
  47024. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47025. */
  47026. intensity: number;
  47027. /**
  47028. * Defines the clear coat layer roughness.
  47029. */
  47030. roughness: number;
  47031. private _indexOfRefraction;
  47032. /**
  47033. * Defines the index of refraction of the clear coat.
  47034. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47035. * The default fits with a polyurethane material.
  47036. * Changing the default value is more performance intensive.
  47037. */
  47038. indexOfRefraction: number;
  47039. private _texture;
  47040. /**
  47041. * Stores the clear coat values in a texture.
  47042. */
  47043. texture: Nullable<BaseTexture>;
  47044. private _bumpTexture;
  47045. /**
  47046. * Define the clear coat specific bump texture.
  47047. */
  47048. bumpTexture: Nullable<BaseTexture>;
  47049. private _isTintEnabled;
  47050. /**
  47051. * Defines if the clear coat tint is enabled in the material.
  47052. */
  47053. isTintEnabled: boolean;
  47054. /**
  47055. * Defines the clear coat tint of the material.
  47056. * This is only use if tint is enabled
  47057. */
  47058. tintColor: Color3;
  47059. /**
  47060. * Defines the distance at which the tint color should be found in the
  47061. * clear coat media.
  47062. * This is only use if tint is enabled
  47063. */
  47064. tintColorAtDistance: number;
  47065. /**
  47066. * Defines the clear coat layer thickness.
  47067. * This is only use if tint is enabled
  47068. */
  47069. tintThickness: number;
  47070. private _tintTexture;
  47071. /**
  47072. * Stores the clear tint values in a texture.
  47073. * rgb is tint
  47074. * a is a thickness factor
  47075. */
  47076. tintTexture: Nullable<BaseTexture>;
  47077. /** @hidden */
  47078. private _internalMarkAllSubMeshesAsTexturesDirty;
  47079. /** @hidden */
  47080. _markAllSubMeshesAsTexturesDirty(): void;
  47081. /**
  47082. * Instantiate a new istance of clear coat configuration.
  47083. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47084. */
  47085. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47086. /**
  47087. * Gets wehter the submesh is ready to be used or not.
  47088. * @param defines the list of "defines" to update.
  47089. * @param scene defines the scene the material belongs to.
  47090. * @param engine defines the engine the material belongs to.
  47091. * @param disableBumpMap defines wether the material disables bump or not.
  47092. * @returns - boolean indicating that the submesh is ready or not.
  47093. */
  47094. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47095. /**
  47096. * Checks to see if a texture is used in the material.
  47097. * @param defines the list of "defines" to update.
  47098. * @param scene defines the scene to the material belongs to.
  47099. */
  47100. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47101. /**
  47102. * Binds the material data.
  47103. * @param uniformBuffer defines the Uniform buffer to fill in.
  47104. * @param scene defines the scene the material belongs to.
  47105. * @param engine defines the engine the material belongs to.
  47106. * @param disableBumpMap defines wether the material disables bump or not.
  47107. * @param isFrozen defines wether the material is frozen or not.
  47108. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47109. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47110. */
  47111. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47112. /**
  47113. * Checks to see if a texture is used in the material.
  47114. * @param texture - Base texture to use.
  47115. * @returns - Boolean specifying if a texture is used in the material.
  47116. */
  47117. hasTexture(texture: BaseTexture): boolean;
  47118. /**
  47119. * Returns an array of the actively used textures.
  47120. * @param activeTextures Array of BaseTextures
  47121. */
  47122. getActiveTextures(activeTextures: BaseTexture[]): void;
  47123. /**
  47124. * Returns the animatable textures.
  47125. * @param animatables Array of animatable textures.
  47126. */
  47127. getAnimatables(animatables: IAnimatable[]): void;
  47128. /**
  47129. * Disposes the resources of the material.
  47130. * @param forceDisposeTextures - Forces the disposal of all textures.
  47131. */
  47132. dispose(forceDisposeTextures?: boolean): void;
  47133. /**
  47134. * Get the current class name of the texture useful for serialization or dynamic coding.
  47135. * @returns "PBRClearCoatConfiguration"
  47136. */
  47137. getClassName(): string;
  47138. /**
  47139. * Add fallbacks to the effect fallbacks list.
  47140. * @param defines defines the Base texture to use.
  47141. * @param fallbacks defines the current fallback list.
  47142. * @param currentRank defines the current fallback rank.
  47143. * @returns the new fallback rank.
  47144. */
  47145. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47146. /**
  47147. * Add the required uniforms to the current list.
  47148. * @param uniforms defines the current uniform list.
  47149. */
  47150. static AddUniforms(uniforms: string[]): void;
  47151. /**
  47152. * Add the required samplers to the current list.
  47153. * @param samplers defines the current sampler list.
  47154. */
  47155. static AddSamplers(samplers: string[]): void;
  47156. /**
  47157. * Add the required uniforms to the current buffer.
  47158. * @param uniformBuffer defines the current uniform buffer.
  47159. */
  47160. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47161. /**
  47162. * Makes a duplicate of the current configuration into another one.
  47163. * @param clearCoatConfiguration define the config where to copy the info
  47164. */
  47165. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47166. /**
  47167. * Serializes this clear coat configuration.
  47168. * @returns - An object with the serialized config.
  47169. */
  47170. serialize(): any;
  47171. /**
  47172. * Parses a anisotropy Configuration from a serialized object.
  47173. * @param source - Serialized object.
  47174. * @param scene Defines the scene we are parsing for
  47175. * @param rootUrl Defines the rootUrl to load from
  47176. */
  47177. parse(source: any, scene: Scene, rootUrl: string): void;
  47178. }
  47179. }
  47180. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47181. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47182. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47184. import { Vector2 } from "babylonjs/Maths/math.vector";
  47185. import { Scene } from "babylonjs/scene";
  47186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47187. import { Nullable } from "babylonjs/types";
  47188. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47189. /**
  47190. * @hidden
  47191. */
  47192. export interface IMaterialAnisotropicDefines {
  47193. ANISOTROPIC: boolean;
  47194. ANISOTROPIC_TEXTURE: boolean;
  47195. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47196. MAINUV1: boolean;
  47197. _areTexturesDirty: boolean;
  47198. _needUVs: boolean;
  47199. }
  47200. /**
  47201. * Define the code related to the anisotropic parameters of the pbr material.
  47202. */
  47203. export class PBRAnisotropicConfiguration {
  47204. private _isEnabled;
  47205. /**
  47206. * Defines if the anisotropy is enabled in the material.
  47207. */
  47208. isEnabled: boolean;
  47209. /**
  47210. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47211. */
  47212. intensity: number;
  47213. /**
  47214. * Defines if the effect is along the tangents, bitangents or in between.
  47215. * By default, the effect is "strectching" the highlights along the tangents.
  47216. */
  47217. direction: Vector2;
  47218. private _texture;
  47219. /**
  47220. * Stores the anisotropy values in a texture.
  47221. * rg is direction (like normal from -1 to 1)
  47222. * b is a intensity
  47223. */
  47224. texture: Nullable<BaseTexture>;
  47225. /** @hidden */
  47226. private _internalMarkAllSubMeshesAsTexturesDirty;
  47227. /** @hidden */
  47228. _markAllSubMeshesAsTexturesDirty(): void;
  47229. /**
  47230. * Instantiate a new istance of anisotropy configuration.
  47231. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47232. */
  47233. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47234. /**
  47235. * Specifies that the submesh is ready to be used.
  47236. * @param defines the list of "defines" to update.
  47237. * @param scene defines the scene the material belongs to.
  47238. * @returns - boolean indicating that the submesh is ready or not.
  47239. */
  47240. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47241. /**
  47242. * Checks to see if a texture is used in the material.
  47243. * @param defines the list of "defines" to update.
  47244. * @param mesh the mesh we are preparing the defines for.
  47245. * @param scene defines the scene the material belongs to.
  47246. */
  47247. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47248. /**
  47249. * Binds the material data.
  47250. * @param uniformBuffer defines the Uniform buffer to fill in.
  47251. * @param scene defines the scene the material belongs to.
  47252. * @param isFrozen defines wether the material is frozen or not.
  47253. */
  47254. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47255. /**
  47256. * Checks to see if a texture is used in the material.
  47257. * @param texture - Base texture to use.
  47258. * @returns - Boolean specifying if a texture is used in the material.
  47259. */
  47260. hasTexture(texture: BaseTexture): boolean;
  47261. /**
  47262. * Returns an array of the actively used textures.
  47263. * @param activeTextures Array of BaseTextures
  47264. */
  47265. getActiveTextures(activeTextures: BaseTexture[]): void;
  47266. /**
  47267. * Returns the animatable textures.
  47268. * @param animatables Array of animatable textures.
  47269. */
  47270. getAnimatables(animatables: IAnimatable[]): void;
  47271. /**
  47272. * Disposes the resources of the material.
  47273. * @param forceDisposeTextures - Forces the disposal of all textures.
  47274. */
  47275. dispose(forceDisposeTextures?: boolean): void;
  47276. /**
  47277. * Get the current class name of the texture useful for serialization or dynamic coding.
  47278. * @returns "PBRAnisotropicConfiguration"
  47279. */
  47280. getClassName(): string;
  47281. /**
  47282. * Add fallbacks to the effect fallbacks list.
  47283. * @param defines defines the Base texture to use.
  47284. * @param fallbacks defines the current fallback list.
  47285. * @param currentRank defines the current fallback rank.
  47286. * @returns the new fallback rank.
  47287. */
  47288. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47289. /**
  47290. * Add the required uniforms to the current list.
  47291. * @param uniforms defines the current uniform list.
  47292. */
  47293. static AddUniforms(uniforms: string[]): void;
  47294. /**
  47295. * Add the required uniforms to the current buffer.
  47296. * @param uniformBuffer defines the current uniform buffer.
  47297. */
  47298. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47299. /**
  47300. * Add the required samplers to the current list.
  47301. * @param samplers defines the current sampler list.
  47302. */
  47303. static AddSamplers(samplers: string[]): void;
  47304. /**
  47305. * Makes a duplicate of the current configuration into another one.
  47306. * @param anisotropicConfiguration define the config where to copy the info
  47307. */
  47308. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47309. /**
  47310. * Serializes this anisotropy configuration.
  47311. * @returns - An object with the serialized config.
  47312. */
  47313. serialize(): any;
  47314. /**
  47315. * Parses a anisotropy Configuration from a serialized object.
  47316. * @param source - Serialized object.
  47317. * @param scene Defines the scene we are parsing for
  47318. * @param rootUrl Defines the rootUrl to load from
  47319. */
  47320. parse(source: any, scene: Scene, rootUrl: string): void;
  47321. }
  47322. }
  47323. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47324. import { Scene } from "babylonjs/scene";
  47325. /**
  47326. * @hidden
  47327. */
  47328. export interface IMaterialBRDFDefines {
  47329. BRDF_V_HEIGHT_CORRELATED: boolean;
  47330. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47331. SPHERICAL_HARMONICS: boolean;
  47332. /** @hidden */
  47333. _areMiscDirty: boolean;
  47334. }
  47335. /**
  47336. * Define the code related to the BRDF parameters of the pbr material.
  47337. */
  47338. export class PBRBRDFConfiguration {
  47339. /**
  47340. * Default value used for the energy conservation.
  47341. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47342. */
  47343. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47344. /**
  47345. * Default value used for the Smith Visibility Height Correlated mode.
  47346. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47347. */
  47348. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47349. /**
  47350. * Default value used for the IBL diffuse part.
  47351. * This can help switching back to the polynomials mode globally which is a tiny bit
  47352. * less GPU intensive at the drawback of a lower quality.
  47353. */
  47354. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47355. private _useEnergyConservation;
  47356. /**
  47357. * Defines if the material uses energy conservation.
  47358. */
  47359. useEnergyConservation: boolean;
  47360. private _useSmithVisibilityHeightCorrelated;
  47361. /**
  47362. * LEGACY Mode set to false
  47363. * Defines if the material uses height smith correlated visibility term.
  47364. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47365. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47366. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47367. * Not relying on height correlated will also disable energy conservation.
  47368. */
  47369. useSmithVisibilityHeightCorrelated: boolean;
  47370. private _useSphericalHarmonics;
  47371. /**
  47372. * LEGACY Mode set to false
  47373. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47374. * diffuse part of the IBL.
  47375. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47376. * to the ground truth.
  47377. */
  47378. useSphericalHarmonics: boolean;
  47379. /** @hidden */
  47380. private _internalMarkAllSubMeshesAsMiscDirty;
  47381. /** @hidden */
  47382. _markAllSubMeshesAsMiscDirty(): void;
  47383. /**
  47384. * Instantiate a new istance of clear coat configuration.
  47385. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47386. */
  47387. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47388. /**
  47389. * Checks to see if a texture is used in the material.
  47390. * @param defines the list of "defines" to update.
  47391. */
  47392. prepareDefines(defines: IMaterialBRDFDefines): void;
  47393. /**
  47394. * Get the current class name of the texture useful for serialization or dynamic coding.
  47395. * @returns "PBRClearCoatConfiguration"
  47396. */
  47397. getClassName(): string;
  47398. /**
  47399. * Makes a duplicate of the current configuration into another one.
  47400. * @param brdfConfiguration define the config where to copy the info
  47401. */
  47402. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47403. /**
  47404. * Serializes this BRDF configuration.
  47405. * @returns - An object with the serialized config.
  47406. */
  47407. serialize(): any;
  47408. /**
  47409. * Parses a anisotropy Configuration from a serialized object.
  47410. * @param source - Serialized object.
  47411. * @param scene Defines the scene we are parsing for
  47412. * @param rootUrl Defines the rootUrl to load from
  47413. */
  47414. parse(source: any, scene: Scene, rootUrl: string): void;
  47415. }
  47416. }
  47417. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47418. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47419. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47420. import { Color3 } from "babylonjs/Maths/math.color";
  47421. import { Scene } from "babylonjs/scene";
  47422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47423. import { Nullable } from "babylonjs/types";
  47424. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47425. /**
  47426. * @hidden
  47427. */
  47428. export interface IMaterialSheenDefines {
  47429. SHEEN: boolean;
  47430. SHEEN_TEXTURE: boolean;
  47431. SHEEN_TEXTUREDIRECTUV: number;
  47432. SHEEN_LINKWITHALBEDO: boolean;
  47433. /** @hidden */
  47434. _areTexturesDirty: boolean;
  47435. }
  47436. /**
  47437. * Define the code related to the Sheen parameters of the pbr material.
  47438. */
  47439. export class PBRSheenConfiguration {
  47440. private _isEnabled;
  47441. /**
  47442. * Defines if the material uses sheen.
  47443. */
  47444. isEnabled: boolean;
  47445. private _linkSheenWithAlbedo;
  47446. /**
  47447. * Defines if the sheen is linked to the sheen color.
  47448. */
  47449. linkSheenWithAlbedo: boolean;
  47450. /**
  47451. * Defines the sheen intensity.
  47452. */
  47453. intensity: number;
  47454. /**
  47455. * Defines the sheen color.
  47456. */
  47457. color: Color3;
  47458. private _texture;
  47459. /**
  47460. * Stores the sheen tint values in a texture.
  47461. * rgb is tint
  47462. * a is a intensity
  47463. */
  47464. texture: Nullable<BaseTexture>;
  47465. /** @hidden */
  47466. private _internalMarkAllSubMeshesAsTexturesDirty;
  47467. /** @hidden */
  47468. _markAllSubMeshesAsTexturesDirty(): void;
  47469. /**
  47470. * Instantiate a new istance of clear coat configuration.
  47471. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47472. */
  47473. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47474. /**
  47475. * Specifies that the submesh is ready to be used.
  47476. * @param defines the list of "defines" to update.
  47477. * @param scene defines the scene the material belongs to.
  47478. * @returns - boolean indicating that the submesh is ready or not.
  47479. */
  47480. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47481. /**
  47482. * Checks to see if a texture is used in the material.
  47483. * @param defines the list of "defines" to update.
  47484. * @param scene defines the scene the material belongs to.
  47485. */
  47486. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47487. /**
  47488. * Binds the material data.
  47489. * @param uniformBuffer defines the Uniform buffer to fill in.
  47490. * @param scene defines the scene the material belongs to.
  47491. * @param isFrozen defines wether the material is frozen or not.
  47492. */
  47493. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47494. /**
  47495. * Checks to see if a texture is used in the material.
  47496. * @param texture - Base texture to use.
  47497. * @returns - Boolean specifying if a texture is used in the material.
  47498. */
  47499. hasTexture(texture: BaseTexture): boolean;
  47500. /**
  47501. * Returns an array of the actively used textures.
  47502. * @param activeTextures Array of BaseTextures
  47503. */
  47504. getActiveTextures(activeTextures: BaseTexture[]): void;
  47505. /**
  47506. * Returns the animatable textures.
  47507. * @param animatables Array of animatable textures.
  47508. */
  47509. getAnimatables(animatables: IAnimatable[]): void;
  47510. /**
  47511. * Disposes the resources of the material.
  47512. * @param forceDisposeTextures - Forces the disposal of all textures.
  47513. */
  47514. dispose(forceDisposeTextures?: boolean): void;
  47515. /**
  47516. * Get the current class name of the texture useful for serialization or dynamic coding.
  47517. * @returns "PBRSheenConfiguration"
  47518. */
  47519. getClassName(): string;
  47520. /**
  47521. * Add fallbacks to the effect fallbacks list.
  47522. * @param defines defines the Base texture to use.
  47523. * @param fallbacks defines the current fallback list.
  47524. * @param currentRank defines the current fallback rank.
  47525. * @returns the new fallback rank.
  47526. */
  47527. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47528. /**
  47529. * Add the required uniforms to the current list.
  47530. * @param uniforms defines the current uniform list.
  47531. */
  47532. static AddUniforms(uniforms: string[]): void;
  47533. /**
  47534. * Add the required uniforms to the current buffer.
  47535. * @param uniformBuffer defines the current uniform buffer.
  47536. */
  47537. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47538. /**
  47539. * Add the required samplers to the current list.
  47540. * @param samplers defines the current sampler list.
  47541. */
  47542. static AddSamplers(samplers: string[]): void;
  47543. /**
  47544. * Makes a duplicate of the current configuration into another one.
  47545. * @param sheenConfiguration define the config where to copy the info
  47546. */
  47547. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47548. /**
  47549. * Serializes this BRDF configuration.
  47550. * @returns - An object with the serialized config.
  47551. */
  47552. serialize(): any;
  47553. /**
  47554. * Parses a anisotropy Configuration from a serialized object.
  47555. * @param source - Serialized object.
  47556. * @param scene Defines the scene we are parsing for
  47557. * @param rootUrl Defines the rootUrl to load from
  47558. */
  47559. parse(source: any, scene: Scene, rootUrl: string): void;
  47560. }
  47561. }
  47562. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47563. import { Nullable } from "babylonjs/types";
  47564. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47565. import { Color3 } from "babylonjs/Maths/math.color";
  47566. import { SmartArray } from "babylonjs/Misc/smartArray";
  47567. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47568. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47569. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47570. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47571. import { Engine } from "babylonjs/Engines/engine";
  47572. import { Scene } from "babylonjs/scene";
  47573. /**
  47574. * @hidden
  47575. */
  47576. export interface IMaterialSubSurfaceDefines {
  47577. SUBSURFACE: boolean;
  47578. SS_REFRACTION: boolean;
  47579. SS_TRANSLUCENCY: boolean;
  47580. SS_SCATERRING: boolean;
  47581. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47582. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47583. SS_REFRACTIONMAP_3D: boolean;
  47584. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47585. SS_LODINREFRACTIONALPHA: boolean;
  47586. SS_GAMMAREFRACTION: boolean;
  47587. SS_RGBDREFRACTION: boolean;
  47588. SS_LINEARSPECULARREFRACTION: boolean;
  47589. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47590. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47591. /** @hidden */
  47592. _areTexturesDirty: boolean;
  47593. }
  47594. /**
  47595. * Define the code related to the sub surface parameters of the pbr material.
  47596. */
  47597. export class PBRSubSurfaceConfiguration {
  47598. private _isRefractionEnabled;
  47599. /**
  47600. * Defines if the refraction is enabled in the material.
  47601. */
  47602. isRefractionEnabled: boolean;
  47603. private _isTranslucencyEnabled;
  47604. /**
  47605. * Defines if the translucency is enabled in the material.
  47606. */
  47607. isTranslucencyEnabled: boolean;
  47608. private _isScatteringEnabled;
  47609. /**
  47610. * Defines the refraction intensity of the material.
  47611. * The refraction when enabled replaces the Diffuse part of the material.
  47612. * The intensity helps transitionning between diffuse and refraction.
  47613. */
  47614. refractionIntensity: number;
  47615. /**
  47616. * Defines the translucency intensity of the material.
  47617. * When translucency has been enabled, this defines how much of the "translucency"
  47618. * is addded to the diffuse part of the material.
  47619. */
  47620. translucencyIntensity: number;
  47621. /**
  47622. * Defines the scattering intensity of the material.
  47623. * When scattering has been enabled, this defines how much of the "scattered light"
  47624. * is addded to the diffuse part of the material.
  47625. */
  47626. scatteringIntensity: number;
  47627. private _thicknessTexture;
  47628. /**
  47629. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47630. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47631. * 0 would mean minimumThickness
  47632. * 1 would mean maximumThickness
  47633. * The other channels might be use as a mask to vary the different effects intensity.
  47634. */
  47635. thicknessTexture: Nullable<BaseTexture>;
  47636. private _refractionTexture;
  47637. /**
  47638. * Defines the texture to use for refraction.
  47639. */
  47640. refractionTexture: Nullable<BaseTexture>;
  47641. private _indexOfRefraction;
  47642. /**
  47643. * Defines the index of refraction used in the material.
  47644. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47645. */
  47646. indexOfRefraction: number;
  47647. private _invertRefractionY;
  47648. /**
  47649. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47650. */
  47651. invertRefractionY: boolean;
  47652. private _linkRefractionWithTransparency;
  47653. /**
  47654. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47655. * Materials half opaque for instance using refraction could benefit from this control.
  47656. */
  47657. linkRefractionWithTransparency: boolean;
  47658. /**
  47659. * Defines the minimum thickness stored in the thickness map.
  47660. * If no thickness map is defined, this value will be used to simulate thickness.
  47661. */
  47662. minimumThickness: number;
  47663. /**
  47664. * Defines the maximum thickness stored in the thickness map.
  47665. */
  47666. maximumThickness: number;
  47667. /**
  47668. * Defines the volume tint of the material.
  47669. * This is used for both translucency and scattering.
  47670. */
  47671. tintColor: Color3;
  47672. /**
  47673. * Defines the distance at which the tint color should be found in the media.
  47674. * This is used for refraction only.
  47675. */
  47676. tintColorAtDistance: number;
  47677. /**
  47678. * Defines how far each channel transmit through the media.
  47679. * It is defined as a color to simplify it selection.
  47680. */
  47681. diffusionDistance: Color3;
  47682. private _useMaskFromThicknessTexture;
  47683. /**
  47684. * Stores the intensity of the different subsurface effects in the thickness texture.
  47685. * * the green channel is the translucency intensity.
  47686. * * the blue channel is the scattering intensity.
  47687. * * the alpha channel is the refraction intensity.
  47688. */
  47689. useMaskFromThicknessTexture: boolean;
  47690. /** @hidden */
  47691. private _internalMarkAllSubMeshesAsTexturesDirty;
  47692. /** @hidden */
  47693. _markAllSubMeshesAsTexturesDirty(): void;
  47694. /**
  47695. * Instantiate a new istance of sub surface configuration.
  47696. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47697. */
  47698. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47699. /**
  47700. * Gets wehter the submesh is ready to be used or not.
  47701. * @param defines the list of "defines" to update.
  47702. * @param scene defines the scene the material belongs to.
  47703. * @returns - boolean indicating that the submesh is ready or not.
  47704. */
  47705. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47706. /**
  47707. * Checks to see if a texture is used in the material.
  47708. * @param defines the list of "defines" to update.
  47709. * @param scene defines the scene to the material belongs to.
  47710. */
  47711. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47712. /**
  47713. * Binds the material data.
  47714. * @param uniformBuffer defines the Uniform buffer to fill in.
  47715. * @param scene defines the scene the material belongs to.
  47716. * @param engine defines the engine the material belongs to.
  47717. * @param isFrozen defines wether the material is frozen or not.
  47718. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47719. */
  47720. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47721. /**
  47722. * Unbinds the material from the mesh.
  47723. * @param activeEffect defines the effect that should be unbound from.
  47724. * @returns true if unbound, otherwise false
  47725. */
  47726. unbind(activeEffect: Effect): boolean;
  47727. /**
  47728. * Returns the texture used for refraction or null if none is used.
  47729. * @param scene defines the scene the material belongs to.
  47730. * @returns - Refraction texture if present. If no refraction texture and refraction
  47731. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47732. */
  47733. private _getRefractionTexture;
  47734. /**
  47735. * Returns true if alpha blending should be disabled.
  47736. */
  47737. readonly disableAlphaBlending: boolean;
  47738. /**
  47739. * Fills the list of render target textures.
  47740. * @param renderTargets the list of render targets to update
  47741. */
  47742. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47743. /**
  47744. * Checks to see if a texture is used in the material.
  47745. * @param texture - Base texture to use.
  47746. * @returns - Boolean specifying if a texture is used in the material.
  47747. */
  47748. hasTexture(texture: BaseTexture): boolean;
  47749. /**
  47750. * Gets a boolean indicating that current material needs to register RTT
  47751. * @returns true if this uses a render target otherwise false.
  47752. */
  47753. hasRenderTargetTextures(): boolean;
  47754. /**
  47755. * Returns an array of the actively used textures.
  47756. * @param activeTextures Array of BaseTextures
  47757. */
  47758. getActiveTextures(activeTextures: BaseTexture[]): void;
  47759. /**
  47760. * Returns the animatable textures.
  47761. * @param animatables Array of animatable textures.
  47762. */
  47763. getAnimatables(animatables: IAnimatable[]): void;
  47764. /**
  47765. * Disposes the resources of the material.
  47766. * @param forceDisposeTextures - Forces the disposal of all textures.
  47767. */
  47768. dispose(forceDisposeTextures?: boolean): void;
  47769. /**
  47770. * Get the current class name of the texture useful for serialization or dynamic coding.
  47771. * @returns "PBRSubSurfaceConfiguration"
  47772. */
  47773. getClassName(): string;
  47774. /**
  47775. * Add fallbacks to the effect fallbacks list.
  47776. * @param defines defines the Base texture to use.
  47777. * @param fallbacks defines the current fallback list.
  47778. * @param currentRank defines the current fallback rank.
  47779. * @returns the new fallback rank.
  47780. */
  47781. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47782. /**
  47783. * Add the required uniforms to the current list.
  47784. * @param uniforms defines the current uniform list.
  47785. */
  47786. static AddUniforms(uniforms: string[]): void;
  47787. /**
  47788. * Add the required samplers to the current list.
  47789. * @param samplers defines the current sampler list.
  47790. */
  47791. static AddSamplers(samplers: string[]): void;
  47792. /**
  47793. * Add the required uniforms to the current buffer.
  47794. * @param uniformBuffer defines the current uniform buffer.
  47795. */
  47796. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47797. /**
  47798. * Makes a duplicate of the current configuration into another one.
  47799. * @param configuration define the config where to copy the info
  47800. */
  47801. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47802. /**
  47803. * Serializes this Sub Surface configuration.
  47804. * @returns - An object with the serialized config.
  47805. */
  47806. serialize(): any;
  47807. /**
  47808. * Parses a anisotropy Configuration from a serialized object.
  47809. * @param source - Serialized object.
  47810. * @param scene Defines the scene we are parsing for
  47811. * @param rootUrl Defines the rootUrl to load from
  47812. */
  47813. parse(source: any, scene: Scene, rootUrl: string): void;
  47814. }
  47815. }
  47816. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47817. /** @hidden */
  47818. export var pbrFragmentDeclaration: {
  47819. name: string;
  47820. shader: string;
  47821. };
  47822. }
  47823. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47824. /** @hidden */
  47825. export var pbrUboDeclaration: {
  47826. name: string;
  47827. shader: string;
  47828. };
  47829. }
  47830. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47831. /** @hidden */
  47832. export var pbrFragmentExtraDeclaration: {
  47833. name: string;
  47834. shader: string;
  47835. };
  47836. }
  47837. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47838. /** @hidden */
  47839. export var pbrFragmentSamplersDeclaration: {
  47840. name: string;
  47841. shader: string;
  47842. };
  47843. }
  47844. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47845. /** @hidden */
  47846. export var pbrHelperFunctions: {
  47847. name: string;
  47848. shader: string;
  47849. };
  47850. }
  47851. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47852. /** @hidden */
  47853. export var harmonicsFunctions: {
  47854. name: string;
  47855. shader: string;
  47856. };
  47857. }
  47858. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47859. /** @hidden */
  47860. export var pbrDirectLightingSetupFunctions: {
  47861. name: string;
  47862. shader: string;
  47863. };
  47864. }
  47865. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47866. /** @hidden */
  47867. export var pbrDirectLightingFalloffFunctions: {
  47868. name: string;
  47869. shader: string;
  47870. };
  47871. }
  47872. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47873. /** @hidden */
  47874. export var pbrBRDFFunctions: {
  47875. name: string;
  47876. shader: string;
  47877. };
  47878. }
  47879. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47880. /** @hidden */
  47881. export var pbrDirectLightingFunctions: {
  47882. name: string;
  47883. shader: string;
  47884. };
  47885. }
  47886. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47887. /** @hidden */
  47888. export var pbrIBLFunctions: {
  47889. name: string;
  47890. shader: string;
  47891. };
  47892. }
  47893. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47894. /** @hidden */
  47895. export var pbrDebug: {
  47896. name: string;
  47897. shader: string;
  47898. };
  47899. }
  47900. declare module "babylonjs/Shaders/pbr.fragment" {
  47901. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47902. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47903. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47904. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47905. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47906. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47907. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47908. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47909. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47910. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47911. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47912. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47913. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47914. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47915. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47916. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47917. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47918. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47919. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47920. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47921. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47922. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47923. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47924. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47925. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47926. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47927. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47928. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47929. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47930. /** @hidden */
  47931. export var pbrPixelShader: {
  47932. name: string;
  47933. shader: string;
  47934. };
  47935. }
  47936. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47937. /** @hidden */
  47938. export var pbrVertexDeclaration: {
  47939. name: string;
  47940. shader: string;
  47941. };
  47942. }
  47943. declare module "babylonjs/Shaders/pbr.vertex" {
  47944. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47945. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47946. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47947. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47948. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47949. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47950. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47951. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47952. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47953. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47954. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47955. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47956. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47957. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47958. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47959. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47960. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47961. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47962. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47963. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47964. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47965. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47966. /** @hidden */
  47967. export var pbrVertexShader: {
  47968. name: string;
  47969. shader: string;
  47970. };
  47971. }
  47972. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47973. import { Nullable } from "babylonjs/types";
  47974. import { Scene } from "babylonjs/scene";
  47975. import { Matrix } from "babylonjs/Maths/math.vector";
  47976. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47978. import { Mesh } from "babylonjs/Meshes/mesh";
  47979. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47980. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47981. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47982. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47983. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47984. import { Color3 } from "babylonjs/Maths/math.color";
  47985. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47986. import { Material } from "babylonjs/Materials/material";
  47987. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47988. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47989. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47990. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47991. import "babylonjs/Shaders/pbr.fragment";
  47992. import "babylonjs/Shaders/pbr.vertex";
  47993. /**
  47994. * Manages the defines for the PBR Material.
  47995. * @hidden
  47996. */
  47997. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47998. PBR: boolean;
  47999. MAINUV1: boolean;
  48000. MAINUV2: boolean;
  48001. UV1: boolean;
  48002. UV2: boolean;
  48003. ALBEDO: boolean;
  48004. ALBEDODIRECTUV: number;
  48005. VERTEXCOLOR: boolean;
  48006. AMBIENT: boolean;
  48007. AMBIENTDIRECTUV: number;
  48008. AMBIENTINGRAYSCALE: boolean;
  48009. OPACITY: boolean;
  48010. VERTEXALPHA: boolean;
  48011. OPACITYDIRECTUV: number;
  48012. OPACITYRGB: boolean;
  48013. ALPHATEST: boolean;
  48014. DEPTHPREPASS: boolean;
  48015. ALPHABLEND: boolean;
  48016. ALPHAFROMALBEDO: boolean;
  48017. ALPHATESTVALUE: string;
  48018. SPECULAROVERALPHA: boolean;
  48019. RADIANCEOVERALPHA: boolean;
  48020. ALPHAFRESNEL: boolean;
  48021. LINEARALPHAFRESNEL: boolean;
  48022. PREMULTIPLYALPHA: boolean;
  48023. EMISSIVE: boolean;
  48024. EMISSIVEDIRECTUV: number;
  48025. REFLECTIVITY: boolean;
  48026. REFLECTIVITYDIRECTUV: number;
  48027. SPECULARTERM: boolean;
  48028. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48029. MICROSURFACEAUTOMATIC: boolean;
  48030. LODBASEDMICROSFURACE: boolean;
  48031. MICROSURFACEMAP: boolean;
  48032. MICROSURFACEMAPDIRECTUV: number;
  48033. METALLICWORKFLOW: boolean;
  48034. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48035. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48036. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48037. AOSTOREINMETALMAPRED: boolean;
  48038. ENVIRONMENTBRDF: boolean;
  48039. ENVIRONMENTBRDF_RGBD: boolean;
  48040. NORMAL: boolean;
  48041. TANGENT: boolean;
  48042. BUMP: boolean;
  48043. BUMPDIRECTUV: number;
  48044. OBJECTSPACE_NORMALMAP: boolean;
  48045. PARALLAX: boolean;
  48046. PARALLAXOCCLUSION: boolean;
  48047. NORMALXYSCALE: boolean;
  48048. LIGHTMAP: boolean;
  48049. LIGHTMAPDIRECTUV: number;
  48050. USELIGHTMAPASSHADOWMAP: boolean;
  48051. GAMMALIGHTMAP: boolean;
  48052. REFLECTION: boolean;
  48053. REFLECTIONMAP_3D: boolean;
  48054. REFLECTIONMAP_SPHERICAL: boolean;
  48055. REFLECTIONMAP_PLANAR: boolean;
  48056. REFLECTIONMAP_CUBIC: boolean;
  48057. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48058. REFLECTIONMAP_PROJECTION: boolean;
  48059. REFLECTIONMAP_SKYBOX: boolean;
  48060. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48061. REFLECTIONMAP_EXPLICIT: boolean;
  48062. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48063. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48064. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48065. INVERTCUBICMAP: boolean;
  48066. USESPHERICALFROMREFLECTIONMAP: boolean;
  48067. USEIRRADIANCEMAP: boolean;
  48068. SPHERICAL_HARMONICS: boolean;
  48069. USESPHERICALINVERTEX: boolean;
  48070. REFLECTIONMAP_OPPOSITEZ: boolean;
  48071. LODINREFLECTIONALPHA: boolean;
  48072. GAMMAREFLECTION: boolean;
  48073. RGBDREFLECTION: boolean;
  48074. LINEARSPECULARREFLECTION: boolean;
  48075. RADIANCEOCCLUSION: boolean;
  48076. HORIZONOCCLUSION: boolean;
  48077. INSTANCES: boolean;
  48078. NUM_BONE_INFLUENCERS: number;
  48079. BonesPerMesh: number;
  48080. BONETEXTURE: boolean;
  48081. NONUNIFORMSCALING: boolean;
  48082. MORPHTARGETS: boolean;
  48083. MORPHTARGETS_NORMAL: boolean;
  48084. MORPHTARGETS_TANGENT: boolean;
  48085. MORPHTARGETS_UV: boolean;
  48086. NUM_MORPH_INFLUENCERS: number;
  48087. IMAGEPROCESSING: boolean;
  48088. VIGNETTE: boolean;
  48089. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48090. VIGNETTEBLENDMODEOPAQUE: boolean;
  48091. TONEMAPPING: boolean;
  48092. TONEMAPPING_ACES: boolean;
  48093. CONTRAST: boolean;
  48094. COLORCURVES: boolean;
  48095. COLORGRADING: boolean;
  48096. COLORGRADING3D: boolean;
  48097. SAMPLER3DGREENDEPTH: boolean;
  48098. SAMPLER3DBGRMAP: boolean;
  48099. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48100. EXPOSURE: boolean;
  48101. MULTIVIEW: boolean;
  48102. USEPHYSICALLIGHTFALLOFF: boolean;
  48103. USEGLTFLIGHTFALLOFF: boolean;
  48104. TWOSIDEDLIGHTING: boolean;
  48105. SHADOWFLOAT: boolean;
  48106. CLIPPLANE: boolean;
  48107. CLIPPLANE2: boolean;
  48108. CLIPPLANE3: boolean;
  48109. CLIPPLANE4: boolean;
  48110. POINTSIZE: boolean;
  48111. FOG: boolean;
  48112. LOGARITHMICDEPTH: boolean;
  48113. FORCENORMALFORWARD: boolean;
  48114. SPECULARAA: boolean;
  48115. CLEARCOAT: boolean;
  48116. CLEARCOAT_DEFAULTIOR: boolean;
  48117. CLEARCOAT_TEXTURE: boolean;
  48118. CLEARCOAT_TEXTUREDIRECTUV: number;
  48119. CLEARCOAT_BUMP: boolean;
  48120. CLEARCOAT_BUMPDIRECTUV: number;
  48121. CLEARCOAT_TINT: boolean;
  48122. CLEARCOAT_TINT_TEXTURE: boolean;
  48123. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48124. ANISOTROPIC: boolean;
  48125. ANISOTROPIC_TEXTURE: boolean;
  48126. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48127. BRDF_V_HEIGHT_CORRELATED: boolean;
  48128. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48129. SHEEN: boolean;
  48130. SHEEN_TEXTURE: boolean;
  48131. SHEEN_TEXTUREDIRECTUV: number;
  48132. SHEEN_LINKWITHALBEDO: boolean;
  48133. SUBSURFACE: boolean;
  48134. SS_REFRACTION: boolean;
  48135. SS_TRANSLUCENCY: boolean;
  48136. SS_SCATERRING: boolean;
  48137. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48138. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48139. SS_REFRACTIONMAP_3D: boolean;
  48140. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48141. SS_LODINREFRACTIONALPHA: boolean;
  48142. SS_GAMMAREFRACTION: boolean;
  48143. SS_RGBDREFRACTION: boolean;
  48144. SS_LINEARSPECULARREFRACTION: boolean;
  48145. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48146. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48147. UNLIT: boolean;
  48148. DEBUGMODE: number;
  48149. /**
  48150. * Initializes the PBR Material defines.
  48151. */
  48152. constructor();
  48153. /**
  48154. * Resets the PBR Material defines.
  48155. */
  48156. reset(): void;
  48157. }
  48158. /**
  48159. * The Physically based material base class of BJS.
  48160. *
  48161. * This offers the main features of a standard PBR material.
  48162. * For more information, please refer to the documentation :
  48163. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48164. */
  48165. export abstract class PBRBaseMaterial extends PushMaterial {
  48166. /**
  48167. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48168. */
  48169. static readonly PBRMATERIAL_OPAQUE: number;
  48170. /**
  48171. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48172. */
  48173. static readonly PBRMATERIAL_ALPHATEST: number;
  48174. /**
  48175. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48176. */
  48177. static readonly PBRMATERIAL_ALPHABLEND: number;
  48178. /**
  48179. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48180. * They are also discarded below the alpha cutoff threshold to improve performances.
  48181. */
  48182. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48183. /**
  48184. * Defines the default value of how much AO map is occluding the analytical lights
  48185. * (point spot...).
  48186. */
  48187. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48188. /**
  48189. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48190. */
  48191. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48192. /**
  48193. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48194. * to enhance interoperability with other engines.
  48195. */
  48196. static readonly LIGHTFALLOFF_GLTF: number;
  48197. /**
  48198. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48199. * to enhance interoperability with other materials.
  48200. */
  48201. static readonly LIGHTFALLOFF_STANDARD: number;
  48202. /**
  48203. * Intensity of the direct lights e.g. the four lights available in your scene.
  48204. * This impacts both the direct diffuse and specular highlights.
  48205. */
  48206. protected _directIntensity: number;
  48207. /**
  48208. * Intensity of the emissive part of the material.
  48209. * This helps controlling the emissive effect without modifying the emissive color.
  48210. */
  48211. protected _emissiveIntensity: number;
  48212. /**
  48213. * Intensity of the environment e.g. how much the environment will light the object
  48214. * either through harmonics for rough material or through the refelction for shiny ones.
  48215. */
  48216. protected _environmentIntensity: number;
  48217. /**
  48218. * This is a special control allowing the reduction of the specular highlights coming from the
  48219. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48220. */
  48221. protected _specularIntensity: number;
  48222. /**
  48223. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48224. */
  48225. private _lightingInfos;
  48226. /**
  48227. * Debug Control allowing disabling the bump map on this material.
  48228. */
  48229. protected _disableBumpMap: boolean;
  48230. /**
  48231. * AKA Diffuse Texture in standard nomenclature.
  48232. */
  48233. protected _albedoTexture: Nullable<BaseTexture>;
  48234. /**
  48235. * AKA Occlusion Texture in other nomenclature.
  48236. */
  48237. protected _ambientTexture: Nullable<BaseTexture>;
  48238. /**
  48239. * AKA Occlusion Texture Intensity in other nomenclature.
  48240. */
  48241. protected _ambientTextureStrength: number;
  48242. /**
  48243. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48244. * 1 means it completely occludes it
  48245. * 0 mean it has no impact
  48246. */
  48247. protected _ambientTextureImpactOnAnalyticalLights: number;
  48248. /**
  48249. * Stores the alpha values in a texture.
  48250. */
  48251. protected _opacityTexture: Nullable<BaseTexture>;
  48252. /**
  48253. * Stores the reflection values in a texture.
  48254. */
  48255. protected _reflectionTexture: Nullable<BaseTexture>;
  48256. /**
  48257. * Stores the emissive values in a texture.
  48258. */
  48259. protected _emissiveTexture: Nullable<BaseTexture>;
  48260. /**
  48261. * AKA Specular texture in other nomenclature.
  48262. */
  48263. protected _reflectivityTexture: Nullable<BaseTexture>;
  48264. /**
  48265. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48266. */
  48267. protected _metallicTexture: Nullable<BaseTexture>;
  48268. /**
  48269. * Specifies the metallic scalar of the metallic/roughness workflow.
  48270. * Can also be used to scale the metalness values of the metallic texture.
  48271. */
  48272. protected _metallic: Nullable<number>;
  48273. /**
  48274. * Specifies the roughness scalar of the metallic/roughness workflow.
  48275. * Can also be used to scale the roughness values of the metallic texture.
  48276. */
  48277. protected _roughness: Nullable<number>;
  48278. /**
  48279. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48280. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48281. */
  48282. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48283. /**
  48284. * Stores surface normal data used to displace a mesh in a texture.
  48285. */
  48286. protected _bumpTexture: Nullable<BaseTexture>;
  48287. /**
  48288. * Stores the pre-calculated light information of a mesh in a texture.
  48289. */
  48290. protected _lightmapTexture: Nullable<BaseTexture>;
  48291. /**
  48292. * The color of a material in ambient lighting.
  48293. */
  48294. protected _ambientColor: Color3;
  48295. /**
  48296. * AKA Diffuse Color in other nomenclature.
  48297. */
  48298. protected _albedoColor: Color3;
  48299. /**
  48300. * AKA Specular Color in other nomenclature.
  48301. */
  48302. protected _reflectivityColor: Color3;
  48303. /**
  48304. * The color applied when light is reflected from a material.
  48305. */
  48306. protected _reflectionColor: Color3;
  48307. /**
  48308. * The color applied when light is emitted from a material.
  48309. */
  48310. protected _emissiveColor: Color3;
  48311. /**
  48312. * AKA Glossiness in other nomenclature.
  48313. */
  48314. protected _microSurface: number;
  48315. /**
  48316. * Specifies that the material will use the light map as a show map.
  48317. */
  48318. protected _useLightmapAsShadowmap: boolean;
  48319. /**
  48320. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48321. * makes the reflect vector face the model (under horizon).
  48322. */
  48323. protected _useHorizonOcclusion: boolean;
  48324. /**
  48325. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48326. * too much the area relying on ambient texture to define their ambient occlusion.
  48327. */
  48328. protected _useRadianceOcclusion: boolean;
  48329. /**
  48330. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48331. */
  48332. protected _useAlphaFromAlbedoTexture: boolean;
  48333. /**
  48334. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48335. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48336. */
  48337. protected _useSpecularOverAlpha: boolean;
  48338. /**
  48339. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48340. */
  48341. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48342. /**
  48343. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48344. */
  48345. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48346. /**
  48347. * Specifies if the metallic texture contains the roughness information in its green channel.
  48348. */
  48349. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48350. /**
  48351. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48352. */
  48353. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48354. /**
  48355. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48356. */
  48357. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48358. /**
  48359. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48360. */
  48361. protected _useAmbientInGrayScale: boolean;
  48362. /**
  48363. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48364. * The material will try to infer what glossiness each pixel should be.
  48365. */
  48366. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48367. /**
  48368. * Defines the falloff type used in this material.
  48369. * It by default is Physical.
  48370. */
  48371. protected _lightFalloff: number;
  48372. /**
  48373. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48374. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48375. */
  48376. protected _useRadianceOverAlpha: boolean;
  48377. /**
  48378. * Allows using an object space normal map (instead of tangent space).
  48379. */
  48380. protected _useObjectSpaceNormalMap: boolean;
  48381. /**
  48382. * Allows using the bump map in parallax mode.
  48383. */
  48384. protected _useParallax: boolean;
  48385. /**
  48386. * Allows using the bump map in parallax occlusion mode.
  48387. */
  48388. protected _useParallaxOcclusion: boolean;
  48389. /**
  48390. * Controls the scale bias of the parallax mode.
  48391. */
  48392. protected _parallaxScaleBias: number;
  48393. /**
  48394. * If sets to true, disables all the lights affecting the material.
  48395. */
  48396. protected _disableLighting: boolean;
  48397. /**
  48398. * Number of Simultaneous lights allowed on the material.
  48399. */
  48400. protected _maxSimultaneousLights: number;
  48401. /**
  48402. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48403. */
  48404. protected _invertNormalMapX: boolean;
  48405. /**
  48406. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48407. */
  48408. protected _invertNormalMapY: boolean;
  48409. /**
  48410. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48411. */
  48412. protected _twoSidedLighting: boolean;
  48413. /**
  48414. * Defines the alpha limits in alpha test mode.
  48415. */
  48416. protected _alphaCutOff: number;
  48417. /**
  48418. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48419. */
  48420. protected _forceAlphaTest: boolean;
  48421. /**
  48422. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48423. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48424. */
  48425. protected _useAlphaFresnel: boolean;
  48426. /**
  48427. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48428. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48429. */
  48430. protected _useLinearAlphaFresnel: boolean;
  48431. /**
  48432. * The transparency mode of the material.
  48433. */
  48434. protected _transparencyMode: Nullable<number>;
  48435. /**
  48436. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48437. * from cos thetav and roughness:
  48438. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48439. */
  48440. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48441. /**
  48442. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48443. */
  48444. protected _forceIrradianceInFragment: boolean;
  48445. /**
  48446. * Force normal to face away from face.
  48447. */
  48448. protected _forceNormalForward: boolean;
  48449. /**
  48450. * Enables specular anti aliasing in the PBR shader.
  48451. * It will both interacts on the Geometry for analytical and IBL lighting.
  48452. * It also prefilter the roughness map based on the bump values.
  48453. */
  48454. protected _enableSpecularAntiAliasing: boolean;
  48455. /**
  48456. * Default configuration related to image processing available in the PBR Material.
  48457. */
  48458. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48459. /**
  48460. * Keep track of the image processing observer to allow dispose and replace.
  48461. */
  48462. private _imageProcessingObserver;
  48463. /**
  48464. * Attaches a new image processing configuration to the PBR Material.
  48465. * @param configuration
  48466. */
  48467. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48468. /**
  48469. * Stores the available render targets.
  48470. */
  48471. private _renderTargets;
  48472. /**
  48473. * Sets the global ambient color for the material used in lighting calculations.
  48474. */
  48475. private _globalAmbientColor;
  48476. /**
  48477. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48478. */
  48479. private _useLogarithmicDepth;
  48480. /**
  48481. * If set to true, no lighting calculations will be applied.
  48482. */
  48483. private _unlit;
  48484. private _debugMode;
  48485. /**
  48486. * @hidden
  48487. * This is reserved for the inspector.
  48488. * Defines the material debug mode.
  48489. * It helps seeing only some components of the material while troubleshooting.
  48490. */
  48491. debugMode: number;
  48492. /**
  48493. * @hidden
  48494. * This is reserved for the inspector.
  48495. * Specify from where on screen the debug mode should start.
  48496. * The value goes from -1 (full screen) to 1 (not visible)
  48497. * It helps with side by side comparison against the final render
  48498. * This defaults to -1
  48499. */
  48500. private debugLimit;
  48501. /**
  48502. * @hidden
  48503. * This is reserved for the inspector.
  48504. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48505. * You can use the factor to better multiply the final value.
  48506. */
  48507. private debugFactor;
  48508. /**
  48509. * Defines the clear coat layer parameters for the material.
  48510. */
  48511. readonly clearCoat: PBRClearCoatConfiguration;
  48512. /**
  48513. * Defines the anisotropic parameters for the material.
  48514. */
  48515. readonly anisotropy: PBRAnisotropicConfiguration;
  48516. /**
  48517. * Defines the BRDF parameters for the material.
  48518. */
  48519. readonly brdf: PBRBRDFConfiguration;
  48520. /**
  48521. * Defines the Sheen parameters for the material.
  48522. */
  48523. readonly sheen: PBRSheenConfiguration;
  48524. /**
  48525. * Defines the SubSurface parameters for the material.
  48526. */
  48527. readonly subSurface: PBRSubSurfaceConfiguration;
  48528. /**
  48529. * Custom callback helping to override the default shader used in the material.
  48530. */
  48531. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48532. /**
  48533. * Instantiates a new PBRMaterial instance.
  48534. *
  48535. * @param name The material name
  48536. * @param scene The scene the material will be use in.
  48537. */
  48538. constructor(name: string, scene: Scene);
  48539. /**
  48540. * Gets a boolean indicating that current material needs to register RTT
  48541. */
  48542. readonly hasRenderTargetTextures: boolean;
  48543. /**
  48544. * Gets the name of the material class.
  48545. */
  48546. getClassName(): string;
  48547. /**
  48548. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48549. */
  48550. /**
  48551. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48552. */
  48553. useLogarithmicDepth: boolean;
  48554. /**
  48555. * Gets the current transparency mode.
  48556. */
  48557. /**
  48558. * Sets the transparency mode of the material.
  48559. *
  48560. * | Value | Type | Description |
  48561. * | ----- | ----------------------------------- | ----------- |
  48562. * | 0 | OPAQUE | |
  48563. * | 1 | ALPHATEST | |
  48564. * | 2 | ALPHABLEND | |
  48565. * | 3 | ALPHATESTANDBLEND | |
  48566. *
  48567. */
  48568. transparencyMode: Nullable<number>;
  48569. /**
  48570. * Returns true if alpha blending should be disabled.
  48571. */
  48572. private readonly _disableAlphaBlending;
  48573. /**
  48574. * Specifies whether or not this material should be rendered in alpha blend mode.
  48575. */
  48576. needAlphaBlending(): boolean;
  48577. /**
  48578. * Specifies if the mesh will require alpha blending.
  48579. * @param mesh - BJS mesh.
  48580. */
  48581. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48582. /**
  48583. * Specifies whether or not this material should be rendered in alpha test mode.
  48584. */
  48585. needAlphaTesting(): boolean;
  48586. /**
  48587. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48588. */
  48589. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48590. /**
  48591. * Gets the texture used for the alpha test.
  48592. */
  48593. getAlphaTestTexture(): Nullable<BaseTexture>;
  48594. /**
  48595. * Specifies that the submesh is ready to be used.
  48596. * @param mesh - BJS mesh.
  48597. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48598. * @param useInstances - Specifies that instances should be used.
  48599. * @returns - boolean indicating that the submesh is ready or not.
  48600. */
  48601. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48602. /**
  48603. * Specifies if the material uses metallic roughness workflow.
  48604. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48605. */
  48606. isMetallicWorkflow(): boolean;
  48607. private _prepareEffect;
  48608. private _prepareDefines;
  48609. /**
  48610. * Force shader compilation
  48611. */
  48612. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48613. clipPlane: boolean;
  48614. }>): void;
  48615. /**
  48616. * Initializes the uniform buffer layout for the shader.
  48617. */
  48618. buildUniformLayout(): void;
  48619. /**
  48620. * Unbinds the material from the mesh
  48621. */
  48622. unbind(): void;
  48623. /**
  48624. * Binds the submesh data.
  48625. * @param world - The world matrix.
  48626. * @param mesh - The BJS mesh.
  48627. * @param subMesh - A submesh of the BJS mesh.
  48628. */
  48629. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48630. /**
  48631. * Returns the animatable textures.
  48632. * @returns - Array of animatable textures.
  48633. */
  48634. getAnimatables(): IAnimatable[];
  48635. /**
  48636. * Returns the texture used for reflections.
  48637. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48638. */
  48639. private _getReflectionTexture;
  48640. /**
  48641. * Returns an array of the actively used textures.
  48642. * @returns - Array of BaseTextures
  48643. */
  48644. getActiveTextures(): BaseTexture[];
  48645. /**
  48646. * Checks to see if a texture is used in the material.
  48647. * @param texture - Base texture to use.
  48648. * @returns - Boolean specifying if a texture is used in the material.
  48649. */
  48650. hasTexture(texture: BaseTexture): boolean;
  48651. /**
  48652. * Disposes the resources of the material.
  48653. * @param forceDisposeEffect - Forces the disposal of effects.
  48654. * @param forceDisposeTextures - Forces the disposal of all textures.
  48655. */
  48656. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48657. }
  48658. }
  48659. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48660. import { Nullable } from "babylonjs/types";
  48661. import { Scene } from "babylonjs/scene";
  48662. import { Color3 } from "babylonjs/Maths/math.color";
  48663. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48664. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48665. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48666. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48667. /**
  48668. * The Physically based material of BJS.
  48669. *
  48670. * This offers the main features of a standard PBR material.
  48671. * For more information, please refer to the documentation :
  48672. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48673. */
  48674. export class PBRMaterial extends PBRBaseMaterial {
  48675. /**
  48676. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48677. */
  48678. static readonly PBRMATERIAL_OPAQUE: number;
  48679. /**
  48680. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48681. */
  48682. static readonly PBRMATERIAL_ALPHATEST: number;
  48683. /**
  48684. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48685. */
  48686. static readonly PBRMATERIAL_ALPHABLEND: number;
  48687. /**
  48688. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48689. * They are also discarded below the alpha cutoff threshold to improve performances.
  48690. */
  48691. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48692. /**
  48693. * Defines the default value of how much AO map is occluding the analytical lights
  48694. * (point spot...).
  48695. */
  48696. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48697. /**
  48698. * Intensity of the direct lights e.g. the four lights available in your scene.
  48699. * This impacts both the direct diffuse and specular highlights.
  48700. */
  48701. directIntensity: number;
  48702. /**
  48703. * Intensity of the emissive part of the material.
  48704. * This helps controlling the emissive effect without modifying the emissive color.
  48705. */
  48706. emissiveIntensity: number;
  48707. /**
  48708. * Intensity of the environment e.g. how much the environment will light the object
  48709. * either through harmonics for rough material or through the refelction for shiny ones.
  48710. */
  48711. environmentIntensity: number;
  48712. /**
  48713. * This is a special control allowing the reduction of the specular highlights coming from the
  48714. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48715. */
  48716. specularIntensity: number;
  48717. /**
  48718. * Debug Control allowing disabling the bump map on this material.
  48719. */
  48720. disableBumpMap: boolean;
  48721. /**
  48722. * AKA Diffuse Texture in standard nomenclature.
  48723. */
  48724. albedoTexture: BaseTexture;
  48725. /**
  48726. * AKA Occlusion Texture in other nomenclature.
  48727. */
  48728. ambientTexture: BaseTexture;
  48729. /**
  48730. * AKA Occlusion Texture Intensity in other nomenclature.
  48731. */
  48732. ambientTextureStrength: number;
  48733. /**
  48734. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48735. * 1 means it completely occludes it
  48736. * 0 mean it has no impact
  48737. */
  48738. ambientTextureImpactOnAnalyticalLights: number;
  48739. /**
  48740. * Stores the alpha values in a texture.
  48741. */
  48742. opacityTexture: BaseTexture;
  48743. /**
  48744. * Stores the reflection values in a texture.
  48745. */
  48746. reflectionTexture: Nullable<BaseTexture>;
  48747. /**
  48748. * Stores the emissive values in a texture.
  48749. */
  48750. emissiveTexture: BaseTexture;
  48751. /**
  48752. * AKA Specular texture in other nomenclature.
  48753. */
  48754. reflectivityTexture: BaseTexture;
  48755. /**
  48756. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48757. */
  48758. metallicTexture: BaseTexture;
  48759. /**
  48760. * Specifies the metallic scalar of the metallic/roughness workflow.
  48761. * Can also be used to scale the metalness values of the metallic texture.
  48762. */
  48763. metallic: Nullable<number>;
  48764. /**
  48765. * Specifies the roughness scalar of the metallic/roughness workflow.
  48766. * Can also be used to scale the roughness values of the metallic texture.
  48767. */
  48768. roughness: Nullable<number>;
  48769. /**
  48770. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48771. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48772. */
  48773. microSurfaceTexture: BaseTexture;
  48774. /**
  48775. * Stores surface normal data used to displace a mesh in a texture.
  48776. */
  48777. bumpTexture: BaseTexture;
  48778. /**
  48779. * Stores the pre-calculated light information of a mesh in a texture.
  48780. */
  48781. lightmapTexture: BaseTexture;
  48782. /**
  48783. * Stores the refracted light information in a texture.
  48784. */
  48785. refractionTexture: Nullable<BaseTexture>;
  48786. /**
  48787. * The color of a material in ambient lighting.
  48788. */
  48789. ambientColor: Color3;
  48790. /**
  48791. * AKA Diffuse Color in other nomenclature.
  48792. */
  48793. albedoColor: Color3;
  48794. /**
  48795. * AKA Specular Color in other nomenclature.
  48796. */
  48797. reflectivityColor: Color3;
  48798. /**
  48799. * The color reflected from the material.
  48800. */
  48801. reflectionColor: Color3;
  48802. /**
  48803. * The color emitted from the material.
  48804. */
  48805. emissiveColor: Color3;
  48806. /**
  48807. * AKA Glossiness in other nomenclature.
  48808. */
  48809. microSurface: number;
  48810. /**
  48811. * source material index of refraction (IOR)' / 'destination material IOR.
  48812. */
  48813. indexOfRefraction: number;
  48814. /**
  48815. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48816. */
  48817. invertRefractionY: boolean;
  48818. /**
  48819. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48820. * Materials half opaque for instance using refraction could benefit from this control.
  48821. */
  48822. linkRefractionWithTransparency: boolean;
  48823. /**
  48824. * If true, the light map contains occlusion information instead of lighting info.
  48825. */
  48826. useLightmapAsShadowmap: boolean;
  48827. /**
  48828. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48829. */
  48830. useAlphaFromAlbedoTexture: boolean;
  48831. /**
  48832. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48833. */
  48834. forceAlphaTest: boolean;
  48835. /**
  48836. * Defines the alpha limits in alpha test mode.
  48837. */
  48838. alphaCutOff: number;
  48839. /**
  48840. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48841. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48842. */
  48843. useSpecularOverAlpha: boolean;
  48844. /**
  48845. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48846. */
  48847. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48848. /**
  48849. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48850. */
  48851. useRoughnessFromMetallicTextureAlpha: boolean;
  48852. /**
  48853. * Specifies if the metallic texture contains the roughness information in its green channel.
  48854. */
  48855. useRoughnessFromMetallicTextureGreen: boolean;
  48856. /**
  48857. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48858. */
  48859. useMetallnessFromMetallicTextureBlue: boolean;
  48860. /**
  48861. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48862. */
  48863. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48864. /**
  48865. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48866. */
  48867. useAmbientInGrayScale: boolean;
  48868. /**
  48869. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48870. * The material will try to infer what glossiness each pixel should be.
  48871. */
  48872. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48873. /**
  48874. * BJS is using an harcoded light falloff based on a manually sets up range.
  48875. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48876. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48877. */
  48878. /**
  48879. * BJS is using an harcoded light falloff based on a manually sets up range.
  48880. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48881. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48882. */
  48883. usePhysicalLightFalloff: boolean;
  48884. /**
  48885. * In order to support the falloff compatibility with gltf, a special mode has been added
  48886. * to reproduce the gltf light falloff.
  48887. */
  48888. /**
  48889. * In order to support the falloff compatibility with gltf, a special mode has been added
  48890. * to reproduce the gltf light falloff.
  48891. */
  48892. useGLTFLightFalloff: boolean;
  48893. /**
  48894. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48895. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48896. */
  48897. useRadianceOverAlpha: boolean;
  48898. /**
  48899. * Allows using an object space normal map (instead of tangent space).
  48900. */
  48901. useObjectSpaceNormalMap: boolean;
  48902. /**
  48903. * Allows using the bump map in parallax mode.
  48904. */
  48905. useParallax: boolean;
  48906. /**
  48907. * Allows using the bump map in parallax occlusion mode.
  48908. */
  48909. useParallaxOcclusion: boolean;
  48910. /**
  48911. * Controls the scale bias of the parallax mode.
  48912. */
  48913. parallaxScaleBias: number;
  48914. /**
  48915. * If sets to true, disables all the lights affecting the material.
  48916. */
  48917. disableLighting: boolean;
  48918. /**
  48919. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48920. */
  48921. forceIrradianceInFragment: boolean;
  48922. /**
  48923. * Number of Simultaneous lights allowed on the material.
  48924. */
  48925. maxSimultaneousLights: number;
  48926. /**
  48927. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48928. */
  48929. invertNormalMapX: boolean;
  48930. /**
  48931. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48932. */
  48933. invertNormalMapY: boolean;
  48934. /**
  48935. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48936. */
  48937. twoSidedLighting: boolean;
  48938. /**
  48939. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48940. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48941. */
  48942. useAlphaFresnel: boolean;
  48943. /**
  48944. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48945. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48946. */
  48947. useLinearAlphaFresnel: boolean;
  48948. /**
  48949. * Let user defines the brdf lookup texture used for IBL.
  48950. * A default 8bit version is embedded but you could point at :
  48951. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48952. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48953. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48954. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48955. */
  48956. environmentBRDFTexture: Nullable<BaseTexture>;
  48957. /**
  48958. * Force normal to face away from face.
  48959. */
  48960. forceNormalForward: boolean;
  48961. /**
  48962. * Enables specular anti aliasing in the PBR shader.
  48963. * It will both interacts on the Geometry for analytical and IBL lighting.
  48964. * It also prefilter the roughness map based on the bump values.
  48965. */
  48966. enableSpecularAntiAliasing: boolean;
  48967. /**
  48968. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48969. * makes the reflect vector face the model (under horizon).
  48970. */
  48971. useHorizonOcclusion: boolean;
  48972. /**
  48973. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48974. * too much the area relying on ambient texture to define their ambient occlusion.
  48975. */
  48976. useRadianceOcclusion: boolean;
  48977. /**
  48978. * If set to true, no lighting calculations will be applied.
  48979. */
  48980. unlit: boolean;
  48981. /**
  48982. * Gets the image processing configuration used either in this material.
  48983. */
  48984. /**
  48985. * Sets the Default image processing configuration used either in the this material.
  48986. *
  48987. * If sets to null, the scene one is in use.
  48988. */
  48989. imageProcessingConfiguration: ImageProcessingConfiguration;
  48990. /**
  48991. * Gets wether the color curves effect is enabled.
  48992. */
  48993. /**
  48994. * Sets wether the color curves effect is enabled.
  48995. */
  48996. cameraColorCurvesEnabled: boolean;
  48997. /**
  48998. * Gets wether the color grading effect is enabled.
  48999. */
  49000. /**
  49001. * Gets wether the color grading effect is enabled.
  49002. */
  49003. cameraColorGradingEnabled: boolean;
  49004. /**
  49005. * Gets wether tonemapping is enabled or not.
  49006. */
  49007. /**
  49008. * Sets wether tonemapping is enabled or not
  49009. */
  49010. cameraToneMappingEnabled: boolean;
  49011. /**
  49012. * The camera exposure used on this material.
  49013. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49014. * This corresponds to a photographic exposure.
  49015. */
  49016. /**
  49017. * The camera exposure used on this material.
  49018. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49019. * This corresponds to a photographic exposure.
  49020. */
  49021. cameraExposure: number;
  49022. /**
  49023. * Gets The camera contrast used on this material.
  49024. */
  49025. /**
  49026. * Sets The camera contrast used on this material.
  49027. */
  49028. cameraContrast: number;
  49029. /**
  49030. * Gets the Color Grading 2D Lookup Texture.
  49031. */
  49032. /**
  49033. * Sets the Color Grading 2D Lookup Texture.
  49034. */
  49035. cameraColorGradingTexture: Nullable<BaseTexture>;
  49036. /**
  49037. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49038. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49039. * 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;
  49040. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49041. */
  49042. /**
  49043. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49044. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49045. * 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;
  49046. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49047. */
  49048. cameraColorCurves: Nullable<ColorCurves>;
  49049. /**
  49050. * Instantiates a new PBRMaterial instance.
  49051. *
  49052. * @param name The material name
  49053. * @param scene The scene the material will be use in.
  49054. */
  49055. constructor(name: string, scene: Scene);
  49056. /**
  49057. * Returns the name of this material class.
  49058. */
  49059. getClassName(): string;
  49060. /**
  49061. * Makes a duplicate of the current material.
  49062. * @param name - name to use for the new material.
  49063. */
  49064. clone(name: string): PBRMaterial;
  49065. /**
  49066. * Serializes this PBR Material.
  49067. * @returns - An object with the serialized material.
  49068. */
  49069. serialize(): any;
  49070. /**
  49071. * Parses a PBR Material from a serialized object.
  49072. * @param source - Serialized object.
  49073. * @param scene - BJS scene instance.
  49074. * @param rootUrl - url for the scene object
  49075. * @returns - PBRMaterial
  49076. */
  49077. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49078. }
  49079. }
  49080. declare module "babylonjs/Misc/dds" {
  49081. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49082. import { Engine } from "babylonjs/Engines/engine";
  49083. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49084. import { Nullable } from "babylonjs/types";
  49085. import { Scene } from "babylonjs/scene";
  49086. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49087. /**
  49088. * Direct draw surface info
  49089. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49090. */
  49091. export interface DDSInfo {
  49092. /**
  49093. * Width of the texture
  49094. */
  49095. width: number;
  49096. /**
  49097. * Width of the texture
  49098. */
  49099. height: number;
  49100. /**
  49101. * Number of Mipmaps for the texture
  49102. * @see https://en.wikipedia.org/wiki/Mipmap
  49103. */
  49104. mipmapCount: number;
  49105. /**
  49106. * If the textures format is a known fourCC format
  49107. * @see https://www.fourcc.org/
  49108. */
  49109. isFourCC: boolean;
  49110. /**
  49111. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49112. */
  49113. isRGB: boolean;
  49114. /**
  49115. * If the texture is a lumincance format
  49116. */
  49117. isLuminance: boolean;
  49118. /**
  49119. * If this is a cube texture
  49120. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49121. */
  49122. isCube: boolean;
  49123. /**
  49124. * If the texture is a compressed format eg. FOURCC_DXT1
  49125. */
  49126. isCompressed: boolean;
  49127. /**
  49128. * The dxgiFormat of the texture
  49129. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49130. */
  49131. dxgiFormat: number;
  49132. /**
  49133. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49134. */
  49135. textureType: number;
  49136. /**
  49137. * Sphericle polynomial created for the dds texture
  49138. */
  49139. sphericalPolynomial?: SphericalPolynomial;
  49140. }
  49141. /**
  49142. * Class used to provide DDS decompression tools
  49143. */
  49144. export class DDSTools {
  49145. /**
  49146. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49147. */
  49148. static StoreLODInAlphaChannel: boolean;
  49149. /**
  49150. * Gets DDS information from an array buffer
  49151. * @param arrayBuffer defines the array buffer to read data from
  49152. * @returns the DDS information
  49153. */
  49154. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49155. private static _FloatView;
  49156. private static _Int32View;
  49157. private static _ToHalfFloat;
  49158. private static _FromHalfFloat;
  49159. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49160. private static _GetHalfFloatRGBAArrayBuffer;
  49161. private static _GetFloatRGBAArrayBuffer;
  49162. private static _GetFloatAsUIntRGBAArrayBuffer;
  49163. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49164. private static _GetRGBAArrayBuffer;
  49165. private static _ExtractLongWordOrder;
  49166. private static _GetRGBArrayBuffer;
  49167. private static _GetLuminanceArrayBuffer;
  49168. /**
  49169. * Uploads DDS Levels to a Babylon Texture
  49170. * @hidden
  49171. */
  49172. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49173. }
  49174. module "babylonjs/Engines/engine" {
  49175. interface Engine {
  49176. /**
  49177. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49178. * @param rootUrl defines the url where the file to load is located
  49179. * @param scene defines the current scene
  49180. * @param lodScale defines scale to apply to the mip map selection
  49181. * @param lodOffset defines offset to apply to the mip map selection
  49182. * @param onLoad defines an optional callback raised when the texture is loaded
  49183. * @param onError defines an optional callback raised if there is an issue to load the texture
  49184. * @param format defines the format of the data
  49185. * @param forcedExtension defines the extension to use to pick the right loader
  49186. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49187. * @returns the cube texture as an InternalTexture
  49188. */
  49189. 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;
  49190. }
  49191. }
  49192. }
  49193. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49194. import { Nullable } from "babylonjs/types";
  49195. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49196. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49197. /**
  49198. * Implementation of the DDS Texture Loader.
  49199. * @hidden
  49200. */
  49201. export class _DDSTextureLoader implements IInternalTextureLoader {
  49202. /**
  49203. * Defines wether the loader supports cascade loading the different faces.
  49204. */
  49205. readonly supportCascades: boolean;
  49206. /**
  49207. * This returns if the loader support the current file information.
  49208. * @param extension defines the file extension of the file being loaded
  49209. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49210. * @param fallback defines the fallback internal texture if any
  49211. * @param isBase64 defines whether the texture is encoded as a base64
  49212. * @param isBuffer defines whether the texture data are stored as a buffer
  49213. * @returns true if the loader can load the specified file
  49214. */
  49215. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49216. /**
  49217. * Transform the url before loading if required.
  49218. * @param rootUrl the url of the texture
  49219. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49220. * @returns the transformed texture
  49221. */
  49222. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49223. /**
  49224. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49225. * @param rootUrl the url of the texture
  49226. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49227. * @returns the fallback texture
  49228. */
  49229. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49230. /**
  49231. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49232. * @param data contains the texture data
  49233. * @param texture defines the BabylonJS internal texture
  49234. * @param createPolynomials will be true if polynomials have been requested
  49235. * @param onLoad defines the callback to trigger once the texture is ready
  49236. * @param onError defines the callback to trigger in case of error
  49237. */
  49238. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49239. /**
  49240. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49241. * @param data contains the texture data
  49242. * @param texture defines the BabylonJS internal texture
  49243. * @param callback defines the method to call once ready to upload
  49244. */
  49245. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49246. }
  49247. }
  49248. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49249. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49250. /** @hidden */
  49251. export var rgbdEncodePixelShader: {
  49252. name: string;
  49253. shader: string;
  49254. };
  49255. }
  49256. declare module "babylonjs/Misc/environmentTextureTools" {
  49257. import { Nullable } from "babylonjs/types";
  49258. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49260. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49261. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49262. import "babylonjs/Shaders/rgbdEncode.fragment";
  49263. import "babylonjs/Shaders/rgbdDecode.fragment";
  49264. /**
  49265. * Raw texture data and descriptor sufficient for WebGL texture upload
  49266. */
  49267. export interface EnvironmentTextureInfo {
  49268. /**
  49269. * Version of the environment map
  49270. */
  49271. version: number;
  49272. /**
  49273. * Width of image
  49274. */
  49275. width: number;
  49276. /**
  49277. * Irradiance information stored in the file.
  49278. */
  49279. irradiance: any;
  49280. /**
  49281. * Specular information stored in the file.
  49282. */
  49283. specular: any;
  49284. }
  49285. /**
  49286. * Sets of helpers addressing the serialization and deserialization of environment texture
  49287. * stored in a BabylonJS env file.
  49288. * Those files are usually stored as .env files.
  49289. */
  49290. export class EnvironmentTextureTools {
  49291. /**
  49292. * Magic number identifying the env file.
  49293. */
  49294. private static _MagicBytes;
  49295. /**
  49296. * Gets the environment info from an env file.
  49297. * @param data The array buffer containing the .env bytes.
  49298. * @returns the environment file info (the json header) if successfully parsed.
  49299. */
  49300. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49301. /**
  49302. * Creates an environment texture from a loaded cube texture.
  49303. * @param texture defines the cube texture to convert in env file
  49304. * @return a promise containing the environment data if succesfull.
  49305. */
  49306. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49307. /**
  49308. * Creates a JSON representation of the spherical data.
  49309. * @param texture defines the texture containing the polynomials
  49310. * @return the JSON representation of the spherical info
  49311. */
  49312. private static _CreateEnvTextureIrradiance;
  49313. /**
  49314. * Uploads the texture info contained in the env file to the GPU.
  49315. * @param texture defines the internal texture to upload to
  49316. * @param arrayBuffer defines the buffer cotaining the data to load
  49317. * @param info defines the texture info retrieved through the GetEnvInfo method
  49318. * @returns a promise
  49319. */
  49320. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49321. /**
  49322. * Uploads the levels of image data to the GPU.
  49323. * @param texture defines the internal texture to upload to
  49324. * @param imageData defines the array buffer views of image data [mipmap][face]
  49325. * @returns a promise
  49326. */
  49327. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49328. /**
  49329. * Uploads spherical polynomials information to the texture.
  49330. * @param texture defines the texture we are trying to upload the information to
  49331. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49332. */
  49333. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49334. /** @hidden */
  49335. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49336. }
  49337. }
  49338. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49339. import { Nullable } from "babylonjs/types";
  49340. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49341. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49342. /**
  49343. * Implementation of the ENV Texture Loader.
  49344. * @hidden
  49345. */
  49346. export class _ENVTextureLoader implements IInternalTextureLoader {
  49347. /**
  49348. * Defines wether the loader supports cascade loading the different faces.
  49349. */
  49350. readonly supportCascades: boolean;
  49351. /**
  49352. * This returns if the loader support the current file information.
  49353. * @param extension defines the file extension of the file being loaded
  49354. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49355. * @param fallback defines the fallback internal texture if any
  49356. * @param isBase64 defines whether the texture is encoded as a base64
  49357. * @param isBuffer defines whether the texture data are stored as a buffer
  49358. * @returns true if the loader can load the specified file
  49359. */
  49360. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49361. /**
  49362. * Transform the url before loading if required.
  49363. * @param rootUrl the url of the texture
  49364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49365. * @returns the transformed texture
  49366. */
  49367. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49368. /**
  49369. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49370. * @param rootUrl the url of the texture
  49371. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49372. * @returns the fallback texture
  49373. */
  49374. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49375. /**
  49376. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49377. * @param data contains the texture data
  49378. * @param texture defines the BabylonJS internal texture
  49379. * @param createPolynomials will be true if polynomials have been requested
  49380. * @param onLoad defines the callback to trigger once the texture is ready
  49381. * @param onError defines the callback to trigger in case of error
  49382. */
  49383. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49384. /**
  49385. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49386. * @param data contains the texture data
  49387. * @param texture defines the BabylonJS internal texture
  49388. * @param callback defines the method to call once ready to upload
  49389. */
  49390. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49391. }
  49392. }
  49393. declare module "babylonjs/Misc/khronosTextureContainer" {
  49394. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49395. /**
  49396. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49397. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49398. */
  49399. export class KhronosTextureContainer {
  49400. /** contents of the KTX container file */
  49401. arrayBuffer: any;
  49402. private static HEADER_LEN;
  49403. private static COMPRESSED_2D;
  49404. private static COMPRESSED_3D;
  49405. private static TEX_2D;
  49406. private static TEX_3D;
  49407. /**
  49408. * Gets the openGL type
  49409. */
  49410. glType: number;
  49411. /**
  49412. * Gets the openGL type size
  49413. */
  49414. glTypeSize: number;
  49415. /**
  49416. * Gets the openGL format
  49417. */
  49418. glFormat: number;
  49419. /**
  49420. * Gets the openGL internal format
  49421. */
  49422. glInternalFormat: number;
  49423. /**
  49424. * Gets the base internal format
  49425. */
  49426. glBaseInternalFormat: number;
  49427. /**
  49428. * Gets image width in pixel
  49429. */
  49430. pixelWidth: number;
  49431. /**
  49432. * Gets image height in pixel
  49433. */
  49434. pixelHeight: number;
  49435. /**
  49436. * Gets image depth in pixels
  49437. */
  49438. pixelDepth: number;
  49439. /**
  49440. * Gets the number of array elements
  49441. */
  49442. numberOfArrayElements: number;
  49443. /**
  49444. * Gets the number of faces
  49445. */
  49446. numberOfFaces: number;
  49447. /**
  49448. * Gets the number of mipmap levels
  49449. */
  49450. numberOfMipmapLevels: number;
  49451. /**
  49452. * Gets the bytes of key value data
  49453. */
  49454. bytesOfKeyValueData: number;
  49455. /**
  49456. * Gets the load type
  49457. */
  49458. loadType: number;
  49459. /**
  49460. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49461. */
  49462. isInvalid: boolean;
  49463. /**
  49464. * Creates a new KhronosTextureContainer
  49465. * @param arrayBuffer contents of the KTX container file
  49466. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49467. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49468. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49469. */
  49470. constructor(
  49471. /** contents of the KTX container file */
  49472. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49473. /**
  49474. * Uploads KTX content to a Babylon Texture.
  49475. * It is assumed that the texture has already been created & is currently bound
  49476. * @hidden
  49477. */
  49478. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49479. private _upload2DCompressedLevels;
  49480. }
  49481. }
  49482. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49483. import { Nullable } from "babylonjs/types";
  49484. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49485. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49486. /**
  49487. * Implementation of the KTX Texture Loader.
  49488. * @hidden
  49489. */
  49490. export class _KTXTextureLoader implements IInternalTextureLoader {
  49491. /**
  49492. * Defines wether the loader supports cascade loading the different faces.
  49493. */
  49494. readonly supportCascades: boolean;
  49495. /**
  49496. * This returns if the loader support the current file information.
  49497. * @param extension defines the file extension of the file being loaded
  49498. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49499. * @param fallback defines the fallback internal texture if any
  49500. * @param isBase64 defines whether the texture is encoded as a base64
  49501. * @param isBuffer defines whether the texture data are stored as a buffer
  49502. * @returns true if the loader can load the specified file
  49503. */
  49504. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49505. /**
  49506. * Transform the url before loading if required.
  49507. * @param rootUrl the url of the texture
  49508. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49509. * @returns the transformed texture
  49510. */
  49511. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49512. /**
  49513. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49514. * @param rootUrl the url of the texture
  49515. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49516. * @returns the fallback texture
  49517. */
  49518. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49519. /**
  49520. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49521. * @param data contains the texture data
  49522. * @param texture defines the BabylonJS internal texture
  49523. * @param createPolynomials will be true if polynomials have been requested
  49524. * @param onLoad defines the callback to trigger once the texture is ready
  49525. * @param onError defines the callback to trigger in case of error
  49526. */
  49527. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49528. /**
  49529. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49530. * @param data contains the texture data
  49531. * @param texture defines the BabylonJS internal texture
  49532. * @param callback defines the method to call once ready to upload
  49533. */
  49534. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49535. }
  49536. }
  49537. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49538. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49539. import { Scene } from "babylonjs/scene";
  49540. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49541. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49542. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49543. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49544. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49545. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49547. /**
  49548. * Options for the default xr helper
  49549. */
  49550. export class WebXRDefaultExperienceOptions {
  49551. /**
  49552. * Floor meshes that should be used for teleporting
  49553. */
  49554. floorMeshes: Array<AbstractMesh>;
  49555. }
  49556. /**
  49557. * Default experience which provides a similar setup to the previous webVRExperience
  49558. */
  49559. export class WebXRDefaultExperience {
  49560. /**
  49561. * Base experience
  49562. */
  49563. baseExperience: WebXRExperienceHelper;
  49564. /**
  49565. * Input experience extension
  49566. */
  49567. input: WebXRInput;
  49568. /**
  49569. * Loads the controller models
  49570. */
  49571. controllerModelLoader: WebXRControllerModelLoader;
  49572. /**
  49573. * Enables laser pointer and selection
  49574. */
  49575. pointerSelection: WebXRControllerPointerSelection;
  49576. /**
  49577. * Enables teleportation
  49578. */
  49579. teleportation: WebXRControllerTeleportation;
  49580. /**
  49581. * Enables ui for enetering/exiting xr
  49582. */
  49583. enterExitUI: WebXREnterExitUI;
  49584. /**
  49585. * Default output canvas xr should render to
  49586. */
  49587. outputCanvas: WebXRManagedOutputCanvas;
  49588. /**
  49589. * Creates the default xr experience
  49590. * @param scene scene
  49591. * @param options options for basic configuration
  49592. * @returns resulting WebXRDefaultExperience
  49593. */
  49594. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49595. private constructor();
  49596. /**
  49597. * DIsposes of the experience helper
  49598. */
  49599. dispose(): void;
  49600. }
  49601. }
  49602. declare module "babylonjs/Helpers/sceneHelpers" {
  49603. import { Nullable } from "babylonjs/types";
  49604. import { Mesh } from "babylonjs/Meshes/mesh";
  49605. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49606. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49607. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49608. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49609. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49610. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49611. import "babylonjs/Meshes/Builders/boxBuilder";
  49612. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49613. /** @hidden */
  49614. export var _forceSceneHelpersToBundle: boolean;
  49615. module "babylonjs/scene" {
  49616. interface Scene {
  49617. /**
  49618. * Creates a default light for the scene.
  49619. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49620. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49621. */
  49622. createDefaultLight(replace?: boolean): void;
  49623. /**
  49624. * Creates a default camera for the scene.
  49625. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49626. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49627. * @param replace has default false, when true replaces the active camera in the scene
  49628. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49629. */
  49630. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49631. /**
  49632. * Creates a default camera and a default light.
  49633. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49634. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49635. * @param replace has the default false, when true replaces the active camera/light in the scene
  49636. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49637. */
  49638. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49639. /**
  49640. * Creates a new sky box
  49641. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49642. * @param environmentTexture defines the texture to use as environment texture
  49643. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49644. * @param scale defines the overall scale of the skybox
  49645. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49646. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49647. * @returns a new mesh holding the sky box
  49648. */
  49649. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49650. /**
  49651. * Creates a new environment
  49652. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49653. * @param options defines the options you can use to configure the environment
  49654. * @returns the new EnvironmentHelper
  49655. */
  49656. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49657. /**
  49658. * Creates a new VREXperienceHelper
  49659. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49660. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49661. * @returns a new VREXperienceHelper
  49662. */
  49663. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49664. /**
  49665. * Creates a new WebXRDefaultExperience
  49666. * @see http://doc.babylonjs.com/how_to/webxr
  49667. * @param options experience options
  49668. * @returns a promise for a new WebXRDefaultExperience
  49669. */
  49670. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49671. }
  49672. }
  49673. }
  49674. declare module "babylonjs/Helpers/videoDome" {
  49675. import { Scene } from "babylonjs/scene";
  49676. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49677. import { Mesh } from "babylonjs/Meshes/mesh";
  49678. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49679. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49680. import "babylonjs/Meshes/Builders/sphereBuilder";
  49681. /**
  49682. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49683. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49684. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49685. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49686. */
  49687. export class VideoDome extends TransformNode {
  49688. /**
  49689. * Define the video source as a Monoscopic panoramic 360 video.
  49690. */
  49691. static readonly MODE_MONOSCOPIC: number;
  49692. /**
  49693. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49694. */
  49695. static readonly MODE_TOPBOTTOM: number;
  49696. /**
  49697. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49698. */
  49699. static readonly MODE_SIDEBYSIDE: number;
  49700. private _useDirectMapping;
  49701. /**
  49702. * The video texture being displayed on the sphere
  49703. */
  49704. protected _videoTexture: VideoTexture;
  49705. /**
  49706. * Gets the video texture being displayed on the sphere
  49707. */
  49708. readonly videoTexture: VideoTexture;
  49709. /**
  49710. * The skybox material
  49711. */
  49712. protected _material: BackgroundMaterial;
  49713. /**
  49714. * The surface used for the skybox
  49715. */
  49716. protected _mesh: Mesh;
  49717. /**
  49718. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49719. * Also see the options.resolution property.
  49720. */
  49721. fovMultiplier: number;
  49722. private _videoMode;
  49723. /**
  49724. * Gets or set the current video mode for the video. It can be:
  49725. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49726. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49727. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49728. */
  49729. videoMode: number;
  49730. /**
  49731. * Oberserver used in Stereoscopic VR Mode.
  49732. */
  49733. private _onBeforeCameraRenderObserver;
  49734. /**
  49735. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49736. * @param name Element's name, child elements will append suffixes for their own names.
  49737. * @param urlsOrVideo defines the url(s) or the video element to use
  49738. * @param options An object containing optional or exposed sub element properties
  49739. */
  49740. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49741. resolution?: number;
  49742. clickToPlay?: boolean;
  49743. autoPlay?: boolean;
  49744. loop?: boolean;
  49745. size?: number;
  49746. poster?: string;
  49747. faceForward?: boolean;
  49748. useDirectMapping?: boolean;
  49749. }, scene: Scene);
  49750. private _changeVideoMode;
  49751. /**
  49752. * Releases resources associated with this node.
  49753. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49754. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49755. */
  49756. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49757. }
  49758. }
  49759. declare module "babylonjs/Helpers/index" {
  49760. export * from "babylonjs/Helpers/environmentHelper";
  49761. export * from "babylonjs/Helpers/photoDome";
  49762. export * from "babylonjs/Helpers/sceneHelpers";
  49763. export * from "babylonjs/Helpers/videoDome";
  49764. }
  49765. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49766. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49767. import { IDisposable } from "babylonjs/scene";
  49768. import { Engine } from "babylonjs/Engines/engine";
  49769. /**
  49770. * This class can be used to get instrumentation data from a Babylon engine
  49771. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49772. */
  49773. export class EngineInstrumentation implements IDisposable {
  49774. /**
  49775. * Define the instrumented engine.
  49776. */
  49777. engine: Engine;
  49778. private _captureGPUFrameTime;
  49779. private _gpuFrameTimeToken;
  49780. private _gpuFrameTime;
  49781. private _captureShaderCompilationTime;
  49782. private _shaderCompilationTime;
  49783. private _onBeginFrameObserver;
  49784. private _onEndFrameObserver;
  49785. private _onBeforeShaderCompilationObserver;
  49786. private _onAfterShaderCompilationObserver;
  49787. /**
  49788. * Gets the perf counter used for GPU frame time
  49789. */
  49790. readonly gpuFrameTimeCounter: PerfCounter;
  49791. /**
  49792. * Gets the GPU frame time capture status
  49793. */
  49794. /**
  49795. * Enable or disable the GPU frame time capture
  49796. */
  49797. captureGPUFrameTime: boolean;
  49798. /**
  49799. * Gets the perf counter used for shader compilation time
  49800. */
  49801. readonly shaderCompilationTimeCounter: PerfCounter;
  49802. /**
  49803. * Gets the shader compilation time capture status
  49804. */
  49805. /**
  49806. * Enable or disable the shader compilation time capture
  49807. */
  49808. captureShaderCompilationTime: boolean;
  49809. /**
  49810. * Instantiates a new engine instrumentation.
  49811. * This class can be used to get instrumentation data from a Babylon engine
  49812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49813. * @param engine Defines the engine to instrument
  49814. */
  49815. constructor(
  49816. /**
  49817. * Define the instrumented engine.
  49818. */
  49819. engine: Engine);
  49820. /**
  49821. * Dispose and release associated resources.
  49822. */
  49823. dispose(): void;
  49824. }
  49825. }
  49826. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49827. import { Scene, IDisposable } from "babylonjs/scene";
  49828. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49829. /**
  49830. * This class can be used to get instrumentation data from a Babylon engine
  49831. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49832. */
  49833. export class SceneInstrumentation implements IDisposable {
  49834. /**
  49835. * Defines the scene to instrument
  49836. */
  49837. scene: Scene;
  49838. private _captureActiveMeshesEvaluationTime;
  49839. private _activeMeshesEvaluationTime;
  49840. private _captureRenderTargetsRenderTime;
  49841. private _renderTargetsRenderTime;
  49842. private _captureFrameTime;
  49843. private _frameTime;
  49844. private _captureRenderTime;
  49845. private _renderTime;
  49846. private _captureInterFrameTime;
  49847. private _interFrameTime;
  49848. private _captureParticlesRenderTime;
  49849. private _particlesRenderTime;
  49850. private _captureSpritesRenderTime;
  49851. private _spritesRenderTime;
  49852. private _capturePhysicsTime;
  49853. private _physicsTime;
  49854. private _captureAnimationsTime;
  49855. private _animationsTime;
  49856. private _captureCameraRenderTime;
  49857. private _cameraRenderTime;
  49858. private _onBeforeActiveMeshesEvaluationObserver;
  49859. private _onAfterActiveMeshesEvaluationObserver;
  49860. private _onBeforeRenderTargetsRenderObserver;
  49861. private _onAfterRenderTargetsRenderObserver;
  49862. private _onAfterRenderObserver;
  49863. private _onBeforeDrawPhaseObserver;
  49864. private _onAfterDrawPhaseObserver;
  49865. private _onBeforeAnimationsObserver;
  49866. private _onBeforeParticlesRenderingObserver;
  49867. private _onAfterParticlesRenderingObserver;
  49868. private _onBeforeSpritesRenderingObserver;
  49869. private _onAfterSpritesRenderingObserver;
  49870. private _onBeforePhysicsObserver;
  49871. private _onAfterPhysicsObserver;
  49872. private _onAfterAnimationsObserver;
  49873. private _onBeforeCameraRenderObserver;
  49874. private _onAfterCameraRenderObserver;
  49875. /**
  49876. * Gets the perf counter used for active meshes evaluation time
  49877. */
  49878. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49879. /**
  49880. * Gets the active meshes evaluation time capture status
  49881. */
  49882. /**
  49883. * Enable or disable the active meshes evaluation time capture
  49884. */
  49885. captureActiveMeshesEvaluationTime: boolean;
  49886. /**
  49887. * Gets the perf counter used for render targets render time
  49888. */
  49889. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49890. /**
  49891. * Gets the render targets render time capture status
  49892. */
  49893. /**
  49894. * Enable or disable the render targets render time capture
  49895. */
  49896. captureRenderTargetsRenderTime: boolean;
  49897. /**
  49898. * Gets the perf counter used for particles render time
  49899. */
  49900. readonly particlesRenderTimeCounter: PerfCounter;
  49901. /**
  49902. * Gets the particles render time capture status
  49903. */
  49904. /**
  49905. * Enable or disable the particles render time capture
  49906. */
  49907. captureParticlesRenderTime: boolean;
  49908. /**
  49909. * Gets the perf counter used for sprites render time
  49910. */
  49911. readonly spritesRenderTimeCounter: PerfCounter;
  49912. /**
  49913. * Gets the sprites render time capture status
  49914. */
  49915. /**
  49916. * Enable or disable the sprites render time capture
  49917. */
  49918. captureSpritesRenderTime: boolean;
  49919. /**
  49920. * Gets the perf counter used for physics time
  49921. */
  49922. readonly physicsTimeCounter: PerfCounter;
  49923. /**
  49924. * Gets the physics time capture status
  49925. */
  49926. /**
  49927. * Enable or disable the physics time capture
  49928. */
  49929. capturePhysicsTime: boolean;
  49930. /**
  49931. * Gets the perf counter used for animations time
  49932. */
  49933. readonly animationsTimeCounter: PerfCounter;
  49934. /**
  49935. * Gets the animations time capture status
  49936. */
  49937. /**
  49938. * Enable or disable the animations time capture
  49939. */
  49940. captureAnimationsTime: boolean;
  49941. /**
  49942. * Gets the perf counter used for frame time capture
  49943. */
  49944. readonly frameTimeCounter: PerfCounter;
  49945. /**
  49946. * Gets the frame time capture status
  49947. */
  49948. /**
  49949. * Enable or disable the frame time capture
  49950. */
  49951. captureFrameTime: boolean;
  49952. /**
  49953. * Gets the perf counter used for inter-frames time capture
  49954. */
  49955. readonly interFrameTimeCounter: PerfCounter;
  49956. /**
  49957. * Gets the inter-frames time capture status
  49958. */
  49959. /**
  49960. * Enable or disable the inter-frames time capture
  49961. */
  49962. captureInterFrameTime: boolean;
  49963. /**
  49964. * Gets the perf counter used for render time capture
  49965. */
  49966. readonly renderTimeCounter: PerfCounter;
  49967. /**
  49968. * Gets the render time capture status
  49969. */
  49970. /**
  49971. * Enable or disable the render time capture
  49972. */
  49973. captureRenderTime: boolean;
  49974. /**
  49975. * Gets the perf counter used for camera render time capture
  49976. */
  49977. readonly cameraRenderTimeCounter: PerfCounter;
  49978. /**
  49979. * Gets the camera render time capture status
  49980. */
  49981. /**
  49982. * Enable or disable the camera render time capture
  49983. */
  49984. captureCameraRenderTime: boolean;
  49985. /**
  49986. * Gets the perf counter used for draw calls
  49987. */
  49988. readonly drawCallsCounter: PerfCounter;
  49989. /**
  49990. * Instantiates a new scene instrumentation.
  49991. * This class can be used to get instrumentation data from a Babylon engine
  49992. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49993. * @param scene Defines the scene to instrument
  49994. */
  49995. constructor(
  49996. /**
  49997. * Defines the scene to instrument
  49998. */
  49999. scene: Scene);
  50000. /**
  50001. * Dispose and release associated resources.
  50002. */
  50003. dispose(): void;
  50004. }
  50005. }
  50006. declare module "babylonjs/Instrumentation/index" {
  50007. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50008. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50009. export * from "babylonjs/Instrumentation/timeToken";
  50010. }
  50011. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50012. /** @hidden */
  50013. export var glowMapGenerationPixelShader: {
  50014. name: string;
  50015. shader: string;
  50016. };
  50017. }
  50018. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50019. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50020. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50021. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50022. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50023. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50024. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50025. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50026. /** @hidden */
  50027. export var glowMapGenerationVertexShader: {
  50028. name: string;
  50029. shader: string;
  50030. };
  50031. }
  50032. declare module "babylonjs/Layers/effectLayer" {
  50033. import { Observable } from "babylonjs/Misc/observable";
  50034. import { Nullable } from "babylonjs/types";
  50035. import { Camera } from "babylonjs/Cameras/camera";
  50036. import { Scene } from "babylonjs/scene";
  50037. import { ISize } from "babylonjs/Maths/math.size";
  50038. import { Color4 } from "babylonjs/Maths/math.color";
  50039. import { Engine } from "babylonjs/Engines/engine";
  50040. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50042. import { Mesh } from "babylonjs/Meshes/mesh";
  50043. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50045. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50046. import { Effect } from "babylonjs/Materials/effect";
  50047. import { Material } from "babylonjs/Materials/material";
  50048. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50049. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50050. /**
  50051. * Effect layer options. This helps customizing the behaviour
  50052. * of the effect layer.
  50053. */
  50054. export interface IEffectLayerOptions {
  50055. /**
  50056. * Multiplication factor apply to the canvas size to compute the render target size
  50057. * used to generated the objects (the smaller the faster).
  50058. */
  50059. mainTextureRatio: number;
  50060. /**
  50061. * Enforces a fixed size texture to ensure effect stability across devices.
  50062. */
  50063. mainTextureFixedSize?: number;
  50064. /**
  50065. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50066. */
  50067. alphaBlendingMode: number;
  50068. /**
  50069. * The camera attached to the layer.
  50070. */
  50071. camera: Nullable<Camera>;
  50072. /**
  50073. * The rendering group to draw the layer in.
  50074. */
  50075. renderingGroupId: number;
  50076. }
  50077. /**
  50078. * The effect layer Helps adding post process effect blended with the main pass.
  50079. *
  50080. * This can be for instance use to generate glow or higlight effects on the scene.
  50081. *
  50082. * The effect layer class can not be used directly and is intented to inherited from to be
  50083. * customized per effects.
  50084. */
  50085. export abstract class EffectLayer {
  50086. private _vertexBuffers;
  50087. private _indexBuffer;
  50088. private _cachedDefines;
  50089. private _effectLayerMapGenerationEffect;
  50090. private _effectLayerOptions;
  50091. private _mergeEffect;
  50092. protected _scene: Scene;
  50093. protected _engine: Engine;
  50094. protected _maxSize: number;
  50095. protected _mainTextureDesiredSize: ISize;
  50096. protected _mainTexture: RenderTargetTexture;
  50097. protected _shouldRender: boolean;
  50098. protected _postProcesses: PostProcess[];
  50099. protected _textures: BaseTexture[];
  50100. protected _emissiveTextureAndColor: {
  50101. texture: Nullable<BaseTexture>;
  50102. color: Color4;
  50103. };
  50104. /**
  50105. * The name of the layer
  50106. */
  50107. name: string;
  50108. /**
  50109. * The clear color of the texture used to generate the glow map.
  50110. */
  50111. neutralColor: Color4;
  50112. /**
  50113. * Specifies wether the highlight layer is enabled or not.
  50114. */
  50115. isEnabled: boolean;
  50116. /**
  50117. * Gets the camera attached to the layer.
  50118. */
  50119. readonly camera: Nullable<Camera>;
  50120. /**
  50121. * Gets the rendering group id the layer should render in.
  50122. */
  50123. renderingGroupId: number;
  50124. /**
  50125. * An event triggered when the effect layer has been disposed.
  50126. */
  50127. onDisposeObservable: Observable<EffectLayer>;
  50128. /**
  50129. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50130. */
  50131. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50132. /**
  50133. * An event triggered when the generated texture is being merged in the scene.
  50134. */
  50135. onBeforeComposeObservable: Observable<EffectLayer>;
  50136. /**
  50137. * An event triggered when the generated texture has been merged in the scene.
  50138. */
  50139. onAfterComposeObservable: Observable<EffectLayer>;
  50140. /**
  50141. * An event triggered when the efffect layer changes its size.
  50142. */
  50143. onSizeChangedObservable: Observable<EffectLayer>;
  50144. /** @hidden */
  50145. static _SceneComponentInitialization: (scene: Scene) => void;
  50146. /**
  50147. * Instantiates a new effect Layer and references it in the scene.
  50148. * @param name The name of the layer
  50149. * @param scene The scene to use the layer in
  50150. */
  50151. constructor(
  50152. /** The Friendly of the effect in the scene */
  50153. name: string, scene: Scene);
  50154. /**
  50155. * Get the effect name of the layer.
  50156. * @return The effect name
  50157. */
  50158. abstract getEffectName(): string;
  50159. /**
  50160. * Checks for the readiness of the element composing the layer.
  50161. * @param subMesh the mesh to check for
  50162. * @param useInstances specify wether or not to use instances to render the mesh
  50163. * @return true if ready otherwise, false
  50164. */
  50165. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50166. /**
  50167. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50168. * @returns true if the effect requires stencil during the main canvas render pass.
  50169. */
  50170. abstract needStencil(): boolean;
  50171. /**
  50172. * Create the merge effect. This is the shader use to blit the information back
  50173. * to the main canvas at the end of the scene rendering.
  50174. * @returns The effect containing the shader used to merge the effect on the main canvas
  50175. */
  50176. protected abstract _createMergeEffect(): Effect;
  50177. /**
  50178. * Creates the render target textures and post processes used in the effect layer.
  50179. */
  50180. protected abstract _createTextureAndPostProcesses(): void;
  50181. /**
  50182. * Implementation specific of rendering the generating effect on the main canvas.
  50183. * @param effect The effect used to render through
  50184. */
  50185. protected abstract _internalRender(effect: Effect): void;
  50186. /**
  50187. * Sets the required values for both the emissive texture and and the main color.
  50188. */
  50189. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50190. /**
  50191. * Free any resources and references associated to a mesh.
  50192. * Internal use
  50193. * @param mesh The mesh to free.
  50194. */
  50195. abstract _disposeMesh(mesh: Mesh): void;
  50196. /**
  50197. * Serializes this layer (Glow or Highlight for example)
  50198. * @returns a serialized layer object
  50199. */
  50200. abstract serialize?(): any;
  50201. /**
  50202. * Initializes the effect layer with the required options.
  50203. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50204. */
  50205. protected _init(options: Partial<IEffectLayerOptions>): void;
  50206. /**
  50207. * Generates the index buffer of the full screen quad blending to the main canvas.
  50208. */
  50209. private _generateIndexBuffer;
  50210. /**
  50211. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50212. */
  50213. private _generateVertexBuffer;
  50214. /**
  50215. * Sets the main texture desired size which is the closest power of two
  50216. * of the engine canvas size.
  50217. */
  50218. private _setMainTextureSize;
  50219. /**
  50220. * Creates the main texture for the effect layer.
  50221. */
  50222. protected _createMainTexture(): void;
  50223. /**
  50224. * Adds specific effects defines.
  50225. * @param defines The defines to add specifics to.
  50226. */
  50227. protected _addCustomEffectDefines(defines: string[]): void;
  50228. /**
  50229. * Checks for the readiness of the element composing the layer.
  50230. * @param subMesh the mesh to check for
  50231. * @param useInstances specify wether or not to use instances to render the mesh
  50232. * @param emissiveTexture the associated emissive texture used to generate the glow
  50233. * @return true if ready otherwise, false
  50234. */
  50235. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50236. /**
  50237. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50238. */
  50239. render(): void;
  50240. /**
  50241. * Determine if a given mesh will be used in the current effect.
  50242. * @param mesh mesh to test
  50243. * @returns true if the mesh will be used
  50244. */
  50245. hasMesh(mesh: AbstractMesh): boolean;
  50246. /**
  50247. * Returns true if the layer contains information to display, otherwise false.
  50248. * @returns true if the glow layer should be rendered
  50249. */
  50250. shouldRender(): boolean;
  50251. /**
  50252. * Returns true if the mesh should render, otherwise false.
  50253. * @param mesh The mesh to render
  50254. * @returns true if it should render otherwise false
  50255. */
  50256. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50257. /**
  50258. * Returns true if the mesh can be rendered, otherwise false.
  50259. * @param mesh The mesh to render
  50260. * @param material The material used on the mesh
  50261. * @returns true if it can be rendered otherwise false
  50262. */
  50263. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50264. /**
  50265. * Returns true if the mesh should render, otherwise false.
  50266. * @param mesh The mesh to render
  50267. * @returns true if it should render otherwise false
  50268. */
  50269. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50270. /**
  50271. * Renders the submesh passed in parameter to the generation map.
  50272. */
  50273. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50274. /**
  50275. * Rebuild the required buffers.
  50276. * @hidden Internal use only.
  50277. */
  50278. _rebuild(): void;
  50279. /**
  50280. * Dispose only the render target textures and post process.
  50281. */
  50282. private _disposeTextureAndPostProcesses;
  50283. /**
  50284. * Dispose the highlight layer and free resources.
  50285. */
  50286. dispose(): void;
  50287. /**
  50288. * Gets the class name of the effect layer
  50289. * @returns the string with the class name of the effect layer
  50290. */
  50291. getClassName(): string;
  50292. /**
  50293. * Creates an effect layer from parsed effect layer data
  50294. * @param parsedEffectLayer defines effect layer data
  50295. * @param scene defines the current scene
  50296. * @param rootUrl defines the root URL containing the effect layer information
  50297. * @returns a parsed effect Layer
  50298. */
  50299. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50300. }
  50301. }
  50302. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50303. import { Scene } from "babylonjs/scene";
  50304. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50305. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50306. import { AbstractScene } from "babylonjs/abstractScene";
  50307. module "babylonjs/abstractScene" {
  50308. interface AbstractScene {
  50309. /**
  50310. * The list of effect layers (highlights/glow) added to the scene
  50311. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50312. * @see http://doc.babylonjs.com/how_to/glow_layer
  50313. */
  50314. effectLayers: Array<EffectLayer>;
  50315. /**
  50316. * Removes the given effect layer from this scene.
  50317. * @param toRemove defines the effect layer to remove
  50318. * @returns the index of the removed effect layer
  50319. */
  50320. removeEffectLayer(toRemove: EffectLayer): number;
  50321. /**
  50322. * Adds the given effect layer to this scene
  50323. * @param newEffectLayer defines the effect layer to add
  50324. */
  50325. addEffectLayer(newEffectLayer: EffectLayer): void;
  50326. }
  50327. }
  50328. /**
  50329. * Defines the layer scene component responsible to manage any effect layers
  50330. * in a given scene.
  50331. */
  50332. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50333. /**
  50334. * The component name helpfull to identify the component in the list of scene components.
  50335. */
  50336. readonly name: string;
  50337. /**
  50338. * The scene the component belongs to.
  50339. */
  50340. scene: Scene;
  50341. private _engine;
  50342. private _renderEffects;
  50343. private _needStencil;
  50344. private _previousStencilState;
  50345. /**
  50346. * Creates a new instance of the component for the given scene
  50347. * @param scene Defines the scene to register the component in
  50348. */
  50349. constructor(scene: Scene);
  50350. /**
  50351. * Registers the component in a given scene
  50352. */
  50353. register(): void;
  50354. /**
  50355. * Rebuilds the elements related to this component in case of
  50356. * context lost for instance.
  50357. */
  50358. rebuild(): void;
  50359. /**
  50360. * Serializes the component data to the specified json object
  50361. * @param serializationObject The object to serialize to
  50362. */
  50363. serialize(serializationObject: any): void;
  50364. /**
  50365. * Adds all the elements from the container to the scene
  50366. * @param container the container holding the elements
  50367. */
  50368. addFromContainer(container: AbstractScene): void;
  50369. /**
  50370. * Removes all the elements in the container from the scene
  50371. * @param container contains the elements to remove
  50372. * @param dispose if the removed element should be disposed (default: false)
  50373. */
  50374. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50375. /**
  50376. * Disposes the component and the associated ressources.
  50377. */
  50378. dispose(): void;
  50379. private _isReadyForMesh;
  50380. private _renderMainTexture;
  50381. private _setStencil;
  50382. private _setStencilBack;
  50383. private _draw;
  50384. private _drawCamera;
  50385. private _drawRenderingGroup;
  50386. }
  50387. }
  50388. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50389. /** @hidden */
  50390. export var glowMapMergePixelShader: {
  50391. name: string;
  50392. shader: string;
  50393. };
  50394. }
  50395. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50396. /** @hidden */
  50397. export var glowMapMergeVertexShader: {
  50398. name: string;
  50399. shader: string;
  50400. };
  50401. }
  50402. declare module "babylonjs/Layers/glowLayer" {
  50403. import { Nullable } from "babylonjs/types";
  50404. import { Camera } from "babylonjs/Cameras/camera";
  50405. import { Scene } from "babylonjs/scene";
  50406. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50408. import { Mesh } from "babylonjs/Meshes/mesh";
  50409. import { Texture } from "babylonjs/Materials/Textures/texture";
  50410. import { Effect } from "babylonjs/Materials/effect";
  50411. import { Material } from "babylonjs/Materials/material";
  50412. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50413. import { Color4 } from "babylonjs/Maths/math.color";
  50414. import "babylonjs/Shaders/glowMapMerge.fragment";
  50415. import "babylonjs/Shaders/glowMapMerge.vertex";
  50416. import "babylonjs/Layers/effectLayerSceneComponent";
  50417. module "babylonjs/abstractScene" {
  50418. interface AbstractScene {
  50419. /**
  50420. * Return a the first highlight layer of the scene with a given name.
  50421. * @param name The name of the highlight layer to look for.
  50422. * @return The highlight layer if found otherwise null.
  50423. */
  50424. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50425. }
  50426. }
  50427. /**
  50428. * Glow layer options. This helps customizing the behaviour
  50429. * of the glow layer.
  50430. */
  50431. export interface IGlowLayerOptions {
  50432. /**
  50433. * Multiplication factor apply to the canvas size to compute the render target size
  50434. * used to generated the glowing objects (the smaller the faster).
  50435. */
  50436. mainTextureRatio: number;
  50437. /**
  50438. * Enforces a fixed size texture to ensure resize independant blur.
  50439. */
  50440. mainTextureFixedSize?: number;
  50441. /**
  50442. * How big is the kernel of the blur texture.
  50443. */
  50444. blurKernelSize: number;
  50445. /**
  50446. * The camera attached to the layer.
  50447. */
  50448. camera: Nullable<Camera>;
  50449. /**
  50450. * Enable MSAA by chosing the number of samples.
  50451. */
  50452. mainTextureSamples?: number;
  50453. /**
  50454. * The rendering group to draw the layer in.
  50455. */
  50456. renderingGroupId: number;
  50457. }
  50458. /**
  50459. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50460. *
  50461. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50462. * glowy meshes to your scene.
  50463. *
  50464. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50465. */
  50466. export class GlowLayer extends EffectLayer {
  50467. /**
  50468. * Effect Name of the layer.
  50469. */
  50470. static readonly EffectName: string;
  50471. /**
  50472. * The default blur kernel size used for the glow.
  50473. */
  50474. static DefaultBlurKernelSize: number;
  50475. /**
  50476. * The default texture size ratio used for the glow.
  50477. */
  50478. static DefaultTextureRatio: number;
  50479. /**
  50480. * Sets the kernel size of the blur.
  50481. */
  50482. /**
  50483. * Gets the kernel size of the blur.
  50484. */
  50485. blurKernelSize: number;
  50486. /**
  50487. * Sets the glow intensity.
  50488. */
  50489. /**
  50490. * Gets the glow intensity.
  50491. */
  50492. intensity: number;
  50493. private _options;
  50494. private _intensity;
  50495. private _horizontalBlurPostprocess1;
  50496. private _verticalBlurPostprocess1;
  50497. private _horizontalBlurPostprocess2;
  50498. private _verticalBlurPostprocess2;
  50499. private _blurTexture1;
  50500. private _blurTexture2;
  50501. private _postProcesses1;
  50502. private _postProcesses2;
  50503. private _includedOnlyMeshes;
  50504. private _excludedMeshes;
  50505. /**
  50506. * Callback used to let the user override the color selection on a per mesh basis
  50507. */
  50508. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50509. /**
  50510. * Callback used to let the user override the texture selection on a per mesh basis
  50511. */
  50512. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50513. /**
  50514. * Instantiates a new glow Layer and references it to the scene.
  50515. * @param name The name of the layer
  50516. * @param scene The scene to use the layer in
  50517. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50518. */
  50519. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50520. /**
  50521. * Get the effect name of the layer.
  50522. * @return The effect name
  50523. */
  50524. getEffectName(): string;
  50525. /**
  50526. * Create the merge effect. This is the shader use to blit the information back
  50527. * to the main canvas at the end of the scene rendering.
  50528. */
  50529. protected _createMergeEffect(): Effect;
  50530. /**
  50531. * Creates the render target textures and post processes used in the glow layer.
  50532. */
  50533. protected _createTextureAndPostProcesses(): void;
  50534. /**
  50535. * Checks for the readiness of the element composing the layer.
  50536. * @param subMesh the mesh to check for
  50537. * @param useInstances specify wether or not to use instances to render the mesh
  50538. * @param emissiveTexture the associated emissive texture used to generate the glow
  50539. * @return true if ready otherwise, false
  50540. */
  50541. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50542. /**
  50543. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50544. */
  50545. needStencil(): boolean;
  50546. /**
  50547. * Returns true if the mesh can be rendered, otherwise false.
  50548. * @param mesh The mesh to render
  50549. * @param material The material used on the mesh
  50550. * @returns true if it can be rendered otherwise false
  50551. */
  50552. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50553. /**
  50554. * Implementation specific of rendering the generating effect on the main canvas.
  50555. * @param effect The effect used to render through
  50556. */
  50557. protected _internalRender(effect: Effect): void;
  50558. /**
  50559. * Sets the required values for both the emissive texture and and the main color.
  50560. */
  50561. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50562. /**
  50563. * Returns true if the mesh should render, otherwise false.
  50564. * @param mesh The mesh to render
  50565. * @returns true if it should render otherwise false
  50566. */
  50567. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50568. /**
  50569. * Adds specific effects defines.
  50570. * @param defines The defines to add specifics to.
  50571. */
  50572. protected _addCustomEffectDefines(defines: string[]): void;
  50573. /**
  50574. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50575. * @param mesh The mesh to exclude from the glow layer
  50576. */
  50577. addExcludedMesh(mesh: Mesh): void;
  50578. /**
  50579. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50580. * @param mesh The mesh to remove
  50581. */
  50582. removeExcludedMesh(mesh: Mesh): void;
  50583. /**
  50584. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50585. * @param mesh The mesh to include in the glow layer
  50586. */
  50587. addIncludedOnlyMesh(mesh: Mesh): void;
  50588. /**
  50589. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50590. * @param mesh The mesh to remove
  50591. */
  50592. removeIncludedOnlyMesh(mesh: Mesh): void;
  50593. /**
  50594. * Determine if a given mesh will be used in the glow layer
  50595. * @param mesh The mesh to test
  50596. * @returns true if the mesh will be highlighted by the current glow layer
  50597. */
  50598. hasMesh(mesh: AbstractMesh): boolean;
  50599. /**
  50600. * Free any resources and references associated to a mesh.
  50601. * Internal use
  50602. * @param mesh The mesh to free.
  50603. * @hidden
  50604. */
  50605. _disposeMesh(mesh: Mesh): void;
  50606. /**
  50607. * Gets the class name of the effect layer
  50608. * @returns the string with the class name of the effect layer
  50609. */
  50610. getClassName(): string;
  50611. /**
  50612. * Serializes this glow layer
  50613. * @returns a serialized glow layer object
  50614. */
  50615. serialize(): any;
  50616. /**
  50617. * Creates a Glow Layer from parsed glow layer data
  50618. * @param parsedGlowLayer defines glow layer data
  50619. * @param scene defines the current scene
  50620. * @param rootUrl defines the root URL containing the glow layer information
  50621. * @returns a parsed Glow Layer
  50622. */
  50623. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50624. }
  50625. }
  50626. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50627. /** @hidden */
  50628. export var glowBlurPostProcessPixelShader: {
  50629. name: string;
  50630. shader: string;
  50631. };
  50632. }
  50633. declare module "babylonjs/Layers/highlightLayer" {
  50634. import { Observable } from "babylonjs/Misc/observable";
  50635. import { Nullable } from "babylonjs/types";
  50636. import { Camera } from "babylonjs/Cameras/camera";
  50637. import { Scene } from "babylonjs/scene";
  50638. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50640. import { Mesh } from "babylonjs/Meshes/mesh";
  50641. import { Effect } from "babylonjs/Materials/effect";
  50642. import { Material } from "babylonjs/Materials/material";
  50643. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50644. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  50645. import "babylonjs/Shaders/glowMapMerge.fragment";
  50646. import "babylonjs/Shaders/glowMapMerge.vertex";
  50647. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50648. module "babylonjs/abstractScene" {
  50649. interface AbstractScene {
  50650. /**
  50651. * Return a the first highlight layer of the scene with a given name.
  50652. * @param name The name of the highlight layer to look for.
  50653. * @return The highlight layer if found otherwise null.
  50654. */
  50655. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50656. }
  50657. }
  50658. /**
  50659. * Highlight layer options. This helps customizing the behaviour
  50660. * of the highlight layer.
  50661. */
  50662. export interface IHighlightLayerOptions {
  50663. /**
  50664. * Multiplication factor apply to the canvas size to compute the render target size
  50665. * used to generated the glowing objects (the smaller the faster).
  50666. */
  50667. mainTextureRatio: number;
  50668. /**
  50669. * Enforces a fixed size texture to ensure resize independant blur.
  50670. */
  50671. mainTextureFixedSize?: number;
  50672. /**
  50673. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50674. * of the picture to blur (the smaller the faster).
  50675. */
  50676. blurTextureSizeRatio: number;
  50677. /**
  50678. * How big in texel of the blur texture is the vertical blur.
  50679. */
  50680. blurVerticalSize: number;
  50681. /**
  50682. * How big in texel of the blur texture is the horizontal blur.
  50683. */
  50684. blurHorizontalSize: number;
  50685. /**
  50686. * Alpha blending mode used to apply the blur. Default is combine.
  50687. */
  50688. alphaBlendingMode: number;
  50689. /**
  50690. * The camera attached to the layer.
  50691. */
  50692. camera: Nullable<Camera>;
  50693. /**
  50694. * Should we display highlight as a solid stroke?
  50695. */
  50696. isStroke?: boolean;
  50697. /**
  50698. * The rendering group to draw the layer in.
  50699. */
  50700. renderingGroupId: number;
  50701. }
  50702. /**
  50703. * The highlight layer Helps adding a glow effect around a mesh.
  50704. *
  50705. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50706. * glowy meshes to your scene.
  50707. *
  50708. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50709. */
  50710. export class HighlightLayer extends EffectLayer {
  50711. name: string;
  50712. /**
  50713. * Effect Name of the highlight layer.
  50714. */
  50715. static readonly EffectName: string;
  50716. /**
  50717. * The neutral color used during the preparation of the glow effect.
  50718. * This is black by default as the blend operation is a blend operation.
  50719. */
  50720. static NeutralColor: Color4;
  50721. /**
  50722. * Stencil value used for glowing meshes.
  50723. */
  50724. static GlowingMeshStencilReference: number;
  50725. /**
  50726. * Stencil value used for the other meshes in the scene.
  50727. */
  50728. static NormalMeshStencilReference: number;
  50729. /**
  50730. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50731. */
  50732. innerGlow: boolean;
  50733. /**
  50734. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50735. */
  50736. outerGlow: boolean;
  50737. /**
  50738. * Specifies the horizontal size of the blur.
  50739. */
  50740. /**
  50741. * Gets the horizontal size of the blur.
  50742. */
  50743. blurHorizontalSize: number;
  50744. /**
  50745. * Specifies the vertical size of the blur.
  50746. */
  50747. /**
  50748. * Gets the vertical size of the blur.
  50749. */
  50750. blurVerticalSize: number;
  50751. /**
  50752. * An event triggered when the highlight layer is being blurred.
  50753. */
  50754. onBeforeBlurObservable: Observable<HighlightLayer>;
  50755. /**
  50756. * An event triggered when the highlight layer has been blurred.
  50757. */
  50758. onAfterBlurObservable: Observable<HighlightLayer>;
  50759. private _instanceGlowingMeshStencilReference;
  50760. private _options;
  50761. private _downSamplePostprocess;
  50762. private _horizontalBlurPostprocess;
  50763. private _verticalBlurPostprocess;
  50764. private _blurTexture;
  50765. private _meshes;
  50766. private _excludedMeshes;
  50767. /**
  50768. * Instantiates a new highlight Layer and references it to the scene..
  50769. * @param name The name of the layer
  50770. * @param scene The scene to use the layer in
  50771. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50772. */
  50773. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50774. /**
  50775. * Get the effect name of the layer.
  50776. * @return The effect name
  50777. */
  50778. getEffectName(): string;
  50779. /**
  50780. * Create the merge effect. This is the shader use to blit the information back
  50781. * to the main canvas at the end of the scene rendering.
  50782. */
  50783. protected _createMergeEffect(): Effect;
  50784. /**
  50785. * Creates the render target textures and post processes used in the highlight layer.
  50786. */
  50787. protected _createTextureAndPostProcesses(): void;
  50788. /**
  50789. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50790. */
  50791. needStencil(): boolean;
  50792. /**
  50793. * Checks for the readiness of the element composing the layer.
  50794. * @param subMesh the mesh to check for
  50795. * @param useInstances specify wether or not to use instances to render the mesh
  50796. * @param emissiveTexture the associated emissive texture used to generate the glow
  50797. * @return true if ready otherwise, false
  50798. */
  50799. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50800. /**
  50801. * Implementation specific of rendering the generating effect on the main canvas.
  50802. * @param effect The effect used to render through
  50803. */
  50804. protected _internalRender(effect: Effect): void;
  50805. /**
  50806. * Returns true if the layer contains information to display, otherwise false.
  50807. */
  50808. shouldRender(): boolean;
  50809. /**
  50810. * Returns true if the mesh should render, otherwise false.
  50811. * @param mesh The mesh to render
  50812. * @returns true if it should render otherwise false
  50813. */
  50814. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50815. /**
  50816. * Sets the required values for both the emissive texture and and the main color.
  50817. */
  50818. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50819. /**
  50820. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50821. * @param mesh The mesh to exclude from the highlight layer
  50822. */
  50823. addExcludedMesh(mesh: Mesh): void;
  50824. /**
  50825. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50826. * @param mesh The mesh to highlight
  50827. */
  50828. removeExcludedMesh(mesh: Mesh): void;
  50829. /**
  50830. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50831. * @param mesh mesh to test
  50832. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50833. */
  50834. hasMesh(mesh: AbstractMesh): boolean;
  50835. /**
  50836. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50837. * @param mesh The mesh to highlight
  50838. * @param color The color of the highlight
  50839. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50840. */
  50841. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50842. /**
  50843. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50844. * @param mesh The mesh to highlight
  50845. */
  50846. removeMesh(mesh: Mesh): void;
  50847. /**
  50848. * Force the stencil to the normal expected value for none glowing parts
  50849. */
  50850. private _defaultStencilReference;
  50851. /**
  50852. * Free any resources and references associated to a mesh.
  50853. * Internal use
  50854. * @param mesh The mesh to free.
  50855. * @hidden
  50856. */
  50857. _disposeMesh(mesh: Mesh): void;
  50858. /**
  50859. * Dispose the highlight layer and free resources.
  50860. */
  50861. dispose(): void;
  50862. /**
  50863. * Gets the class name of the effect layer
  50864. * @returns the string with the class name of the effect layer
  50865. */
  50866. getClassName(): string;
  50867. /**
  50868. * Serializes this Highlight layer
  50869. * @returns a serialized Highlight layer object
  50870. */
  50871. serialize(): any;
  50872. /**
  50873. * Creates a Highlight layer from parsed Highlight layer data
  50874. * @param parsedHightlightLayer defines the Highlight layer data
  50875. * @param scene defines the current scene
  50876. * @param rootUrl defines the root URL containing the Highlight layer information
  50877. * @returns a parsed Highlight layer
  50878. */
  50879. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50880. }
  50881. }
  50882. declare module "babylonjs/Layers/layerSceneComponent" {
  50883. import { Scene } from "babylonjs/scene";
  50884. import { ISceneComponent } from "babylonjs/sceneComponent";
  50885. import { Layer } from "babylonjs/Layers/layer";
  50886. import { AbstractScene } from "babylonjs/abstractScene";
  50887. module "babylonjs/abstractScene" {
  50888. interface AbstractScene {
  50889. /**
  50890. * The list of layers (background and foreground) of the scene
  50891. */
  50892. layers: Array<Layer>;
  50893. }
  50894. }
  50895. /**
  50896. * Defines the layer scene component responsible to manage any layers
  50897. * in a given scene.
  50898. */
  50899. export class LayerSceneComponent implements ISceneComponent {
  50900. /**
  50901. * The component name helpfull to identify the component in the list of scene components.
  50902. */
  50903. readonly name: string;
  50904. /**
  50905. * The scene the component belongs to.
  50906. */
  50907. scene: Scene;
  50908. private _engine;
  50909. /**
  50910. * Creates a new instance of the component for the given scene
  50911. * @param scene Defines the scene to register the component in
  50912. */
  50913. constructor(scene: Scene);
  50914. /**
  50915. * Registers the component in a given scene
  50916. */
  50917. register(): void;
  50918. /**
  50919. * Rebuilds the elements related to this component in case of
  50920. * context lost for instance.
  50921. */
  50922. rebuild(): void;
  50923. /**
  50924. * Disposes the component and the associated ressources.
  50925. */
  50926. dispose(): void;
  50927. private _draw;
  50928. private _drawCameraPredicate;
  50929. private _drawCameraBackground;
  50930. private _drawCameraForeground;
  50931. private _drawRenderTargetPredicate;
  50932. private _drawRenderTargetBackground;
  50933. private _drawRenderTargetForeground;
  50934. /**
  50935. * Adds all the elements from the container to the scene
  50936. * @param container the container holding the elements
  50937. */
  50938. addFromContainer(container: AbstractScene): void;
  50939. /**
  50940. * Removes all the elements in the container from the scene
  50941. * @param container contains the elements to remove
  50942. * @param dispose if the removed element should be disposed (default: false)
  50943. */
  50944. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50945. }
  50946. }
  50947. declare module "babylonjs/Shaders/layer.fragment" {
  50948. /** @hidden */
  50949. export var layerPixelShader: {
  50950. name: string;
  50951. shader: string;
  50952. };
  50953. }
  50954. declare module "babylonjs/Shaders/layer.vertex" {
  50955. /** @hidden */
  50956. export var layerVertexShader: {
  50957. name: string;
  50958. shader: string;
  50959. };
  50960. }
  50961. declare module "babylonjs/Layers/layer" {
  50962. import { Observable } from "babylonjs/Misc/observable";
  50963. import { Nullable } from "babylonjs/types";
  50964. import { Scene } from "babylonjs/scene";
  50965. import { Vector2 } from "babylonjs/Maths/math.vector";
  50966. import { Color4 } from "babylonjs/Maths/math.color";
  50967. import { Texture } from "babylonjs/Materials/Textures/texture";
  50968. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50969. import "babylonjs/Shaders/layer.fragment";
  50970. import "babylonjs/Shaders/layer.vertex";
  50971. /**
  50972. * This represents a full screen 2d layer.
  50973. * This can be useful to display a picture in the background of your scene for instance.
  50974. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50975. */
  50976. export class Layer {
  50977. /**
  50978. * Define the name of the layer.
  50979. */
  50980. name: string;
  50981. /**
  50982. * Define the texture the layer should display.
  50983. */
  50984. texture: Nullable<Texture>;
  50985. /**
  50986. * Is the layer in background or foreground.
  50987. */
  50988. isBackground: boolean;
  50989. /**
  50990. * Define the color of the layer (instead of texture).
  50991. */
  50992. color: Color4;
  50993. /**
  50994. * Define the scale of the layer in order to zoom in out of the texture.
  50995. */
  50996. scale: Vector2;
  50997. /**
  50998. * Define an offset for the layer in order to shift the texture.
  50999. */
  51000. offset: Vector2;
  51001. /**
  51002. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51003. */
  51004. alphaBlendingMode: number;
  51005. /**
  51006. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51007. * Alpha test will not mix with the background color in case of transparency.
  51008. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51009. */
  51010. alphaTest: boolean;
  51011. /**
  51012. * Define a mask to restrict the layer to only some of the scene cameras.
  51013. */
  51014. layerMask: number;
  51015. /**
  51016. * Define the list of render target the layer is visible into.
  51017. */
  51018. renderTargetTextures: RenderTargetTexture[];
  51019. /**
  51020. * Define if the layer is only used in renderTarget or if it also
  51021. * renders in the main frame buffer of the canvas.
  51022. */
  51023. renderOnlyInRenderTargetTextures: boolean;
  51024. private _scene;
  51025. private _vertexBuffers;
  51026. private _indexBuffer;
  51027. private _effect;
  51028. private _alphaTestEffect;
  51029. /**
  51030. * An event triggered when the layer is disposed.
  51031. */
  51032. onDisposeObservable: Observable<Layer>;
  51033. private _onDisposeObserver;
  51034. /**
  51035. * Back compatibility with callback before the onDisposeObservable existed.
  51036. * The set callback will be triggered when the layer has been disposed.
  51037. */
  51038. onDispose: () => void;
  51039. /**
  51040. * An event triggered before rendering the scene
  51041. */
  51042. onBeforeRenderObservable: Observable<Layer>;
  51043. private _onBeforeRenderObserver;
  51044. /**
  51045. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51046. * The set callback will be triggered just before rendering the layer.
  51047. */
  51048. onBeforeRender: () => void;
  51049. /**
  51050. * An event triggered after rendering the scene
  51051. */
  51052. onAfterRenderObservable: Observable<Layer>;
  51053. private _onAfterRenderObserver;
  51054. /**
  51055. * Back compatibility with callback before the onAfterRenderObservable existed.
  51056. * The set callback will be triggered just after rendering the layer.
  51057. */
  51058. onAfterRender: () => void;
  51059. /**
  51060. * Instantiates a new layer.
  51061. * This represents a full screen 2d layer.
  51062. * This can be useful to display a picture in the background of your scene for instance.
  51063. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51064. * @param name Define the name of the layer in the scene
  51065. * @param imgUrl Define the url of the texture to display in the layer
  51066. * @param scene Define the scene the layer belongs to
  51067. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51068. * @param color Defines a color for the layer
  51069. */
  51070. constructor(
  51071. /**
  51072. * Define the name of the layer.
  51073. */
  51074. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51075. private _createIndexBuffer;
  51076. /** @hidden */
  51077. _rebuild(): void;
  51078. /**
  51079. * Renders the layer in the scene.
  51080. */
  51081. render(): void;
  51082. /**
  51083. * Disposes and releases the associated ressources.
  51084. */
  51085. dispose(): void;
  51086. }
  51087. }
  51088. declare module "babylonjs/Layers/index" {
  51089. export * from "babylonjs/Layers/effectLayer";
  51090. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51091. export * from "babylonjs/Layers/glowLayer";
  51092. export * from "babylonjs/Layers/highlightLayer";
  51093. export * from "babylonjs/Layers/layer";
  51094. export * from "babylonjs/Layers/layerSceneComponent";
  51095. }
  51096. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51097. /** @hidden */
  51098. export var lensFlarePixelShader: {
  51099. name: string;
  51100. shader: string;
  51101. };
  51102. }
  51103. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51104. /** @hidden */
  51105. export var lensFlareVertexShader: {
  51106. name: string;
  51107. shader: string;
  51108. };
  51109. }
  51110. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51111. import { Scene } from "babylonjs/scene";
  51112. import { Vector3 } from "babylonjs/Maths/math.vector";
  51113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51114. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51115. import "babylonjs/Shaders/lensFlare.fragment";
  51116. import "babylonjs/Shaders/lensFlare.vertex";
  51117. import { Viewport } from "babylonjs/Maths/math.viewport";
  51118. /**
  51119. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51120. * It is usually composed of several `lensFlare`.
  51121. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51122. */
  51123. export class LensFlareSystem {
  51124. /**
  51125. * Define the name of the lens flare system
  51126. */
  51127. name: string;
  51128. /**
  51129. * List of lens flares used in this system.
  51130. */
  51131. lensFlares: LensFlare[];
  51132. /**
  51133. * Define a limit from the border the lens flare can be visible.
  51134. */
  51135. borderLimit: number;
  51136. /**
  51137. * Define a viewport border we do not want to see the lens flare in.
  51138. */
  51139. viewportBorder: number;
  51140. /**
  51141. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51142. */
  51143. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51144. /**
  51145. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51146. */
  51147. layerMask: number;
  51148. /**
  51149. * Define the id of the lens flare system in the scene.
  51150. * (equal to name by default)
  51151. */
  51152. id: string;
  51153. private _scene;
  51154. private _emitter;
  51155. private _vertexBuffers;
  51156. private _indexBuffer;
  51157. private _effect;
  51158. private _positionX;
  51159. private _positionY;
  51160. private _isEnabled;
  51161. /** @hidden */
  51162. static _SceneComponentInitialization: (scene: Scene) => void;
  51163. /**
  51164. * Instantiates a lens flare system.
  51165. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51166. * It is usually composed of several `lensFlare`.
  51167. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51168. * @param name Define the name of the lens flare system in the scene
  51169. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51170. * @param scene Define the scene the lens flare system belongs to
  51171. */
  51172. constructor(
  51173. /**
  51174. * Define the name of the lens flare system
  51175. */
  51176. name: string, emitter: any, scene: Scene);
  51177. /**
  51178. * Define if the lens flare system is enabled.
  51179. */
  51180. isEnabled: boolean;
  51181. /**
  51182. * Get the scene the effects belongs to.
  51183. * @returns the scene holding the lens flare system
  51184. */
  51185. getScene(): Scene;
  51186. /**
  51187. * Get the emitter of the lens flare system.
  51188. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51189. * @returns the emitter of the lens flare system
  51190. */
  51191. getEmitter(): any;
  51192. /**
  51193. * Set the emitter of the lens flare system.
  51194. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51195. * @param newEmitter Define the new emitter of the system
  51196. */
  51197. setEmitter(newEmitter: any): void;
  51198. /**
  51199. * Get the lens flare system emitter position.
  51200. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51201. * @returns the position
  51202. */
  51203. getEmitterPosition(): Vector3;
  51204. /**
  51205. * @hidden
  51206. */
  51207. computeEffectivePosition(globalViewport: Viewport): boolean;
  51208. /** @hidden */
  51209. _isVisible(): boolean;
  51210. /**
  51211. * @hidden
  51212. */
  51213. render(): boolean;
  51214. /**
  51215. * Dispose and release the lens flare with its associated resources.
  51216. */
  51217. dispose(): void;
  51218. /**
  51219. * Parse a lens flare system from a JSON repressentation
  51220. * @param parsedLensFlareSystem Define the JSON to parse
  51221. * @param scene Define the scene the parsed system should be instantiated in
  51222. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51223. * @returns the parsed system
  51224. */
  51225. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51226. /**
  51227. * Serialize the current Lens Flare System into a JSON representation.
  51228. * @returns the serialized JSON
  51229. */
  51230. serialize(): any;
  51231. }
  51232. }
  51233. declare module "babylonjs/LensFlares/lensFlare" {
  51234. import { Nullable } from "babylonjs/types";
  51235. import { Color3 } from "babylonjs/Maths/math.color";
  51236. import { Texture } from "babylonjs/Materials/Textures/texture";
  51237. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51238. /**
  51239. * This represents one of the lens effect in a `lensFlareSystem`.
  51240. * It controls one of the indiviual texture used in the effect.
  51241. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51242. */
  51243. export class LensFlare {
  51244. /**
  51245. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51246. */
  51247. size: number;
  51248. /**
  51249. * 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.
  51250. */
  51251. position: number;
  51252. /**
  51253. * Define the lens color.
  51254. */
  51255. color: Color3;
  51256. /**
  51257. * Define the lens texture.
  51258. */
  51259. texture: Nullable<Texture>;
  51260. /**
  51261. * Define the alpha mode to render this particular lens.
  51262. */
  51263. alphaMode: number;
  51264. private _system;
  51265. /**
  51266. * Creates a new Lens Flare.
  51267. * This represents one of the lens effect in a `lensFlareSystem`.
  51268. * It controls one of the indiviual texture used in the effect.
  51269. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51270. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51271. * @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.
  51272. * @param color Define the lens color
  51273. * @param imgUrl Define the lens texture url
  51274. * @param system Define the `lensFlareSystem` this flare is part of
  51275. * @returns The newly created Lens Flare
  51276. */
  51277. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51278. /**
  51279. * Instantiates a new Lens Flare.
  51280. * This represents one of the lens effect in a `lensFlareSystem`.
  51281. * It controls one of the indiviual texture used in the effect.
  51282. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51283. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51284. * @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.
  51285. * @param color Define the lens color
  51286. * @param imgUrl Define the lens texture url
  51287. * @param system Define the `lensFlareSystem` this flare is part of
  51288. */
  51289. constructor(
  51290. /**
  51291. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51292. */
  51293. size: number,
  51294. /**
  51295. * 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.
  51296. */
  51297. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51298. /**
  51299. * Dispose and release the lens flare with its associated resources.
  51300. */
  51301. dispose(): void;
  51302. }
  51303. }
  51304. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51305. import { Nullable } from "babylonjs/types";
  51306. import { Scene } from "babylonjs/scene";
  51307. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51308. import { AbstractScene } from "babylonjs/abstractScene";
  51309. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51310. module "babylonjs/abstractScene" {
  51311. interface AbstractScene {
  51312. /**
  51313. * The list of lens flare system added to the scene
  51314. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51315. */
  51316. lensFlareSystems: Array<LensFlareSystem>;
  51317. /**
  51318. * Removes the given lens flare system from this scene.
  51319. * @param toRemove The lens flare system to remove
  51320. * @returns The index of the removed lens flare system
  51321. */
  51322. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51323. /**
  51324. * Adds the given lens flare system to this scene
  51325. * @param newLensFlareSystem The lens flare system to add
  51326. */
  51327. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51328. /**
  51329. * Gets a lens flare system using its name
  51330. * @param name defines the name to look for
  51331. * @returns the lens flare system or null if not found
  51332. */
  51333. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51334. /**
  51335. * Gets a lens flare system using its id
  51336. * @param id defines the id to look for
  51337. * @returns the lens flare system or null if not found
  51338. */
  51339. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51340. }
  51341. }
  51342. /**
  51343. * Defines the lens flare scene component responsible to manage any lens flares
  51344. * in a given scene.
  51345. */
  51346. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51347. /**
  51348. * The component name helpfull to identify the component in the list of scene components.
  51349. */
  51350. readonly name: string;
  51351. /**
  51352. * The scene the component belongs to.
  51353. */
  51354. scene: Scene;
  51355. /**
  51356. * Creates a new instance of the component for the given scene
  51357. * @param scene Defines the scene to register the component in
  51358. */
  51359. constructor(scene: Scene);
  51360. /**
  51361. * Registers the component in a given scene
  51362. */
  51363. register(): void;
  51364. /**
  51365. * Rebuilds the elements related to this component in case of
  51366. * context lost for instance.
  51367. */
  51368. rebuild(): void;
  51369. /**
  51370. * Adds all the elements from the container to the scene
  51371. * @param container the container holding the elements
  51372. */
  51373. addFromContainer(container: AbstractScene): void;
  51374. /**
  51375. * Removes all the elements in the container from the scene
  51376. * @param container contains the elements to remove
  51377. * @param dispose if the removed element should be disposed (default: false)
  51378. */
  51379. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51380. /**
  51381. * Serializes the component data to the specified json object
  51382. * @param serializationObject The object to serialize to
  51383. */
  51384. serialize(serializationObject: any): void;
  51385. /**
  51386. * Disposes the component and the associated ressources.
  51387. */
  51388. dispose(): void;
  51389. private _draw;
  51390. }
  51391. }
  51392. declare module "babylonjs/LensFlares/index" {
  51393. export * from "babylonjs/LensFlares/lensFlare";
  51394. export * from "babylonjs/LensFlares/lensFlareSystem";
  51395. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51396. }
  51397. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51398. import { Scene } from "babylonjs/scene";
  51399. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51400. import { AbstractScene } from "babylonjs/abstractScene";
  51401. /**
  51402. * Defines the shadow generator component responsible to manage any shadow generators
  51403. * in a given scene.
  51404. */
  51405. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51406. /**
  51407. * The component name helpfull to identify the component in the list of scene components.
  51408. */
  51409. readonly name: string;
  51410. /**
  51411. * The scene the component belongs to.
  51412. */
  51413. scene: Scene;
  51414. /**
  51415. * Creates a new instance of the component for the given scene
  51416. * @param scene Defines the scene to register the component in
  51417. */
  51418. constructor(scene: Scene);
  51419. /**
  51420. * Registers the component in a given scene
  51421. */
  51422. register(): void;
  51423. /**
  51424. * Rebuilds the elements related to this component in case of
  51425. * context lost for instance.
  51426. */
  51427. rebuild(): void;
  51428. /**
  51429. * Serializes the component data to the specified json object
  51430. * @param serializationObject The object to serialize to
  51431. */
  51432. serialize(serializationObject: any): void;
  51433. /**
  51434. * Adds all the elements from the container to the scene
  51435. * @param container the container holding the elements
  51436. */
  51437. addFromContainer(container: AbstractScene): void;
  51438. /**
  51439. * Removes all the elements in the container from the scene
  51440. * @param container contains the elements to remove
  51441. * @param dispose if the removed element should be disposed (default: false)
  51442. */
  51443. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51444. /**
  51445. * Rebuilds the elements related to this component in case of
  51446. * context lost for instance.
  51447. */
  51448. dispose(): void;
  51449. private _gatherRenderTargets;
  51450. }
  51451. }
  51452. declare module "babylonjs/Lights/Shadows/index" {
  51453. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51454. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51455. }
  51456. declare module "babylonjs/Lights/pointLight" {
  51457. import { Scene } from "babylonjs/scene";
  51458. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51460. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51461. import { Effect } from "babylonjs/Materials/effect";
  51462. /**
  51463. * A point light is a light defined by an unique point in world space.
  51464. * The light is emitted in every direction from this point.
  51465. * A good example of a point light is a standard light bulb.
  51466. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51467. */
  51468. export class PointLight extends ShadowLight {
  51469. private _shadowAngle;
  51470. /**
  51471. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51472. * This specifies what angle the shadow will use to be created.
  51473. *
  51474. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51475. */
  51476. /**
  51477. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51478. * This specifies what angle the shadow will use to be created.
  51479. *
  51480. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51481. */
  51482. shadowAngle: number;
  51483. /**
  51484. * Gets the direction if it has been set.
  51485. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51486. */
  51487. /**
  51488. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51489. */
  51490. direction: Vector3;
  51491. /**
  51492. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51493. * A PointLight emits the light in every direction.
  51494. * It can cast shadows.
  51495. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51496. * ```javascript
  51497. * var pointLight = new PointLight("pl", camera.position, scene);
  51498. * ```
  51499. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51500. * @param name The light friendly name
  51501. * @param position The position of the point light in the scene
  51502. * @param scene The scene the lights belongs to
  51503. */
  51504. constructor(name: string, position: Vector3, scene: Scene);
  51505. /**
  51506. * Returns the string "PointLight"
  51507. * @returns the class name
  51508. */
  51509. getClassName(): string;
  51510. /**
  51511. * Returns the integer 0.
  51512. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51513. */
  51514. getTypeID(): number;
  51515. /**
  51516. * Specifies wether or not the shadowmap should be a cube texture.
  51517. * @returns true if the shadowmap needs to be a cube texture.
  51518. */
  51519. needCube(): boolean;
  51520. /**
  51521. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51522. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51523. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51524. */
  51525. getShadowDirection(faceIndex?: number): Vector3;
  51526. /**
  51527. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51528. * - fov = PI / 2
  51529. * - aspect ratio : 1.0
  51530. * - z-near and far equal to the active camera minZ and maxZ.
  51531. * Returns the PointLight.
  51532. */
  51533. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51534. protected _buildUniformLayout(): void;
  51535. /**
  51536. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51537. * @param effect The effect to update
  51538. * @param lightIndex The index of the light in the effect to update
  51539. * @returns The point light
  51540. */
  51541. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51542. /**
  51543. * Prepares the list of defines specific to the light type.
  51544. * @param defines the list of defines
  51545. * @param lightIndex defines the index of the light for the effect
  51546. */
  51547. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51548. }
  51549. }
  51550. declare module "babylonjs/Lights/index" {
  51551. export * from "babylonjs/Lights/light";
  51552. export * from "babylonjs/Lights/shadowLight";
  51553. export * from "babylonjs/Lights/Shadows/index";
  51554. export * from "babylonjs/Lights/directionalLight";
  51555. export * from "babylonjs/Lights/hemisphericLight";
  51556. export * from "babylonjs/Lights/pointLight";
  51557. export * from "babylonjs/Lights/spotLight";
  51558. }
  51559. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51560. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51561. /**
  51562. * Header information of HDR texture files.
  51563. */
  51564. export interface HDRInfo {
  51565. /**
  51566. * The height of the texture in pixels.
  51567. */
  51568. height: number;
  51569. /**
  51570. * The width of the texture in pixels.
  51571. */
  51572. width: number;
  51573. /**
  51574. * The index of the beginning of the data in the binary file.
  51575. */
  51576. dataPosition: number;
  51577. }
  51578. /**
  51579. * This groups tools to convert HDR texture to native colors array.
  51580. */
  51581. export class HDRTools {
  51582. private static Ldexp;
  51583. private static Rgbe2float;
  51584. private static readStringLine;
  51585. /**
  51586. * Reads header information from an RGBE texture stored in a native array.
  51587. * More information on this format are available here:
  51588. * https://en.wikipedia.org/wiki/RGBE_image_format
  51589. *
  51590. * @param uint8array The binary file stored in native array.
  51591. * @return The header information.
  51592. */
  51593. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51594. /**
  51595. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51596. * This RGBE texture needs to store the information as a panorama.
  51597. *
  51598. * More information on this format are available here:
  51599. * https://en.wikipedia.org/wiki/RGBE_image_format
  51600. *
  51601. * @param buffer The binary file stored in an array buffer.
  51602. * @param size The expected size of the extracted cubemap.
  51603. * @return The Cube Map information.
  51604. */
  51605. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51606. /**
  51607. * Returns the pixels data extracted from an RGBE texture.
  51608. * This pixels will be stored left to right up to down in the R G B order in one array.
  51609. *
  51610. * More information on this format are available here:
  51611. * https://en.wikipedia.org/wiki/RGBE_image_format
  51612. *
  51613. * @param uint8array The binary file stored in an array buffer.
  51614. * @param hdrInfo The header information of the file.
  51615. * @return The pixels data in RGB right to left up to down order.
  51616. */
  51617. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51618. private static RGBE_ReadPixels_RLE;
  51619. }
  51620. }
  51621. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51622. import { Nullable } from "babylonjs/types";
  51623. import { Scene } from "babylonjs/scene";
  51624. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51625. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51626. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51627. /**
  51628. * This represents a texture coming from an HDR input.
  51629. *
  51630. * The only supported format is currently panorama picture stored in RGBE format.
  51631. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51632. */
  51633. export class HDRCubeTexture extends BaseTexture {
  51634. private static _facesMapping;
  51635. private _generateHarmonics;
  51636. private _noMipmap;
  51637. private _textureMatrix;
  51638. private _size;
  51639. private _onLoad;
  51640. private _onError;
  51641. /**
  51642. * The texture URL.
  51643. */
  51644. url: string;
  51645. /**
  51646. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51647. */
  51648. coordinatesMode: number;
  51649. protected _isBlocking: boolean;
  51650. /**
  51651. * Sets wether or not the texture is blocking during loading.
  51652. */
  51653. /**
  51654. * Gets wether or not the texture is blocking during loading.
  51655. */
  51656. isBlocking: boolean;
  51657. protected _rotationY: number;
  51658. /**
  51659. * Sets texture matrix rotation angle around Y axis in radians.
  51660. */
  51661. /**
  51662. * Gets texture matrix rotation angle around Y axis radians.
  51663. */
  51664. rotationY: number;
  51665. /**
  51666. * Gets or sets the center of the bounding box associated with the cube texture
  51667. * It must define where the camera used to render the texture was set
  51668. */
  51669. boundingBoxPosition: Vector3;
  51670. private _boundingBoxSize;
  51671. /**
  51672. * Gets or sets the size of the bounding box associated with the cube texture
  51673. * When defined, the cubemap will switch to local mode
  51674. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51675. * @example https://www.babylonjs-playground.com/#RNASML
  51676. */
  51677. boundingBoxSize: Vector3;
  51678. /**
  51679. * Instantiates an HDRTexture from the following parameters.
  51680. *
  51681. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51682. * @param scene The scene the texture will be used in
  51683. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51684. * @param noMipmap Forces to not generate the mipmap if true
  51685. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51686. * @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)
  51687. * @param reserved Reserved flag for internal use.
  51688. */
  51689. 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>);
  51690. /**
  51691. * Get the current class name of the texture useful for serialization or dynamic coding.
  51692. * @returns "HDRCubeTexture"
  51693. */
  51694. getClassName(): string;
  51695. /**
  51696. * Occurs when the file is raw .hdr file.
  51697. */
  51698. private loadTexture;
  51699. clone(): HDRCubeTexture;
  51700. delayLoad(): void;
  51701. /**
  51702. * Get the texture reflection matrix used to rotate/transform the reflection.
  51703. * @returns the reflection matrix
  51704. */
  51705. getReflectionTextureMatrix(): Matrix;
  51706. /**
  51707. * Set the texture reflection matrix used to rotate/transform the reflection.
  51708. * @param value Define the reflection matrix to set
  51709. */
  51710. setReflectionTextureMatrix(value: Matrix): void;
  51711. /**
  51712. * Parses a JSON representation of an HDR Texture in order to create the texture
  51713. * @param parsedTexture Define the JSON representation
  51714. * @param scene Define the scene the texture should be created in
  51715. * @param rootUrl Define the root url in case we need to load relative dependencies
  51716. * @returns the newly created texture after parsing
  51717. */
  51718. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51719. serialize(): any;
  51720. }
  51721. }
  51722. declare module "babylonjs/Physics/physicsEngine" {
  51723. import { Nullable } from "babylonjs/types";
  51724. import { Vector3 } from "babylonjs/Maths/math.vector";
  51725. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51726. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51727. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51728. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51729. /**
  51730. * Class used to control physics engine
  51731. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51732. */
  51733. export class PhysicsEngine implements IPhysicsEngine {
  51734. private _physicsPlugin;
  51735. /**
  51736. * Global value used to control the smallest number supported by the simulation
  51737. */
  51738. static Epsilon: number;
  51739. private _impostors;
  51740. private _joints;
  51741. /**
  51742. * Gets the gravity vector used by the simulation
  51743. */
  51744. gravity: Vector3;
  51745. /**
  51746. * Factory used to create the default physics plugin.
  51747. * @returns The default physics plugin
  51748. */
  51749. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51750. /**
  51751. * Creates a new Physics Engine
  51752. * @param gravity defines the gravity vector used by the simulation
  51753. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51754. */
  51755. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51756. /**
  51757. * Sets the gravity vector used by the simulation
  51758. * @param gravity defines the gravity vector to use
  51759. */
  51760. setGravity(gravity: Vector3): void;
  51761. /**
  51762. * Set the time step of the physics engine.
  51763. * Default is 1/60.
  51764. * To slow it down, enter 1/600 for example.
  51765. * To speed it up, 1/30
  51766. * @param newTimeStep defines the new timestep to apply to this world.
  51767. */
  51768. setTimeStep(newTimeStep?: number): void;
  51769. /**
  51770. * Get the time step of the physics engine.
  51771. * @returns the current time step
  51772. */
  51773. getTimeStep(): number;
  51774. /**
  51775. * Release all resources
  51776. */
  51777. dispose(): void;
  51778. /**
  51779. * Gets the name of the current physics plugin
  51780. * @returns the name of the plugin
  51781. */
  51782. getPhysicsPluginName(): string;
  51783. /**
  51784. * Adding a new impostor for the impostor tracking.
  51785. * This will be done by the impostor itself.
  51786. * @param impostor the impostor to add
  51787. */
  51788. addImpostor(impostor: PhysicsImpostor): void;
  51789. /**
  51790. * Remove an impostor from the engine.
  51791. * This impostor and its mesh will not longer be updated by the physics engine.
  51792. * @param impostor the impostor to remove
  51793. */
  51794. removeImpostor(impostor: PhysicsImpostor): void;
  51795. /**
  51796. * Add a joint to the physics engine
  51797. * @param mainImpostor defines the main impostor to which the joint is added.
  51798. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51799. * @param joint defines the joint that will connect both impostors.
  51800. */
  51801. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51802. /**
  51803. * Removes a joint from the simulation
  51804. * @param mainImpostor defines the impostor used with the joint
  51805. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51806. * @param joint defines the joint to remove
  51807. */
  51808. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51809. /**
  51810. * Called by the scene. No need to call it.
  51811. * @param delta defines the timespam between frames
  51812. */
  51813. _step(delta: number): void;
  51814. /**
  51815. * Gets the current plugin used to run the simulation
  51816. * @returns current plugin
  51817. */
  51818. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51819. /**
  51820. * Gets the list of physic impostors
  51821. * @returns an array of PhysicsImpostor
  51822. */
  51823. getImpostors(): Array<PhysicsImpostor>;
  51824. /**
  51825. * Gets the impostor for a physics enabled object
  51826. * @param object defines the object impersonated by the impostor
  51827. * @returns the PhysicsImpostor or null if not found
  51828. */
  51829. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51830. /**
  51831. * Gets the impostor for a physics body object
  51832. * @param body defines physics body used by the impostor
  51833. * @returns the PhysicsImpostor or null if not found
  51834. */
  51835. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51836. /**
  51837. * Does a raycast in the physics world
  51838. * @param from when should the ray start?
  51839. * @param to when should the ray end?
  51840. * @returns PhysicsRaycastResult
  51841. */
  51842. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51843. }
  51844. }
  51845. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51846. import { Nullable } from "babylonjs/types";
  51847. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51849. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51850. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51851. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51852. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51853. /** @hidden */
  51854. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51855. private _useDeltaForWorldStep;
  51856. world: any;
  51857. name: string;
  51858. private _physicsMaterials;
  51859. private _fixedTimeStep;
  51860. private _cannonRaycastResult;
  51861. private _raycastResult;
  51862. private _physicsBodysToRemoveAfterStep;
  51863. BJSCANNON: any;
  51864. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51865. setGravity(gravity: Vector3): void;
  51866. setTimeStep(timeStep: number): void;
  51867. getTimeStep(): number;
  51868. executeStep(delta: number): void;
  51869. private _removeMarkedPhysicsBodiesFromWorld;
  51870. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51871. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51872. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51873. private _processChildMeshes;
  51874. removePhysicsBody(impostor: PhysicsImpostor): void;
  51875. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51876. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51877. private _addMaterial;
  51878. private _checkWithEpsilon;
  51879. private _createShape;
  51880. private _createHeightmap;
  51881. private _minus90X;
  51882. private _plus90X;
  51883. private _tmpPosition;
  51884. private _tmpDeltaPosition;
  51885. private _tmpUnityRotation;
  51886. private _updatePhysicsBodyTransformation;
  51887. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51888. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51889. isSupported(): boolean;
  51890. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51891. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51892. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51893. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51894. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51895. getBodyMass(impostor: PhysicsImpostor): number;
  51896. getBodyFriction(impostor: PhysicsImpostor): number;
  51897. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51898. getBodyRestitution(impostor: PhysicsImpostor): number;
  51899. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51900. sleepBody(impostor: PhysicsImpostor): void;
  51901. wakeUpBody(impostor: PhysicsImpostor): void;
  51902. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51903. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51904. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51905. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51906. getRadius(impostor: PhysicsImpostor): number;
  51907. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51908. dispose(): void;
  51909. private _extendNamespace;
  51910. /**
  51911. * Does a raycast in the physics world
  51912. * @param from when should the ray start?
  51913. * @param to when should the ray end?
  51914. * @returns PhysicsRaycastResult
  51915. */
  51916. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51917. }
  51918. }
  51919. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51920. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51921. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51922. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51924. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51925. import { Nullable } from "babylonjs/types";
  51926. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51927. /** @hidden */
  51928. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51929. world: any;
  51930. name: string;
  51931. BJSOIMO: any;
  51932. private _raycastResult;
  51933. constructor(iterations?: number, oimoInjection?: any);
  51934. setGravity(gravity: Vector3): void;
  51935. setTimeStep(timeStep: number): void;
  51936. getTimeStep(): number;
  51937. private _tmpImpostorsArray;
  51938. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51939. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51940. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51941. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51942. private _tmpPositionVector;
  51943. removePhysicsBody(impostor: PhysicsImpostor): void;
  51944. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51945. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51946. isSupported(): boolean;
  51947. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51948. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51949. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51950. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51951. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51952. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51953. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51954. getBodyMass(impostor: PhysicsImpostor): number;
  51955. getBodyFriction(impostor: PhysicsImpostor): number;
  51956. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51957. getBodyRestitution(impostor: PhysicsImpostor): number;
  51958. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51959. sleepBody(impostor: PhysicsImpostor): void;
  51960. wakeUpBody(impostor: PhysicsImpostor): void;
  51961. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51962. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51963. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51964. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51965. getRadius(impostor: PhysicsImpostor): number;
  51966. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51967. dispose(): void;
  51968. /**
  51969. * Does a raycast in the physics world
  51970. * @param from when should the ray start?
  51971. * @param to when should the ray end?
  51972. * @returns PhysicsRaycastResult
  51973. */
  51974. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51975. }
  51976. }
  51977. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51978. import { Nullable } from "babylonjs/types";
  51979. import { Scene } from "babylonjs/scene";
  51980. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  51981. import { Color4 } from "babylonjs/Maths/math.color";
  51982. import { Mesh } from "babylonjs/Meshes/mesh";
  51983. /**
  51984. * Class containing static functions to help procedurally build meshes
  51985. */
  51986. export class RibbonBuilder {
  51987. /**
  51988. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51989. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51990. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51991. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51992. * * 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
  51993. * * 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
  51994. * * 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
  51995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51997. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51998. * * 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
  51999. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52000. * * 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
  52001. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52003. * @param name defines the name of the mesh
  52004. * @param options defines the options used to create the mesh
  52005. * @param scene defines the hosting scene
  52006. * @returns the ribbon mesh
  52007. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52008. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52009. */
  52010. static CreateRibbon(name: string, options: {
  52011. pathArray: Vector3[][];
  52012. closeArray?: boolean;
  52013. closePath?: boolean;
  52014. offset?: number;
  52015. updatable?: boolean;
  52016. sideOrientation?: number;
  52017. frontUVs?: Vector4;
  52018. backUVs?: Vector4;
  52019. instance?: Mesh;
  52020. invertUV?: boolean;
  52021. uvs?: Vector2[];
  52022. colors?: Color4[];
  52023. }, scene?: Nullable<Scene>): Mesh;
  52024. }
  52025. }
  52026. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52027. import { Nullable } from "babylonjs/types";
  52028. import { Scene } from "babylonjs/scene";
  52029. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52030. import { Mesh } from "babylonjs/Meshes/mesh";
  52031. /**
  52032. * Class containing static functions to help procedurally build meshes
  52033. */
  52034. export class ShapeBuilder {
  52035. /**
  52036. * 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.
  52037. * * 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.
  52038. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52039. * * 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.
  52040. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52041. * * 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
  52042. * * 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
  52043. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52046. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52048. * @param name defines the name of the mesh
  52049. * @param options defines the options used to create the mesh
  52050. * @param scene defines the hosting scene
  52051. * @returns the extruded shape mesh
  52052. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52053. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52054. */
  52055. static ExtrudeShape(name: string, options: {
  52056. shape: Vector3[];
  52057. path: Vector3[];
  52058. scale?: number;
  52059. rotation?: number;
  52060. cap?: number;
  52061. updatable?: boolean;
  52062. sideOrientation?: number;
  52063. frontUVs?: Vector4;
  52064. backUVs?: Vector4;
  52065. instance?: Mesh;
  52066. invertUV?: boolean;
  52067. }, scene?: Nullable<Scene>): Mesh;
  52068. /**
  52069. * Creates an custom extruded shape mesh.
  52070. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52071. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  52072. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52073. * * The parameter `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
  52074. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52075. * * 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
  52076. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52077. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52078. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52079. * * 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
  52080. * * 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
  52081. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52083. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52084. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52086. * @param name defines the name of the mesh
  52087. * @param options defines the options used to create the mesh
  52088. * @param scene defines the hosting scene
  52089. * @returns the custom extruded shape mesh
  52090. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52091. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52093. */
  52094. static ExtrudeShapeCustom(name: string, options: {
  52095. shape: Vector3[];
  52096. path: Vector3[];
  52097. scaleFunction?: any;
  52098. rotationFunction?: any;
  52099. ribbonCloseArray?: boolean;
  52100. ribbonClosePath?: boolean;
  52101. cap?: number;
  52102. updatable?: boolean;
  52103. sideOrientation?: number;
  52104. frontUVs?: Vector4;
  52105. backUVs?: Vector4;
  52106. instance?: Mesh;
  52107. invertUV?: boolean;
  52108. }, scene?: Nullable<Scene>): Mesh;
  52109. private static _ExtrudeShapeGeneric;
  52110. }
  52111. }
  52112. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52113. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52114. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52115. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52116. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52117. import { Nullable } from "babylonjs/types";
  52118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52119. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52120. /**
  52121. * AmmoJS Physics plugin
  52122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52123. * @see https://github.com/kripken/ammo.js/
  52124. */
  52125. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52126. private _useDeltaForWorldStep;
  52127. /**
  52128. * Reference to the Ammo library
  52129. */
  52130. bjsAMMO: any;
  52131. /**
  52132. * Created ammoJS world which physics bodies are added to
  52133. */
  52134. world: any;
  52135. /**
  52136. * Name of the plugin
  52137. */
  52138. name: string;
  52139. private _timeStep;
  52140. private _fixedTimeStep;
  52141. private _maxSteps;
  52142. private _tmpQuaternion;
  52143. private _tmpAmmoTransform;
  52144. private _tmpAmmoQuaternion;
  52145. private _tmpAmmoConcreteContactResultCallback;
  52146. private _collisionConfiguration;
  52147. private _dispatcher;
  52148. private _overlappingPairCache;
  52149. private _solver;
  52150. private _softBodySolver;
  52151. private _tmpAmmoVectorA;
  52152. private _tmpAmmoVectorB;
  52153. private _tmpAmmoVectorC;
  52154. private _tmpAmmoVectorD;
  52155. private _tmpContactCallbackResult;
  52156. private _tmpAmmoVectorRCA;
  52157. private _tmpAmmoVectorRCB;
  52158. private _raycastResult;
  52159. private static readonly DISABLE_COLLISION_FLAG;
  52160. private static readonly KINEMATIC_FLAG;
  52161. private static readonly DISABLE_DEACTIVATION_FLAG;
  52162. /**
  52163. * Initializes the ammoJS plugin
  52164. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52165. * @param ammoInjection can be used to inject your own ammo reference
  52166. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52167. */
  52168. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52169. /**
  52170. * Sets the gravity of the physics world (m/(s^2))
  52171. * @param gravity Gravity to set
  52172. */
  52173. setGravity(gravity: Vector3): void;
  52174. /**
  52175. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52176. * @param timeStep timestep to use in seconds
  52177. */
  52178. setTimeStep(timeStep: number): void;
  52179. /**
  52180. * 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)
  52181. * @param fixedTimeStep fixedTimeStep to use in seconds
  52182. */
  52183. setFixedTimeStep(fixedTimeStep: number): void;
  52184. /**
  52185. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52186. * @param maxSteps the maximum number of steps by the physics engine per frame
  52187. */
  52188. setMaxSteps(maxSteps: number): void;
  52189. /**
  52190. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52191. * @returns the current timestep in seconds
  52192. */
  52193. getTimeStep(): number;
  52194. private _isImpostorInContact;
  52195. private _isImpostorPairInContact;
  52196. private _stepSimulation;
  52197. /**
  52198. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52199. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52200. * After the step the babylon meshes are set to the position of the physics imposters
  52201. * @param delta amount of time to step forward
  52202. * @param impostors array of imposters to update before/after the step
  52203. */
  52204. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52205. /**
  52206. * Update babylon mesh to match physics world object
  52207. * @param impostor imposter to match
  52208. */
  52209. private _afterSoftStep;
  52210. /**
  52211. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52212. * @param impostor imposter to match
  52213. */
  52214. private _ropeStep;
  52215. /**
  52216. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52217. * @param impostor imposter to match
  52218. */
  52219. private _softbodyOrClothStep;
  52220. private _tmpVector;
  52221. private _tmpMatrix;
  52222. /**
  52223. * Applies an impulse on the imposter
  52224. * @param impostor imposter to apply impulse to
  52225. * @param force amount of force to be applied to the imposter
  52226. * @param contactPoint the location to apply the impulse on the imposter
  52227. */
  52228. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52229. /**
  52230. * Applies a force on the imposter
  52231. * @param impostor imposter to apply force
  52232. * @param force amount of force to be applied to the imposter
  52233. * @param contactPoint the location to apply the force on the imposter
  52234. */
  52235. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52236. /**
  52237. * Creates a physics body using the plugin
  52238. * @param impostor the imposter to create the physics body on
  52239. */
  52240. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52241. /**
  52242. * Removes the physics body from the imposter and disposes of the body's memory
  52243. * @param impostor imposter to remove the physics body from
  52244. */
  52245. removePhysicsBody(impostor: PhysicsImpostor): void;
  52246. /**
  52247. * Generates a joint
  52248. * @param impostorJoint the imposter joint to create the joint with
  52249. */
  52250. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52251. /**
  52252. * Removes a joint
  52253. * @param impostorJoint the imposter joint to remove the joint from
  52254. */
  52255. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52256. private _addMeshVerts;
  52257. /**
  52258. * Initialise the soft body vertices to match its object's (mesh) vertices
  52259. * Softbody vertices (nodes) are in world space and to match this
  52260. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52261. * @param impostor to create the softbody for
  52262. */
  52263. private _softVertexData;
  52264. /**
  52265. * Create an impostor's soft body
  52266. * @param impostor to create the softbody for
  52267. */
  52268. private _createSoftbody;
  52269. /**
  52270. * Create cloth for an impostor
  52271. * @param impostor to create the softbody for
  52272. */
  52273. private _createCloth;
  52274. /**
  52275. * Create rope for an impostor
  52276. * @param impostor to create the softbody for
  52277. */
  52278. private _createRope;
  52279. private _addHullVerts;
  52280. private _createShape;
  52281. /**
  52282. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52283. * @param impostor imposter containing the physics body and babylon object
  52284. */
  52285. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52286. /**
  52287. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52288. * @param impostor imposter containing the physics body and babylon object
  52289. * @param newPosition new position
  52290. * @param newRotation new rotation
  52291. */
  52292. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52293. /**
  52294. * If this plugin is supported
  52295. * @returns true if its supported
  52296. */
  52297. isSupported(): boolean;
  52298. /**
  52299. * Sets the linear velocity of the physics body
  52300. * @param impostor imposter to set the velocity on
  52301. * @param velocity velocity to set
  52302. */
  52303. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52304. /**
  52305. * Sets the angular velocity of the physics body
  52306. * @param impostor imposter to set the velocity on
  52307. * @param velocity velocity to set
  52308. */
  52309. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52310. /**
  52311. * gets the linear velocity
  52312. * @param impostor imposter to get linear velocity from
  52313. * @returns linear velocity
  52314. */
  52315. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52316. /**
  52317. * gets the angular velocity
  52318. * @param impostor imposter to get angular velocity from
  52319. * @returns angular velocity
  52320. */
  52321. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52322. /**
  52323. * Sets the mass of physics body
  52324. * @param impostor imposter to set the mass on
  52325. * @param mass mass to set
  52326. */
  52327. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52328. /**
  52329. * Gets the mass of the physics body
  52330. * @param impostor imposter to get the mass from
  52331. * @returns mass
  52332. */
  52333. getBodyMass(impostor: PhysicsImpostor): number;
  52334. /**
  52335. * Gets friction of the impostor
  52336. * @param impostor impostor to get friction from
  52337. * @returns friction value
  52338. */
  52339. getBodyFriction(impostor: PhysicsImpostor): number;
  52340. /**
  52341. * Sets friction of the impostor
  52342. * @param impostor impostor to set friction on
  52343. * @param friction friction value
  52344. */
  52345. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52346. /**
  52347. * Gets restitution of the impostor
  52348. * @param impostor impostor to get restitution from
  52349. * @returns restitution value
  52350. */
  52351. getBodyRestitution(impostor: PhysicsImpostor): number;
  52352. /**
  52353. * Sets resitution of the impostor
  52354. * @param impostor impostor to set resitution on
  52355. * @param restitution resitution value
  52356. */
  52357. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52358. /**
  52359. * Gets pressure inside the impostor
  52360. * @param impostor impostor to get pressure from
  52361. * @returns pressure value
  52362. */
  52363. getBodyPressure(impostor: PhysicsImpostor): number;
  52364. /**
  52365. * Sets pressure inside a soft body impostor
  52366. * Cloth and rope must remain 0 pressure
  52367. * @param impostor impostor to set pressure on
  52368. * @param pressure pressure value
  52369. */
  52370. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52371. /**
  52372. * Gets stiffness of the impostor
  52373. * @param impostor impostor to get stiffness from
  52374. * @returns pressure value
  52375. */
  52376. getBodyStiffness(impostor: PhysicsImpostor): number;
  52377. /**
  52378. * Sets stiffness of the impostor
  52379. * @param impostor impostor to set stiffness on
  52380. * @param stiffness stiffness value from 0 to 1
  52381. */
  52382. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52383. /**
  52384. * Gets velocityIterations of the impostor
  52385. * @param impostor impostor to get velocity iterations from
  52386. * @returns velocityIterations value
  52387. */
  52388. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52389. /**
  52390. * Sets velocityIterations of the impostor
  52391. * @param impostor impostor to set velocity iterations on
  52392. * @param velocityIterations velocityIterations value
  52393. */
  52394. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52395. /**
  52396. * Gets positionIterations of the impostor
  52397. * @param impostor impostor to get position iterations from
  52398. * @returns positionIterations value
  52399. */
  52400. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52401. /**
  52402. * Sets positionIterations of the impostor
  52403. * @param impostor impostor to set position on
  52404. * @param positionIterations positionIterations value
  52405. */
  52406. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52407. /**
  52408. * Append an anchor to a cloth object
  52409. * @param impostor is the cloth impostor to add anchor to
  52410. * @param otherImpostor is the rigid impostor to anchor to
  52411. * @param width ratio across width from 0 to 1
  52412. * @param height ratio up height from 0 to 1
  52413. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52414. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52415. */
  52416. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52417. /**
  52418. * Append an hook to a rope object
  52419. * @param impostor is the rope impostor to add hook to
  52420. * @param otherImpostor is the rigid impostor to hook to
  52421. * @param length ratio along the rope from 0 to 1
  52422. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52423. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52424. */
  52425. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52426. /**
  52427. * Sleeps the physics body and stops it from being active
  52428. * @param impostor impostor to sleep
  52429. */
  52430. sleepBody(impostor: PhysicsImpostor): void;
  52431. /**
  52432. * Activates the physics body
  52433. * @param impostor impostor to activate
  52434. */
  52435. wakeUpBody(impostor: PhysicsImpostor): void;
  52436. /**
  52437. * Updates the distance parameters of the joint
  52438. * @param joint joint to update
  52439. * @param maxDistance maximum distance of the joint
  52440. * @param minDistance minimum distance of the joint
  52441. */
  52442. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52443. /**
  52444. * Sets a motor on the joint
  52445. * @param joint joint to set motor on
  52446. * @param speed speed of the motor
  52447. * @param maxForce maximum force of the motor
  52448. * @param motorIndex index of the motor
  52449. */
  52450. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52451. /**
  52452. * Sets the motors limit
  52453. * @param joint joint to set limit on
  52454. * @param upperLimit upper limit
  52455. * @param lowerLimit lower limit
  52456. */
  52457. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52458. /**
  52459. * Syncs the position and rotation of a mesh with the impostor
  52460. * @param mesh mesh to sync
  52461. * @param impostor impostor to update the mesh with
  52462. */
  52463. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52464. /**
  52465. * Gets the radius of the impostor
  52466. * @param impostor impostor to get radius from
  52467. * @returns the radius
  52468. */
  52469. getRadius(impostor: PhysicsImpostor): number;
  52470. /**
  52471. * Gets the box size of the impostor
  52472. * @param impostor impostor to get box size from
  52473. * @param result the resulting box size
  52474. */
  52475. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52476. /**
  52477. * Disposes of the impostor
  52478. */
  52479. dispose(): void;
  52480. /**
  52481. * Does a raycast in the physics world
  52482. * @param from when should the ray start?
  52483. * @param to when should the ray end?
  52484. * @returns PhysicsRaycastResult
  52485. */
  52486. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52487. }
  52488. }
  52489. declare module "babylonjs/Probes/reflectionProbe" {
  52490. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52491. import { Vector3 } from "babylonjs/Maths/math.vector";
  52492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52493. import { Nullable } from "babylonjs/types";
  52494. import { Scene } from "babylonjs/scene";
  52495. module "babylonjs/abstractScene" {
  52496. interface AbstractScene {
  52497. /**
  52498. * The list of reflection probes added to the scene
  52499. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52500. */
  52501. reflectionProbes: Array<ReflectionProbe>;
  52502. /**
  52503. * Removes the given reflection probe from this scene.
  52504. * @param toRemove The reflection probe to remove
  52505. * @returns The index of the removed reflection probe
  52506. */
  52507. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52508. /**
  52509. * Adds the given reflection probe to this scene.
  52510. * @param newReflectionProbe The reflection probe to add
  52511. */
  52512. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52513. }
  52514. }
  52515. /**
  52516. * Class used to generate realtime reflection / refraction cube textures
  52517. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52518. */
  52519. export class ReflectionProbe {
  52520. /** defines the name of the probe */
  52521. name: string;
  52522. private _scene;
  52523. private _renderTargetTexture;
  52524. private _projectionMatrix;
  52525. private _viewMatrix;
  52526. private _target;
  52527. private _add;
  52528. private _attachedMesh;
  52529. private _invertYAxis;
  52530. /** Gets or sets probe position (center of the cube map) */
  52531. position: Vector3;
  52532. /**
  52533. * Creates a new reflection probe
  52534. * @param name defines the name of the probe
  52535. * @param size defines the texture resolution (for each face)
  52536. * @param scene defines the hosting scene
  52537. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52538. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52539. */
  52540. constructor(
  52541. /** defines the name of the probe */
  52542. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52543. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52544. samples: number;
  52545. /** Gets or sets the refresh rate to use (on every frame by default) */
  52546. refreshRate: number;
  52547. /**
  52548. * Gets the hosting scene
  52549. * @returns a Scene
  52550. */
  52551. getScene(): Scene;
  52552. /** Gets the internal CubeTexture used to render to */
  52553. readonly cubeTexture: RenderTargetTexture;
  52554. /** Gets the list of meshes to render */
  52555. readonly renderList: Nullable<AbstractMesh[]>;
  52556. /**
  52557. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52558. * @param mesh defines the mesh to attach to
  52559. */
  52560. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52561. /**
  52562. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52563. * @param renderingGroupId The rendering group id corresponding to its index
  52564. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52565. */
  52566. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52567. /**
  52568. * Clean all associated resources
  52569. */
  52570. dispose(): void;
  52571. /**
  52572. * Converts the reflection probe information to a readable string for debug purpose.
  52573. * @param fullDetails Supports for multiple levels of logging within scene loading
  52574. * @returns the human readable reflection probe info
  52575. */
  52576. toString(fullDetails?: boolean): string;
  52577. /**
  52578. * Get the class name of the relfection probe.
  52579. * @returns "ReflectionProbe"
  52580. */
  52581. getClassName(): string;
  52582. /**
  52583. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52584. * @returns The JSON representation of the texture
  52585. */
  52586. serialize(): any;
  52587. /**
  52588. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52589. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52590. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52591. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52592. * @returns The parsed reflection probe if successful
  52593. */
  52594. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52595. }
  52596. }
  52597. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52598. /** @hidden */
  52599. export var _BabylonLoaderRegistered: boolean;
  52600. }
  52601. declare module "babylonjs/Loading/Plugins/index" {
  52602. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52603. }
  52604. declare module "babylonjs/Loading/index" {
  52605. export * from "babylonjs/Loading/loadingScreen";
  52606. export * from "babylonjs/Loading/Plugins/index";
  52607. export * from "babylonjs/Loading/sceneLoader";
  52608. export * from "babylonjs/Loading/sceneLoaderFlags";
  52609. }
  52610. declare module "babylonjs/Materials/Background/index" {
  52611. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52612. }
  52613. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52614. import { Scene } from "babylonjs/scene";
  52615. import { Color3 } from "babylonjs/Maths/math.color";
  52616. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52617. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52618. /**
  52619. * The Physically based simple base material of BJS.
  52620. *
  52621. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52622. * It is used as the base class for both the specGloss and metalRough conventions.
  52623. */
  52624. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52625. /**
  52626. * Number of Simultaneous lights allowed on the material.
  52627. */
  52628. maxSimultaneousLights: number;
  52629. /**
  52630. * If sets to true, disables all the lights affecting the material.
  52631. */
  52632. disableLighting: boolean;
  52633. /**
  52634. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52635. */
  52636. environmentTexture: BaseTexture;
  52637. /**
  52638. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52639. */
  52640. invertNormalMapX: boolean;
  52641. /**
  52642. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52643. */
  52644. invertNormalMapY: boolean;
  52645. /**
  52646. * Normal map used in the model.
  52647. */
  52648. normalTexture: BaseTexture;
  52649. /**
  52650. * Emissivie color used to self-illuminate the model.
  52651. */
  52652. emissiveColor: Color3;
  52653. /**
  52654. * Emissivie texture used to self-illuminate the model.
  52655. */
  52656. emissiveTexture: BaseTexture;
  52657. /**
  52658. * Occlusion Channel Strenght.
  52659. */
  52660. occlusionStrength: number;
  52661. /**
  52662. * Occlusion Texture of the material (adding extra occlusion effects).
  52663. */
  52664. occlusionTexture: BaseTexture;
  52665. /**
  52666. * Defines the alpha limits in alpha test mode.
  52667. */
  52668. alphaCutOff: number;
  52669. /**
  52670. * Gets the current double sided mode.
  52671. */
  52672. /**
  52673. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52674. */
  52675. doubleSided: boolean;
  52676. /**
  52677. * Stores the pre-calculated light information of a mesh in a texture.
  52678. */
  52679. lightmapTexture: BaseTexture;
  52680. /**
  52681. * If true, the light map contains occlusion information instead of lighting info.
  52682. */
  52683. useLightmapAsShadowmap: boolean;
  52684. /**
  52685. * Instantiates a new PBRMaterial instance.
  52686. *
  52687. * @param name The material name
  52688. * @param scene The scene the material will be use in.
  52689. */
  52690. constructor(name: string, scene: Scene);
  52691. getClassName(): string;
  52692. }
  52693. }
  52694. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52695. import { Scene } from "babylonjs/scene";
  52696. import { Color3 } from "babylonjs/Maths/math.color";
  52697. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52698. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52699. /**
  52700. * The PBR material of BJS following the metal roughness convention.
  52701. *
  52702. * This fits to the PBR convention in the GLTF definition:
  52703. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52704. */
  52705. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52706. /**
  52707. * The base color has two different interpretations depending on the value of metalness.
  52708. * When the material is a metal, the base color is the specific measured reflectance value
  52709. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52710. * of the material.
  52711. */
  52712. baseColor: Color3;
  52713. /**
  52714. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52715. * well as opacity information in the alpha channel.
  52716. */
  52717. baseTexture: BaseTexture;
  52718. /**
  52719. * Specifies the metallic scalar value of the material.
  52720. * Can also be used to scale the metalness values of the metallic texture.
  52721. */
  52722. metallic: number;
  52723. /**
  52724. * Specifies the roughness scalar value of the material.
  52725. * Can also be used to scale the roughness values of the metallic texture.
  52726. */
  52727. roughness: number;
  52728. /**
  52729. * Texture containing both the metallic value in the B channel and the
  52730. * roughness value in the G channel to keep better precision.
  52731. */
  52732. metallicRoughnessTexture: BaseTexture;
  52733. /**
  52734. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52735. *
  52736. * @param name The material name
  52737. * @param scene The scene the material will be use in.
  52738. */
  52739. constructor(name: string, scene: Scene);
  52740. /**
  52741. * Return the currrent class name of the material.
  52742. */
  52743. getClassName(): string;
  52744. /**
  52745. * Makes a duplicate of the current material.
  52746. * @param name - name to use for the new material.
  52747. */
  52748. clone(name: string): PBRMetallicRoughnessMaterial;
  52749. /**
  52750. * Serialize the material to a parsable JSON object.
  52751. */
  52752. serialize(): any;
  52753. /**
  52754. * Parses a JSON object correponding to the serialize function.
  52755. */
  52756. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52757. }
  52758. }
  52759. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52760. import { Scene } from "babylonjs/scene";
  52761. import { Color3 } from "babylonjs/Maths/math.color";
  52762. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52763. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52764. /**
  52765. * The PBR material of BJS following the specular glossiness convention.
  52766. *
  52767. * This fits to the PBR convention in the GLTF definition:
  52768. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52769. */
  52770. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52771. /**
  52772. * Specifies the diffuse color of the material.
  52773. */
  52774. diffuseColor: Color3;
  52775. /**
  52776. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52777. * channel.
  52778. */
  52779. diffuseTexture: BaseTexture;
  52780. /**
  52781. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52782. */
  52783. specularColor: Color3;
  52784. /**
  52785. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52786. */
  52787. glossiness: number;
  52788. /**
  52789. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52790. */
  52791. specularGlossinessTexture: BaseTexture;
  52792. /**
  52793. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52794. *
  52795. * @param name The material name
  52796. * @param scene The scene the material will be use in.
  52797. */
  52798. constructor(name: string, scene: Scene);
  52799. /**
  52800. * Return the currrent class name of the material.
  52801. */
  52802. getClassName(): string;
  52803. /**
  52804. * Makes a duplicate of the current material.
  52805. * @param name - name to use for the new material.
  52806. */
  52807. clone(name: string): PBRSpecularGlossinessMaterial;
  52808. /**
  52809. * Serialize the material to a parsable JSON object.
  52810. */
  52811. serialize(): any;
  52812. /**
  52813. * Parses a JSON object correponding to the serialize function.
  52814. */
  52815. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52816. }
  52817. }
  52818. declare module "babylonjs/Materials/PBR/index" {
  52819. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52820. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52821. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52822. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52823. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52824. }
  52825. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52826. import { Nullable } from "babylonjs/types";
  52827. import { Scene } from "babylonjs/scene";
  52828. import { Matrix } from "babylonjs/Maths/math.vector";
  52829. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52830. /**
  52831. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52832. * It can help converting any input color in a desired output one. This can then be used to create effects
  52833. * from sepia, black and white to sixties or futuristic rendering...
  52834. *
  52835. * The only supported format is currently 3dl.
  52836. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52837. */
  52838. export class ColorGradingTexture extends BaseTexture {
  52839. /**
  52840. * The current texture matrix. (will always be identity in color grading texture)
  52841. */
  52842. private _textureMatrix;
  52843. /**
  52844. * The texture URL.
  52845. */
  52846. url: string;
  52847. /**
  52848. * Empty line regex stored for GC.
  52849. */
  52850. private static _noneEmptyLineRegex;
  52851. private _engine;
  52852. /**
  52853. * Instantiates a ColorGradingTexture from the following parameters.
  52854. *
  52855. * @param url The location of the color gradind data (currently only supporting 3dl)
  52856. * @param scene The scene the texture will be used in
  52857. */
  52858. constructor(url: string, scene: Scene);
  52859. /**
  52860. * Returns the texture matrix used in most of the material.
  52861. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52862. */
  52863. getTextureMatrix(): Matrix;
  52864. /**
  52865. * Occurs when the file being loaded is a .3dl LUT file.
  52866. */
  52867. private load3dlTexture;
  52868. /**
  52869. * Starts the loading process of the texture.
  52870. */
  52871. private loadTexture;
  52872. /**
  52873. * Clones the color gradind texture.
  52874. */
  52875. clone(): ColorGradingTexture;
  52876. /**
  52877. * Called during delayed load for textures.
  52878. */
  52879. delayLoad(): void;
  52880. /**
  52881. * Parses a color grading texture serialized by Babylon.
  52882. * @param parsedTexture The texture information being parsedTexture
  52883. * @param scene The scene to load the texture in
  52884. * @param rootUrl The root url of the data assets to load
  52885. * @return A color gradind texture
  52886. */
  52887. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52888. /**
  52889. * Serializes the LUT texture to json format.
  52890. */
  52891. serialize(): any;
  52892. }
  52893. }
  52894. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52895. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52896. import { Scene } from "babylonjs/scene";
  52897. import { Nullable } from "babylonjs/types";
  52898. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52899. /**
  52900. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52901. */
  52902. export class EquiRectangularCubeTexture extends BaseTexture {
  52903. /** The six faces of the cube. */
  52904. private static _FacesMapping;
  52905. private _noMipmap;
  52906. private _onLoad;
  52907. private _onError;
  52908. /** The size of the cubemap. */
  52909. private _size;
  52910. /** The buffer of the image. */
  52911. private _buffer;
  52912. /** The width of the input image. */
  52913. private _width;
  52914. /** The height of the input image. */
  52915. private _height;
  52916. /** The URL to the image. */
  52917. url: string;
  52918. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52919. coordinatesMode: number;
  52920. /**
  52921. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52922. * @param url The location of the image
  52923. * @param scene The scene the texture will be used in
  52924. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52925. * @param noMipmap Forces to not generate the mipmap if true
  52926. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52927. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52928. * @param onLoad — defines a callback called when texture is loaded
  52929. * @param onError — defines a callback called if there is an error
  52930. */
  52931. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52932. /**
  52933. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52934. */
  52935. private loadImage;
  52936. /**
  52937. * Convert the image buffer into a cubemap and create a CubeTexture.
  52938. */
  52939. private loadTexture;
  52940. /**
  52941. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52942. * @param buffer The ArrayBuffer that should be converted.
  52943. * @returns The buffer as Float32Array.
  52944. */
  52945. private getFloat32ArrayFromArrayBuffer;
  52946. /**
  52947. * Get the current class name of the texture useful for serialization or dynamic coding.
  52948. * @returns "EquiRectangularCubeTexture"
  52949. */
  52950. getClassName(): string;
  52951. /**
  52952. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52953. * @returns A clone of the current EquiRectangularCubeTexture.
  52954. */
  52955. clone(): EquiRectangularCubeTexture;
  52956. }
  52957. }
  52958. declare module "babylonjs/Misc/tga" {
  52959. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52960. /**
  52961. * Based on jsTGALoader - Javascript loader for TGA file
  52962. * By Vincent Thibault
  52963. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52964. */
  52965. export class TGATools {
  52966. private static _TYPE_INDEXED;
  52967. private static _TYPE_RGB;
  52968. private static _TYPE_GREY;
  52969. private static _TYPE_RLE_INDEXED;
  52970. private static _TYPE_RLE_RGB;
  52971. private static _TYPE_RLE_GREY;
  52972. private static _ORIGIN_MASK;
  52973. private static _ORIGIN_SHIFT;
  52974. private static _ORIGIN_BL;
  52975. private static _ORIGIN_BR;
  52976. private static _ORIGIN_UL;
  52977. private static _ORIGIN_UR;
  52978. /**
  52979. * Gets the header of a TGA file
  52980. * @param data defines the TGA data
  52981. * @returns the header
  52982. */
  52983. static GetTGAHeader(data: Uint8Array): any;
  52984. /**
  52985. * Uploads TGA content to a Babylon Texture
  52986. * @hidden
  52987. */
  52988. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52989. /** @hidden */
  52990. 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;
  52991. /** @hidden */
  52992. 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;
  52993. /** @hidden */
  52994. 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;
  52995. /** @hidden */
  52996. 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;
  52997. /** @hidden */
  52998. 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;
  52999. /** @hidden */
  53000. 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;
  53001. }
  53002. }
  53003. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53004. import { Nullable } from "babylonjs/types";
  53005. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53006. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53007. /**
  53008. * Implementation of the TGA Texture Loader.
  53009. * @hidden
  53010. */
  53011. export class _TGATextureLoader implements IInternalTextureLoader {
  53012. /**
  53013. * Defines wether the loader supports cascade loading the different faces.
  53014. */
  53015. readonly supportCascades: boolean;
  53016. /**
  53017. * This returns if the loader support the current file information.
  53018. * @param extension defines the file extension of the file being loaded
  53019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53020. * @param fallback defines the fallback internal texture if any
  53021. * @param isBase64 defines whether the texture is encoded as a base64
  53022. * @param isBuffer defines whether the texture data are stored as a buffer
  53023. * @returns true if the loader can load the specified file
  53024. */
  53025. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53026. /**
  53027. * Transform the url before loading if required.
  53028. * @param rootUrl the url of the texture
  53029. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53030. * @returns the transformed texture
  53031. */
  53032. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53033. /**
  53034. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53035. * @param rootUrl the url of the texture
  53036. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53037. * @returns the fallback texture
  53038. */
  53039. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53040. /**
  53041. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53042. * @param data contains the texture data
  53043. * @param texture defines the BabylonJS internal texture
  53044. * @param createPolynomials will be true if polynomials have been requested
  53045. * @param onLoad defines the callback to trigger once the texture is ready
  53046. * @param onError defines the callback to trigger in case of error
  53047. */
  53048. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53049. /**
  53050. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53051. * @param data contains the texture data
  53052. * @param texture defines the BabylonJS internal texture
  53053. * @param callback defines the method to call once ready to upload
  53054. */
  53055. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53056. }
  53057. }
  53058. declare module "babylonjs/Misc/basis" {
  53059. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53060. /**
  53061. * Info about the .basis files
  53062. */
  53063. class BasisFileInfo {
  53064. /**
  53065. * If the file has alpha
  53066. */
  53067. hasAlpha: boolean;
  53068. /**
  53069. * Info about each image of the basis file
  53070. */
  53071. images: Array<{
  53072. levels: Array<{
  53073. width: number;
  53074. height: number;
  53075. transcodedPixels: ArrayBufferView;
  53076. }>;
  53077. }>;
  53078. }
  53079. /**
  53080. * Result of transcoding a basis file
  53081. */
  53082. class TranscodeResult {
  53083. /**
  53084. * Info about the .basis file
  53085. */
  53086. fileInfo: BasisFileInfo;
  53087. /**
  53088. * Format to use when loading the file
  53089. */
  53090. format: number;
  53091. }
  53092. /**
  53093. * Configuration options for the Basis transcoder
  53094. */
  53095. export class BasisTranscodeConfiguration {
  53096. /**
  53097. * Supported compression formats used to determine the supported output format of the transcoder
  53098. */
  53099. supportedCompressionFormats?: {
  53100. /**
  53101. * etc1 compression format
  53102. */
  53103. etc1?: boolean;
  53104. /**
  53105. * s3tc compression format
  53106. */
  53107. s3tc?: boolean;
  53108. /**
  53109. * pvrtc compression format
  53110. */
  53111. pvrtc?: boolean;
  53112. /**
  53113. * etc2 compression format
  53114. */
  53115. etc2?: boolean;
  53116. };
  53117. /**
  53118. * If mipmap levels should be loaded for transcoded images (Default: true)
  53119. */
  53120. loadMipmapLevels?: boolean;
  53121. /**
  53122. * Index of a single image to load (Default: all images)
  53123. */
  53124. loadSingleImage?: number;
  53125. }
  53126. /**
  53127. * Used to load .Basis files
  53128. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53129. */
  53130. export class BasisTools {
  53131. private static _IgnoreSupportedFormats;
  53132. /**
  53133. * URL to use when loading the basis transcoder
  53134. */
  53135. static JSModuleURL: string;
  53136. /**
  53137. * URL to use when loading the wasm module for the transcoder
  53138. */
  53139. static WasmModuleURL: string;
  53140. /**
  53141. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53142. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53143. * @returns internal format corresponding to the Basis format
  53144. */
  53145. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53146. private static _WorkerPromise;
  53147. private static _Worker;
  53148. private static _actionId;
  53149. private static _CreateWorkerAsync;
  53150. /**
  53151. * Transcodes a loaded image file to compressed pixel data
  53152. * @param imageData image data to transcode
  53153. * @param config configuration options for the transcoding
  53154. * @returns a promise resulting in the transcoded image
  53155. */
  53156. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53157. /**
  53158. * Loads a texture from the transcode result
  53159. * @param texture texture load to
  53160. * @param transcodeResult the result of transcoding the basis file to load from
  53161. */
  53162. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53163. }
  53164. }
  53165. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53166. import { Nullable } from "babylonjs/types";
  53167. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53168. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53169. /**
  53170. * Loader for .basis file format
  53171. */
  53172. export class _BasisTextureLoader implements IInternalTextureLoader {
  53173. /**
  53174. * Defines whether the loader supports cascade loading the different faces.
  53175. */
  53176. readonly supportCascades: boolean;
  53177. /**
  53178. * This returns if the loader support the current file information.
  53179. * @param extension defines the file extension of the file being loaded
  53180. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53181. * @param fallback defines the fallback internal texture if any
  53182. * @param isBase64 defines whether the texture is encoded as a base64
  53183. * @param isBuffer defines whether the texture data are stored as a buffer
  53184. * @returns true if the loader can load the specified file
  53185. */
  53186. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53187. /**
  53188. * Transform the url before loading if required.
  53189. * @param rootUrl the url of the texture
  53190. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53191. * @returns the transformed texture
  53192. */
  53193. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53194. /**
  53195. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53196. * @param rootUrl the url of the texture
  53197. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53198. * @returns the fallback texture
  53199. */
  53200. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53201. /**
  53202. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53203. * @param data contains the texture data
  53204. * @param texture defines the BabylonJS internal texture
  53205. * @param createPolynomials will be true if polynomials have been requested
  53206. * @param onLoad defines the callback to trigger once the texture is ready
  53207. * @param onError defines the callback to trigger in case of error
  53208. */
  53209. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53210. /**
  53211. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53212. * @param data contains the texture data
  53213. * @param texture defines the BabylonJS internal texture
  53214. * @param callback defines the method to call once ready to upload
  53215. */
  53216. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53217. }
  53218. }
  53219. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53220. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53221. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53222. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53223. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53224. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53225. }
  53226. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53227. import { Scene } from "babylonjs/scene";
  53228. import { Texture } from "babylonjs/Materials/Textures/texture";
  53229. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53230. /**
  53231. * 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.
  53232. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53233. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53234. */
  53235. export class CustomProceduralTexture extends ProceduralTexture {
  53236. private _animate;
  53237. private _time;
  53238. private _config;
  53239. private _texturePath;
  53240. /**
  53241. * Instantiates a new Custom Procedural Texture.
  53242. * 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.
  53243. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53244. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53245. * @param name Define the name of the texture
  53246. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53247. * @param size Define the size of the texture to create
  53248. * @param scene Define the scene the texture belongs to
  53249. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53250. * @param generateMipMaps Define if the texture should creates mip maps or not
  53251. */
  53252. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53253. private _loadJson;
  53254. /**
  53255. * Is the texture ready to be used ? (rendered at least once)
  53256. * @returns true if ready, otherwise, false.
  53257. */
  53258. isReady(): boolean;
  53259. /**
  53260. * Render the texture to its associated render target.
  53261. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53262. */
  53263. render(useCameraPostProcess?: boolean): void;
  53264. /**
  53265. * Update the list of dependant textures samplers in the shader.
  53266. */
  53267. updateTextures(): void;
  53268. /**
  53269. * Update the uniform values of the procedural texture in the shader.
  53270. */
  53271. updateShaderUniforms(): void;
  53272. /**
  53273. * Define if the texture animates or not.
  53274. */
  53275. animate: boolean;
  53276. }
  53277. }
  53278. declare module "babylonjs/Shaders/noise.fragment" {
  53279. /** @hidden */
  53280. export var noisePixelShader: {
  53281. name: string;
  53282. shader: string;
  53283. };
  53284. }
  53285. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53286. import { Nullable } from "babylonjs/types";
  53287. import { Scene } from "babylonjs/scene";
  53288. import { Texture } from "babylonjs/Materials/Textures/texture";
  53289. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53290. import "babylonjs/Shaders/noise.fragment";
  53291. /**
  53292. * Class used to generate noise procedural textures
  53293. */
  53294. export class NoiseProceduralTexture extends ProceduralTexture {
  53295. private _time;
  53296. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53297. brightness: number;
  53298. /** Defines the number of octaves to process */
  53299. octaves: number;
  53300. /** Defines the level of persistence (0.8 by default) */
  53301. persistence: number;
  53302. /** Gets or sets animation speed factor (default is 1) */
  53303. animationSpeedFactor: number;
  53304. /**
  53305. * Creates a new NoiseProceduralTexture
  53306. * @param name defines the name fo the texture
  53307. * @param size defines the size of the texture (default is 256)
  53308. * @param scene defines the hosting scene
  53309. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53310. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53311. */
  53312. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53313. private _updateShaderUniforms;
  53314. protected _getDefines(): string;
  53315. /** Generate the current state of the procedural texture */
  53316. render(useCameraPostProcess?: boolean): void;
  53317. /**
  53318. * Serializes this noise procedural texture
  53319. * @returns a serialized noise procedural texture object
  53320. */
  53321. serialize(): any;
  53322. /**
  53323. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53324. * @param parsedTexture defines parsed texture data
  53325. * @param scene defines the current scene
  53326. * @param rootUrl defines the root URL containing noise procedural texture information
  53327. * @returns a parsed NoiseProceduralTexture
  53328. */
  53329. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53330. }
  53331. }
  53332. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53333. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53334. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53335. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53336. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53337. }
  53338. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53339. import { Nullable } from "babylonjs/types";
  53340. import { Scene } from "babylonjs/scene";
  53341. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53342. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53343. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53344. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53345. /**
  53346. * Raw cube texture where the raw buffers are passed in
  53347. */
  53348. export class RawCubeTexture extends CubeTexture {
  53349. /**
  53350. * Creates a cube texture where the raw buffers are passed in.
  53351. * @param scene defines the scene the texture is attached to
  53352. * @param data defines the array of data to use to create each face
  53353. * @param size defines the size of the textures
  53354. * @param format defines the format of the data
  53355. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53356. * @param generateMipMaps defines if the engine should generate the mip levels
  53357. * @param invertY defines if data must be stored with Y axis inverted
  53358. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53359. * @param compression defines the compression used (null by default)
  53360. */
  53361. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53362. /**
  53363. * Updates the raw cube texture.
  53364. * @param data defines the data to store
  53365. * @param format defines the data format
  53366. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53367. * @param invertY defines if data must be stored with Y axis inverted
  53368. * @param compression defines the compression used (null by default)
  53369. * @param level defines which level of the texture to update
  53370. */
  53371. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53372. /**
  53373. * Updates a raw cube texture with RGBD encoded data.
  53374. * @param data defines the array of data [mipmap][face] to use to create each face
  53375. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53376. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53377. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53378. * @returns a promsie that resolves when the operation is complete
  53379. */
  53380. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53381. /**
  53382. * Clones the raw cube texture.
  53383. * @return a new cube texture
  53384. */
  53385. clone(): CubeTexture;
  53386. /** @hidden */
  53387. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53388. }
  53389. }
  53390. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53391. import { Scene } from "babylonjs/scene";
  53392. import { Texture } from "babylonjs/Materials/Textures/texture";
  53393. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53394. /**
  53395. * Class used to store 3D textures containing user data
  53396. */
  53397. export class RawTexture3D extends Texture {
  53398. /** Gets or sets the texture format to use */
  53399. format: number;
  53400. private _engine;
  53401. /**
  53402. * Create a new RawTexture3D
  53403. * @param data defines the data of the texture
  53404. * @param width defines the width of the texture
  53405. * @param height defines the height of the texture
  53406. * @param depth defines the depth of the texture
  53407. * @param format defines the texture format to use
  53408. * @param scene defines the hosting scene
  53409. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53410. * @param invertY defines if texture must be stored with Y axis inverted
  53411. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53412. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53413. */
  53414. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53415. /** Gets or sets the texture format to use */
  53416. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53417. /**
  53418. * Update the texture with new data
  53419. * @param data defines the data to store in the texture
  53420. */
  53421. update(data: ArrayBufferView): void;
  53422. }
  53423. }
  53424. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53425. import { Scene } from "babylonjs/scene";
  53426. import { Plane } from "babylonjs/Maths/math.plane";
  53427. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53428. /**
  53429. * Creates a refraction texture used by refraction channel of the standard material.
  53430. * It is like a mirror but to see through a material.
  53431. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53432. */
  53433. export class RefractionTexture extends RenderTargetTexture {
  53434. /**
  53435. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53436. * 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.
  53437. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53438. */
  53439. refractionPlane: Plane;
  53440. /**
  53441. * Define how deep under the surface we should see.
  53442. */
  53443. depth: number;
  53444. /**
  53445. * Creates a refraction texture used by refraction channel of the standard material.
  53446. * It is like a mirror but to see through a material.
  53447. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53448. * @param name Define the texture name
  53449. * @param size Define the size of the underlying texture
  53450. * @param scene Define the scene the refraction belongs to
  53451. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53452. */
  53453. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53454. /**
  53455. * Clone the refraction texture.
  53456. * @returns the cloned texture
  53457. */
  53458. clone(): RefractionTexture;
  53459. /**
  53460. * Serialize the texture to a JSON representation you could use in Parse later on
  53461. * @returns the serialized JSON representation
  53462. */
  53463. serialize(): any;
  53464. }
  53465. }
  53466. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53467. import { Nullable } from "babylonjs/types";
  53468. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53469. import { Matrix } from "babylonjs/Maths/math.vector";
  53470. import { Engine } from "babylonjs/Engines/engine";
  53471. import { Scene } from "babylonjs/scene";
  53472. /**
  53473. * Defines the options related to the creation of an HtmlElementTexture
  53474. */
  53475. export interface IHtmlElementTextureOptions {
  53476. /**
  53477. * Defines wether mip maps should be created or not.
  53478. */
  53479. generateMipMaps?: boolean;
  53480. /**
  53481. * Defines the sampling mode of the texture.
  53482. */
  53483. samplingMode?: number;
  53484. /**
  53485. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53486. */
  53487. engine: Nullable<Engine>;
  53488. /**
  53489. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53490. */
  53491. scene: Nullable<Scene>;
  53492. }
  53493. /**
  53494. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53495. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53496. * is automatically managed.
  53497. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53498. * in your application.
  53499. *
  53500. * As the update is not automatic, you need to call them manually.
  53501. */
  53502. export class HtmlElementTexture extends BaseTexture {
  53503. /**
  53504. * The texture URL.
  53505. */
  53506. element: HTMLVideoElement | HTMLCanvasElement;
  53507. private static readonly DefaultOptions;
  53508. private _textureMatrix;
  53509. private _engine;
  53510. private _isVideo;
  53511. private _generateMipMaps;
  53512. private _samplingMode;
  53513. /**
  53514. * Instantiates a HtmlElementTexture from the following parameters.
  53515. *
  53516. * @param name Defines the name of the texture
  53517. * @param element Defines the video or canvas the texture is filled with
  53518. * @param options Defines the other none mandatory texture creation options
  53519. */
  53520. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53521. private _createInternalTexture;
  53522. /**
  53523. * Returns the texture matrix used in most of the material.
  53524. */
  53525. getTextureMatrix(): Matrix;
  53526. /**
  53527. * Updates the content of the texture.
  53528. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53529. */
  53530. update(invertY?: Nullable<boolean>): void;
  53531. }
  53532. }
  53533. declare module "babylonjs/Materials/Textures/index" {
  53534. export * from "babylonjs/Materials/Textures/baseTexture";
  53535. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53536. export * from "babylonjs/Materials/Textures/cubeTexture";
  53537. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53538. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53539. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53540. export * from "babylonjs/Materials/Textures/internalTexture";
  53541. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53542. export * from "babylonjs/Materials/Textures/Loaders/index";
  53543. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53544. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53545. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53546. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53547. export * from "babylonjs/Materials/Textures/rawTexture";
  53548. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53549. export * from "babylonjs/Materials/Textures/refractionTexture";
  53550. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53551. export * from "babylonjs/Materials/Textures/texture";
  53552. export * from "babylonjs/Materials/Textures/videoTexture";
  53553. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53554. }
  53555. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53556. /**
  53557. * Enum used to define the target of a block
  53558. */
  53559. export enum NodeMaterialBlockTargets {
  53560. /** Vertex shader */
  53561. Vertex = 1,
  53562. /** Fragment shader */
  53563. Fragment = 2,
  53564. /** Neutral */
  53565. Neutral = 4,
  53566. /** Vertex and Fragment */
  53567. VertexAndFragment = 3
  53568. }
  53569. }
  53570. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53571. /**
  53572. * Defines the kind of connection point for node based material
  53573. */
  53574. export enum NodeMaterialBlockConnectionPointTypes {
  53575. /** Float */
  53576. Float = 1,
  53577. /** Int */
  53578. Int = 2,
  53579. /** Vector2 */
  53580. Vector2 = 4,
  53581. /** Vector3 */
  53582. Vector3 = 8,
  53583. /** Vector4 */
  53584. Vector4 = 16,
  53585. /** Color3 */
  53586. Color3 = 32,
  53587. /** Color4 */
  53588. Color4 = 64,
  53589. /** Matrix */
  53590. Matrix = 128,
  53591. /** Detect type based on connection */
  53592. AutoDetect = 1024,
  53593. /** Output type that will be defined by input type */
  53594. BasedOnInput = 2048
  53595. }
  53596. }
  53597. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53599. /**
  53600. * Root class for all node material optimizers
  53601. */
  53602. export class NodeMaterialOptimizer {
  53603. /**
  53604. * Function used to optimize a NodeMaterial graph
  53605. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53606. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53607. */
  53608. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53609. }
  53610. }
  53611. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  53612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53615. import { Scene } from "babylonjs/scene";
  53616. /**
  53617. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53618. */
  53619. export class TransformBlock extends NodeMaterialBlock {
  53620. /**
  53621. * Defines the value to use to complement W value to transform it to a Vector4
  53622. */
  53623. complementW: number;
  53624. /**
  53625. * Defines the value to use to complement z value to transform it to a Vector4
  53626. */
  53627. complementZ: number;
  53628. /**
  53629. * Creates a new TransformBlock
  53630. * @param name defines the block name
  53631. */
  53632. constructor(name: string);
  53633. /**
  53634. * Gets the current class name
  53635. * @returns the class name
  53636. */
  53637. getClassName(): string;
  53638. /**
  53639. * Gets the vector input
  53640. */
  53641. readonly vector: NodeMaterialConnectionPoint;
  53642. /**
  53643. * Gets the output component
  53644. */
  53645. readonly output: NodeMaterialConnectionPoint;
  53646. /**
  53647. * Gets the matrix transform input
  53648. */
  53649. readonly transform: NodeMaterialConnectionPoint;
  53650. protected _buildBlock(state: NodeMaterialBuildState): this;
  53651. serialize(): any;
  53652. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53653. }
  53654. }
  53655. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53659. /**
  53660. * Block used to output the vertex position
  53661. */
  53662. export class VertexOutputBlock extends NodeMaterialBlock {
  53663. /**
  53664. * Creates a new VertexOutputBlock
  53665. * @param name defines the block name
  53666. */
  53667. constructor(name: string);
  53668. /**
  53669. * Gets the current class name
  53670. * @returns the class name
  53671. */
  53672. getClassName(): string;
  53673. /**
  53674. * Gets the vector input component
  53675. */
  53676. readonly vector: NodeMaterialConnectionPoint;
  53677. protected _buildBlock(state: NodeMaterialBuildState): this;
  53678. }
  53679. }
  53680. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53681. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53682. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53684. /**
  53685. * Block used to output the final color
  53686. */
  53687. export class FragmentOutputBlock extends NodeMaterialBlock {
  53688. /**
  53689. * Create a new FragmentOutputBlock
  53690. * @param name defines the block name
  53691. */
  53692. constructor(name: string);
  53693. /**
  53694. * Gets the current class name
  53695. * @returns the class name
  53696. */
  53697. getClassName(): string;
  53698. /**
  53699. * Gets the rgba input component
  53700. */
  53701. readonly rgba: NodeMaterialConnectionPoint;
  53702. /**
  53703. * Gets the rgb input component
  53704. */
  53705. readonly rgb: NodeMaterialConnectionPoint;
  53706. /**
  53707. * Gets the a input component
  53708. */
  53709. readonly a: NodeMaterialConnectionPoint;
  53710. protected _buildBlock(state: NodeMaterialBuildState): this;
  53711. }
  53712. }
  53713. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53715. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53716. import { Scene } from "babylonjs/scene";
  53717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53718. import { Matrix } from "babylonjs/Maths/math.vector";
  53719. import { Mesh } from "babylonjs/Meshes/mesh";
  53720. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53721. import { Observable } from "babylonjs/Misc/observable";
  53722. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53723. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53724. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53725. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53726. import { Nullable } from "babylonjs/types";
  53727. /**
  53728. * Interface used to configure the node material editor
  53729. */
  53730. export interface INodeMaterialEditorOptions {
  53731. /** Define the URl to load node editor script */
  53732. editorURL?: string;
  53733. }
  53734. /** @hidden */
  53735. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53736. /** BONES */
  53737. NUM_BONE_INFLUENCERS: number;
  53738. BonesPerMesh: number;
  53739. BONETEXTURE: boolean;
  53740. /** MORPH TARGETS */
  53741. MORPHTARGETS: boolean;
  53742. MORPHTARGETS_NORMAL: boolean;
  53743. MORPHTARGETS_TANGENT: boolean;
  53744. MORPHTARGETS_UV: boolean;
  53745. NUM_MORPH_INFLUENCERS: number;
  53746. /** IMAGE PROCESSING */
  53747. IMAGEPROCESSING: boolean;
  53748. VIGNETTE: boolean;
  53749. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53750. VIGNETTEBLENDMODEOPAQUE: boolean;
  53751. TONEMAPPING: boolean;
  53752. TONEMAPPING_ACES: boolean;
  53753. CONTRAST: boolean;
  53754. EXPOSURE: boolean;
  53755. COLORCURVES: boolean;
  53756. COLORGRADING: boolean;
  53757. COLORGRADING3D: boolean;
  53758. SAMPLER3DGREENDEPTH: boolean;
  53759. SAMPLER3DBGRMAP: boolean;
  53760. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53761. constructor();
  53762. setValue(name: string, value: boolean): void;
  53763. }
  53764. /**
  53765. * Class used to configure NodeMaterial
  53766. */
  53767. export interface INodeMaterialOptions {
  53768. /**
  53769. * Defines if blocks should emit comments
  53770. */
  53771. emitComments: boolean;
  53772. }
  53773. /**
  53774. * Class used to create a node based material built by assembling shader blocks
  53775. */
  53776. export class NodeMaterial extends PushMaterial {
  53777. private _options;
  53778. private _vertexCompilationState;
  53779. private _fragmentCompilationState;
  53780. private _sharedData;
  53781. private _buildId;
  53782. private _buildWasSuccessful;
  53783. private _cachedWorldViewMatrix;
  53784. private _cachedWorldViewProjectionMatrix;
  53785. private _optimizers;
  53786. /** Define the URl to load node editor script */
  53787. static EditorURL: string;
  53788. private BJSNODEMATERIALEDITOR;
  53789. /** Get the inspector from bundle or global */
  53790. private _getGlobalNodeMaterialEditor;
  53791. /**
  53792. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  53793. */
  53794. ignoreAlpha: boolean;
  53795. /**
  53796. * Defines the maximum number of lights that can be used in the material
  53797. */
  53798. maxSimultaneousLights: number;
  53799. /**
  53800. * Observable raised when the material is built
  53801. */
  53802. onBuildObservable: Observable<NodeMaterial>;
  53803. /**
  53804. * Gets or sets the root nodes of the material vertex shader
  53805. */
  53806. _vertexOutputNodes: NodeMaterialBlock[];
  53807. /**
  53808. * Gets or sets the root nodes of the material fragment (pixel) shader
  53809. */
  53810. _fragmentOutputNodes: NodeMaterialBlock[];
  53811. /** Gets or sets options to control the node material overall behavior */
  53812. options: INodeMaterialOptions;
  53813. /**
  53814. * Default configuration related to image processing available in the standard Material.
  53815. */
  53816. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53817. /**
  53818. * Gets the image processing configuration used either in this material.
  53819. */
  53820. /**
  53821. * Sets the Default image processing configuration used either in the this material.
  53822. *
  53823. * If sets to null, the scene one is in use.
  53824. */
  53825. imageProcessingConfiguration: ImageProcessingConfiguration;
  53826. /**
  53827. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  53828. */
  53829. attachedBlocks: NodeMaterialBlock[];
  53830. /**
  53831. * Create a new node based material
  53832. * @param name defines the material name
  53833. * @param scene defines the hosting scene
  53834. * @param options defines creation option
  53835. */
  53836. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53837. /**
  53838. * Gets the current class name of the material e.g. "NodeMaterial"
  53839. * @returns the class name
  53840. */
  53841. getClassName(): string;
  53842. /**
  53843. * Keep track of the image processing observer to allow dispose and replace.
  53844. */
  53845. private _imageProcessingObserver;
  53846. /**
  53847. * Attaches a new image processing configuration to the Standard Material.
  53848. * @param configuration
  53849. */
  53850. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53851. /**
  53852. * Adds a new optimizer to the list of optimizers
  53853. * @param optimizer defines the optimizers to add
  53854. * @returns the current material
  53855. */
  53856. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53857. /**
  53858. * Remove an optimizer from the list of optimizers
  53859. * @param optimizer defines the optimizers to remove
  53860. * @returns the current material
  53861. */
  53862. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53863. /**
  53864. * Add a new block to the list of output nodes
  53865. * @param node defines the node to add
  53866. * @returns the current material
  53867. */
  53868. addOutputNode(node: NodeMaterialBlock): this;
  53869. /**
  53870. * Remove a block from the list of root nodes
  53871. * @param node defines the node to remove
  53872. * @returns the current material
  53873. */
  53874. removeOutputNode(node: NodeMaterialBlock): this;
  53875. private _addVertexOutputNode;
  53876. private _removeVertexOutputNode;
  53877. private _addFragmentOutputNode;
  53878. private _removeFragmentOutputNode;
  53879. /**
  53880. * Specifies if the material will require alpha blending
  53881. * @returns a boolean specifying if alpha blending is needed
  53882. */
  53883. needAlphaBlending(): boolean;
  53884. /**
  53885. * Specifies if this material should be rendered in alpha test mode
  53886. * @returns a boolean specifying if an alpha test is needed.
  53887. */
  53888. needAlphaTesting(): boolean;
  53889. private _initializeBlock;
  53890. private _resetDualBlocks;
  53891. /**
  53892. * Build the material and generates the inner effect
  53893. * @param verbose defines if the build should log activity
  53894. */
  53895. build(verbose?: boolean): void;
  53896. /**
  53897. * Runs an otpimization phase to try to improve the shader code
  53898. */
  53899. optimize(): void;
  53900. private _prepareDefinesForAttributes;
  53901. /**
  53902. * Get if the submesh is ready to be used and all its information available.
  53903. * Child classes can use it to update shaders
  53904. * @param mesh defines the mesh to check
  53905. * @param subMesh defines which submesh to check
  53906. * @param useInstances specifies that instances should be used
  53907. * @returns a boolean indicating that the submesh is ready or not
  53908. */
  53909. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53910. /**
  53911. * Get a string representing the shaders built by the current node graph
  53912. */
  53913. readonly compiledShaders: string;
  53914. /**
  53915. * Binds the world matrix to the material
  53916. * @param world defines the world transformation matrix
  53917. */
  53918. bindOnlyWorldMatrix(world: Matrix): void;
  53919. /**
  53920. * Binds the submesh to this material by preparing the effect and shader to draw
  53921. * @param world defines the world transformation matrix
  53922. * @param mesh defines the mesh containing the submesh
  53923. * @param subMesh defines the submesh to bind the material to
  53924. */
  53925. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53926. /**
  53927. * Gets the active textures from the material
  53928. * @returns an array of textures
  53929. */
  53930. getActiveTextures(): BaseTexture[];
  53931. /**
  53932. * Specifies if the material uses a texture
  53933. * @param texture defines the texture to check against the material
  53934. * @returns a boolean specifying if the material uses the texture
  53935. */
  53936. hasTexture(texture: BaseTexture): boolean;
  53937. /**
  53938. * Disposes the material
  53939. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53940. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53941. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53942. */
  53943. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53944. /** Creates the node editor window. */
  53945. private _createNodeEditor;
  53946. /**
  53947. * Launch the node material editor
  53948. * @param config Define the configuration of the editor
  53949. * @return a promise fulfilled when the node editor is visible
  53950. */
  53951. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53952. /**
  53953. * Clear the current material
  53954. */
  53955. clear(): void;
  53956. /**
  53957. * Clear the current material and set it to a default state
  53958. */
  53959. setToDefault(): void;
  53960. private _gatherBlocks;
  53961. /**
  53962. * Serializes this material in a JSON representation
  53963. * @returns the serialized material object
  53964. */
  53965. serialize(): any;
  53966. /**
  53967. * Clear the current graph and load a new one from a serialization object
  53968. * @param source defines the JSON representation of the material
  53969. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53970. */
  53971. loadFromSerialization(source: any, rootUrl?: string): void;
  53972. /**
  53973. * Creates a node material from parsed material data
  53974. * @param source defines the JSON representation of the material
  53975. * @param scene defines the hosting scene
  53976. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53977. * @returns a new node material
  53978. */
  53979. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53980. }
  53981. }
  53982. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  53983. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53985. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53986. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53988. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53989. import { Effect } from "babylonjs/Materials/effect";
  53990. import { Mesh } from "babylonjs/Meshes/mesh";
  53991. import { Nullable } from "babylonjs/types";
  53992. import { Scene } from "babylonjs/scene";
  53993. /**
  53994. * Block used to read a texture from a sampler
  53995. */
  53996. export class TextureBlock extends NodeMaterialBlock {
  53997. private _defineName;
  53998. private _samplerName;
  53999. private _transformedUVName;
  54000. private _textureTransformName;
  54001. private _textureInfoName;
  54002. private _mainUVName;
  54003. private _mainUVDefineName;
  54004. /**
  54005. * Gets or sets the texture associated with the node
  54006. */
  54007. texture: Nullable<BaseTexture>;
  54008. /**
  54009. * Create a new TextureBlock
  54010. * @param name defines the block name
  54011. */
  54012. constructor(name: string);
  54013. /**
  54014. * Gets the current class name
  54015. * @returns the class name
  54016. */
  54017. getClassName(): string;
  54018. /**
  54019. * Gets the uv input component
  54020. */
  54021. readonly uv: NodeMaterialConnectionPoint;
  54022. /**
  54023. * Gets the output component
  54024. */
  54025. readonly output: NodeMaterialConnectionPoint;
  54026. autoConfigure(): void;
  54027. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54028. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54029. isReady(): boolean;
  54030. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54031. private _injectVertexCode;
  54032. private _writeOutput;
  54033. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54034. serialize(): any;
  54035. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54036. }
  54037. }
  54038. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54039. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54040. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54041. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54042. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54043. /**
  54044. * Class used to store shared data between 2 NodeMaterialBuildState
  54045. */
  54046. export class NodeMaterialBuildStateSharedData {
  54047. /**
  54048. * Gets the list of emitted varyings
  54049. */
  54050. varyings: string[];
  54051. /**
  54052. * Gets the varying declaration string
  54053. */
  54054. varyingDeclaration: string;
  54055. /**
  54056. * Input blocks
  54057. */
  54058. inputBlocks: InputBlock[];
  54059. /**
  54060. * Input blocks
  54061. */
  54062. textureBlocks: TextureBlock[];
  54063. /**
  54064. * Bindable blocks (Blocks that need to set data to the effect)
  54065. */
  54066. bindableBlocks: NodeMaterialBlock[];
  54067. /**
  54068. * List of blocks that can provide a compilation fallback
  54069. */
  54070. blocksWithFallbacks: NodeMaterialBlock[];
  54071. /**
  54072. * List of blocks that can provide a define update
  54073. */
  54074. blocksWithDefines: NodeMaterialBlock[];
  54075. /**
  54076. * List of blocks that can provide a repeatable content
  54077. */
  54078. repeatableContentBlocks: NodeMaterialBlock[];
  54079. /**
  54080. * List of blocks that can provide a dynamic list of uniforms
  54081. */
  54082. dynamicUniformBlocks: NodeMaterialBlock[];
  54083. /**
  54084. * List of blocks that can block the isReady function for the material
  54085. */
  54086. blockingBlocks: NodeMaterialBlock[];
  54087. /**
  54088. * Build Id used to avoid multiple recompilations
  54089. */
  54090. buildId: number;
  54091. /** List of emitted variables */
  54092. variableNames: {
  54093. [key: string]: number;
  54094. };
  54095. /** List of emitted defines */
  54096. defineNames: {
  54097. [key: string]: number;
  54098. };
  54099. /** Should emit comments? */
  54100. emitComments: boolean;
  54101. /** Emit build activity */
  54102. verbose: boolean;
  54103. /**
  54104. * Gets the compilation hints emitted at compilation time
  54105. */
  54106. hints: {
  54107. needWorldViewMatrix: boolean;
  54108. needWorldViewProjectionMatrix: boolean;
  54109. needAlphaBlending: boolean;
  54110. needAlphaTesting: boolean;
  54111. };
  54112. /**
  54113. * List of compilation checks
  54114. */
  54115. checks: {
  54116. emitVertex: boolean;
  54117. emitFragment: boolean;
  54118. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54119. };
  54120. /** Creates a new shared data */
  54121. constructor();
  54122. /**
  54123. * Emits console errors and exceptions if there is a failing check
  54124. */
  54125. emitErrors(): void;
  54126. }
  54127. }
  54128. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54129. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54130. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54131. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54132. /**
  54133. * Class used to store node based material build state
  54134. */
  54135. export class NodeMaterialBuildState {
  54136. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54137. supportUniformBuffers: boolean;
  54138. /**
  54139. * Gets the list of emitted attributes
  54140. */
  54141. attributes: string[];
  54142. /**
  54143. * Gets the list of emitted uniforms
  54144. */
  54145. uniforms: string[];
  54146. /**
  54147. * Gets the list of emitted uniform buffers
  54148. */
  54149. uniformBuffers: string[];
  54150. /**
  54151. * Gets the list of emitted samplers
  54152. */
  54153. samplers: string[];
  54154. /**
  54155. * Gets the list of emitted functions
  54156. */
  54157. functions: {
  54158. [key: string]: string;
  54159. };
  54160. /**
  54161. * Gets the target of the compilation state
  54162. */
  54163. target: NodeMaterialBlockTargets;
  54164. /**
  54165. * Gets the list of emitted counters
  54166. */
  54167. counters: {
  54168. [key: string]: number;
  54169. };
  54170. /**
  54171. * Shared data between multiple NodeMaterialBuildState instances
  54172. */
  54173. sharedData: NodeMaterialBuildStateSharedData;
  54174. /** @hidden */
  54175. _vertexState: NodeMaterialBuildState;
  54176. /** @hidden */
  54177. _attributeDeclaration: string;
  54178. /** @hidden */
  54179. _uniformDeclaration: string;
  54180. /** @hidden */
  54181. _samplerDeclaration: string;
  54182. /** @hidden */
  54183. _varyingTransfer: string;
  54184. private _repeatableContentAnchorIndex;
  54185. /** @hidden */
  54186. _builtCompilationString: string;
  54187. /**
  54188. * Gets the emitted compilation strings
  54189. */
  54190. compilationString: string;
  54191. /**
  54192. * Finalize the compilation strings
  54193. * @param state defines the current compilation state
  54194. */
  54195. finalize(state: NodeMaterialBuildState): void;
  54196. /** @hidden */
  54197. readonly _repeatableContentAnchor: string;
  54198. /** @hidden */
  54199. _getFreeVariableName(prefix: string): string;
  54200. /** @hidden */
  54201. _getFreeDefineName(prefix: string): string;
  54202. /** @hidden */
  54203. _excludeVariableName(name: string): void;
  54204. /** @hidden */
  54205. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54206. /** @hidden */
  54207. _emitFunction(name: string, code: string, comments: string): void;
  54208. /** @hidden */
  54209. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54210. replaceStrings?: {
  54211. search: RegExp;
  54212. replace: string;
  54213. }[];
  54214. repeatKey?: string;
  54215. }): string;
  54216. /** @hidden */
  54217. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54218. repeatKey?: string;
  54219. removeAttributes?: boolean;
  54220. removeUniforms?: boolean;
  54221. removeVaryings?: boolean;
  54222. removeIfDef?: boolean;
  54223. replaceStrings?: {
  54224. search: RegExp;
  54225. replace: string;
  54226. }[];
  54227. }, storeKey?: string): void;
  54228. /** @hidden */
  54229. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54230. /** @hidden */
  54231. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54232. }
  54233. }
  54234. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54235. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54237. import { Nullable } from "babylonjs/types";
  54238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54239. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54240. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54242. import { Mesh } from "babylonjs/Meshes/mesh";
  54243. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54244. import { Scene } from "babylonjs/scene";
  54245. /**
  54246. * Defines a block that can be used inside a node based material
  54247. */
  54248. export class NodeMaterialBlock {
  54249. private _buildId;
  54250. private _buildTarget;
  54251. private _target;
  54252. private _isFinalMerger;
  54253. private _isInput;
  54254. /** @hidden */
  54255. _inputs: NodeMaterialConnectionPoint[];
  54256. /** @hidden */
  54257. _outputs: NodeMaterialConnectionPoint[];
  54258. /**
  54259. * Gets or sets the name of the block
  54260. */
  54261. name: string;
  54262. /**
  54263. * Gets or sets the unique id of the node
  54264. */
  54265. uniqueId: number;
  54266. /**
  54267. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54268. */
  54269. readonly isFinalMerger: boolean;
  54270. /**
  54271. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54272. */
  54273. readonly isInput: boolean;
  54274. /**
  54275. * Gets or sets the build Id
  54276. */
  54277. buildId: number;
  54278. /**
  54279. * Gets or sets the target of the block
  54280. */
  54281. target: NodeMaterialBlockTargets;
  54282. /**
  54283. * Gets the list of input points
  54284. */
  54285. readonly inputs: NodeMaterialConnectionPoint[];
  54286. /** Gets the list of output points */
  54287. readonly outputs: NodeMaterialConnectionPoint[];
  54288. /**
  54289. * Find an input by its name
  54290. * @param name defines the name of the input to look for
  54291. * @returns the input or null if not found
  54292. */
  54293. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54294. /**
  54295. * Find an output by its name
  54296. * @param name defines the name of the outputto look for
  54297. * @returns the output or null if not found
  54298. */
  54299. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54300. /**
  54301. * Creates a new NodeMaterialBlock
  54302. * @param name defines the block name
  54303. * @param target defines the target of that block (Vertex by default)
  54304. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54305. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54306. */
  54307. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54308. /**
  54309. * Initialize the block and prepare the context for build
  54310. * @param state defines the state that will be used for the build
  54311. */
  54312. initialize(state: NodeMaterialBuildState): void;
  54313. /**
  54314. * Bind data to effect. Will only be called for blocks with isBindable === true
  54315. * @param effect defines the effect to bind data to
  54316. * @param nodeMaterial defines the hosting NodeMaterial
  54317. * @param mesh defines the mesh that will be rendered
  54318. */
  54319. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54320. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54321. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54322. protected _writeFloat(value: number): string;
  54323. /**
  54324. * Gets the current class name e.g. "NodeMaterialBlock"
  54325. * @returns the class name
  54326. */
  54327. getClassName(): string;
  54328. /**
  54329. * Register a new input. Must be called inside a block constructor
  54330. * @param name defines the connection point name
  54331. * @param type defines the connection point type
  54332. * @param isOptional defines a boolean indicating that this input can be omitted
  54333. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54334. * @returns the current block
  54335. */
  54336. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54337. /**
  54338. * Register a new output. Must be called inside a block constructor
  54339. * @param name defines the connection point name
  54340. * @param type defines the connection point type
  54341. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54342. * @returns the current block
  54343. */
  54344. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54345. /**
  54346. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54347. * @param forOutput defines an optional connection point to check compatibility with
  54348. * @returns the first available input or null
  54349. */
  54350. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54351. /**
  54352. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54353. * @param forBlock defines an optional block to check compatibility with
  54354. * @returns the first available input or null
  54355. */
  54356. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54357. /**
  54358. * Connect current block with another block
  54359. * @param other defines the block to connect with
  54360. * @param options define the various options to help pick the right connections
  54361. * @returns the current block
  54362. */
  54363. connectTo(other: NodeMaterialBlock, options?: {
  54364. input?: string;
  54365. output?: string;
  54366. outputSwizzle?: string;
  54367. }): this | undefined;
  54368. protected _buildBlock(state: NodeMaterialBuildState): void;
  54369. /**
  54370. * Add uniforms, samplers and uniform buffers at compilation time
  54371. * @param state defines the state to update
  54372. * @param nodeMaterial defines the node material requesting the update
  54373. * @param defines defines the material defines to update
  54374. */
  54375. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54376. /**
  54377. * Add potential fallbacks if shader compilation fails
  54378. * @param mesh defines the mesh to be rendered
  54379. * @param fallbacks defines the current prioritized list of fallbacks
  54380. */
  54381. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54382. /**
  54383. * Update defines for shader compilation
  54384. * @param mesh defines the mesh to be rendered
  54385. * @param nodeMaterial defines the node material requesting the update
  54386. * @param defines defines the material defines to update
  54387. * @param useInstances specifies that instances should be used
  54388. */
  54389. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54390. /**
  54391. * Initialize defines for shader compilation
  54392. * @param mesh defines the mesh to be rendered
  54393. * @param nodeMaterial defines the node material requesting the update
  54394. * @param defines defines the material defines to be prepared
  54395. * @param useInstances specifies that instances should be used
  54396. */
  54397. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54398. /**
  54399. * Lets the block try to connect some inputs automatically
  54400. */
  54401. autoConfigure(): void;
  54402. /**
  54403. * Function called when a block is declared as repeatable content generator
  54404. * @param vertexShaderState defines the current compilation state for the vertex shader
  54405. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54406. * @param mesh defines the mesh to be rendered
  54407. * @param defines defines the material defines to update
  54408. */
  54409. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54410. /**
  54411. * Checks if the block is ready
  54412. * @param mesh defines the mesh to be rendered
  54413. * @param nodeMaterial defines the node material requesting the update
  54414. * @param defines defines the material defines to update
  54415. * @param useInstances specifies that instances should be used
  54416. * @returns true if the block is ready
  54417. */
  54418. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54419. private _processBuild;
  54420. /**
  54421. * Compile the current node and generate the shader code
  54422. * @param state defines the current compilation state (uniforms, samplers, current string)
  54423. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  54424. * @returns true if already built
  54425. */
  54426. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  54427. /**
  54428. * Serializes this block in a JSON representation
  54429. * @returns the serialized block object
  54430. */
  54431. serialize(): any;
  54432. /** @hidden */
  54433. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54434. }
  54435. }
  54436. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  54437. /**
  54438. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54439. */
  54440. export enum NodeMaterialBlockConnectionPointMode {
  54441. /** Value is an uniform */
  54442. Uniform = 0,
  54443. /** Value is a mesh attribute */
  54444. Attribute = 1,
  54445. /** Value is a varying between vertex and fragment shaders */
  54446. Varying = 2,
  54447. /** Mode is undefined */
  54448. Undefined = 3
  54449. }
  54450. }
  54451. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54452. /**
  54453. * Enum used to define well known values e.g. values automatically provided by the system
  54454. */
  54455. export enum NodeMaterialWellKnownValues {
  54456. /** World */
  54457. World = 1,
  54458. /** View */
  54459. View = 2,
  54460. /** Projection */
  54461. Projection = 3,
  54462. /** ViewProjection */
  54463. ViewProjection = 4,
  54464. /** WorldView */
  54465. WorldView = 5,
  54466. /** WorldViewProjection */
  54467. WorldViewProjection = 6,
  54468. /** CameraPosition */
  54469. CameraPosition = 7,
  54470. /** Fog Color */
  54471. FogColor = 8
  54472. }
  54473. }
  54474. declare module "babylonjs/Maths/math.vertexFormat" {
  54475. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  54476. /**
  54477. * Contains position and normal vectors for a vertex
  54478. */
  54479. export class PositionNormalVertex {
  54480. /** the position of the vertex (defaut: 0,0,0) */
  54481. position: Vector3;
  54482. /** the normal of the vertex (defaut: 0,1,0) */
  54483. normal: Vector3;
  54484. /**
  54485. * Creates a PositionNormalVertex
  54486. * @param position the position of the vertex (defaut: 0,0,0)
  54487. * @param normal the normal of the vertex (defaut: 0,1,0)
  54488. */
  54489. constructor(
  54490. /** the position of the vertex (defaut: 0,0,0) */
  54491. position?: Vector3,
  54492. /** the normal of the vertex (defaut: 0,1,0) */
  54493. normal?: Vector3);
  54494. /**
  54495. * Clones the PositionNormalVertex
  54496. * @returns the cloned PositionNormalVertex
  54497. */
  54498. clone(): PositionNormalVertex;
  54499. }
  54500. /**
  54501. * Contains position, normal and uv vectors for a vertex
  54502. */
  54503. export class PositionNormalTextureVertex {
  54504. /** the position of the vertex (defaut: 0,0,0) */
  54505. position: Vector3;
  54506. /** the normal of the vertex (defaut: 0,1,0) */
  54507. normal: Vector3;
  54508. /** the uv of the vertex (default: 0,0) */
  54509. uv: Vector2;
  54510. /**
  54511. * Creates a PositionNormalTextureVertex
  54512. * @param position the position of the vertex (defaut: 0,0,0)
  54513. * @param normal the normal of the vertex (defaut: 0,1,0)
  54514. * @param uv the uv of the vertex (default: 0,0)
  54515. */
  54516. constructor(
  54517. /** the position of the vertex (defaut: 0,0,0) */
  54518. position?: Vector3,
  54519. /** the normal of the vertex (defaut: 0,1,0) */
  54520. normal?: Vector3,
  54521. /** the uv of the vertex (default: 0,0) */
  54522. uv?: Vector2);
  54523. /**
  54524. * Clones the PositionNormalTextureVertex
  54525. * @returns the cloned PositionNormalTextureVertex
  54526. */
  54527. clone(): PositionNormalTextureVertex;
  54528. }
  54529. }
  54530. declare module "babylonjs/Maths/math" {
  54531. export * from "babylonjs/Maths/math.axis";
  54532. export * from "babylonjs/Maths/math.color";
  54533. export * from "babylonjs/Maths/math.constants";
  54534. export * from "babylonjs/Maths/math.frustum";
  54535. export * from "babylonjs/Maths/math.path";
  54536. export * from "babylonjs/Maths/math.plane";
  54537. export * from "babylonjs/Maths/math.size";
  54538. export * from "babylonjs/Maths/math.vector";
  54539. export * from "babylonjs/Maths/math.vertexFormat";
  54540. export * from "babylonjs/Maths/math.viewport";
  54541. }
  54542. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  54543. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54544. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54545. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54546. import { Nullable } from "babylonjs/types";
  54547. import { Effect } from "babylonjs/Materials/effect";
  54548. import { Matrix } from "babylonjs/Maths/math.vector";
  54549. import { Scene } from "babylonjs/scene";
  54550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54551. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54552. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54553. /**
  54554. * Block used to expose an input value
  54555. */
  54556. export class InputBlock extends NodeMaterialBlock {
  54557. private _mode;
  54558. private _associatedVariableName;
  54559. private _storedValue;
  54560. private _valueCallback;
  54561. private _type;
  54562. /** @hidden */
  54563. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54564. /**
  54565. * Gets or sets the connection point type (default is float)
  54566. */
  54567. readonly type: NodeMaterialBlockConnectionPointTypes;
  54568. /**
  54569. * Creates a new InputBlock
  54570. * @param name defines the block name
  54571. * @param target defines the target of that block (Vertex by default)
  54572. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54573. */
  54574. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54575. /**
  54576. * Gets the output component
  54577. */
  54578. readonly output: NodeMaterialConnectionPoint;
  54579. /**
  54580. * Set the source of this connection point to a vertex attribute
  54581. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54582. * @returns the current connection point
  54583. */
  54584. setAsAttribute(attributeName?: string): InputBlock;
  54585. /**
  54586. * Set the source of this connection point to a well known value
  54587. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  54588. * @returns the current connection point
  54589. */
  54590. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  54591. /**
  54592. * Gets or sets the value of that point.
  54593. * Please note that this value will be ignored if valueCallback is defined
  54594. */
  54595. value: any;
  54596. /**
  54597. * Gets or sets a callback used to get the value of that point.
  54598. * Please note that setting this value will force the connection point to ignore the value property
  54599. */
  54600. valueCallback: () => any;
  54601. /**
  54602. * Gets or sets the associated variable name in the shader
  54603. */
  54604. associatedVariableName: string;
  54605. /**
  54606. * Gets a boolean indicating that this connection point not defined yet
  54607. */
  54608. readonly isUndefined: boolean;
  54609. /**
  54610. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54611. * In this case the connection point name must be the name of the uniform to use.
  54612. * Can only be set on inputs
  54613. */
  54614. isUniform: boolean;
  54615. /**
  54616. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54617. * In this case the connection point name must be the name of the attribute to use
  54618. * Can only be set on inputs
  54619. */
  54620. isAttribute: boolean;
  54621. /**
  54622. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54623. * Can only be set on exit points
  54624. */
  54625. isVarying: boolean;
  54626. /**
  54627. * Gets a boolean indicating that the current connection point is a well known value
  54628. */
  54629. readonly isWellKnownValue: boolean;
  54630. /**
  54631. * Gets or sets the current well known value or null if not defined as well know value
  54632. */
  54633. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54634. /**
  54635. * Gets the current class name
  54636. * @returns the class name
  54637. */
  54638. getClassName(): string;
  54639. private _emitDefine;
  54640. /**
  54641. * Set the input block to its default value (based on its type)
  54642. */
  54643. setDefaultValue(): void;
  54644. private _emit;
  54645. /** @hidden */
  54646. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54647. /** @hidden */
  54648. _transmit(effect: Effect, scene: Scene): void;
  54649. protected _buildBlock(state: NodeMaterialBuildState): void;
  54650. serialize(): any;
  54651. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54652. }
  54653. }
  54654. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  54655. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54656. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54657. import { Nullable } from "babylonjs/types";
  54658. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54660. /**
  54661. * Defines a connection point for a block
  54662. */
  54663. export class NodeMaterialConnectionPoint {
  54664. /** @hidden */
  54665. _ownerBlock: NodeMaterialBlock;
  54666. /** @hidden */
  54667. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54668. private _endpoints;
  54669. private _associatedVariableName;
  54670. /** @hidden */
  54671. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54672. private _type;
  54673. /** @hidden */
  54674. _enforceAssociatedVariableName: boolean;
  54675. /**
  54676. * Gets or sets the additional types supported byt this connection point
  54677. */
  54678. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54679. /**
  54680. * Gets or sets the associated variable name in the shader
  54681. */
  54682. associatedVariableName: string;
  54683. /**
  54684. * Gets or sets the connection point type (default is float)
  54685. */
  54686. type: NodeMaterialBlockConnectionPointTypes;
  54687. /**
  54688. * Gets or sets the connection point name
  54689. */
  54690. name: string;
  54691. /**
  54692. * Gets or sets a boolean indicating that this connection point can be omitted
  54693. */
  54694. isOptional: boolean;
  54695. /**
  54696. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54697. */
  54698. define: string;
  54699. /** Gets or sets the target of that connection point */
  54700. target: NodeMaterialBlockTargets;
  54701. /**
  54702. * Gets a boolean indicating that the current point is connected
  54703. */
  54704. readonly isConnected: boolean;
  54705. /**
  54706. * Gets a boolean indicating that the current point is connected to an input block
  54707. */
  54708. readonly isConnectedToInput: boolean;
  54709. /**
  54710. * Gets a the connected input block (if any)
  54711. */
  54712. readonly connectInputBlock: Nullable<InputBlock>;
  54713. /** Get the other side of the connection (if any) */
  54714. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54715. /** Get the block that owns this connection point */
  54716. readonly ownerBlock: NodeMaterialBlock;
  54717. /** Get the block connected on the other side of this connection (if any) */
  54718. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54719. /** Get the block connected on the endpoints of this connection (if any) */
  54720. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54721. /** Gets the list of connected endpoints */
  54722. readonly endpoints: NodeMaterialConnectionPoint[];
  54723. /**
  54724. * Creates a new connection point
  54725. * @param name defines the connection point name
  54726. * @param ownerBlock defines the block hosting this connection point
  54727. */
  54728. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54729. /**
  54730. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54731. * @returns the class name
  54732. */
  54733. getClassName(): string;
  54734. /**
  54735. * Gets an boolean indicating if the current point can be connected to another point
  54736. * @param connectionPoint defines the other connection point
  54737. * @returns true if the connection is possible
  54738. */
  54739. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54740. /**
  54741. * Connect this point to another connection point
  54742. * @param connectionPoint defines the other connection point
  54743. * @returns the current connection point
  54744. */
  54745. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54746. /**
  54747. * Disconnect this point from one of his endpoint
  54748. * @param endpoint defines the other connection point
  54749. * @returns the current connection point
  54750. */
  54751. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54752. /**
  54753. * Serializes this point in a JSON representation
  54754. * @returns the serialized point object
  54755. */
  54756. serialize(): any;
  54757. }
  54758. }
  54759. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  54760. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54761. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54763. import { Mesh } from "babylonjs/Meshes/mesh";
  54764. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54765. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54766. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54767. /**
  54768. * Block used to add support for vertex skinning (bones)
  54769. */
  54770. export class BonesBlock extends NodeMaterialBlock {
  54771. /**
  54772. * Creates a new BonesBlock
  54773. * @param name defines the block name
  54774. */
  54775. constructor(name: string);
  54776. /**
  54777. * Initialize the block and prepare the context for build
  54778. * @param state defines the state that will be used for the build
  54779. */
  54780. initialize(state: NodeMaterialBuildState): void;
  54781. /**
  54782. * Gets the current class name
  54783. * @returns the class name
  54784. */
  54785. getClassName(): string;
  54786. /**
  54787. * Gets the matrix indices input component
  54788. */
  54789. readonly matricesIndices: NodeMaterialConnectionPoint;
  54790. /**
  54791. * Gets the matrix weights input component
  54792. */
  54793. readonly matricesWeights: NodeMaterialConnectionPoint;
  54794. /**
  54795. * Gets the extra matrix indices input component
  54796. */
  54797. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54798. /**
  54799. * Gets the extra matrix weights input component
  54800. */
  54801. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54802. /**
  54803. * Gets the world input component
  54804. */
  54805. readonly world: NodeMaterialConnectionPoint;
  54806. /**
  54807. * Gets the output component
  54808. */
  54809. readonly output: NodeMaterialConnectionPoint;
  54810. autoConfigure(): void;
  54811. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54812. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54813. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54814. protected _buildBlock(state: NodeMaterialBuildState): this;
  54815. }
  54816. }
  54817. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  54818. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54819. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54820. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54822. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54823. /**
  54824. * Block used to add support for instances
  54825. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54826. */
  54827. export class InstancesBlock extends NodeMaterialBlock {
  54828. /**
  54829. * Creates a new InstancesBlock
  54830. * @param name defines the block name
  54831. */
  54832. constructor(name: string);
  54833. /**
  54834. * Gets the current class name
  54835. * @returns the class name
  54836. */
  54837. getClassName(): string;
  54838. /**
  54839. * Gets the first world row input component
  54840. */
  54841. readonly world0: NodeMaterialConnectionPoint;
  54842. /**
  54843. * Gets the second world row input component
  54844. */
  54845. readonly world1: NodeMaterialConnectionPoint;
  54846. /**
  54847. * Gets the third world row input component
  54848. */
  54849. readonly world2: NodeMaterialConnectionPoint;
  54850. /**
  54851. * Gets the forth world row input component
  54852. */
  54853. readonly world3: NodeMaterialConnectionPoint;
  54854. /**
  54855. * Gets the world input component
  54856. */
  54857. readonly world: NodeMaterialConnectionPoint;
  54858. /**
  54859. * Gets the output component
  54860. */
  54861. readonly output: NodeMaterialConnectionPoint;
  54862. autoConfigure(): void;
  54863. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54864. protected _buildBlock(state: NodeMaterialBuildState): this;
  54865. }
  54866. }
  54867. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54868. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54869. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54870. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54872. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54873. import { Effect } from "babylonjs/Materials/effect";
  54874. import { Mesh } from "babylonjs/Meshes/mesh";
  54875. /**
  54876. * Block used to add morph targets support to vertex shader
  54877. */
  54878. export class MorphTargetsBlock extends NodeMaterialBlock {
  54879. private _repeatableContentAnchor;
  54880. private _repeatebleContentGenerated;
  54881. /**
  54882. * Create a new MorphTargetsBlock
  54883. * @param name defines the block name
  54884. */
  54885. constructor(name: string);
  54886. /**
  54887. * Gets the current class name
  54888. * @returns the class name
  54889. */
  54890. getClassName(): string;
  54891. /**
  54892. * Gets the position input component
  54893. */
  54894. readonly position: NodeMaterialConnectionPoint;
  54895. /**
  54896. * Gets the normal input component
  54897. */
  54898. readonly normal: NodeMaterialConnectionPoint;
  54899. /**
  54900. * Gets the tangent input component
  54901. */
  54902. readonly tangent: NodeMaterialConnectionPoint;
  54903. /**
  54904. * Gets the tangent input component
  54905. */
  54906. readonly uv: NodeMaterialConnectionPoint;
  54907. /**
  54908. * Gets the position output component
  54909. */
  54910. readonly positionOutput: NodeMaterialConnectionPoint;
  54911. /**
  54912. * Gets the normal output component
  54913. */
  54914. readonly normalOutput: NodeMaterialConnectionPoint;
  54915. /**
  54916. * Gets the tangent output component
  54917. */
  54918. readonly tangentOutput: NodeMaterialConnectionPoint;
  54919. /**
  54920. * Gets the tangent output component
  54921. */
  54922. readonly uvOutput: NodeMaterialConnectionPoint;
  54923. initialize(state: NodeMaterialBuildState): void;
  54924. autoConfigure(): void;
  54925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54926. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54927. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54928. protected _buildBlock(state: NodeMaterialBuildState): this;
  54929. }
  54930. }
  54931. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54932. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54933. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54934. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54935. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54936. }
  54937. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54938. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54939. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54940. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54941. /**
  54942. * Block used to add an alpha test in the fragment shader
  54943. */
  54944. export class AlphaTestBlock extends NodeMaterialBlock {
  54945. /**
  54946. * Gets or sets the alpha value where alpha testing happens
  54947. */
  54948. alphaCutOff: number;
  54949. /**
  54950. * Create a new AlphaTestBlock
  54951. * @param name defines the block name
  54952. */
  54953. constructor(name: string);
  54954. /**
  54955. * Gets the current class name
  54956. * @returns the class name
  54957. */
  54958. getClassName(): string;
  54959. /**
  54960. * Gets the color input component
  54961. */
  54962. readonly color: NodeMaterialConnectionPoint;
  54963. /**
  54964. * Gets the alpha input component
  54965. */
  54966. readonly alpha: NodeMaterialConnectionPoint;
  54967. protected _buildBlock(state: NodeMaterialBuildState): this;
  54968. }
  54969. }
  54970. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  54971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54974. /**
  54975. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54976. */
  54977. export class ColorMergerBlock extends NodeMaterialBlock {
  54978. /**
  54979. * Create a new ColorMergerBlock
  54980. * @param name defines the block name
  54981. */
  54982. constructor(name: string);
  54983. /**
  54984. * Gets the current class name
  54985. * @returns the class name
  54986. */
  54987. getClassName(): string;
  54988. /**
  54989. * Gets the r component (input)
  54990. */
  54991. readonly r: NodeMaterialConnectionPoint;
  54992. /**
  54993. * Gets the g component (input)
  54994. */
  54995. readonly g: NodeMaterialConnectionPoint;
  54996. /**
  54997. * Gets the b component (input)
  54998. */
  54999. readonly b: NodeMaterialConnectionPoint;
  55000. /**
  55001. * Gets the a component (input)
  55002. */
  55003. readonly a: NodeMaterialConnectionPoint;
  55004. /**
  55005. * Gets the rgba component (output)
  55006. */
  55007. readonly rgba: NodeMaterialConnectionPoint;
  55008. /**
  55009. * Gets the rgb component (output)
  55010. */
  55011. readonly rgb: NodeMaterialConnectionPoint;
  55012. protected _buildBlock(state: NodeMaterialBuildState): this;
  55013. }
  55014. }
  55015. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  55016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55019. /**
  55020. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55021. */
  55022. export class VectorMergerBlock extends NodeMaterialBlock {
  55023. /**
  55024. * Create a new VectorMergerBlock
  55025. * @param name defines the block name
  55026. */
  55027. constructor(name: string);
  55028. /**
  55029. * Gets the current class name
  55030. * @returns the class name
  55031. */
  55032. getClassName(): string;
  55033. /**
  55034. * Gets the x component (input)
  55035. */
  55036. readonly x: NodeMaterialConnectionPoint;
  55037. /**
  55038. * Gets the y component (input)
  55039. */
  55040. readonly y: NodeMaterialConnectionPoint;
  55041. /**
  55042. * Gets the z component (input)
  55043. */
  55044. readonly z: NodeMaterialConnectionPoint;
  55045. /**
  55046. * Gets the w component (input)
  55047. */
  55048. readonly w: NodeMaterialConnectionPoint;
  55049. /**
  55050. * Gets the xyzw component (output)
  55051. */
  55052. readonly xyzw: NodeMaterialConnectionPoint;
  55053. /**
  55054. * Gets the xyz component (output)
  55055. */
  55056. readonly xyz: NodeMaterialConnectionPoint;
  55057. /**
  55058. * Gets the xy component (output)
  55059. */
  55060. readonly xy: NodeMaterialConnectionPoint;
  55061. protected _buildBlock(state: NodeMaterialBuildState): this;
  55062. }
  55063. }
  55064. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  55065. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55066. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55067. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55068. /**
  55069. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55070. */
  55071. export class ColorSplitterBlock extends NodeMaterialBlock {
  55072. /**
  55073. * Create a new ColorSplitterBlock
  55074. * @param name defines the block name
  55075. */
  55076. constructor(name: string);
  55077. /**
  55078. * Gets the current class name
  55079. * @returns the class name
  55080. */
  55081. getClassName(): string;
  55082. /**
  55083. * Gets the rgba component (input)
  55084. */
  55085. readonly rgba: NodeMaterialConnectionPoint;
  55086. /**
  55087. * Gets the rgb component (input)
  55088. */
  55089. readonly rgbIn: NodeMaterialConnectionPoint;
  55090. /**
  55091. * Gets the rgb component (output)
  55092. */
  55093. readonly rgbOut: NodeMaterialConnectionPoint;
  55094. /**
  55095. * Gets the r component (output)
  55096. */
  55097. readonly r: NodeMaterialConnectionPoint;
  55098. /**
  55099. * Gets the g component (output)
  55100. */
  55101. readonly g: NodeMaterialConnectionPoint;
  55102. /**
  55103. * Gets the b component (output)
  55104. */
  55105. readonly b: NodeMaterialConnectionPoint;
  55106. /**
  55107. * Gets the a component (output)
  55108. */
  55109. readonly a: NodeMaterialConnectionPoint;
  55110. protected _buildBlock(state: NodeMaterialBuildState): this;
  55111. }
  55112. }
  55113. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  55114. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55115. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55116. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55117. /**
  55118. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55119. */
  55120. export class VectorSplitterBlock extends NodeMaterialBlock {
  55121. /**
  55122. * Create a new VectorSplitterBlock
  55123. * @param name defines the block name
  55124. */
  55125. constructor(name: string);
  55126. /**
  55127. * Gets the current class name
  55128. * @returns the class name
  55129. */
  55130. getClassName(): string;
  55131. /**
  55132. * Gets the xyzw component (input)
  55133. */
  55134. readonly xyzw: NodeMaterialConnectionPoint;
  55135. /**
  55136. * Gets the xyz component (input)
  55137. */
  55138. readonly xyzIn: NodeMaterialConnectionPoint;
  55139. /**
  55140. * Gets the xyz component (output)
  55141. */
  55142. readonly xyzOut: NodeMaterialConnectionPoint;
  55143. /**
  55144. * Gets the xy component (output)
  55145. */
  55146. readonly xy: NodeMaterialConnectionPoint;
  55147. /**
  55148. * Gets the x component (output)
  55149. */
  55150. readonly x: NodeMaterialConnectionPoint;
  55151. /**
  55152. * Gets the y component (output)
  55153. */
  55154. readonly y: NodeMaterialConnectionPoint;
  55155. /**
  55156. * Gets the z component (output)
  55157. */
  55158. readonly z: NodeMaterialConnectionPoint;
  55159. /**
  55160. * Gets the w component (output)
  55161. */
  55162. readonly w: NodeMaterialConnectionPoint;
  55163. protected _buildBlock(state: NodeMaterialBuildState): this;
  55164. }
  55165. }
  55166. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55167. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55168. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55169. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55171. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55172. import { Effect } from "babylonjs/Materials/effect";
  55173. import { Mesh } from "babylonjs/Meshes/mesh";
  55174. /**
  55175. * Block used to add image processing support to fragment shader
  55176. */
  55177. export class ImageProcessingBlock extends NodeMaterialBlock {
  55178. /**
  55179. * Create a new ImageProcessingBlock
  55180. * @param name defines the block name
  55181. */
  55182. constructor(name: string);
  55183. /**
  55184. * Gets the current class name
  55185. * @returns the class name
  55186. */
  55187. getClassName(): string;
  55188. /**
  55189. * Gets the color input component
  55190. */
  55191. readonly color: NodeMaterialConnectionPoint;
  55192. /**
  55193. * Gets the output component
  55194. */
  55195. readonly output: NodeMaterialConnectionPoint;
  55196. /**
  55197. * Initialize the block and prepare the context for build
  55198. * @param state defines the state that will be used for the build
  55199. */
  55200. initialize(state: NodeMaterialBuildState): void;
  55201. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55202. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55203. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55204. protected _buildBlock(state: NodeMaterialBuildState): this;
  55205. }
  55206. }
  55207. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55208. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55209. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55210. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  55211. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  55212. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  55213. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  55214. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55215. }
  55216. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55217. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55218. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55219. import { Mesh } from "babylonjs/Meshes/mesh";
  55220. import { Effect } from "babylonjs/Materials/effect";
  55221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55223. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55224. /**
  55225. * Block used to add support for scene fog
  55226. */
  55227. export class FogBlock extends NodeMaterialBlock {
  55228. private _fogDistanceName;
  55229. private _fogParameters;
  55230. /**
  55231. * Create a new FogBlock
  55232. * @param name defines the block name
  55233. */
  55234. constructor(name: string);
  55235. /**
  55236. * Gets the current class name
  55237. * @returns the class name
  55238. */
  55239. getClassName(): string;
  55240. /**
  55241. * Gets the world position input component
  55242. */
  55243. readonly worldPosition: NodeMaterialConnectionPoint;
  55244. /**
  55245. * Gets the view input component
  55246. */
  55247. readonly view: NodeMaterialConnectionPoint;
  55248. /**
  55249. * Gets the color input component
  55250. */
  55251. readonly color: NodeMaterialConnectionPoint;
  55252. /**
  55253. * Gets the fog color input component
  55254. */
  55255. readonly fogColor: NodeMaterialConnectionPoint;
  55256. /**
  55257. * Gets the output component
  55258. */
  55259. readonly output: NodeMaterialConnectionPoint;
  55260. autoConfigure(): void;
  55261. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55262. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55263. protected _buildBlock(state: NodeMaterialBuildState): this;
  55264. }
  55265. }
  55266. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55267. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55268. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55269. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55271. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55272. import { Effect } from "babylonjs/Materials/effect";
  55273. import { Mesh } from "babylonjs/Meshes/mesh";
  55274. import { Light } from "babylonjs/Lights/light";
  55275. import { Nullable } from "babylonjs/types";
  55276. import { Scene } from "babylonjs/scene";
  55277. /**
  55278. * Block used to add light in the fragment shader
  55279. */
  55280. export class LightBlock extends NodeMaterialBlock {
  55281. private _lightId;
  55282. /**
  55283. * Gets or sets the light associated with this block
  55284. */
  55285. light: Nullable<Light>;
  55286. /**
  55287. * Create a new LightBlock
  55288. * @param name defines the block name
  55289. */
  55290. constructor(name: string);
  55291. /**
  55292. * Gets the current class name
  55293. * @returns the class name
  55294. */
  55295. getClassName(): string;
  55296. /**
  55297. * Gets the world position input component
  55298. */
  55299. readonly worldPosition: NodeMaterialConnectionPoint;
  55300. /**
  55301. * Gets the world normal input component
  55302. */
  55303. readonly worldNormal: NodeMaterialConnectionPoint;
  55304. /**
  55305. * Gets the camera (or eye) position component
  55306. */
  55307. readonly cameraPosition: NodeMaterialConnectionPoint;
  55308. /**
  55309. * Gets the diffuse output component
  55310. */
  55311. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55312. /**
  55313. * Gets the specular output component
  55314. */
  55315. readonly specularOutput: NodeMaterialConnectionPoint;
  55316. autoConfigure(): void;
  55317. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55318. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55319. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55320. private _injectVertexCode;
  55321. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55322. serialize(): any;
  55323. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55324. }
  55325. }
  55326. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55327. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55328. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55329. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55330. }
  55331. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55332. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55333. }
  55334. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55338. /**
  55339. * Block used to multiply 2 values
  55340. */
  55341. export class MultiplyBlock extends NodeMaterialBlock {
  55342. /**
  55343. * Creates a new MultiplyBlock
  55344. * @param name defines the block name
  55345. */
  55346. constructor(name: string);
  55347. /**
  55348. * Gets the current class name
  55349. * @returns the class name
  55350. */
  55351. getClassName(): string;
  55352. /**
  55353. * Gets the left operand input component
  55354. */
  55355. readonly left: NodeMaterialConnectionPoint;
  55356. /**
  55357. * Gets the right operand input component
  55358. */
  55359. readonly right: NodeMaterialConnectionPoint;
  55360. /**
  55361. * Gets the output component
  55362. */
  55363. readonly output: NodeMaterialConnectionPoint;
  55364. protected _buildBlock(state: NodeMaterialBuildState): this;
  55365. }
  55366. }
  55367. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55369. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55370. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55371. /**
  55372. * Block used to add 2 vectors
  55373. */
  55374. export class AddBlock extends NodeMaterialBlock {
  55375. /**
  55376. * Creates a new AddBlock
  55377. * @param name defines the block name
  55378. */
  55379. constructor(name: string);
  55380. /**
  55381. * Gets the current class name
  55382. * @returns the class name
  55383. */
  55384. getClassName(): string;
  55385. /**
  55386. * Gets the left operand input component
  55387. */
  55388. readonly left: NodeMaterialConnectionPoint;
  55389. /**
  55390. * Gets the right operand input component
  55391. */
  55392. readonly right: NodeMaterialConnectionPoint;
  55393. /**
  55394. * Gets the output component
  55395. */
  55396. readonly output: NodeMaterialConnectionPoint;
  55397. protected _buildBlock(state: NodeMaterialBuildState): this;
  55398. }
  55399. }
  55400. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55404. /**
  55405. * Block used to clamp a float
  55406. */
  55407. export class ClampBlock extends NodeMaterialBlock {
  55408. /** Gets or sets the minimum range */
  55409. minimum: number;
  55410. /** Gets or sets the maximum range */
  55411. maximum: number;
  55412. /**
  55413. * Creates a new ClampBlock
  55414. * @param name defines the block name
  55415. */
  55416. constructor(name: string);
  55417. /**
  55418. * Gets the current class name
  55419. * @returns the class name
  55420. */
  55421. getClassName(): string;
  55422. /**
  55423. * Gets the value input component
  55424. */
  55425. readonly value: NodeMaterialConnectionPoint;
  55426. /**
  55427. * Gets the output component
  55428. */
  55429. readonly output: NodeMaterialConnectionPoint;
  55430. protected _buildBlock(state: NodeMaterialBuildState): this;
  55431. }
  55432. }
  55433. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55437. /**
  55438. * Block used to apply a cross product between 2 vectors
  55439. */
  55440. export class CrossBlock extends NodeMaterialBlock {
  55441. /**
  55442. * Creates a new CrossBlock
  55443. * @param name defines the block name
  55444. */
  55445. constructor(name: string);
  55446. /**
  55447. * Gets the current class name
  55448. * @returns the class name
  55449. */
  55450. getClassName(): string;
  55451. /**
  55452. * Gets the left operand input component
  55453. */
  55454. readonly left: NodeMaterialConnectionPoint;
  55455. /**
  55456. * Gets the right operand input component
  55457. */
  55458. readonly right: NodeMaterialConnectionPoint;
  55459. /**
  55460. * Gets the output component
  55461. */
  55462. readonly output: NodeMaterialConnectionPoint;
  55463. protected _buildBlock(state: NodeMaterialBuildState): this;
  55464. }
  55465. }
  55466. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55470. /**
  55471. * Block used to apply a dot product between 2 vectors
  55472. */
  55473. export class DotBlock extends NodeMaterialBlock {
  55474. /**
  55475. * Creates a new DotBlock
  55476. * @param name defines the block name
  55477. */
  55478. constructor(name: string);
  55479. /**
  55480. * Gets the current class name
  55481. * @returns the class name
  55482. */
  55483. getClassName(): string;
  55484. /**
  55485. * Gets the left operand input component
  55486. */
  55487. readonly left: NodeMaterialConnectionPoint;
  55488. /**
  55489. * Gets the right operand input component
  55490. */
  55491. readonly right: NodeMaterialConnectionPoint;
  55492. /**
  55493. * Gets the output component
  55494. */
  55495. readonly output: NodeMaterialConnectionPoint;
  55496. protected _buildBlock(state: NodeMaterialBuildState): this;
  55497. }
  55498. }
  55499. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  55500. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55501. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55502. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55503. import { Vector2 } from "babylonjs/Maths/math.vector";
  55504. /**
  55505. * Block used to remap a float from a range to a new one
  55506. */
  55507. export class RemapBlock extends NodeMaterialBlock {
  55508. /**
  55509. * Gets or sets the source range
  55510. */
  55511. sourceRange: Vector2;
  55512. /**
  55513. * Gets or sets the target range
  55514. */
  55515. targetRange: Vector2;
  55516. /**
  55517. * Creates a new RemapBlock
  55518. * @param name defines the block name
  55519. */
  55520. constructor(name: string);
  55521. /**
  55522. * Gets the current class name
  55523. * @returns the class name
  55524. */
  55525. getClassName(): string;
  55526. /**
  55527. * Gets the input component
  55528. */
  55529. readonly input: NodeMaterialConnectionPoint;
  55530. /**
  55531. * Gets the output component
  55532. */
  55533. readonly output: NodeMaterialConnectionPoint;
  55534. protected _buildBlock(state: NodeMaterialBuildState): this;
  55535. }
  55536. }
  55537. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  55538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55541. /**
  55542. * Block used to normalize a vector
  55543. */
  55544. export class NormalizeBlock extends NodeMaterialBlock {
  55545. /**
  55546. * Creates a new NormalizeBlock
  55547. * @param name defines the block name
  55548. */
  55549. constructor(name: string);
  55550. /**
  55551. * Gets the current class name
  55552. * @returns the class name
  55553. */
  55554. getClassName(): string;
  55555. /**
  55556. * Gets the input component
  55557. */
  55558. readonly input: NodeMaterialConnectionPoint;
  55559. /**
  55560. * Gets the output component
  55561. */
  55562. readonly output: NodeMaterialConnectionPoint;
  55563. protected _buildBlock(state: NodeMaterialBuildState): this;
  55564. }
  55565. }
  55566. declare module "babylonjs/Materials/Node/Blocks/index" {
  55567. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  55568. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  55569. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  55570. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  55571. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  55572. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  55573. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  55574. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  55575. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  55576. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  55577. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  55578. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  55579. }
  55580. declare module "babylonjs/Materials/Node/Optimizers/index" {
  55581. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55582. }
  55583. declare module "babylonjs/Materials/Node/index" {
  55584. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55585. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55586. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55587. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  55588. export * from "babylonjs/Materials/Node/nodeMaterial";
  55589. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55590. export * from "babylonjs/Materials/Node/Blocks/index";
  55591. export * from "babylonjs/Materials/Node/Optimizers/index";
  55592. }
  55593. declare module "babylonjs/Materials/effectRenderer" {
  55594. import { Nullable } from "babylonjs/types";
  55595. import { Texture } from "babylonjs/Materials/Textures/texture";
  55596. import { Engine } from "babylonjs/Engines/engine";
  55597. import { Viewport } from "babylonjs/Maths/math.viewport";
  55598. import { Observable } from "babylonjs/Misc/observable";
  55599. import { Effect } from "babylonjs/Materials/effect";
  55600. import "babylonjs/Shaders/postprocess.vertex";
  55601. /**
  55602. * Effect Render Options
  55603. */
  55604. export interface IEffectRendererOptions {
  55605. /**
  55606. * Defines the vertices positions.
  55607. */
  55608. positions?: number[];
  55609. /**
  55610. * Defines the indices.
  55611. */
  55612. indices?: number[];
  55613. }
  55614. /**
  55615. * Helper class to render one or more effects
  55616. */
  55617. export class EffectRenderer {
  55618. private engine;
  55619. private static _DefaultOptions;
  55620. private _vertexBuffers;
  55621. private _indexBuffer;
  55622. private _ringBufferIndex;
  55623. private _ringScreenBuffer;
  55624. private _fullscreenViewport;
  55625. private _getNextFrameBuffer;
  55626. /**
  55627. * Creates an effect renderer
  55628. * @param engine the engine to use for rendering
  55629. * @param options defines the options of the effect renderer
  55630. */
  55631. constructor(engine: Engine, options?: IEffectRendererOptions);
  55632. /**
  55633. * Sets the current viewport in normalized coordinates 0-1
  55634. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55635. */
  55636. setViewport(viewport?: Viewport): void;
  55637. /**
  55638. * Sets the current effect wrapper to use during draw.
  55639. * The effect needs to be ready before calling this api.
  55640. * This also sets the default full screen position attribute.
  55641. * @param effectWrapper Defines the effect to draw with
  55642. */
  55643. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55644. /**
  55645. * Draws a full screen quad.
  55646. */
  55647. draw(): void;
  55648. /**
  55649. * renders one or more effects to a specified texture
  55650. * @param effectWrappers list of effects to renderer
  55651. * @param outputTexture texture to draw to, if null it will render to the screen
  55652. */
  55653. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55654. /**
  55655. * Disposes of the effect renderer
  55656. */
  55657. dispose(): void;
  55658. }
  55659. /**
  55660. * Options to create an EffectWrapper
  55661. */
  55662. interface EffectWrapperCreationOptions {
  55663. /**
  55664. * Engine to use to create the effect
  55665. */
  55666. engine: Engine;
  55667. /**
  55668. * Fragment shader for the effect
  55669. */
  55670. fragmentShader: string;
  55671. /**
  55672. * Vertex shader for the effect
  55673. */
  55674. vertexShader: string;
  55675. /**
  55676. * Attributes to use in the shader
  55677. */
  55678. attributeNames?: Array<string>;
  55679. /**
  55680. * Uniforms to use in the shader
  55681. */
  55682. uniformNames?: Array<string>;
  55683. /**
  55684. * Texture sampler names to use in the shader
  55685. */
  55686. samplerNames?: Array<string>;
  55687. /**
  55688. * The friendly name of the effect displayed in Spector.
  55689. */
  55690. name?: string;
  55691. }
  55692. /**
  55693. * Wraps an effect to be used for rendering
  55694. */
  55695. export class EffectWrapper {
  55696. /**
  55697. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55698. */
  55699. onApplyObservable: Observable<{}>;
  55700. /**
  55701. * The underlying effect
  55702. */
  55703. effect: Effect;
  55704. /**
  55705. * Creates an effect to be renderer
  55706. * @param creationOptions options to create the effect
  55707. */
  55708. constructor(creationOptions: EffectWrapperCreationOptions);
  55709. /**
  55710. * Disposes of the effect wrapper
  55711. */
  55712. dispose(): void;
  55713. }
  55714. }
  55715. declare module "babylonjs/Materials/index" {
  55716. export * from "babylonjs/Materials/Background/index";
  55717. export * from "babylonjs/Materials/colorCurves";
  55718. export * from "babylonjs/Materials/effect";
  55719. export * from "babylonjs/Materials/fresnelParameters";
  55720. export * from "babylonjs/Materials/imageProcessingConfiguration";
  55721. export * from "babylonjs/Materials/material";
  55722. export * from "babylonjs/Materials/materialDefines";
  55723. export * from "babylonjs/Materials/materialHelper";
  55724. export * from "babylonjs/Materials/multiMaterial";
  55725. export * from "babylonjs/Materials/PBR/index";
  55726. export * from "babylonjs/Materials/pushMaterial";
  55727. export * from "babylonjs/Materials/shaderMaterial";
  55728. export * from "babylonjs/Materials/standardMaterial";
  55729. export * from "babylonjs/Materials/Textures/index";
  55730. export * from "babylonjs/Materials/uniformBuffer";
  55731. export * from "babylonjs/Materials/materialFlags";
  55732. export * from "babylonjs/Materials/Node/index";
  55733. export * from "babylonjs/Materials/effectRenderer";
  55734. }
  55735. declare module "babylonjs/Maths/index" {
  55736. export * from "babylonjs/Maths/math.scalar";
  55737. export * from "babylonjs/Maths/math";
  55738. export * from "babylonjs/Maths/sphericalPolynomial";
  55739. }
  55740. declare module "babylonjs/Misc/workerPool" {
  55741. import { IDisposable } from "babylonjs/scene";
  55742. /**
  55743. * Helper class to push actions to a pool of workers.
  55744. */
  55745. export class WorkerPool implements IDisposable {
  55746. private _workerInfos;
  55747. private _pendingActions;
  55748. /**
  55749. * Constructor
  55750. * @param workers Array of workers to use for actions
  55751. */
  55752. constructor(workers: Array<Worker>);
  55753. /**
  55754. * Terminates all workers and clears any pending actions.
  55755. */
  55756. dispose(): void;
  55757. /**
  55758. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55759. * pended until a worker has completed its action.
  55760. * @param action The action to perform. Call onComplete when the action is complete.
  55761. */
  55762. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55763. private _execute;
  55764. }
  55765. }
  55766. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  55767. import { IDisposable } from "babylonjs/scene";
  55768. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55769. /**
  55770. * Configuration for Draco compression
  55771. */
  55772. export interface IDracoCompressionConfiguration {
  55773. /**
  55774. * Configuration for the decoder.
  55775. */
  55776. decoder: {
  55777. /**
  55778. * The url to the WebAssembly module.
  55779. */
  55780. wasmUrl?: string;
  55781. /**
  55782. * The url to the WebAssembly binary.
  55783. */
  55784. wasmBinaryUrl?: string;
  55785. /**
  55786. * The url to the fallback JavaScript module.
  55787. */
  55788. fallbackUrl?: string;
  55789. };
  55790. }
  55791. /**
  55792. * Draco compression (https://google.github.io/draco/)
  55793. *
  55794. * This class wraps the Draco module.
  55795. *
  55796. * **Encoder**
  55797. *
  55798. * The encoder is not currently implemented.
  55799. *
  55800. * **Decoder**
  55801. *
  55802. * 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.
  55803. *
  55804. * To update the configuration, use the following code:
  55805. * ```javascript
  55806. * DracoCompression.Configuration = {
  55807. * decoder: {
  55808. * wasmUrl: "<url to the WebAssembly library>",
  55809. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55810. * fallbackUrl: "<url to the fallback JavaScript library>",
  55811. * }
  55812. * };
  55813. * ```
  55814. *
  55815. * 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.
  55816. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55817. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55818. *
  55819. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55820. * ```javascript
  55821. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55822. * ```
  55823. *
  55824. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55825. */
  55826. export class DracoCompression implements IDisposable {
  55827. private _workerPoolPromise?;
  55828. private _decoderModulePromise?;
  55829. /**
  55830. * The configuration. Defaults to the following urls:
  55831. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55832. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55833. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55834. */
  55835. static Configuration: IDracoCompressionConfiguration;
  55836. /**
  55837. * Returns true if the decoder configuration is available.
  55838. */
  55839. static readonly DecoderAvailable: boolean;
  55840. /**
  55841. * Default number of workers to create when creating the draco compression object.
  55842. */
  55843. static DefaultNumWorkers: number;
  55844. private static GetDefaultNumWorkers;
  55845. private static _Default;
  55846. /**
  55847. * Default instance for the draco compression object.
  55848. */
  55849. static readonly Default: DracoCompression;
  55850. /**
  55851. * Constructor
  55852. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55853. */
  55854. constructor(numWorkers?: number);
  55855. /**
  55856. * Stop all async operations and release resources.
  55857. */
  55858. dispose(): void;
  55859. /**
  55860. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55861. * @returns a promise that resolves when ready
  55862. */
  55863. whenReadyAsync(): Promise<void>;
  55864. /**
  55865. * Decode Draco compressed mesh data to vertex data.
  55866. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55867. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55868. * @returns A promise that resolves with the decoded vertex data
  55869. */
  55870. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55871. [kind: string]: number;
  55872. }): Promise<VertexData>;
  55873. }
  55874. }
  55875. declare module "babylonjs/Meshes/Compression/index" {
  55876. export * from "babylonjs/Meshes/Compression/dracoCompression";
  55877. }
  55878. declare module "babylonjs/Meshes/csg" {
  55879. import { Nullable } from "babylonjs/types";
  55880. import { Scene } from "babylonjs/scene";
  55881. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55882. import { Mesh } from "babylonjs/Meshes/mesh";
  55883. import { Material } from "babylonjs/Materials/material";
  55884. /**
  55885. * Class for building Constructive Solid Geometry
  55886. */
  55887. export class CSG {
  55888. private polygons;
  55889. /**
  55890. * The world matrix
  55891. */
  55892. matrix: Matrix;
  55893. /**
  55894. * Stores the position
  55895. */
  55896. position: Vector3;
  55897. /**
  55898. * Stores the rotation
  55899. */
  55900. rotation: Vector3;
  55901. /**
  55902. * Stores the rotation quaternion
  55903. */
  55904. rotationQuaternion: Nullable<Quaternion>;
  55905. /**
  55906. * Stores the scaling vector
  55907. */
  55908. scaling: Vector3;
  55909. /**
  55910. * Convert the Mesh to CSG
  55911. * @param mesh The Mesh to convert to CSG
  55912. * @returns A new CSG from the Mesh
  55913. */
  55914. static FromMesh(mesh: Mesh): CSG;
  55915. /**
  55916. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55917. * @param polygons Polygons used to construct a CSG solid
  55918. */
  55919. private static FromPolygons;
  55920. /**
  55921. * Clones, or makes a deep copy, of the CSG
  55922. * @returns A new CSG
  55923. */
  55924. clone(): CSG;
  55925. /**
  55926. * Unions this CSG with another CSG
  55927. * @param csg The CSG to union against this CSG
  55928. * @returns The unioned CSG
  55929. */
  55930. union(csg: CSG): CSG;
  55931. /**
  55932. * Unions this CSG with another CSG in place
  55933. * @param csg The CSG to union against this CSG
  55934. */
  55935. unionInPlace(csg: CSG): void;
  55936. /**
  55937. * Subtracts this CSG with another CSG
  55938. * @param csg The CSG to subtract against this CSG
  55939. * @returns A new CSG
  55940. */
  55941. subtract(csg: CSG): CSG;
  55942. /**
  55943. * Subtracts this CSG with another CSG in place
  55944. * @param csg The CSG to subtact against this CSG
  55945. */
  55946. subtractInPlace(csg: CSG): void;
  55947. /**
  55948. * Intersect this CSG with another CSG
  55949. * @param csg The CSG to intersect against this CSG
  55950. * @returns A new CSG
  55951. */
  55952. intersect(csg: CSG): CSG;
  55953. /**
  55954. * Intersects this CSG with another CSG in place
  55955. * @param csg The CSG to intersect against this CSG
  55956. */
  55957. intersectInPlace(csg: CSG): void;
  55958. /**
  55959. * Return a new CSG solid with solid and empty space switched. This solid is
  55960. * not modified.
  55961. * @returns A new CSG solid with solid and empty space switched
  55962. */
  55963. inverse(): CSG;
  55964. /**
  55965. * Inverses the CSG in place
  55966. */
  55967. inverseInPlace(): void;
  55968. /**
  55969. * This is used to keep meshes transformations so they can be restored
  55970. * when we build back a Babylon Mesh
  55971. * NB : All CSG operations are performed in world coordinates
  55972. * @param csg The CSG to copy the transform attributes from
  55973. * @returns This CSG
  55974. */
  55975. copyTransformAttributes(csg: CSG): CSG;
  55976. /**
  55977. * Build Raw mesh from CSG
  55978. * Coordinates here are in world space
  55979. * @param name The name of the mesh geometry
  55980. * @param scene The Scene
  55981. * @param keepSubMeshes Specifies if the submeshes should be kept
  55982. * @returns A new Mesh
  55983. */
  55984. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  55985. /**
  55986. * Build Mesh from CSG taking material and transforms into account
  55987. * @param name The name of the Mesh
  55988. * @param material The material of the Mesh
  55989. * @param scene The Scene
  55990. * @param keepSubMeshes Specifies if submeshes should be kept
  55991. * @returns The new Mesh
  55992. */
  55993. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  55994. }
  55995. }
  55996. declare module "babylonjs/Meshes/trailMesh" {
  55997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55998. import { Mesh } from "babylonjs/Meshes/mesh";
  55999. import { Scene } from "babylonjs/scene";
  56000. /**
  56001. * Class used to create a trail following a mesh
  56002. */
  56003. export class TrailMesh extends Mesh {
  56004. private _generator;
  56005. private _autoStart;
  56006. private _running;
  56007. private _diameter;
  56008. private _length;
  56009. private _sectionPolygonPointsCount;
  56010. private _sectionVectors;
  56011. private _sectionNormalVectors;
  56012. private _beforeRenderObserver;
  56013. /**
  56014. * @constructor
  56015. * @param name The value used by scene.getMeshByName() to do a lookup.
  56016. * @param generator The mesh to generate a trail.
  56017. * @param scene The scene to add this mesh to.
  56018. * @param diameter Diameter of trailing mesh. Default is 1.
  56019. * @param length Length of trailing mesh. Default is 60.
  56020. * @param autoStart Automatically start trailing mesh. Default true.
  56021. */
  56022. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56023. /**
  56024. * "TrailMesh"
  56025. * @returns "TrailMesh"
  56026. */
  56027. getClassName(): string;
  56028. private _createMesh;
  56029. /**
  56030. * Start trailing mesh.
  56031. */
  56032. start(): void;
  56033. /**
  56034. * Stop trailing mesh.
  56035. */
  56036. stop(): void;
  56037. /**
  56038. * Update trailing mesh geometry.
  56039. */
  56040. update(): void;
  56041. /**
  56042. * Returns a new TrailMesh object.
  56043. * @param name is a string, the name given to the new mesh
  56044. * @param newGenerator use new generator object for cloned trail mesh
  56045. * @returns a new mesh
  56046. */
  56047. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56048. /**
  56049. * Serializes this trail mesh
  56050. * @param serializationObject object to write serialization to
  56051. */
  56052. serialize(serializationObject: any): void;
  56053. /**
  56054. * Parses a serialized trail mesh
  56055. * @param parsedMesh the serialized mesh
  56056. * @param scene the scene to create the trail mesh in
  56057. * @returns the created trail mesh
  56058. */
  56059. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56060. }
  56061. }
  56062. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  56063. import { Nullable } from "babylonjs/types";
  56064. import { Scene } from "babylonjs/scene";
  56065. import { Vector4 } from "babylonjs/Maths/math.vector";
  56066. import { Color4 } from "babylonjs/Maths/math.color";
  56067. import { Mesh } from "babylonjs/Meshes/mesh";
  56068. /**
  56069. * Class containing static functions to help procedurally build meshes
  56070. */
  56071. export class TiledBoxBuilder {
  56072. /**
  56073. * Creates a box mesh
  56074. * 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)
  56075. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56079. * @param name defines the name of the mesh
  56080. * @param options defines the options used to create the mesh
  56081. * @param scene defines the hosting scene
  56082. * @returns the box mesh
  56083. */
  56084. static CreateTiledBox(name: string, options: {
  56085. pattern?: number;
  56086. width?: number;
  56087. height?: number;
  56088. depth?: number;
  56089. tileSize?: number;
  56090. tileWidth?: number;
  56091. tileHeight?: number;
  56092. alignHorizontal?: number;
  56093. alignVertical?: number;
  56094. faceUV?: Vector4[];
  56095. faceColors?: Color4[];
  56096. sideOrientation?: number;
  56097. updatable?: boolean;
  56098. }, scene?: Nullable<Scene>): Mesh;
  56099. }
  56100. }
  56101. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  56102. import { Vector4 } from "babylonjs/Maths/math.vector";
  56103. import { Mesh } from "babylonjs/Meshes/mesh";
  56104. /**
  56105. * Class containing static functions to help procedurally build meshes
  56106. */
  56107. export class TorusKnotBuilder {
  56108. /**
  56109. * Creates a torus knot mesh
  56110. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56111. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56112. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56113. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56117. * @param name defines the name of the mesh
  56118. * @param options defines the options used to create the mesh
  56119. * @param scene defines the hosting scene
  56120. * @returns the torus knot mesh
  56121. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56122. */
  56123. static CreateTorusKnot(name: string, options: {
  56124. radius?: number;
  56125. tube?: number;
  56126. radialSegments?: number;
  56127. tubularSegments?: number;
  56128. p?: number;
  56129. q?: number;
  56130. updatable?: boolean;
  56131. sideOrientation?: number;
  56132. frontUVs?: Vector4;
  56133. backUVs?: Vector4;
  56134. }, scene: any): Mesh;
  56135. }
  56136. }
  56137. declare module "babylonjs/Meshes/polygonMesh" {
  56138. import { Scene } from "babylonjs/scene";
  56139. import { Vector2 } from "babylonjs/Maths/math.vector";
  56140. import { Mesh } from "babylonjs/Meshes/mesh";
  56141. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56142. import { Path2 } from "babylonjs/Maths/math.path";
  56143. /**
  56144. * Polygon
  56145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56146. */
  56147. export class Polygon {
  56148. /**
  56149. * Creates a rectangle
  56150. * @param xmin bottom X coord
  56151. * @param ymin bottom Y coord
  56152. * @param xmax top X coord
  56153. * @param ymax top Y coord
  56154. * @returns points that make the resulting rectation
  56155. */
  56156. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56157. /**
  56158. * Creates a circle
  56159. * @param radius radius of circle
  56160. * @param cx scale in x
  56161. * @param cy scale in y
  56162. * @param numberOfSides number of sides that make up the circle
  56163. * @returns points that make the resulting circle
  56164. */
  56165. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56166. /**
  56167. * Creates a polygon from input string
  56168. * @param input Input polygon data
  56169. * @returns the parsed points
  56170. */
  56171. static Parse(input: string): Vector2[];
  56172. /**
  56173. * Starts building a polygon from x and y coordinates
  56174. * @param x x coordinate
  56175. * @param y y coordinate
  56176. * @returns the started path2
  56177. */
  56178. static StartingAt(x: number, y: number): Path2;
  56179. }
  56180. /**
  56181. * Builds a polygon
  56182. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56183. */
  56184. export class PolygonMeshBuilder {
  56185. private _points;
  56186. private _outlinepoints;
  56187. private _holes;
  56188. private _name;
  56189. private _scene;
  56190. private _epoints;
  56191. private _eholes;
  56192. private _addToepoint;
  56193. /**
  56194. * Babylon reference to the earcut plugin.
  56195. */
  56196. bjsEarcut: any;
  56197. /**
  56198. * Creates a PolygonMeshBuilder
  56199. * @param name name of the builder
  56200. * @param contours Path of the polygon
  56201. * @param scene scene to add to when creating the mesh
  56202. * @param earcutInjection can be used to inject your own earcut reference
  56203. */
  56204. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56205. /**
  56206. * Adds a whole within the polygon
  56207. * @param hole Array of points defining the hole
  56208. * @returns this
  56209. */
  56210. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56211. /**
  56212. * Creates the polygon
  56213. * @param updatable If the mesh should be updatable
  56214. * @param depth The depth of the mesh created
  56215. * @returns the created mesh
  56216. */
  56217. build(updatable?: boolean, depth?: number): Mesh;
  56218. /**
  56219. * Creates the polygon
  56220. * @param depth The depth of the mesh created
  56221. * @returns the created VertexData
  56222. */
  56223. buildVertexData(depth?: number): VertexData;
  56224. /**
  56225. * Adds a side to the polygon
  56226. * @param positions points that make the polygon
  56227. * @param normals normals of the polygon
  56228. * @param uvs uvs of the polygon
  56229. * @param indices indices of the polygon
  56230. * @param bounds bounds of the polygon
  56231. * @param points points of the polygon
  56232. * @param depth depth of the polygon
  56233. * @param flip flip of the polygon
  56234. */
  56235. private addSide;
  56236. }
  56237. }
  56238. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  56239. import { Scene } from "babylonjs/scene";
  56240. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56241. import { Color4 } from "babylonjs/Maths/math.color";
  56242. import { Mesh } from "babylonjs/Meshes/mesh";
  56243. import { Nullable } from "babylonjs/types";
  56244. /**
  56245. * Class containing static functions to help procedurally build meshes
  56246. */
  56247. export class PolygonBuilder {
  56248. /**
  56249. * Creates a polygon mesh
  56250. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56251. * * 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
  56252. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56255. * * Remember you can only change the shape positions, not their number when updating a polygon
  56256. * @param name defines the name of the mesh
  56257. * @param options defines the options used to create the mesh
  56258. * @param scene defines the hosting scene
  56259. * @param earcutInjection can be used to inject your own earcut reference
  56260. * @returns the polygon mesh
  56261. */
  56262. static CreatePolygon(name: string, options: {
  56263. shape: Vector3[];
  56264. holes?: Vector3[][];
  56265. depth?: number;
  56266. faceUV?: Vector4[];
  56267. faceColors?: Color4[];
  56268. updatable?: boolean;
  56269. sideOrientation?: number;
  56270. frontUVs?: Vector4;
  56271. backUVs?: Vector4;
  56272. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56273. /**
  56274. * Creates an extruded polygon mesh, with depth in the Y direction.
  56275. * * 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)
  56276. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56277. * @param name defines the name of the mesh
  56278. * @param options defines the options used to create the mesh
  56279. * @param scene defines the hosting scene
  56280. * @param earcutInjection can be used to inject your own earcut reference
  56281. * @returns the polygon mesh
  56282. */
  56283. static ExtrudePolygon(name: string, options: {
  56284. shape: Vector3[];
  56285. holes?: Vector3[][];
  56286. depth?: number;
  56287. faceUV?: Vector4[];
  56288. faceColors?: Color4[];
  56289. updatable?: boolean;
  56290. sideOrientation?: number;
  56291. frontUVs?: Vector4;
  56292. backUVs?: Vector4;
  56293. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56294. }
  56295. }
  56296. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  56297. import { Scene } from "babylonjs/scene";
  56298. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56299. import { Mesh } from "babylonjs/Meshes/mesh";
  56300. import { Nullable } from "babylonjs/types";
  56301. /**
  56302. * Class containing static functions to help procedurally build meshes
  56303. */
  56304. export class LatheBuilder {
  56305. /**
  56306. * Creates lathe mesh.
  56307. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56308. * * 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
  56309. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56310. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56311. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56312. * * 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
  56313. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56314. * * 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
  56315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56317. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56319. * @param name defines the name of the mesh
  56320. * @param options defines the options used to create the mesh
  56321. * @param scene defines the hosting scene
  56322. * @returns the lathe mesh
  56323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56324. */
  56325. static CreateLathe(name: string, options: {
  56326. shape: Vector3[];
  56327. radius?: number;
  56328. tessellation?: number;
  56329. clip?: number;
  56330. arc?: number;
  56331. closed?: boolean;
  56332. updatable?: boolean;
  56333. sideOrientation?: number;
  56334. frontUVs?: Vector4;
  56335. backUVs?: Vector4;
  56336. cap?: number;
  56337. invertUV?: boolean;
  56338. }, scene?: Nullable<Scene>): Mesh;
  56339. }
  56340. }
  56341. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  56342. import { Nullable } from "babylonjs/types";
  56343. import { Scene } from "babylonjs/scene";
  56344. import { Vector4 } from "babylonjs/Maths/math.vector";
  56345. import { Mesh } from "babylonjs/Meshes/mesh";
  56346. /**
  56347. * Class containing static functions to help procedurally build meshes
  56348. */
  56349. export class TiledPlaneBuilder {
  56350. /**
  56351. * Creates a tiled plane mesh
  56352. * * The parameter `pattern` will, depending on value, do nothing or
  56353. * * * flip (reflect about central vertical) alternate tiles across and up
  56354. * * * flip every tile on alternate rows
  56355. * * * rotate (180 degs) alternate tiles across and up
  56356. * * * rotate every tile on alternate rows
  56357. * * * flip and rotate alternate tiles across and up
  56358. * * * flip and rotate every tile on alternate rows
  56359. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56360. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56362. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56363. * * 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)
  56364. * * 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)
  56365. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56366. * @param name defines the name of the mesh
  56367. * @param options defines the options used to create the mesh
  56368. * @param scene defines the hosting scene
  56369. * @returns the box mesh
  56370. */
  56371. static CreateTiledPlane(name: string, options: {
  56372. pattern?: number;
  56373. tileSize?: number;
  56374. tileWidth?: number;
  56375. tileHeight?: number;
  56376. size?: number;
  56377. width?: number;
  56378. height?: number;
  56379. alignHorizontal?: number;
  56380. alignVertical?: number;
  56381. sideOrientation?: number;
  56382. frontUVs?: Vector4;
  56383. backUVs?: Vector4;
  56384. updatable?: boolean;
  56385. }, scene?: Nullable<Scene>): Mesh;
  56386. }
  56387. }
  56388. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  56389. import { Nullable } from "babylonjs/types";
  56390. import { Scene } from "babylonjs/scene";
  56391. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56392. import { Mesh } from "babylonjs/Meshes/mesh";
  56393. /**
  56394. * Class containing static functions to help procedurally build meshes
  56395. */
  56396. export class TubeBuilder {
  56397. /**
  56398. * Creates a tube mesh.
  56399. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56400. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56401. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56402. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56403. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56404. * * 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)
  56405. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56406. * * 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
  56407. * * 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
  56408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56412. * @param name defines the name of the mesh
  56413. * @param options defines the options used to create the mesh
  56414. * @param scene defines the hosting scene
  56415. * @returns the tube mesh
  56416. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56417. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56418. */
  56419. static CreateTube(name: string, options: {
  56420. path: Vector3[];
  56421. radius?: number;
  56422. tessellation?: number;
  56423. radiusFunction?: {
  56424. (i: number, distance: number): number;
  56425. };
  56426. cap?: number;
  56427. arc?: number;
  56428. updatable?: boolean;
  56429. sideOrientation?: number;
  56430. frontUVs?: Vector4;
  56431. backUVs?: Vector4;
  56432. instance?: Mesh;
  56433. invertUV?: boolean;
  56434. }, scene?: Nullable<Scene>): Mesh;
  56435. }
  56436. }
  56437. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  56438. import { Scene } from "babylonjs/scene";
  56439. import { Vector4 } from "babylonjs/Maths/math.vector";
  56440. import { Mesh } from "babylonjs/Meshes/mesh";
  56441. import { Nullable } from "babylonjs/types";
  56442. /**
  56443. * Class containing static functions to help procedurally build meshes
  56444. */
  56445. export class IcoSphereBuilder {
  56446. /**
  56447. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56448. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56449. * * 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`)
  56450. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56451. * * 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
  56452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56455. * @param name defines the name of the mesh
  56456. * @param options defines the options used to create the mesh
  56457. * @param scene defines the hosting scene
  56458. * @returns the icosahedron mesh
  56459. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56460. */
  56461. static CreateIcoSphere(name: string, options: {
  56462. radius?: number;
  56463. radiusX?: number;
  56464. radiusY?: number;
  56465. radiusZ?: number;
  56466. flat?: boolean;
  56467. subdivisions?: number;
  56468. sideOrientation?: number;
  56469. frontUVs?: Vector4;
  56470. backUVs?: Vector4;
  56471. updatable?: boolean;
  56472. }, scene?: Nullable<Scene>): Mesh;
  56473. }
  56474. }
  56475. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  56476. import { Vector3 } from "babylonjs/Maths/math.vector";
  56477. import { Mesh } from "babylonjs/Meshes/mesh";
  56478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56479. /**
  56480. * Class containing static functions to help procedurally build meshes
  56481. */
  56482. export class DecalBuilder {
  56483. /**
  56484. * Creates a decal mesh.
  56485. * 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
  56486. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56487. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56488. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56489. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56490. * @param name defines the name of the mesh
  56491. * @param sourceMesh defines the mesh where the decal must be applied
  56492. * @param options defines the options used to create the mesh
  56493. * @param scene defines the hosting scene
  56494. * @returns the decal mesh
  56495. * @see https://doc.babylonjs.com/how_to/decals
  56496. */
  56497. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56498. position?: Vector3;
  56499. normal?: Vector3;
  56500. size?: Vector3;
  56501. angle?: number;
  56502. }): Mesh;
  56503. }
  56504. }
  56505. declare module "babylonjs/Meshes/meshBuilder" {
  56506. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  56507. import { Nullable } from "babylonjs/types";
  56508. import { Scene } from "babylonjs/scene";
  56509. import { Mesh } from "babylonjs/Meshes/mesh";
  56510. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56511. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  56512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56513. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56514. import { Plane } from "babylonjs/Maths/math.plane";
  56515. /**
  56516. * Class containing static functions to help procedurally build meshes
  56517. */
  56518. export class MeshBuilder {
  56519. /**
  56520. * Creates a box mesh
  56521. * * The parameter `size` sets the size (float) of each box side (default 1)
  56522. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56523. * * 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)
  56524. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56528. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56529. * @param name defines the name of the mesh
  56530. * @param options defines the options used to create the mesh
  56531. * @param scene defines the hosting scene
  56532. * @returns the box mesh
  56533. */
  56534. static CreateBox(name: string, options: {
  56535. size?: number;
  56536. width?: number;
  56537. height?: number;
  56538. depth?: number;
  56539. faceUV?: Vector4[];
  56540. faceColors?: Color4[];
  56541. sideOrientation?: number;
  56542. frontUVs?: Vector4;
  56543. backUVs?: Vector4;
  56544. updatable?: boolean;
  56545. }, scene?: Nullable<Scene>): Mesh;
  56546. /**
  56547. * Creates a tiled box mesh
  56548. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56550. * @param name defines the name of the mesh
  56551. * @param options defines the options used to create the mesh
  56552. * @param scene defines the hosting scene
  56553. * @returns the tiled box mesh
  56554. */
  56555. static CreateTiledBox(name: string, options: {
  56556. pattern?: number;
  56557. size?: number;
  56558. width?: number;
  56559. height?: number;
  56560. depth: number;
  56561. tileSize?: number;
  56562. tileWidth?: number;
  56563. tileHeight?: number;
  56564. faceUV?: Vector4[];
  56565. faceColors?: Color4[];
  56566. alignHorizontal?: number;
  56567. alignVertical?: number;
  56568. sideOrientation?: number;
  56569. updatable?: boolean;
  56570. }, scene?: Nullable<Scene>): Mesh;
  56571. /**
  56572. * Creates a sphere mesh
  56573. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56574. * * 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`)
  56575. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56576. * * 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
  56577. * * 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)
  56578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56581. * @param name defines the name of the mesh
  56582. * @param options defines the options used to create the mesh
  56583. * @param scene defines the hosting scene
  56584. * @returns the sphere mesh
  56585. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56586. */
  56587. static CreateSphere(name: string, options: {
  56588. segments?: number;
  56589. diameter?: number;
  56590. diameterX?: number;
  56591. diameterY?: number;
  56592. diameterZ?: number;
  56593. arc?: number;
  56594. slice?: number;
  56595. sideOrientation?: number;
  56596. frontUVs?: Vector4;
  56597. backUVs?: Vector4;
  56598. updatable?: boolean;
  56599. }, scene?: Nullable<Scene>): Mesh;
  56600. /**
  56601. * Creates a plane polygonal mesh. By default, this is a disc
  56602. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56603. * * 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
  56604. * * 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
  56605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56608. * @param name defines the name of the mesh
  56609. * @param options defines the options used to create the mesh
  56610. * @param scene defines the hosting scene
  56611. * @returns the plane polygonal mesh
  56612. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56613. */
  56614. static CreateDisc(name: string, options: {
  56615. radius?: number;
  56616. tessellation?: number;
  56617. arc?: number;
  56618. updatable?: boolean;
  56619. sideOrientation?: number;
  56620. frontUVs?: Vector4;
  56621. backUVs?: Vector4;
  56622. }, scene?: Nullable<Scene>): Mesh;
  56623. /**
  56624. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56625. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56626. * * 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`)
  56627. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56628. * * 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
  56629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56632. * @param name defines the name of the mesh
  56633. * @param options defines the options used to create the mesh
  56634. * @param scene defines the hosting scene
  56635. * @returns the icosahedron mesh
  56636. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56637. */
  56638. static CreateIcoSphere(name: string, options: {
  56639. radius?: number;
  56640. radiusX?: number;
  56641. radiusY?: number;
  56642. radiusZ?: number;
  56643. flat?: boolean;
  56644. subdivisions?: number;
  56645. sideOrientation?: number;
  56646. frontUVs?: Vector4;
  56647. backUVs?: Vector4;
  56648. updatable?: boolean;
  56649. }, scene?: Nullable<Scene>): Mesh;
  56650. /**
  56651. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56652. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56653. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56654. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56655. * * 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
  56656. * * 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
  56657. * * 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
  56658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56660. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56661. * * 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
  56662. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56663. * * 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
  56664. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56666. * @param name defines the name of the mesh
  56667. * @param options defines the options used to create the mesh
  56668. * @param scene defines the hosting scene
  56669. * @returns the ribbon mesh
  56670. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56671. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56672. */
  56673. static CreateRibbon(name: string, options: {
  56674. pathArray: Vector3[][];
  56675. closeArray?: boolean;
  56676. closePath?: boolean;
  56677. offset?: number;
  56678. updatable?: boolean;
  56679. sideOrientation?: number;
  56680. frontUVs?: Vector4;
  56681. backUVs?: Vector4;
  56682. instance?: Mesh;
  56683. invertUV?: boolean;
  56684. uvs?: Vector2[];
  56685. colors?: Color4[];
  56686. }, scene?: Nullable<Scene>): Mesh;
  56687. /**
  56688. * Creates a cylinder or a cone mesh
  56689. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56690. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56691. * * 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.
  56692. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56693. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56694. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56695. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56696. * * 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).
  56697. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56698. * * 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).
  56699. * * 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
  56700. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56701. * * 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
  56702. * * 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.
  56703. * * If `enclose` is false, a ring surface is one element.
  56704. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56705. * * 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
  56706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56709. * @param name defines the name of the mesh
  56710. * @param options defines the options used to create the mesh
  56711. * @param scene defines the hosting scene
  56712. * @returns the cylinder mesh
  56713. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56714. */
  56715. static CreateCylinder(name: string, options: {
  56716. height?: number;
  56717. diameterTop?: number;
  56718. diameterBottom?: number;
  56719. diameter?: number;
  56720. tessellation?: number;
  56721. subdivisions?: number;
  56722. arc?: number;
  56723. faceColors?: Color4[];
  56724. faceUV?: Vector4[];
  56725. updatable?: boolean;
  56726. hasRings?: boolean;
  56727. enclose?: boolean;
  56728. cap?: number;
  56729. sideOrientation?: number;
  56730. frontUVs?: Vector4;
  56731. backUVs?: Vector4;
  56732. }, scene?: Nullable<Scene>): Mesh;
  56733. /**
  56734. * Creates a torus mesh
  56735. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56736. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56737. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56741. * @param name defines the name of the mesh
  56742. * @param options defines the options used to create the mesh
  56743. * @param scene defines the hosting scene
  56744. * @returns the torus mesh
  56745. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56746. */
  56747. static CreateTorus(name: string, options: {
  56748. diameter?: number;
  56749. thickness?: number;
  56750. tessellation?: number;
  56751. updatable?: boolean;
  56752. sideOrientation?: number;
  56753. frontUVs?: Vector4;
  56754. backUVs?: Vector4;
  56755. }, scene?: Nullable<Scene>): Mesh;
  56756. /**
  56757. * Creates a torus knot mesh
  56758. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56759. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56760. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56761. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56765. * @param name defines the name of the mesh
  56766. * @param options defines the options used to create the mesh
  56767. * @param scene defines the hosting scene
  56768. * @returns the torus knot mesh
  56769. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56770. */
  56771. static CreateTorusKnot(name: string, options: {
  56772. radius?: number;
  56773. tube?: number;
  56774. radialSegments?: number;
  56775. tubularSegments?: number;
  56776. p?: number;
  56777. q?: number;
  56778. updatable?: boolean;
  56779. sideOrientation?: number;
  56780. frontUVs?: Vector4;
  56781. backUVs?: Vector4;
  56782. }, scene?: Nullable<Scene>): Mesh;
  56783. /**
  56784. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56785. * * 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
  56786. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56787. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56788. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56789. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56790. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56791. * * 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
  56792. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56794. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56795. * @param name defines the name of the new line system
  56796. * @param options defines the options used to create the line system
  56797. * @param scene defines the hosting scene
  56798. * @returns a new line system mesh
  56799. */
  56800. static CreateLineSystem(name: string, options: {
  56801. lines: Vector3[][];
  56802. updatable?: boolean;
  56803. instance?: Nullable<LinesMesh>;
  56804. colors?: Nullable<Color4[][]>;
  56805. useVertexAlpha?: boolean;
  56806. }, scene: Nullable<Scene>): LinesMesh;
  56807. /**
  56808. * Creates a line mesh
  56809. * 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
  56810. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56811. * * The parameter `points` is an array successive Vector3
  56812. * * 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
  56813. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56814. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56815. * * When updating an instance, remember that only point positions can change, not the number of points
  56816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56818. * @param name defines the name of the new line system
  56819. * @param options defines the options used to create the line system
  56820. * @param scene defines the hosting scene
  56821. * @returns a new line mesh
  56822. */
  56823. static CreateLines(name: string, options: {
  56824. points: Vector3[];
  56825. updatable?: boolean;
  56826. instance?: Nullable<LinesMesh>;
  56827. colors?: Color4[];
  56828. useVertexAlpha?: boolean;
  56829. }, scene?: Nullable<Scene>): LinesMesh;
  56830. /**
  56831. * Creates a dashed line mesh
  56832. * * 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
  56833. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56834. * * The parameter `points` is an array successive Vector3
  56835. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56836. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56837. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56838. * * 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
  56839. * * When updating an instance, remember that only point positions can change, not the number of points
  56840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56841. * @param name defines the name of the mesh
  56842. * @param options defines the options used to create the mesh
  56843. * @param scene defines the hosting scene
  56844. * @returns the dashed line mesh
  56845. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56846. */
  56847. static CreateDashedLines(name: string, options: {
  56848. points: Vector3[];
  56849. dashSize?: number;
  56850. gapSize?: number;
  56851. dashNb?: number;
  56852. updatable?: boolean;
  56853. instance?: LinesMesh;
  56854. }, scene?: Nullable<Scene>): LinesMesh;
  56855. /**
  56856. * 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.
  56857. * * 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.
  56858. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56859. * * 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.
  56860. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56861. * * 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
  56862. * * 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
  56863. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56865. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56866. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56868. * @param name defines the name of the mesh
  56869. * @param options defines the options used to create the mesh
  56870. * @param scene defines the hosting scene
  56871. * @returns the extruded shape mesh
  56872. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56873. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56874. */
  56875. static ExtrudeShape(name: string, options: {
  56876. shape: Vector3[];
  56877. path: Vector3[];
  56878. scale?: number;
  56879. rotation?: number;
  56880. cap?: number;
  56881. updatable?: boolean;
  56882. sideOrientation?: number;
  56883. frontUVs?: Vector4;
  56884. backUVs?: Vector4;
  56885. instance?: Mesh;
  56886. invertUV?: boolean;
  56887. }, scene?: Nullable<Scene>): Mesh;
  56888. /**
  56889. * Creates an custom extruded shape mesh.
  56890. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56891. * * 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.
  56892. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56893. * * 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
  56894. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56895. * * 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
  56896. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56897. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56898. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56899. * * 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
  56900. * * 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
  56901. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56904. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56906. * @param name defines the name of the mesh
  56907. * @param options defines the options used to create the mesh
  56908. * @param scene defines the hosting scene
  56909. * @returns the custom extruded shape mesh
  56910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56911. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56912. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56913. */
  56914. static ExtrudeShapeCustom(name: string, options: {
  56915. shape: Vector3[];
  56916. path: Vector3[];
  56917. scaleFunction?: any;
  56918. rotationFunction?: any;
  56919. ribbonCloseArray?: boolean;
  56920. ribbonClosePath?: boolean;
  56921. cap?: number;
  56922. updatable?: boolean;
  56923. sideOrientation?: number;
  56924. frontUVs?: Vector4;
  56925. backUVs?: Vector4;
  56926. instance?: Mesh;
  56927. invertUV?: boolean;
  56928. }, scene?: Nullable<Scene>): Mesh;
  56929. /**
  56930. * Creates lathe mesh.
  56931. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56932. * * 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
  56933. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56934. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56935. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56936. * * 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
  56937. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56938. * * 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
  56939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56941. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56943. * @param name defines the name of the mesh
  56944. * @param options defines the options used to create the mesh
  56945. * @param scene defines the hosting scene
  56946. * @returns the lathe mesh
  56947. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56948. */
  56949. static CreateLathe(name: string, options: {
  56950. shape: Vector3[];
  56951. radius?: number;
  56952. tessellation?: number;
  56953. clip?: number;
  56954. arc?: number;
  56955. closed?: boolean;
  56956. updatable?: boolean;
  56957. sideOrientation?: number;
  56958. frontUVs?: Vector4;
  56959. backUVs?: Vector4;
  56960. cap?: number;
  56961. invertUV?: boolean;
  56962. }, scene?: Nullable<Scene>): Mesh;
  56963. /**
  56964. * Creates a tiled plane mesh
  56965. * * You can set a limited pattern arrangement with the tiles
  56966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56969. * @param name defines the name of the mesh
  56970. * @param options defines the options used to create the mesh
  56971. * @param scene defines the hosting scene
  56972. * @returns the plane mesh
  56973. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56974. */
  56975. static CreateTiledPlane(name: string, options: {
  56976. pattern?: number;
  56977. tileSize?: number;
  56978. tileWidth?: number;
  56979. tileHeight?: number;
  56980. size?: number;
  56981. width?: number;
  56982. height?: number;
  56983. alignHorizontal?: number;
  56984. alignVertical?: number;
  56985. sideOrientation?: number;
  56986. frontUVs?: Vector4;
  56987. backUVs?: Vector4;
  56988. updatable?: boolean;
  56989. }, scene?: Nullable<Scene>): Mesh;
  56990. /**
  56991. * Creates a plane mesh
  56992. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56993. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56994. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56998. * @param name defines the name of the mesh
  56999. * @param options defines the options used to create the mesh
  57000. * @param scene defines the hosting scene
  57001. * @returns the plane mesh
  57002. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57003. */
  57004. static CreatePlane(name: string, options: {
  57005. size?: number;
  57006. width?: number;
  57007. height?: number;
  57008. sideOrientation?: number;
  57009. frontUVs?: Vector4;
  57010. backUVs?: Vector4;
  57011. updatable?: boolean;
  57012. sourcePlane?: Plane;
  57013. }, scene?: Nullable<Scene>): Mesh;
  57014. /**
  57015. * Creates a ground mesh
  57016. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57017. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57019. * @param name defines the name of the mesh
  57020. * @param options defines the options used to create the mesh
  57021. * @param scene defines the hosting scene
  57022. * @returns the ground mesh
  57023. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57024. */
  57025. static CreateGround(name: string, options: {
  57026. width?: number;
  57027. height?: number;
  57028. subdivisions?: number;
  57029. subdivisionsX?: number;
  57030. subdivisionsY?: number;
  57031. updatable?: boolean;
  57032. }, scene?: Nullable<Scene>): Mesh;
  57033. /**
  57034. * Creates a tiled ground mesh
  57035. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57036. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57037. * * 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
  57038. * * 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
  57039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57040. * @param name defines the name of the mesh
  57041. * @param options defines the options used to create the mesh
  57042. * @param scene defines the hosting scene
  57043. * @returns the tiled ground mesh
  57044. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57045. */
  57046. static CreateTiledGround(name: string, options: {
  57047. xmin: number;
  57048. zmin: number;
  57049. xmax: number;
  57050. zmax: number;
  57051. subdivisions?: {
  57052. w: number;
  57053. h: number;
  57054. };
  57055. precision?: {
  57056. w: number;
  57057. h: number;
  57058. };
  57059. updatable?: boolean;
  57060. }, scene?: Nullable<Scene>): Mesh;
  57061. /**
  57062. * Creates a ground mesh from a height map
  57063. * * The parameter `url` sets the URL of the height map image resource.
  57064. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57065. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57066. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57067. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57068. * * 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.
  57069. * * 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).
  57070. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57072. * @param name defines the name of the mesh
  57073. * @param url defines the url to the height map
  57074. * @param options defines the options used to create the mesh
  57075. * @param scene defines the hosting scene
  57076. * @returns the ground mesh
  57077. * @see https://doc.babylonjs.com/babylon101/height_map
  57078. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57079. */
  57080. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57081. width?: number;
  57082. height?: number;
  57083. subdivisions?: number;
  57084. minHeight?: number;
  57085. maxHeight?: number;
  57086. colorFilter?: Color3;
  57087. alphaFilter?: number;
  57088. updatable?: boolean;
  57089. onReady?: (mesh: GroundMesh) => void;
  57090. }, scene?: Nullable<Scene>): GroundMesh;
  57091. /**
  57092. * Creates a polygon mesh
  57093. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57094. * * 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
  57095. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57098. * * Remember you can only change the shape positions, not their number when updating a polygon
  57099. * @param name defines the name of the mesh
  57100. * @param options defines the options used to create the mesh
  57101. * @param scene defines the hosting scene
  57102. * @param earcutInjection can be used to inject your own earcut reference
  57103. * @returns the polygon mesh
  57104. */
  57105. static CreatePolygon(name: string, options: {
  57106. shape: Vector3[];
  57107. holes?: Vector3[][];
  57108. depth?: number;
  57109. faceUV?: Vector4[];
  57110. faceColors?: Color4[];
  57111. updatable?: boolean;
  57112. sideOrientation?: number;
  57113. frontUVs?: Vector4;
  57114. backUVs?: Vector4;
  57115. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57116. /**
  57117. * Creates an extruded polygon mesh, with depth in the Y direction.
  57118. * * 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)
  57119. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57120. * @param name defines the name of the mesh
  57121. * @param options defines the options used to create the mesh
  57122. * @param scene defines the hosting scene
  57123. * @param earcutInjection can be used to inject your own earcut reference
  57124. * @returns the polygon mesh
  57125. */
  57126. static ExtrudePolygon(name: string, options: {
  57127. shape: Vector3[];
  57128. holes?: Vector3[][];
  57129. depth?: number;
  57130. faceUV?: Vector4[];
  57131. faceColors?: Color4[];
  57132. updatable?: boolean;
  57133. sideOrientation?: number;
  57134. frontUVs?: Vector4;
  57135. backUVs?: Vector4;
  57136. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57137. /**
  57138. * Creates a tube mesh.
  57139. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57140. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57141. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57142. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57143. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57144. * * 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)
  57145. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57146. * * 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
  57147. * * 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
  57148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57152. * @param name defines the name of the mesh
  57153. * @param options defines the options used to create the mesh
  57154. * @param scene defines the hosting scene
  57155. * @returns the tube mesh
  57156. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57157. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57158. */
  57159. static CreateTube(name: string, options: {
  57160. path: Vector3[];
  57161. radius?: number;
  57162. tessellation?: number;
  57163. radiusFunction?: {
  57164. (i: number, distance: number): number;
  57165. };
  57166. cap?: number;
  57167. arc?: number;
  57168. updatable?: boolean;
  57169. sideOrientation?: number;
  57170. frontUVs?: Vector4;
  57171. backUVs?: Vector4;
  57172. instance?: Mesh;
  57173. invertUV?: boolean;
  57174. }, scene?: Nullable<Scene>): Mesh;
  57175. /**
  57176. * Creates a polyhedron mesh
  57177. * * 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
  57178. * * The parameter `size` (positive float, default 1) sets the polygon size
  57179. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57180. * * 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`
  57181. * * 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
  57182. * * 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)`)
  57183. * * 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
  57184. * * 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
  57185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57188. * @param name defines the name of the mesh
  57189. * @param options defines the options used to create the mesh
  57190. * @param scene defines the hosting scene
  57191. * @returns the polyhedron mesh
  57192. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57193. */
  57194. static CreatePolyhedron(name: string, options: {
  57195. type?: number;
  57196. size?: number;
  57197. sizeX?: number;
  57198. sizeY?: number;
  57199. sizeZ?: number;
  57200. custom?: any;
  57201. faceUV?: Vector4[];
  57202. faceColors?: Color4[];
  57203. flat?: boolean;
  57204. updatable?: boolean;
  57205. sideOrientation?: number;
  57206. frontUVs?: Vector4;
  57207. backUVs?: Vector4;
  57208. }, scene?: Nullable<Scene>): Mesh;
  57209. /**
  57210. * Creates a decal mesh.
  57211. * 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
  57212. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57213. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57214. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57215. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57216. * @param name defines the name of the mesh
  57217. * @param sourceMesh defines the mesh where the decal must be applied
  57218. * @param options defines the options used to create the mesh
  57219. * @param scene defines the hosting scene
  57220. * @returns the decal mesh
  57221. * @see https://doc.babylonjs.com/how_to/decals
  57222. */
  57223. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57224. position?: Vector3;
  57225. normal?: Vector3;
  57226. size?: Vector3;
  57227. angle?: number;
  57228. }): Mesh;
  57229. }
  57230. }
  57231. declare module "babylonjs/Meshes/meshSimplification" {
  57232. import { Mesh } from "babylonjs/Meshes/mesh";
  57233. /**
  57234. * A simplifier interface for future simplification implementations
  57235. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57236. */
  57237. export interface ISimplifier {
  57238. /**
  57239. * Simplification of a given mesh according to the given settings.
  57240. * Since this requires computation, it is assumed that the function runs async.
  57241. * @param settings The settings of the simplification, including quality and distance
  57242. * @param successCallback A callback that will be called after the mesh was simplified.
  57243. * @param errorCallback in case of an error, this callback will be called. optional.
  57244. */
  57245. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57246. }
  57247. /**
  57248. * Expected simplification settings.
  57249. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57250. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57251. */
  57252. export interface ISimplificationSettings {
  57253. /**
  57254. * Gets or sets the expected quality
  57255. */
  57256. quality: number;
  57257. /**
  57258. * Gets or sets the distance when this optimized version should be used
  57259. */
  57260. distance: number;
  57261. /**
  57262. * Gets an already optimized mesh
  57263. */
  57264. optimizeMesh?: boolean;
  57265. }
  57266. /**
  57267. * Class used to specify simplification options
  57268. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57269. */
  57270. export class SimplificationSettings implements ISimplificationSettings {
  57271. /** expected quality */
  57272. quality: number;
  57273. /** distance when this optimized version should be used */
  57274. distance: number;
  57275. /** already optimized mesh */
  57276. optimizeMesh?: boolean | undefined;
  57277. /**
  57278. * Creates a SimplificationSettings
  57279. * @param quality expected quality
  57280. * @param distance distance when this optimized version should be used
  57281. * @param optimizeMesh already optimized mesh
  57282. */
  57283. constructor(
  57284. /** expected quality */
  57285. quality: number,
  57286. /** distance when this optimized version should be used */
  57287. distance: number,
  57288. /** already optimized mesh */
  57289. optimizeMesh?: boolean | undefined);
  57290. }
  57291. /**
  57292. * Interface used to define a simplification task
  57293. */
  57294. export interface ISimplificationTask {
  57295. /**
  57296. * Array of settings
  57297. */
  57298. settings: Array<ISimplificationSettings>;
  57299. /**
  57300. * Simplification type
  57301. */
  57302. simplificationType: SimplificationType;
  57303. /**
  57304. * Mesh to simplify
  57305. */
  57306. mesh: Mesh;
  57307. /**
  57308. * Callback called on success
  57309. */
  57310. successCallback?: () => void;
  57311. /**
  57312. * Defines if parallel processing can be used
  57313. */
  57314. parallelProcessing: boolean;
  57315. }
  57316. /**
  57317. * Queue used to order the simplification tasks
  57318. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57319. */
  57320. export class SimplificationQueue {
  57321. private _simplificationArray;
  57322. /**
  57323. * Gets a boolean indicating that the process is still running
  57324. */
  57325. running: boolean;
  57326. /**
  57327. * Creates a new queue
  57328. */
  57329. constructor();
  57330. /**
  57331. * Adds a new simplification task
  57332. * @param task defines a task to add
  57333. */
  57334. addTask(task: ISimplificationTask): void;
  57335. /**
  57336. * Execute next task
  57337. */
  57338. executeNext(): void;
  57339. /**
  57340. * Execute a simplification task
  57341. * @param task defines the task to run
  57342. */
  57343. runSimplification(task: ISimplificationTask): void;
  57344. private getSimplifier;
  57345. }
  57346. /**
  57347. * The implemented types of simplification
  57348. * At the moment only Quadratic Error Decimation is implemented
  57349. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57350. */
  57351. export enum SimplificationType {
  57352. /** Quadratic error decimation */
  57353. QUADRATIC = 0
  57354. }
  57355. }
  57356. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  57357. import { Scene } from "babylonjs/scene";
  57358. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  57359. import { ISceneComponent } from "babylonjs/sceneComponent";
  57360. module "babylonjs/scene" {
  57361. interface Scene {
  57362. /** @hidden (Backing field) */
  57363. _simplificationQueue: SimplificationQueue;
  57364. /**
  57365. * Gets or sets the simplification queue attached to the scene
  57366. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57367. */
  57368. simplificationQueue: SimplificationQueue;
  57369. }
  57370. }
  57371. module "babylonjs/Meshes/mesh" {
  57372. interface Mesh {
  57373. /**
  57374. * Simplify the mesh according to the given array of settings.
  57375. * Function will return immediately and will simplify async
  57376. * @param settings a collection of simplification settings
  57377. * @param parallelProcessing should all levels calculate parallel or one after the other
  57378. * @param simplificationType the type of simplification to run
  57379. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57380. * @returns the current mesh
  57381. */
  57382. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57383. }
  57384. }
  57385. /**
  57386. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57387. * created in a scene
  57388. */
  57389. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57390. /**
  57391. * The component name helpfull to identify the component in the list of scene components.
  57392. */
  57393. readonly name: string;
  57394. /**
  57395. * The scene the component belongs to.
  57396. */
  57397. scene: Scene;
  57398. /**
  57399. * Creates a new instance of the component for the given scene
  57400. * @param scene Defines the scene to register the component in
  57401. */
  57402. constructor(scene: Scene);
  57403. /**
  57404. * Registers the component in a given scene
  57405. */
  57406. register(): void;
  57407. /**
  57408. * Rebuilds the elements related to this component in case of
  57409. * context lost for instance.
  57410. */
  57411. rebuild(): void;
  57412. /**
  57413. * Disposes the component and the associated ressources
  57414. */
  57415. dispose(): void;
  57416. private _beforeCameraUpdate;
  57417. }
  57418. }
  57419. declare module "babylonjs/Meshes/Builders/index" {
  57420. export * from "babylonjs/Meshes/Builders/boxBuilder";
  57421. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  57422. export * from "babylonjs/Meshes/Builders/discBuilder";
  57423. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  57424. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  57425. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  57426. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  57427. export * from "babylonjs/Meshes/Builders/torusBuilder";
  57428. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  57429. export * from "babylonjs/Meshes/Builders/linesBuilder";
  57430. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  57431. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  57432. export * from "babylonjs/Meshes/Builders/latheBuilder";
  57433. export * from "babylonjs/Meshes/Builders/planeBuilder";
  57434. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  57435. export * from "babylonjs/Meshes/Builders/groundBuilder";
  57436. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  57437. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  57438. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  57439. export * from "babylonjs/Meshes/Builders/decalBuilder";
  57440. }
  57441. declare module "babylonjs/Meshes/index" {
  57442. export * from "babylonjs/Meshes/abstractMesh";
  57443. export * from "babylonjs/Meshes/buffer";
  57444. export * from "babylonjs/Meshes/Compression/index";
  57445. export * from "babylonjs/Meshes/csg";
  57446. export * from "babylonjs/Meshes/geometry";
  57447. export * from "babylonjs/Meshes/groundMesh";
  57448. export * from "babylonjs/Meshes/trailMesh";
  57449. export * from "babylonjs/Meshes/instancedMesh";
  57450. export * from "babylonjs/Meshes/linesMesh";
  57451. export * from "babylonjs/Meshes/mesh";
  57452. export * from "babylonjs/Meshes/mesh.vertexData";
  57453. export * from "babylonjs/Meshes/meshBuilder";
  57454. export * from "babylonjs/Meshes/meshSimplification";
  57455. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  57456. export * from "babylonjs/Meshes/polygonMesh";
  57457. export * from "babylonjs/Meshes/subMesh";
  57458. export * from "babylonjs/Meshes/meshLODLevel";
  57459. export * from "babylonjs/Meshes/transformNode";
  57460. export * from "babylonjs/Meshes/Builders/index";
  57461. export * from "babylonjs/Meshes/dataBuffer";
  57462. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  57463. }
  57464. declare module "babylonjs/Morph/index" {
  57465. export * from "babylonjs/Morph/morphTarget";
  57466. export * from "babylonjs/Morph/morphTargetManager";
  57467. }
  57468. declare module "babylonjs/Navigation/INavigationEngine" {
  57469. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57470. import { Vector3 } from "babylonjs/Maths/math";
  57471. import { Mesh } from "babylonjs/Meshes/mesh";
  57472. import { Scene } from "babylonjs/scene";
  57473. /**
  57474. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57475. */
  57476. export interface INavigationEnginePlugin {
  57477. /**
  57478. * plugin name
  57479. */
  57480. name: string;
  57481. /**
  57482. * Creates a navigation mesh
  57483. * @param meshes array of all the geometry used to compute the navigatio mesh
  57484. * @param parameters bunch of parameters used to filter geometry
  57485. */
  57486. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57487. /**
  57488. * Create a navigation mesh debug mesh
  57489. * @param scene is where the mesh will be added
  57490. * @returns debug display mesh
  57491. */
  57492. createDebugNavMesh(scene: Scene): Mesh;
  57493. /**
  57494. * Get a navigation mesh constrained position, closest to the parameter position
  57495. * @param position world position
  57496. * @returns the closest point to position constrained by the navigation mesh
  57497. */
  57498. getClosestPoint(position: Vector3): Vector3;
  57499. /**
  57500. * Get a navigation mesh constrained position, within a particular radius
  57501. * @param position world position
  57502. * @param maxRadius the maximum distance to the constrained world position
  57503. * @returns the closest point to position constrained by the navigation mesh
  57504. */
  57505. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57506. /**
  57507. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57508. * @param start world position
  57509. * @param end world position
  57510. * @returns array containing world position composing the path
  57511. */
  57512. computePath(start: Vector3, end: Vector3): Vector3[];
  57513. /**
  57514. * If this plugin is supported
  57515. * @returns true if plugin is supported
  57516. */
  57517. isSupported(): boolean;
  57518. /**
  57519. * Create a new Crowd so you can add agents
  57520. * @param maxAgents the maximum agent count in the crowd
  57521. * @param maxAgentRadius the maximum radius an agent can have
  57522. * @param scene to attach the crowd to
  57523. * @returns the crowd you can add agents to
  57524. */
  57525. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57526. /**
  57527. * Release all resources
  57528. */
  57529. dispose(): void;
  57530. }
  57531. /**
  57532. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57533. */
  57534. export interface ICrowd {
  57535. /**
  57536. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57537. * You can attach anything to that node. The node position is updated in the scene update tick.
  57538. * @param pos world position that will be constrained by the navigation mesh
  57539. * @param parameters agent parameters
  57540. * @param transform hooked to the agent that will be update by the scene
  57541. * @returns agent index
  57542. */
  57543. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57544. /**
  57545. * Returns the agent position in world space
  57546. * @param index agent index returned by addAgent
  57547. * @returns world space position
  57548. */
  57549. getAgentPosition(index: number): Vector3;
  57550. /**
  57551. * Gets the agent velocity in world space
  57552. * @param index agent index returned by addAgent
  57553. * @returns world space velocity
  57554. */
  57555. getAgentVelocity(index: number): Vector3;
  57556. /**
  57557. * remove a particular agent previously created
  57558. * @param index agent index returned by addAgent
  57559. */
  57560. removeAgent(index: number): void;
  57561. /**
  57562. * get the list of all agents attached to this crowd
  57563. * @returns list of agent indices
  57564. */
  57565. getAgents(): number[];
  57566. /**
  57567. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57568. * @param deltaTime in seconds
  57569. */
  57570. update(deltaTime: number): void;
  57571. /**
  57572. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57573. * @param index agent index returned by addAgent
  57574. * @param destination targeted world position
  57575. */
  57576. agentGoto(index: number, destination: Vector3): void;
  57577. /**
  57578. * Release all resources
  57579. */
  57580. dispose(): void;
  57581. }
  57582. /**
  57583. * Configures an agent
  57584. */
  57585. export interface IAgentParameters {
  57586. /**
  57587. * Agent radius. [Limit: >= 0]
  57588. */
  57589. radius: number;
  57590. /**
  57591. * Agent height. [Limit: > 0]
  57592. */
  57593. height: number;
  57594. /**
  57595. * Maximum allowed acceleration. [Limit: >= 0]
  57596. */
  57597. maxAcceleration: number;
  57598. /**
  57599. * Maximum allowed speed. [Limit: >= 0]
  57600. */
  57601. maxSpeed: number;
  57602. /**
  57603. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57604. */
  57605. collisionQueryRange: number;
  57606. /**
  57607. * The path visibility optimization range. [Limit: > 0]
  57608. */
  57609. pathOptimizationRange: number;
  57610. /**
  57611. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57612. */
  57613. separationWeight: number;
  57614. }
  57615. /**
  57616. * Configures the navigation mesh creation
  57617. */
  57618. export interface INavMeshParameters {
  57619. /**
  57620. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57621. */
  57622. cs: number;
  57623. /**
  57624. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57625. */
  57626. ch: number;
  57627. /**
  57628. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57629. */
  57630. walkableSlopeAngle: number;
  57631. /**
  57632. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57633. * be considered walkable. [Limit: >= 3] [Units: vx]
  57634. */
  57635. walkableHeight: number;
  57636. /**
  57637. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57638. */
  57639. walkableClimb: number;
  57640. /**
  57641. * The distance to erode/shrink the walkable area of the heightfield away from
  57642. * obstructions. [Limit: >=0] [Units: vx]
  57643. */
  57644. walkableRadius: number;
  57645. /**
  57646. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57647. */
  57648. maxEdgeLen: number;
  57649. /**
  57650. * The maximum distance a simplfied contour's border edges should deviate
  57651. * the original raw contour. [Limit: >=0] [Units: vx]
  57652. */
  57653. maxSimplificationError: number;
  57654. /**
  57655. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57656. */
  57657. minRegionArea: number;
  57658. /**
  57659. * Any regions with a span count smaller than this value will, if possible,
  57660. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57661. */
  57662. mergeRegionArea: number;
  57663. /**
  57664. * The maximum number of vertices allowed for polygons generated during the
  57665. * contour to polygon conversion process. [Limit: >= 3]
  57666. */
  57667. maxVertsPerPoly: number;
  57668. /**
  57669. * Sets the sampling distance to use when generating the detail mesh.
  57670. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57671. */
  57672. detailSampleDist: number;
  57673. /**
  57674. * The maximum distance the detail mesh surface should deviate from heightfield
  57675. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57676. */
  57677. detailSampleMaxError: number;
  57678. }
  57679. }
  57680. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  57681. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  57682. import { Mesh } from "babylonjs/Meshes/mesh";
  57683. import { Scene } from "babylonjs/scene";
  57684. import { Vector3 } from "babylonjs/Maths/math";
  57685. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57686. /**
  57687. * RecastJS navigation plugin
  57688. */
  57689. export class RecastJSPlugin implements INavigationEnginePlugin {
  57690. /**
  57691. * Reference to the Recast library
  57692. */
  57693. bjsRECAST: any;
  57694. /**
  57695. * plugin name
  57696. */
  57697. name: string;
  57698. /**
  57699. * the first navmesh created. We might extend this to support multiple navmeshes
  57700. */
  57701. navMesh: any;
  57702. /**
  57703. * Initializes the recastJS plugin
  57704. * @param recastInjection can be used to inject your own recast reference
  57705. */
  57706. constructor(recastInjection?: any);
  57707. /**
  57708. * Creates a navigation mesh
  57709. * @param meshes array of all the geometry used to compute the navigatio mesh
  57710. * @param parameters bunch of parameters used to filter geometry
  57711. */
  57712. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57713. /**
  57714. * Create a navigation mesh debug mesh
  57715. * @param scene is where the mesh will be added
  57716. * @returns debug display mesh
  57717. */
  57718. createDebugNavMesh(scene: Scene): Mesh;
  57719. /**
  57720. * Get a navigation mesh constrained position, closest to the parameter position
  57721. * @param position world position
  57722. * @returns the closest point to position constrained by the navigation mesh
  57723. */
  57724. getClosestPoint(position: Vector3): Vector3;
  57725. /**
  57726. * Get a navigation mesh constrained position, within a particular radius
  57727. * @param position world position
  57728. * @param maxRadius the maximum distance to the constrained world position
  57729. * @returns the closest point to position constrained by the navigation mesh
  57730. */
  57731. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57732. /**
  57733. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57734. * @param start world position
  57735. * @param end world position
  57736. * @returns array containing world position composing the path
  57737. */
  57738. computePath(start: Vector3, end: Vector3): Vector3[];
  57739. /**
  57740. * Create a new Crowd so you can add agents
  57741. * @param maxAgents the maximum agent count in the crowd
  57742. * @param maxAgentRadius the maximum radius an agent can have
  57743. * @param scene to attach the crowd to
  57744. * @returns the crowd you can add agents to
  57745. */
  57746. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57747. /**
  57748. * Disposes
  57749. */
  57750. dispose(): void;
  57751. /**
  57752. * If this plugin is supported
  57753. * @returns true if plugin is supported
  57754. */
  57755. isSupported(): boolean;
  57756. }
  57757. /**
  57758. * Recast detour crowd implementation
  57759. */
  57760. export class RecastJSCrowd implements ICrowd {
  57761. /**
  57762. * Recast/detour plugin
  57763. */
  57764. bjsRECASTPlugin: RecastJSPlugin;
  57765. /**
  57766. * Link to the detour crowd
  57767. */
  57768. recastCrowd: any;
  57769. /**
  57770. * One transform per agent
  57771. */
  57772. transforms: TransformNode[];
  57773. /**
  57774. * All agents created
  57775. */
  57776. agents: number[];
  57777. /**
  57778. * Link to the scene is kept to unregister the crowd from the scene
  57779. */
  57780. private _scene;
  57781. /**
  57782. * Observer for crowd updates
  57783. */
  57784. private _onBeforeAnimationsObserver;
  57785. /**
  57786. * Constructor
  57787. * @param plugin recastJS plugin
  57788. * @param maxAgents the maximum agent count in the crowd
  57789. * @param maxAgentRadius the maximum radius an agent can have
  57790. * @param scene to attach the crowd to
  57791. * @returns the crowd you can add agents to
  57792. */
  57793. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57794. /**
  57795. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57796. * You can attach anything to that node. The node position is updated in the scene update tick.
  57797. * @param pos world position that will be constrained by the navigation mesh
  57798. * @param parameters agent parameters
  57799. * @param transform hooked to the agent that will be update by the scene
  57800. * @returns agent index
  57801. */
  57802. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57803. /**
  57804. * Returns the agent position in world space
  57805. * @param index agent index returned by addAgent
  57806. * @returns world space position
  57807. */
  57808. getAgentPosition(index: number): Vector3;
  57809. /**
  57810. * Returns the agent velocity in world space
  57811. * @param index agent index returned by addAgent
  57812. * @returns world space velocity
  57813. */
  57814. getAgentVelocity(index: number): Vector3;
  57815. /**
  57816. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57817. * @param index agent index returned by addAgent
  57818. * @param destination targeted world position
  57819. */
  57820. agentGoto(index: number, destination: Vector3): void;
  57821. /**
  57822. * remove a particular agent previously created
  57823. * @param index agent index returned by addAgent
  57824. */
  57825. removeAgent(index: number): void;
  57826. /**
  57827. * get the list of all agents attached to this crowd
  57828. * @returns list of agent indices
  57829. */
  57830. getAgents(): number[];
  57831. /**
  57832. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57833. * @param deltaTime in seconds
  57834. */
  57835. update(deltaTime: number): void;
  57836. /**
  57837. * Release all resources
  57838. */
  57839. dispose(): void;
  57840. }
  57841. }
  57842. declare module "babylonjs/Navigation/Plugins/index" {
  57843. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  57844. }
  57845. declare module "babylonjs/Navigation/index" {
  57846. export * from "babylonjs/Navigation/INavigationEngine";
  57847. export * from "babylonjs/Navigation/Plugins/index";
  57848. }
  57849. declare module "babylonjs/Offline/database" {
  57850. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  57851. /**
  57852. * Class used to enable access to IndexedDB
  57853. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57854. */
  57855. export class Database implements IOfflineProvider {
  57856. private _callbackManifestChecked;
  57857. private _currentSceneUrl;
  57858. private _db;
  57859. private _enableSceneOffline;
  57860. private _enableTexturesOffline;
  57861. private _manifestVersionFound;
  57862. private _mustUpdateRessources;
  57863. private _hasReachedQuota;
  57864. private _isSupported;
  57865. private _idbFactory;
  57866. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57867. private static IsUASupportingBlobStorage;
  57868. /**
  57869. * Gets a boolean indicating if Database storate is enabled (off by default)
  57870. */
  57871. static IDBStorageEnabled: boolean;
  57872. /**
  57873. * Gets a boolean indicating if scene must be saved in the database
  57874. */
  57875. readonly enableSceneOffline: boolean;
  57876. /**
  57877. * Gets a boolean indicating if textures must be saved in the database
  57878. */
  57879. readonly enableTexturesOffline: boolean;
  57880. /**
  57881. * Creates a new Database
  57882. * @param urlToScene defines the url to load the scene
  57883. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57884. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57885. */
  57886. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57887. private static _ParseURL;
  57888. private static _ReturnFullUrlLocation;
  57889. private _checkManifestFile;
  57890. /**
  57891. * Open the database and make it available
  57892. * @param successCallback defines the callback to call on success
  57893. * @param errorCallback defines the callback to call on error
  57894. */
  57895. open(successCallback: () => void, errorCallback: () => void): void;
  57896. /**
  57897. * Loads an image from the database
  57898. * @param url defines the url to load from
  57899. * @param image defines the target DOM image
  57900. */
  57901. loadImage(url: string, image: HTMLImageElement): void;
  57902. private _loadImageFromDBAsync;
  57903. private _saveImageIntoDBAsync;
  57904. private _checkVersionFromDB;
  57905. private _loadVersionFromDBAsync;
  57906. private _saveVersionIntoDBAsync;
  57907. /**
  57908. * Loads a file from database
  57909. * @param url defines the URL to load from
  57910. * @param sceneLoaded defines a callback to call on success
  57911. * @param progressCallBack defines a callback to call when progress changed
  57912. * @param errorCallback defines a callback to call on error
  57913. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57914. */
  57915. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57916. private _loadFileAsync;
  57917. private _saveFileAsync;
  57918. /**
  57919. * Validates if xhr data is correct
  57920. * @param xhr defines the request to validate
  57921. * @param dataType defines the expected data type
  57922. * @returns true if data is correct
  57923. */
  57924. private static _ValidateXHRData;
  57925. }
  57926. }
  57927. declare module "babylonjs/Offline/index" {
  57928. export * from "babylonjs/Offline/database";
  57929. export * from "babylonjs/Offline/IOfflineProvider";
  57930. }
  57931. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  57932. /** @hidden */
  57933. export var gpuUpdateParticlesPixelShader: {
  57934. name: string;
  57935. shader: string;
  57936. };
  57937. }
  57938. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  57939. /** @hidden */
  57940. export var gpuUpdateParticlesVertexShader: {
  57941. name: string;
  57942. shader: string;
  57943. };
  57944. }
  57945. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  57946. /** @hidden */
  57947. export var clipPlaneFragmentDeclaration2: {
  57948. name: string;
  57949. shader: string;
  57950. };
  57951. }
  57952. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  57953. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  57954. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57955. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57956. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57957. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57958. /** @hidden */
  57959. export var gpuRenderParticlesPixelShader: {
  57960. name: string;
  57961. shader: string;
  57962. };
  57963. }
  57964. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  57965. /** @hidden */
  57966. export var clipPlaneVertexDeclaration2: {
  57967. name: string;
  57968. shader: string;
  57969. };
  57970. }
  57971. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  57972. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  57973. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57974. /** @hidden */
  57975. export var gpuRenderParticlesVertexShader: {
  57976. name: string;
  57977. shader: string;
  57978. };
  57979. }
  57980. declare module "babylonjs/Particles/gpuParticleSystem" {
  57981. import { Nullable } from "babylonjs/types";
  57982. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  57983. import { Observable } from "babylonjs/Misc/observable";
  57984. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57985. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57986. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  57987. import { Scene, IDisposable } from "babylonjs/scene";
  57988. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  57989. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57990. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  57991. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  57992. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  57993. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  57994. /**
  57995. * This represents a GPU particle system in Babylon
  57996. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57997. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57998. */
  57999. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58000. /**
  58001. * The layer mask we are rendering the particles through.
  58002. */
  58003. layerMask: number;
  58004. private _capacity;
  58005. private _activeCount;
  58006. private _currentActiveCount;
  58007. private _accumulatedCount;
  58008. private _renderEffect;
  58009. private _updateEffect;
  58010. private _buffer0;
  58011. private _buffer1;
  58012. private _spriteBuffer;
  58013. private _updateVAO;
  58014. private _renderVAO;
  58015. private _targetIndex;
  58016. private _sourceBuffer;
  58017. private _targetBuffer;
  58018. private _engine;
  58019. private _currentRenderId;
  58020. private _started;
  58021. private _stopped;
  58022. private _timeDelta;
  58023. private _randomTexture;
  58024. private _randomTexture2;
  58025. private _attributesStrideSize;
  58026. private _updateEffectOptions;
  58027. private _randomTextureSize;
  58028. private _actualFrame;
  58029. private readonly _rawTextureWidth;
  58030. /**
  58031. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58032. */
  58033. static readonly IsSupported: boolean;
  58034. /**
  58035. * An event triggered when the system is disposed.
  58036. */
  58037. onDisposeObservable: Observable<GPUParticleSystem>;
  58038. /**
  58039. * Gets the maximum number of particles active at the same time.
  58040. * @returns The max number of active particles.
  58041. */
  58042. getCapacity(): number;
  58043. /**
  58044. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58045. * to override the particles.
  58046. */
  58047. forceDepthWrite: boolean;
  58048. /**
  58049. * Gets or set the number of active particles
  58050. */
  58051. activeParticleCount: number;
  58052. private _preWarmDone;
  58053. /**
  58054. * Is this system ready to be used/rendered
  58055. * @return true if the system is ready
  58056. */
  58057. isReady(): boolean;
  58058. /**
  58059. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58060. * @returns True if it has been started, otherwise false.
  58061. */
  58062. isStarted(): boolean;
  58063. /**
  58064. * Starts the particle system and begins to emit
  58065. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58066. */
  58067. start(delay?: number): void;
  58068. /**
  58069. * Stops the particle system.
  58070. */
  58071. stop(): void;
  58072. /**
  58073. * Remove all active particles
  58074. */
  58075. reset(): void;
  58076. /**
  58077. * Returns the string "GPUParticleSystem"
  58078. * @returns a string containing the class name
  58079. */
  58080. getClassName(): string;
  58081. private _colorGradientsTexture;
  58082. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58083. /**
  58084. * Adds a new color gradient
  58085. * @param gradient defines the gradient to use (between 0 and 1)
  58086. * @param color1 defines the color to affect to the specified gradient
  58087. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58088. * @returns the current particle system
  58089. */
  58090. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58091. /**
  58092. * Remove a specific color gradient
  58093. * @param gradient defines the gradient to remove
  58094. * @returns the current particle system
  58095. */
  58096. removeColorGradient(gradient: number): GPUParticleSystem;
  58097. private _angularSpeedGradientsTexture;
  58098. private _sizeGradientsTexture;
  58099. private _velocityGradientsTexture;
  58100. private _limitVelocityGradientsTexture;
  58101. private _dragGradientsTexture;
  58102. private _addFactorGradient;
  58103. /**
  58104. * Adds a new size gradient
  58105. * @param gradient defines the gradient to use (between 0 and 1)
  58106. * @param factor defines the size factor to affect to the specified gradient
  58107. * @returns the current particle system
  58108. */
  58109. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58110. /**
  58111. * Remove a specific size gradient
  58112. * @param gradient defines the gradient to remove
  58113. * @returns the current particle system
  58114. */
  58115. removeSizeGradient(gradient: number): GPUParticleSystem;
  58116. /**
  58117. * Adds a new angular speed gradient
  58118. * @param gradient defines the gradient to use (between 0 and 1)
  58119. * @param factor defines the angular speed to affect to the specified gradient
  58120. * @returns the current particle system
  58121. */
  58122. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58123. /**
  58124. * Remove a specific angular speed gradient
  58125. * @param gradient defines the gradient to remove
  58126. * @returns the current particle system
  58127. */
  58128. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58129. /**
  58130. * Adds a new velocity gradient
  58131. * @param gradient defines the gradient to use (between 0 and 1)
  58132. * @param factor defines the velocity to affect to the specified gradient
  58133. * @returns the current particle system
  58134. */
  58135. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58136. /**
  58137. * Remove a specific velocity gradient
  58138. * @param gradient defines the gradient to remove
  58139. * @returns the current particle system
  58140. */
  58141. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58142. /**
  58143. * Adds a new limit velocity gradient
  58144. * @param gradient defines the gradient to use (between 0 and 1)
  58145. * @param factor defines the limit velocity value to affect to the specified gradient
  58146. * @returns the current particle system
  58147. */
  58148. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58149. /**
  58150. * Remove a specific limit velocity gradient
  58151. * @param gradient defines the gradient to remove
  58152. * @returns the current particle system
  58153. */
  58154. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58155. /**
  58156. * Adds a new drag gradient
  58157. * @param gradient defines the gradient to use (between 0 and 1)
  58158. * @param factor defines the drag value to affect to the specified gradient
  58159. * @returns the current particle system
  58160. */
  58161. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58162. /**
  58163. * Remove a specific drag gradient
  58164. * @param gradient defines the gradient to remove
  58165. * @returns the current particle system
  58166. */
  58167. removeDragGradient(gradient: number): GPUParticleSystem;
  58168. /**
  58169. * Not supported by GPUParticleSystem
  58170. * @param gradient defines the gradient to use (between 0 and 1)
  58171. * @param factor defines the emit rate value to affect to the specified gradient
  58172. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58173. * @returns the current particle system
  58174. */
  58175. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58176. /**
  58177. * Not supported by GPUParticleSystem
  58178. * @param gradient defines the gradient to remove
  58179. * @returns the current particle system
  58180. */
  58181. removeEmitRateGradient(gradient: number): IParticleSystem;
  58182. /**
  58183. * Not supported by GPUParticleSystem
  58184. * @param gradient defines the gradient to use (between 0 and 1)
  58185. * @param factor defines the start size value to affect to the specified gradient
  58186. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58187. * @returns the current particle system
  58188. */
  58189. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58190. /**
  58191. * Not supported by GPUParticleSystem
  58192. * @param gradient defines the gradient to remove
  58193. * @returns the current particle system
  58194. */
  58195. removeStartSizeGradient(gradient: number): IParticleSystem;
  58196. /**
  58197. * Not supported by GPUParticleSystem
  58198. * @param gradient defines the gradient to use (between 0 and 1)
  58199. * @param min defines the color remap minimal range
  58200. * @param max defines the color remap maximal range
  58201. * @returns the current particle system
  58202. */
  58203. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58204. /**
  58205. * Not supported by GPUParticleSystem
  58206. * @param gradient defines the gradient to remove
  58207. * @returns the current particle system
  58208. */
  58209. removeColorRemapGradient(): IParticleSystem;
  58210. /**
  58211. * Not supported by GPUParticleSystem
  58212. * @param gradient defines the gradient to use (between 0 and 1)
  58213. * @param min defines the alpha remap minimal range
  58214. * @param max defines the alpha remap maximal range
  58215. * @returns the current particle system
  58216. */
  58217. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58218. /**
  58219. * Not supported by GPUParticleSystem
  58220. * @param gradient defines the gradient to remove
  58221. * @returns the current particle system
  58222. */
  58223. removeAlphaRemapGradient(): IParticleSystem;
  58224. /**
  58225. * Not supported by GPUParticleSystem
  58226. * @param gradient defines the gradient to use (between 0 and 1)
  58227. * @param color defines the color to affect to the specified gradient
  58228. * @returns the current particle system
  58229. */
  58230. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58231. /**
  58232. * Not supported by GPUParticleSystem
  58233. * @param gradient defines the gradient to remove
  58234. * @returns the current particle system
  58235. */
  58236. removeRampGradient(): IParticleSystem;
  58237. /**
  58238. * Not supported by GPUParticleSystem
  58239. * @returns the list of ramp gradients
  58240. */
  58241. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58242. /**
  58243. * Not supported by GPUParticleSystem
  58244. * Gets or sets a boolean indicating that ramp gradients must be used
  58245. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58246. */
  58247. useRampGradients: boolean;
  58248. /**
  58249. * Not supported by GPUParticleSystem
  58250. * @param gradient defines the gradient to use (between 0 and 1)
  58251. * @param factor defines the life time factor to affect to the specified gradient
  58252. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58253. * @returns the current particle system
  58254. */
  58255. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58256. /**
  58257. * Not supported by GPUParticleSystem
  58258. * @param gradient defines the gradient to remove
  58259. * @returns the current particle system
  58260. */
  58261. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58262. /**
  58263. * Instantiates a GPU particle system.
  58264. * 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.
  58265. * @param name The name of the particle system
  58266. * @param options The options used to create the system
  58267. * @param scene The scene the particle system belongs to
  58268. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58269. */
  58270. constructor(name: string, options: Partial<{
  58271. capacity: number;
  58272. randomTextureSize: number;
  58273. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58274. protected _reset(): void;
  58275. private _createUpdateVAO;
  58276. private _createRenderVAO;
  58277. private _initialize;
  58278. /** @hidden */
  58279. _recreateUpdateEffect(): void;
  58280. /** @hidden */
  58281. _recreateRenderEffect(): void;
  58282. /**
  58283. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58284. * @param preWarm defines if we are in the pre-warmimg phase
  58285. */
  58286. animate(preWarm?: boolean): void;
  58287. private _createFactorGradientTexture;
  58288. private _createSizeGradientTexture;
  58289. private _createAngularSpeedGradientTexture;
  58290. private _createVelocityGradientTexture;
  58291. private _createLimitVelocityGradientTexture;
  58292. private _createDragGradientTexture;
  58293. private _createColorGradientTexture;
  58294. /**
  58295. * Renders the particle system in its current state
  58296. * @param preWarm defines if the system should only update the particles but not render them
  58297. * @returns the current number of particles
  58298. */
  58299. render(preWarm?: boolean): number;
  58300. /**
  58301. * Rebuilds the particle system
  58302. */
  58303. rebuild(): void;
  58304. private _releaseBuffers;
  58305. private _releaseVAOs;
  58306. /**
  58307. * Disposes the particle system and free the associated resources
  58308. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58309. */
  58310. dispose(disposeTexture?: boolean): void;
  58311. /**
  58312. * Clones the particle system.
  58313. * @param name The name of the cloned object
  58314. * @param newEmitter The new emitter to use
  58315. * @returns the cloned particle system
  58316. */
  58317. clone(name: string, newEmitter: any): GPUParticleSystem;
  58318. /**
  58319. * Serializes the particle system to a JSON object.
  58320. * @returns the JSON object
  58321. */
  58322. serialize(): any;
  58323. /**
  58324. * Parses a JSON object to create a GPU particle system.
  58325. * @param parsedParticleSystem The JSON object to parse
  58326. * @param scene The scene to create the particle system in
  58327. * @param rootUrl The root url to use to load external dependencies like texture
  58328. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58329. * @returns the parsed GPU particle system
  58330. */
  58331. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58332. }
  58333. }
  58334. declare module "babylonjs/Particles/particleSystemSet" {
  58335. import { Nullable } from "babylonjs/types";
  58336. import { Color3 } from "babylonjs/Maths/math.color";
  58337. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58339. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58340. import { Scene, IDisposable } from "babylonjs/scene";
  58341. /**
  58342. * Represents a set of particle systems working together to create a specific effect
  58343. */
  58344. export class ParticleSystemSet implements IDisposable {
  58345. private _emitterCreationOptions;
  58346. private _emitterNode;
  58347. /**
  58348. * Gets the particle system list
  58349. */
  58350. systems: IParticleSystem[];
  58351. /**
  58352. * Gets the emitter node used with this set
  58353. */
  58354. readonly emitterNode: Nullable<TransformNode>;
  58355. /**
  58356. * Creates a new emitter mesh as a sphere
  58357. * @param options defines the options used to create the sphere
  58358. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58359. * @param scene defines the hosting scene
  58360. */
  58361. setEmitterAsSphere(options: {
  58362. diameter: number;
  58363. segments: number;
  58364. color: Color3;
  58365. }, renderingGroupId: number, scene: Scene): void;
  58366. /**
  58367. * Starts all particle systems of the set
  58368. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58369. */
  58370. start(emitter?: AbstractMesh): void;
  58371. /**
  58372. * Release all associated resources
  58373. */
  58374. dispose(): void;
  58375. /**
  58376. * Serialize the set into a JSON compatible object
  58377. * @returns a JSON compatible representation of the set
  58378. */
  58379. serialize(): any;
  58380. /**
  58381. * Parse a new ParticleSystemSet from a serialized source
  58382. * @param data defines a JSON compatible representation of the set
  58383. * @param scene defines the hosting scene
  58384. * @param gpu defines if we want GPU particles or CPU particles
  58385. * @returns a new ParticleSystemSet
  58386. */
  58387. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58388. }
  58389. }
  58390. declare module "babylonjs/Particles/particleHelper" {
  58391. import { Nullable } from "babylonjs/types";
  58392. import { Scene } from "babylonjs/scene";
  58393. import { Vector3 } from "babylonjs/Maths/math.vector";
  58394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58395. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58396. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  58397. /**
  58398. * This class is made for on one-liner static method to help creating particle system set.
  58399. */
  58400. export class ParticleHelper {
  58401. /**
  58402. * Gets or sets base Assets URL
  58403. */
  58404. static BaseAssetsUrl: string;
  58405. /**
  58406. * Create a default particle system that you can tweak
  58407. * @param emitter defines the emitter to use
  58408. * @param capacity defines the system capacity (default is 500 particles)
  58409. * @param scene defines the hosting scene
  58410. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58411. * @returns the new Particle system
  58412. */
  58413. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58414. /**
  58415. * This is the main static method (one-liner) of this helper to create different particle systems
  58416. * @param type This string represents the type to the particle system to create
  58417. * @param scene The scene where the particle system should live
  58418. * @param gpu If the system will use gpu
  58419. * @returns the ParticleSystemSet created
  58420. */
  58421. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58422. /**
  58423. * Static function used to export a particle system to a ParticleSystemSet variable.
  58424. * Please note that the emitter shape is not exported
  58425. * @param systems defines the particle systems to export
  58426. * @returns the created particle system set
  58427. */
  58428. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58429. }
  58430. }
  58431. declare module "babylonjs/Particles/particleSystemComponent" {
  58432. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58433. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  58434. import "babylonjs/Shaders/particles.vertex";
  58435. module "babylonjs/Engines/engine" {
  58436. interface Engine {
  58437. /**
  58438. * Create an effect to use with particle systems.
  58439. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58440. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58441. * @param uniformsNames defines a list of attribute names
  58442. * @param samplers defines an array of string used to represent textures
  58443. * @param defines defines the string containing the defines to use to compile the shaders
  58444. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58445. * @param onCompiled defines a function to call when the effect creation is successful
  58446. * @param onError defines a function to call when the effect creation has failed
  58447. * @returns the new Effect
  58448. */
  58449. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58450. }
  58451. }
  58452. module "babylonjs/Meshes/mesh" {
  58453. interface Mesh {
  58454. /**
  58455. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58456. * @returns an array of IParticleSystem
  58457. */
  58458. getEmittedParticleSystems(): IParticleSystem[];
  58459. /**
  58460. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58461. * @returns an array of IParticleSystem
  58462. */
  58463. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58464. }
  58465. }
  58466. /**
  58467. * @hidden
  58468. */
  58469. export var _IDoNeedToBeInTheBuild: number;
  58470. }
  58471. declare module "babylonjs/Particles/index" {
  58472. export * from "babylonjs/Particles/baseParticleSystem";
  58473. export * from "babylonjs/Particles/EmitterTypes/index";
  58474. export * from "babylonjs/Particles/gpuParticleSystem";
  58475. export * from "babylonjs/Particles/IParticleSystem";
  58476. export * from "babylonjs/Particles/particle";
  58477. export * from "babylonjs/Particles/particleHelper";
  58478. export * from "babylonjs/Particles/particleSystem";
  58479. export * from "babylonjs/Particles/particleSystemComponent";
  58480. export * from "babylonjs/Particles/particleSystemSet";
  58481. export * from "babylonjs/Particles/solidParticle";
  58482. export * from "babylonjs/Particles/solidParticleSystem";
  58483. export * from "babylonjs/Particles/subEmitter";
  58484. }
  58485. declare module "babylonjs/Physics/physicsEngineComponent" {
  58486. import { Nullable } from "babylonjs/types";
  58487. import { Observable, Observer } from "babylonjs/Misc/observable";
  58488. import { Vector3 } from "babylonjs/Maths/math.vector";
  58489. import { Mesh } from "babylonjs/Meshes/mesh";
  58490. import { ISceneComponent } from "babylonjs/sceneComponent";
  58491. import { Scene } from "babylonjs/scene";
  58492. import { Node } from "babylonjs/node";
  58493. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58494. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58495. module "babylonjs/scene" {
  58496. interface Scene {
  58497. /** @hidden (Backing field) */
  58498. _physicsEngine: Nullable<IPhysicsEngine>;
  58499. /**
  58500. * Gets the current physics engine
  58501. * @returns a IPhysicsEngine or null if none attached
  58502. */
  58503. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58504. /**
  58505. * Enables physics to the current scene
  58506. * @param gravity defines the scene's gravity for the physics engine
  58507. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58508. * @return a boolean indicating if the physics engine was initialized
  58509. */
  58510. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58511. /**
  58512. * Disables and disposes the physics engine associated with the scene
  58513. */
  58514. disablePhysicsEngine(): void;
  58515. /**
  58516. * Gets a boolean indicating if there is an active physics engine
  58517. * @returns a boolean indicating if there is an active physics engine
  58518. */
  58519. isPhysicsEnabled(): boolean;
  58520. /**
  58521. * Deletes a physics compound impostor
  58522. * @param compound defines the compound to delete
  58523. */
  58524. deleteCompoundImpostor(compound: any): void;
  58525. /**
  58526. * An event triggered when physic simulation is about to be run
  58527. */
  58528. onBeforePhysicsObservable: Observable<Scene>;
  58529. /**
  58530. * An event triggered when physic simulation has been done
  58531. */
  58532. onAfterPhysicsObservable: Observable<Scene>;
  58533. }
  58534. }
  58535. module "babylonjs/Meshes/abstractMesh" {
  58536. interface AbstractMesh {
  58537. /** @hidden */
  58538. _physicsImpostor: Nullable<PhysicsImpostor>;
  58539. /**
  58540. * Gets or sets impostor used for physic simulation
  58541. * @see http://doc.babylonjs.com/features/physics_engine
  58542. */
  58543. physicsImpostor: Nullable<PhysicsImpostor>;
  58544. /**
  58545. * Gets the current physics impostor
  58546. * @see http://doc.babylonjs.com/features/physics_engine
  58547. * @returns a physics impostor or null
  58548. */
  58549. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58550. /** Apply a physic impulse to the mesh
  58551. * @param force defines the force to apply
  58552. * @param contactPoint defines where to apply the force
  58553. * @returns the current mesh
  58554. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58555. */
  58556. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58557. /**
  58558. * Creates a physic joint between two meshes
  58559. * @param otherMesh defines the other mesh to use
  58560. * @param pivot1 defines the pivot to use on this mesh
  58561. * @param pivot2 defines the pivot to use on the other mesh
  58562. * @param options defines additional options (can be plugin dependent)
  58563. * @returns the current mesh
  58564. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58565. */
  58566. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58567. /** @hidden */
  58568. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58569. }
  58570. }
  58571. /**
  58572. * Defines the physics engine scene component responsible to manage a physics engine
  58573. */
  58574. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58575. /**
  58576. * The component name helpful to identify the component in the list of scene components.
  58577. */
  58578. readonly name: string;
  58579. /**
  58580. * The scene the component belongs to.
  58581. */
  58582. scene: Scene;
  58583. /**
  58584. * Creates a new instance of the component for the given scene
  58585. * @param scene Defines the scene to register the component in
  58586. */
  58587. constructor(scene: Scene);
  58588. /**
  58589. * Registers the component in a given scene
  58590. */
  58591. register(): void;
  58592. /**
  58593. * Rebuilds the elements related to this component in case of
  58594. * context lost for instance.
  58595. */
  58596. rebuild(): void;
  58597. /**
  58598. * Disposes the component and the associated ressources
  58599. */
  58600. dispose(): void;
  58601. }
  58602. }
  58603. declare module "babylonjs/Physics/physicsHelper" {
  58604. import { Nullable } from "babylonjs/types";
  58605. import { Vector3 } from "babylonjs/Maths/math.vector";
  58606. import { Mesh } from "babylonjs/Meshes/mesh";
  58607. import { Scene } from "babylonjs/scene";
  58608. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58609. /**
  58610. * A helper for physics simulations
  58611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58612. */
  58613. export class PhysicsHelper {
  58614. private _scene;
  58615. private _physicsEngine;
  58616. /**
  58617. * Initializes the Physics helper
  58618. * @param scene Babylon.js scene
  58619. */
  58620. constructor(scene: Scene);
  58621. /**
  58622. * Applies a radial explosion impulse
  58623. * @param origin the origin of the explosion
  58624. * @param radiusOrEventOptions the radius or the options of radial explosion
  58625. * @param strength the explosion strength
  58626. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58627. * @returns A physics radial explosion event, or null
  58628. */
  58629. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58630. /**
  58631. * Applies a radial explosion force
  58632. * @param origin the origin of the explosion
  58633. * @param radiusOrEventOptions the radius or the options of radial explosion
  58634. * @param strength the explosion strength
  58635. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58636. * @returns A physics radial explosion event, or null
  58637. */
  58638. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58639. /**
  58640. * Creates a gravitational field
  58641. * @param origin the origin of the explosion
  58642. * @param radiusOrEventOptions the radius or the options of radial explosion
  58643. * @param strength the explosion strength
  58644. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58645. * @returns A physics gravitational field event, or null
  58646. */
  58647. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58648. /**
  58649. * Creates a physics updraft event
  58650. * @param origin the origin of the updraft
  58651. * @param radiusOrEventOptions the radius or the options of the updraft
  58652. * @param strength the strength of the updraft
  58653. * @param height the height of the updraft
  58654. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58655. * @returns A physics updraft event, or null
  58656. */
  58657. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58658. /**
  58659. * Creates a physics vortex event
  58660. * @param origin the of the vortex
  58661. * @param radiusOrEventOptions the radius or the options of the vortex
  58662. * @param strength the strength of the vortex
  58663. * @param height the height of the vortex
  58664. * @returns a Physics vortex event, or null
  58665. * A physics vortex event or null
  58666. */
  58667. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58668. }
  58669. /**
  58670. * Represents a physics radial explosion event
  58671. */
  58672. class PhysicsRadialExplosionEvent {
  58673. private _scene;
  58674. private _options;
  58675. private _sphere;
  58676. private _dataFetched;
  58677. /**
  58678. * Initializes a radial explosioin event
  58679. * @param _scene BabylonJS scene
  58680. * @param _options The options for the vortex event
  58681. */
  58682. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58683. /**
  58684. * Returns the data related to the radial explosion event (sphere).
  58685. * @returns The radial explosion event data
  58686. */
  58687. getData(): PhysicsRadialExplosionEventData;
  58688. /**
  58689. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58690. * @param impostor A physics imposter
  58691. * @param origin the origin of the explosion
  58692. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58693. */
  58694. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58695. /**
  58696. * Triggers affecterd impostors callbacks
  58697. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58698. */
  58699. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58700. /**
  58701. * Disposes the sphere.
  58702. * @param force Specifies if the sphere should be disposed by force
  58703. */
  58704. dispose(force?: boolean): void;
  58705. /*** Helpers ***/
  58706. private _prepareSphere;
  58707. private _intersectsWithSphere;
  58708. }
  58709. /**
  58710. * Represents a gravitational field event
  58711. */
  58712. class PhysicsGravitationalFieldEvent {
  58713. private _physicsHelper;
  58714. private _scene;
  58715. private _origin;
  58716. private _options;
  58717. private _tickCallback;
  58718. private _sphere;
  58719. private _dataFetched;
  58720. /**
  58721. * Initializes the physics gravitational field event
  58722. * @param _physicsHelper A physics helper
  58723. * @param _scene BabylonJS scene
  58724. * @param _origin The origin position of the gravitational field event
  58725. * @param _options The options for the vortex event
  58726. */
  58727. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58728. /**
  58729. * Returns the data related to the gravitational field event (sphere).
  58730. * @returns A gravitational field event
  58731. */
  58732. getData(): PhysicsGravitationalFieldEventData;
  58733. /**
  58734. * Enables the gravitational field.
  58735. */
  58736. enable(): void;
  58737. /**
  58738. * Disables the gravitational field.
  58739. */
  58740. disable(): void;
  58741. /**
  58742. * Disposes the sphere.
  58743. * @param force The force to dispose from the gravitational field event
  58744. */
  58745. dispose(force?: boolean): void;
  58746. private _tick;
  58747. }
  58748. /**
  58749. * Represents a physics updraft event
  58750. */
  58751. class PhysicsUpdraftEvent {
  58752. private _scene;
  58753. private _origin;
  58754. private _options;
  58755. private _physicsEngine;
  58756. private _originTop;
  58757. private _originDirection;
  58758. private _tickCallback;
  58759. private _cylinder;
  58760. private _cylinderPosition;
  58761. private _dataFetched;
  58762. /**
  58763. * Initializes the physics updraft event
  58764. * @param _scene BabylonJS scene
  58765. * @param _origin The origin position of the updraft
  58766. * @param _options The options for the updraft event
  58767. */
  58768. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58769. /**
  58770. * Returns the data related to the updraft event (cylinder).
  58771. * @returns A physics updraft event
  58772. */
  58773. getData(): PhysicsUpdraftEventData;
  58774. /**
  58775. * Enables the updraft.
  58776. */
  58777. enable(): void;
  58778. /**
  58779. * Disables the updraft.
  58780. */
  58781. disable(): void;
  58782. /**
  58783. * Disposes the cylinder.
  58784. * @param force Specifies if the updraft should be disposed by force
  58785. */
  58786. dispose(force?: boolean): void;
  58787. private getImpostorHitData;
  58788. private _tick;
  58789. /*** Helpers ***/
  58790. private _prepareCylinder;
  58791. private _intersectsWithCylinder;
  58792. }
  58793. /**
  58794. * Represents a physics vortex event
  58795. */
  58796. class PhysicsVortexEvent {
  58797. private _scene;
  58798. private _origin;
  58799. private _options;
  58800. private _physicsEngine;
  58801. private _originTop;
  58802. private _tickCallback;
  58803. private _cylinder;
  58804. private _cylinderPosition;
  58805. private _dataFetched;
  58806. /**
  58807. * Initializes the physics vortex event
  58808. * @param _scene The BabylonJS scene
  58809. * @param _origin The origin position of the vortex
  58810. * @param _options The options for the vortex event
  58811. */
  58812. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58813. /**
  58814. * Returns the data related to the vortex event (cylinder).
  58815. * @returns The physics vortex event data
  58816. */
  58817. getData(): PhysicsVortexEventData;
  58818. /**
  58819. * Enables the vortex.
  58820. */
  58821. enable(): void;
  58822. /**
  58823. * Disables the cortex.
  58824. */
  58825. disable(): void;
  58826. /**
  58827. * Disposes the sphere.
  58828. * @param force
  58829. */
  58830. dispose(force?: boolean): void;
  58831. private getImpostorHitData;
  58832. private _tick;
  58833. /*** Helpers ***/
  58834. private _prepareCylinder;
  58835. private _intersectsWithCylinder;
  58836. }
  58837. /**
  58838. * Options fot the radial explosion event
  58839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58840. */
  58841. export class PhysicsRadialExplosionEventOptions {
  58842. /**
  58843. * The radius of the sphere for the radial explosion.
  58844. */
  58845. radius: number;
  58846. /**
  58847. * The strenth of the explosion.
  58848. */
  58849. strength: number;
  58850. /**
  58851. * The strenght of the force in correspondence to the distance of the affected object
  58852. */
  58853. falloff: PhysicsRadialImpulseFalloff;
  58854. /**
  58855. * Sphere options for the radial explosion.
  58856. */
  58857. sphere: {
  58858. segments: number;
  58859. diameter: number;
  58860. };
  58861. /**
  58862. * Sphere options for the radial explosion.
  58863. */
  58864. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58865. }
  58866. /**
  58867. * Options fot the updraft event
  58868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58869. */
  58870. export class PhysicsUpdraftEventOptions {
  58871. /**
  58872. * The radius of the cylinder for the vortex
  58873. */
  58874. radius: number;
  58875. /**
  58876. * The strenth of the updraft.
  58877. */
  58878. strength: number;
  58879. /**
  58880. * The height of the cylinder for the updraft.
  58881. */
  58882. height: number;
  58883. /**
  58884. * The mode for the the updraft.
  58885. */
  58886. updraftMode: PhysicsUpdraftMode;
  58887. }
  58888. /**
  58889. * Options fot the vortex event
  58890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58891. */
  58892. export class PhysicsVortexEventOptions {
  58893. /**
  58894. * The radius of the cylinder for the vortex
  58895. */
  58896. radius: number;
  58897. /**
  58898. * The strenth of the vortex.
  58899. */
  58900. strength: number;
  58901. /**
  58902. * The height of the cylinder for the vortex.
  58903. */
  58904. height: number;
  58905. /**
  58906. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58907. */
  58908. centripetalForceThreshold: number;
  58909. /**
  58910. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58911. */
  58912. centripetalForceMultiplier: number;
  58913. /**
  58914. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58915. */
  58916. centrifugalForceMultiplier: number;
  58917. /**
  58918. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58919. */
  58920. updraftForceMultiplier: number;
  58921. }
  58922. /**
  58923. * The strenght of the force in correspondence to the distance of the affected object
  58924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58925. */
  58926. export enum PhysicsRadialImpulseFalloff {
  58927. /** Defines that impulse is constant in strength across it's whole radius */
  58928. Constant = 0,
  58929. /** Defines that impulse gets weaker if it's further from the origin */
  58930. Linear = 1
  58931. }
  58932. /**
  58933. * The strength of the force in correspondence to the distance of the affected object
  58934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58935. */
  58936. export enum PhysicsUpdraftMode {
  58937. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58938. Center = 0,
  58939. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58940. Perpendicular = 1
  58941. }
  58942. /**
  58943. * Interface for a physics hit data
  58944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58945. */
  58946. export interface PhysicsHitData {
  58947. /**
  58948. * The force applied at the contact point
  58949. */
  58950. force: Vector3;
  58951. /**
  58952. * The contact point
  58953. */
  58954. contactPoint: Vector3;
  58955. /**
  58956. * The distance from the origin to the contact point
  58957. */
  58958. distanceFromOrigin: number;
  58959. }
  58960. /**
  58961. * Interface for radial explosion event data
  58962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58963. */
  58964. export interface PhysicsRadialExplosionEventData {
  58965. /**
  58966. * A sphere used for the radial explosion event
  58967. */
  58968. sphere: Mesh;
  58969. }
  58970. /**
  58971. * Interface for gravitational field event data
  58972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58973. */
  58974. export interface PhysicsGravitationalFieldEventData {
  58975. /**
  58976. * A sphere mesh used for the gravitational field event
  58977. */
  58978. sphere: Mesh;
  58979. }
  58980. /**
  58981. * Interface for updraft event data
  58982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58983. */
  58984. export interface PhysicsUpdraftEventData {
  58985. /**
  58986. * A cylinder used for the updraft event
  58987. */
  58988. cylinder: Mesh;
  58989. }
  58990. /**
  58991. * Interface for vortex event data
  58992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58993. */
  58994. export interface PhysicsVortexEventData {
  58995. /**
  58996. * A cylinder used for the vortex event
  58997. */
  58998. cylinder: Mesh;
  58999. }
  59000. /**
  59001. * Interface for an affected physics impostor
  59002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59003. */
  59004. export interface PhysicsAffectedImpostorWithData {
  59005. /**
  59006. * The impostor affected by the effect
  59007. */
  59008. impostor: PhysicsImpostor;
  59009. /**
  59010. * The data about the hit/horce from the explosion
  59011. */
  59012. hitData: PhysicsHitData;
  59013. }
  59014. }
  59015. declare module "babylonjs/Physics/Plugins/index" {
  59016. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  59017. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  59018. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  59019. }
  59020. declare module "babylonjs/Physics/index" {
  59021. export * from "babylonjs/Physics/IPhysicsEngine";
  59022. export * from "babylonjs/Physics/physicsEngine";
  59023. export * from "babylonjs/Physics/physicsEngineComponent";
  59024. export * from "babylonjs/Physics/physicsHelper";
  59025. export * from "babylonjs/Physics/physicsImpostor";
  59026. export * from "babylonjs/Physics/physicsJoint";
  59027. export * from "babylonjs/Physics/Plugins/index";
  59028. }
  59029. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  59030. /** @hidden */
  59031. export var blackAndWhitePixelShader: {
  59032. name: string;
  59033. shader: string;
  59034. };
  59035. }
  59036. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  59037. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59038. import { Camera } from "babylonjs/Cameras/camera";
  59039. import { Engine } from "babylonjs/Engines/engine";
  59040. import "babylonjs/Shaders/blackAndWhite.fragment";
  59041. /**
  59042. * Post process used to render in black and white
  59043. */
  59044. export class BlackAndWhitePostProcess extends PostProcess {
  59045. /**
  59046. * Linear about to convert he result to black and white (default: 1)
  59047. */
  59048. degree: number;
  59049. /**
  59050. * Creates a black and white post process
  59051. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59052. * @param name The name of the effect.
  59053. * @param options The required width/height ratio to downsize to before computing the render pass.
  59054. * @param camera The camera to apply the render pass to.
  59055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59056. * @param engine The engine which the post process will be applied. (default: current engine)
  59057. * @param reusable If the post process can be reused on the same frame. (default: false)
  59058. */
  59059. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59060. }
  59061. }
  59062. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  59063. import { Nullable } from "babylonjs/types";
  59064. import { Camera } from "babylonjs/Cameras/camera";
  59065. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59066. import { Engine } from "babylonjs/Engines/engine";
  59067. /**
  59068. * This represents a set of one or more post processes in Babylon.
  59069. * A post process can be used to apply a shader to a texture after it is rendered.
  59070. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59071. */
  59072. export class PostProcessRenderEffect {
  59073. private _postProcesses;
  59074. private _getPostProcesses;
  59075. private _singleInstance;
  59076. private _cameras;
  59077. private _indicesForCamera;
  59078. /**
  59079. * Name of the effect
  59080. * @hidden
  59081. */
  59082. _name: string;
  59083. /**
  59084. * Instantiates a post process render effect.
  59085. * A post process can be used to apply a shader to a texture after it is rendered.
  59086. * @param engine The engine the effect is tied to
  59087. * @param name The name of the effect
  59088. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59089. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59090. */
  59091. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59092. /**
  59093. * Checks if all the post processes in the effect are supported.
  59094. */
  59095. readonly isSupported: boolean;
  59096. /**
  59097. * Updates the current state of the effect
  59098. * @hidden
  59099. */
  59100. _update(): void;
  59101. /**
  59102. * Attaches the effect on cameras
  59103. * @param cameras The camera to attach to.
  59104. * @hidden
  59105. */
  59106. _attachCameras(cameras: Camera): void;
  59107. /**
  59108. * Attaches the effect on cameras
  59109. * @param cameras The camera to attach to.
  59110. * @hidden
  59111. */
  59112. _attachCameras(cameras: Camera[]): void;
  59113. /**
  59114. * Detaches the effect on cameras
  59115. * @param cameras The camera to detatch from.
  59116. * @hidden
  59117. */
  59118. _detachCameras(cameras: Camera): void;
  59119. /**
  59120. * Detatches the effect on cameras
  59121. * @param cameras The camera to detatch from.
  59122. * @hidden
  59123. */
  59124. _detachCameras(cameras: Camera[]): void;
  59125. /**
  59126. * Enables the effect on given cameras
  59127. * @param cameras The camera to enable.
  59128. * @hidden
  59129. */
  59130. _enable(cameras: Camera): void;
  59131. /**
  59132. * Enables the effect on given cameras
  59133. * @param cameras The camera to enable.
  59134. * @hidden
  59135. */
  59136. _enable(cameras: Nullable<Camera[]>): void;
  59137. /**
  59138. * Disables the effect on the given cameras
  59139. * @param cameras The camera to disable.
  59140. * @hidden
  59141. */
  59142. _disable(cameras: Camera): void;
  59143. /**
  59144. * Disables the effect on the given cameras
  59145. * @param cameras The camera to disable.
  59146. * @hidden
  59147. */
  59148. _disable(cameras: Nullable<Camera[]>): void;
  59149. /**
  59150. * Gets a list of the post processes contained in the effect.
  59151. * @param camera The camera to get the post processes on.
  59152. * @returns The list of the post processes in the effect.
  59153. */
  59154. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59155. }
  59156. }
  59157. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  59158. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59159. /** @hidden */
  59160. export var extractHighlightsPixelShader: {
  59161. name: string;
  59162. shader: string;
  59163. };
  59164. }
  59165. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  59166. import { Nullable } from "babylonjs/types";
  59167. import { Camera } from "babylonjs/Cameras/camera";
  59168. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59169. import { Engine } from "babylonjs/Engines/engine";
  59170. import "babylonjs/Shaders/extractHighlights.fragment";
  59171. /**
  59172. * 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.
  59173. */
  59174. export class ExtractHighlightsPostProcess extends PostProcess {
  59175. /**
  59176. * The luminance threshold, pixels below this value will be set to black.
  59177. */
  59178. threshold: number;
  59179. /** @hidden */
  59180. _exposure: number;
  59181. /**
  59182. * Post process which has the input texture to be used when performing highlight extraction
  59183. * @hidden
  59184. */
  59185. _inputPostProcess: Nullable<PostProcess>;
  59186. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59187. }
  59188. }
  59189. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  59190. /** @hidden */
  59191. export var bloomMergePixelShader: {
  59192. name: string;
  59193. shader: string;
  59194. };
  59195. }
  59196. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  59197. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59198. import { Nullable } from "babylonjs/types";
  59199. import { Engine } from "babylonjs/Engines/engine";
  59200. import { Camera } from "babylonjs/Cameras/camera";
  59201. import "babylonjs/Shaders/bloomMerge.fragment";
  59202. /**
  59203. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59204. */
  59205. export class BloomMergePostProcess extends PostProcess {
  59206. /** Weight of the bloom to be added to the original input. */
  59207. weight: number;
  59208. /**
  59209. * Creates a new instance of @see BloomMergePostProcess
  59210. * @param name The name of the effect.
  59211. * @param originalFromInput Post process which's input will be used for the merge.
  59212. * @param blurred Blurred highlights post process which's output will be used.
  59213. * @param weight Weight of the bloom to be added to the original input.
  59214. * @param options The required width/height ratio to downsize to before computing the render pass.
  59215. * @param camera The camera to apply the render pass to.
  59216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59217. * @param engine The engine which the post process will be applied. (default: current engine)
  59218. * @param reusable If the post process can be reused on the same frame. (default: false)
  59219. * @param textureType Type of textures used when performing the post process. (default: 0)
  59220. * @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)
  59221. */
  59222. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59223. /** Weight of the bloom to be added to the original input. */
  59224. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59225. }
  59226. }
  59227. declare module "babylonjs/PostProcesses/bloomEffect" {
  59228. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59229. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59230. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59231. import { Camera } from "babylonjs/Cameras/camera";
  59232. import { Scene } from "babylonjs/scene";
  59233. /**
  59234. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59235. */
  59236. export class BloomEffect extends PostProcessRenderEffect {
  59237. private bloomScale;
  59238. /**
  59239. * @hidden Internal
  59240. */
  59241. _effects: Array<PostProcess>;
  59242. /**
  59243. * @hidden Internal
  59244. */
  59245. _downscale: ExtractHighlightsPostProcess;
  59246. private _blurX;
  59247. private _blurY;
  59248. private _merge;
  59249. /**
  59250. * The luminance threshold to find bright areas of the image to bloom.
  59251. */
  59252. threshold: number;
  59253. /**
  59254. * The strength of the bloom.
  59255. */
  59256. weight: number;
  59257. /**
  59258. * Specifies the size of the bloom blur kernel, relative to the final output size
  59259. */
  59260. kernel: number;
  59261. /**
  59262. * Creates a new instance of @see BloomEffect
  59263. * @param scene The scene the effect belongs to.
  59264. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59265. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59266. * @param bloomWeight The the strength of bloom.
  59267. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59268. * @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)
  59269. */
  59270. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59271. /**
  59272. * Disposes each of the internal effects for a given camera.
  59273. * @param camera The camera to dispose the effect on.
  59274. */
  59275. disposeEffects(camera: Camera): void;
  59276. /**
  59277. * @hidden Internal
  59278. */
  59279. _updateEffects(): void;
  59280. /**
  59281. * Internal
  59282. * @returns if all the contained post processes are ready.
  59283. * @hidden
  59284. */
  59285. _isReady(): boolean;
  59286. }
  59287. }
  59288. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  59289. /** @hidden */
  59290. export var chromaticAberrationPixelShader: {
  59291. name: string;
  59292. shader: string;
  59293. };
  59294. }
  59295. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  59296. import { Vector2 } from "babylonjs/Maths/math.vector";
  59297. import { Nullable } from "babylonjs/types";
  59298. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59299. import { Camera } from "babylonjs/Cameras/camera";
  59300. import { Engine } from "babylonjs/Engines/engine";
  59301. import "babylonjs/Shaders/chromaticAberration.fragment";
  59302. /**
  59303. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59304. */
  59305. export class ChromaticAberrationPostProcess extends PostProcess {
  59306. /**
  59307. * The amount of seperation of rgb channels (default: 30)
  59308. */
  59309. aberrationAmount: number;
  59310. /**
  59311. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59312. */
  59313. radialIntensity: number;
  59314. /**
  59315. * 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))
  59316. */
  59317. direction: Vector2;
  59318. /**
  59319. * 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))
  59320. */
  59321. centerPosition: Vector2;
  59322. /**
  59323. * Creates a new instance ChromaticAberrationPostProcess
  59324. * @param name The name of the effect.
  59325. * @param screenWidth The width of the screen to apply the effect on.
  59326. * @param screenHeight The height of the screen to apply the effect on.
  59327. * @param options The required width/height ratio to downsize to before computing the render pass.
  59328. * @param camera The camera to apply the render pass to.
  59329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59330. * @param engine The engine which the post process will be applied. (default: current engine)
  59331. * @param reusable If the post process can be reused on the same frame. (default: false)
  59332. * @param textureType Type of textures used when performing the post process. (default: 0)
  59333. * @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)
  59334. */
  59335. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59336. }
  59337. }
  59338. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  59339. /** @hidden */
  59340. export var circleOfConfusionPixelShader: {
  59341. name: string;
  59342. shader: string;
  59343. };
  59344. }
  59345. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  59346. import { Nullable } from "babylonjs/types";
  59347. import { Engine } from "babylonjs/Engines/engine";
  59348. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59350. import { Camera } from "babylonjs/Cameras/camera";
  59351. import "babylonjs/Shaders/circleOfConfusion.fragment";
  59352. /**
  59353. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59354. */
  59355. export class CircleOfConfusionPostProcess extends PostProcess {
  59356. /**
  59357. * 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.
  59358. */
  59359. lensSize: number;
  59360. /**
  59361. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59362. */
  59363. fStop: number;
  59364. /**
  59365. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59366. */
  59367. focusDistance: number;
  59368. /**
  59369. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59370. */
  59371. focalLength: number;
  59372. private _depthTexture;
  59373. /**
  59374. * Creates a new instance CircleOfConfusionPostProcess
  59375. * @param name The name of the effect.
  59376. * @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.
  59377. * @param options The required width/height ratio to downsize to before computing the render pass.
  59378. * @param camera The camera to apply the render pass to.
  59379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59380. * @param engine The engine which the post process will be applied. (default: current engine)
  59381. * @param reusable If the post process can be reused on the same frame. (default: false)
  59382. * @param textureType Type of textures used when performing the post process. (default: 0)
  59383. * @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)
  59384. */
  59385. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59386. /**
  59387. * 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.
  59388. */
  59389. depthTexture: RenderTargetTexture;
  59390. }
  59391. }
  59392. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  59393. /** @hidden */
  59394. export var colorCorrectionPixelShader: {
  59395. name: string;
  59396. shader: string;
  59397. };
  59398. }
  59399. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  59400. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59401. import { Engine } from "babylonjs/Engines/engine";
  59402. import { Camera } from "babylonjs/Cameras/camera";
  59403. import "babylonjs/Shaders/colorCorrection.fragment";
  59404. /**
  59405. *
  59406. * This post-process allows the modification of rendered colors by using
  59407. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59408. *
  59409. * The object needs to be provided an url to a texture containing the color
  59410. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59411. * Use an image editing software to tweak the LUT to match your needs.
  59412. *
  59413. * For an example of a color LUT, see here:
  59414. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59415. * For explanations on color grading, see here:
  59416. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59417. *
  59418. */
  59419. export class ColorCorrectionPostProcess extends PostProcess {
  59420. private _colorTableTexture;
  59421. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59422. }
  59423. }
  59424. declare module "babylonjs/Shaders/convolution.fragment" {
  59425. /** @hidden */
  59426. export var convolutionPixelShader: {
  59427. name: string;
  59428. shader: string;
  59429. };
  59430. }
  59431. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  59432. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59433. import { Nullable } from "babylonjs/types";
  59434. import { Camera } from "babylonjs/Cameras/camera";
  59435. import { Engine } from "babylonjs/Engines/engine";
  59436. import "babylonjs/Shaders/convolution.fragment";
  59437. /**
  59438. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59439. * input texture to perform effects such as edge detection or sharpening
  59440. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59441. */
  59442. export class ConvolutionPostProcess extends PostProcess {
  59443. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59444. kernel: number[];
  59445. /**
  59446. * Creates a new instance ConvolutionPostProcess
  59447. * @param name The name of the effect.
  59448. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59449. * @param options The required width/height ratio to downsize to before computing the render pass.
  59450. * @param camera The camera to apply the render pass to.
  59451. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59452. * @param engine The engine which the post process will be applied. (default: current engine)
  59453. * @param reusable If the post process can be reused on the same frame. (default: false)
  59454. * @param textureType Type of textures used when performing the post process. (default: 0)
  59455. */
  59456. constructor(name: string,
  59457. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59458. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59459. /**
  59460. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59461. */
  59462. static EdgeDetect0Kernel: number[];
  59463. /**
  59464. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59465. */
  59466. static EdgeDetect1Kernel: number[];
  59467. /**
  59468. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59469. */
  59470. static EdgeDetect2Kernel: number[];
  59471. /**
  59472. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59473. */
  59474. static SharpenKernel: number[];
  59475. /**
  59476. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59477. */
  59478. static EmbossKernel: number[];
  59479. /**
  59480. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59481. */
  59482. static GaussianKernel: number[];
  59483. }
  59484. }
  59485. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  59486. import { Nullable } from "babylonjs/types";
  59487. import { Vector2 } from "babylonjs/Maths/math.vector";
  59488. import { Camera } from "babylonjs/Cameras/camera";
  59489. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59490. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59491. import { Engine } from "babylonjs/Engines/engine";
  59492. import { Scene } from "babylonjs/scene";
  59493. /**
  59494. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59495. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59496. * based on samples that have a large difference in distance than the center pixel.
  59497. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59498. */
  59499. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59500. direction: Vector2;
  59501. /**
  59502. * Creates a new instance CircleOfConfusionPostProcess
  59503. * @param name The name of the effect.
  59504. * @param scene The scene the effect belongs to.
  59505. * @param direction The direction the blur should be applied.
  59506. * @param kernel The size of the kernel used to blur.
  59507. * @param options The required width/height ratio to downsize to before computing the render pass.
  59508. * @param camera The camera to apply the render pass to.
  59509. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59510. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59512. * @param engine The engine which the post process will be applied. (default: current engine)
  59513. * @param reusable If the post process can be reused on the same frame. (default: false)
  59514. * @param textureType Type of textures used when performing the post process. (default: 0)
  59515. * @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)
  59516. */
  59517. 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);
  59518. }
  59519. }
  59520. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  59521. /** @hidden */
  59522. export var depthOfFieldMergePixelShader: {
  59523. name: string;
  59524. shader: string;
  59525. };
  59526. }
  59527. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  59528. import { Nullable } from "babylonjs/types";
  59529. import { Camera } from "babylonjs/Cameras/camera";
  59530. import { Effect } from "babylonjs/Materials/effect";
  59531. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59532. import { Engine } from "babylonjs/Engines/engine";
  59533. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  59534. /**
  59535. * Options to be set when merging outputs from the default pipeline.
  59536. */
  59537. export class DepthOfFieldMergePostProcessOptions {
  59538. /**
  59539. * The original image to merge on top of
  59540. */
  59541. originalFromInput: PostProcess;
  59542. /**
  59543. * Parameters to perform the merge of the depth of field effect
  59544. */
  59545. depthOfField?: {
  59546. circleOfConfusion: PostProcess;
  59547. blurSteps: Array<PostProcess>;
  59548. };
  59549. /**
  59550. * Parameters to perform the merge of bloom effect
  59551. */
  59552. bloom?: {
  59553. blurred: PostProcess;
  59554. weight: number;
  59555. };
  59556. }
  59557. /**
  59558. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59559. */
  59560. export class DepthOfFieldMergePostProcess extends PostProcess {
  59561. private blurSteps;
  59562. /**
  59563. * Creates a new instance of DepthOfFieldMergePostProcess
  59564. * @param name The name of the effect.
  59565. * @param originalFromInput Post process which's input will be used for the merge.
  59566. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59567. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59568. * @param options The required width/height ratio to downsize to before computing the render pass.
  59569. * @param camera The camera to apply the render pass to.
  59570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59571. * @param engine The engine which the post process will be applied. (default: current engine)
  59572. * @param reusable If the post process can be reused on the same frame. (default: false)
  59573. * @param textureType Type of textures used when performing the post process. (default: 0)
  59574. * @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)
  59575. */
  59576. 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);
  59577. /**
  59578. * Updates the effect with the current post process compile time values and recompiles the shader.
  59579. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59580. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59581. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59582. * @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
  59583. * @param onCompiled Called when the shader has been compiled.
  59584. * @param onError Called if there is an error when compiling a shader.
  59585. */
  59586. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59587. }
  59588. }
  59589. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  59590. import { Nullable } from "babylonjs/types";
  59591. import { Camera } from "babylonjs/Cameras/camera";
  59592. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59593. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59594. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59595. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59596. import { Scene } from "babylonjs/scene";
  59597. /**
  59598. * Specifies the level of max blur that should be applied when using the depth of field effect
  59599. */
  59600. export enum DepthOfFieldEffectBlurLevel {
  59601. /**
  59602. * Subtle blur
  59603. */
  59604. Low = 0,
  59605. /**
  59606. * Medium blur
  59607. */
  59608. Medium = 1,
  59609. /**
  59610. * Large blur
  59611. */
  59612. High = 2
  59613. }
  59614. /**
  59615. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59616. */
  59617. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59618. private _circleOfConfusion;
  59619. /**
  59620. * @hidden Internal, blurs from high to low
  59621. */
  59622. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59623. private _depthOfFieldBlurY;
  59624. private _dofMerge;
  59625. /**
  59626. * @hidden Internal post processes in depth of field effect
  59627. */
  59628. _effects: Array<PostProcess>;
  59629. /**
  59630. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59631. */
  59632. focalLength: number;
  59633. /**
  59634. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59635. */
  59636. fStop: number;
  59637. /**
  59638. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59639. */
  59640. focusDistance: number;
  59641. /**
  59642. * 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.
  59643. */
  59644. lensSize: number;
  59645. /**
  59646. * Creates a new instance DepthOfFieldEffect
  59647. * @param scene The scene the effect belongs to.
  59648. * @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.
  59649. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59650. * @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)
  59651. */
  59652. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59653. /**
  59654. * Get the current class name of the current effet
  59655. * @returns "DepthOfFieldEffect"
  59656. */
  59657. getClassName(): string;
  59658. /**
  59659. * 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.
  59660. */
  59661. depthTexture: RenderTargetTexture;
  59662. /**
  59663. * Disposes each of the internal effects for a given camera.
  59664. * @param camera The camera to dispose the effect on.
  59665. */
  59666. disposeEffects(camera: Camera): void;
  59667. /**
  59668. * @hidden Internal
  59669. */
  59670. _updateEffects(): void;
  59671. /**
  59672. * Internal
  59673. * @returns if all the contained post processes are ready.
  59674. * @hidden
  59675. */
  59676. _isReady(): boolean;
  59677. }
  59678. }
  59679. declare module "babylonjs/Shaders/displayPass.fragment" {
  59680. /** @hidden */
  59681. export var displayPassPixelShader: {
  59682. name: string;
  59683. shader: string;
  59684. };
  59685. }
  59686. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  59687. import { Nullable } from "babylonjs/types";
  59688. import { Camera } from "babylonjs/Cameras/camera";
  59689. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59690. import { Engine } from "babylonjs/Engines/engine";
  59691. import "babylonjs/Shaders/displayPass.fragment";
  59692. /**
  59693. * DisplayPassPostProcess which produces an output the same as it's input
  59694. */
  59695. export class DisplayPassPostProcess extends PostProcess {
  59696. /**
  59697. * Creates the DisplayPassPostProcess
  59698. * @param name The name of the effect.
  59699. * @param options The required width/height ratio to downsize to before computing the render pass.
  59700. * @param camera The camera to apply the render pass to.
  59701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59702. * @param engine The engine which the post process will be applied. (default: current engine)
  59703. * @param reusable If the post process can be reused on the same frame. (default: false)
  59704. */
  59705. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59706. }
  59707. }
  59708. declare module "babylonjs/Shaders/filter.fragment" {
  59709. /** @hidden */
  59710. export var filterPixelShader: {
  59711. name: string;
  59712. shader: string;
  59713. };
  59714. }
  59715. declare module "babylonjs/PostProcesses/filterPostProcess" {
  59716. import { Nullable } from "babylonjs/types";
  59717. import { Matrix } from "babylonjs/Maths/math.vector";
  59718. import { Camera } from "babylonjs/Cameras/camera";
  59719. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59720. import { Engine } from "babylonjs/Engines/engine";
  59721. import "babylonjs/Shaders/filter.fragment";
  59722. /**
  59723. * Applies a kernel filter to the image
  59724. */
  59725. export class FilterPostProcess extends PostProcess {
  59726. /** The matrix to be applied to the image */
  59727. kernelMatrix: Matrix;
  59728. /**
  59729. *
  59730. * @param name The name of the effect.
  59731. * @param kernelMatrix The matrix to be applied to the image
  59732. * @param options The required width/height ratio to downsize to before computing the render pass.
  59733. * @param camera The camera to apply the render pass to.
  59734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59735. * @param engine The engine which the post process will be applied. (default: current engine)
  59736. * @param reusable If the post process can be reused on the same frame. (default: false)
  59737. */
  59738. constructor(name: string,
  59739. /** The matrix to be applied to the image */
  59740. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59741. }
  59742. }
  59743. declare module "babylonjs/Shaders/fxaa.fragment" {
  59744. /** @hidden */
  59745. export var fxaaPixelShader: {
  59746. name: string;
  59747. shader: string;
  59748. };
  59749. }
  59750. declare module "babylonjs/Shaders/fxaa.vertex" {
  59751. /** @hidden */
  59752. export var fxaaVertexShader: {
  59753. name: string;
  59754. shader: string;
  59755. };
  59756. }
  59757. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  59758. import { Nullable } from "babylonjs/types";
  59759. import { Camera } from "babylonjs/Cameras/camera";
  59760. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59761. import { Engine } from "babylonjs/Engines/engine";
  59762. import "babylonjs/Shaders/fxaa.fragment";
  59763. import "babylonjs/Shaders/fxaa.vertex";
  59764. /**
  59765. * Fxaa post process
  59766. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59767. */
  59768. export class FxaaPostProcess extends PostProcess {
  59769. /** @hidden */
  59770. texelWidth: number;
  59771. /** @hidden */
  59772. texelHeight: number;
  59773. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59774. private _getDefines;
  59775. }
  59776. }
  59777. declare module "babylonjs/Shaders/grain.fragment" {
  59778. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59779. /** @hidden */
  59780. export var grainPixelShader: {
  59781. name: string;
  59782. shader: string;
  59783. };
  59784. }
  59785. declare module "babylonjs/PostProcesses/grainPostProcess" {
  59786. import { Nullable } from "babylonjs/types";
  59787. import { Camera } from "babylonjs/Cameras/camera";
  59788. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59789. import { Engine } from "babylonjs/Engines/engine";
  59790. import "babylonjs/Shaders/grain.fragment";
  59791. /**
  59792. * The GrainPostProcess adds noise to the image at mid luminance levels
  59793. */
  59794. export class GrainPostProcess extends PostProcess {
  59795. /**
  59796. * The intensity of the grain added (default: 30)
  59797. */
  59798. intensity: number;
  59799. /**
  59800. * If the grain should be randomized on every frame
  59801. */
  59802. animated: boolean;
  59803. /**
  59804. * Creates a new instance of @see GrainPostProcess
  59805. * @param name The name of the effect.
  59806. * @param options The required width/height ratio to downsize to before computing the render pass.
  59807. * @param camera The camera to apply the render pass to.
  59808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59809. * @param engine The engine which the post process will be applied. (default: current engine)
  59810. * @param reusable If the post process can be reused on the same frame. (default: false)
  59811. * @param textureType Type of textures used when performing the post process. (default: 0)
  59812. * @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)
  59813. */
  59814. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59815. }
  59816. }
  59817. declare module "babylonjs/Shaders/highlights.fragment" {
  59818. /** @hidden */
  59819. export var highlightsPixelShader: {
  59820. name: string;
  59821. shader: string;
  59822. };
  59823. }
  59824. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  59825. import { Nullable } from "babylonjs/types";
  59826. import { Camera } from "babylonjs/Cameras/camera";
  59827. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59828. import { Engine } from "babylonjs/Engines/engine";
  59829. import "babylonjs/Shaders/highlights.fragment";
  59830. /**
  59831. * Extracts highlights from the image
  59832. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59833. */
  59834. export class HighlightsPostProcess extends PostProcess {
  59835. /**
  59836. * Extracts highlights from the image
  59837. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59838. * @param name The name of the effect.
  59839. * @param options The required width/height ratio to downsize to before computing the render pass.
  59840. * @param camera The camera to apply the render pass to.
  59841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59842. * @param engine The engine which the post process will be applied. (default: current engine)
  59843. * @param reusable If the post process can be reused on the same frame. (default: false)
  59844. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59845. */
  59846. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59847. }
  59848. }
  59849. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  59850. /** @hidden */
  59851. export var mrtFragmentDeclaration: {
  59852. name: string;
  59853. shader: string;
  59854. };
  59855. }
  59856. declare module "babylonjs/Shaders/geometry.fragment" {
  59857. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  59858. /** @hidden */
  59859. export var geometryPixelShader: {
  59860. name: string;
  59861. shader: string;
  59862. };
  59863. }
  59864. declare module "babylonjs/Shaders/geometry.vertex" {
  59865. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59866. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59867. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59868. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59869. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59870. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59871. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59872. /** @hidden */
  59873. export var geometryVertexShader: {
  59874. name: string;
  59875. shader: string;
  59876. };
  59877. }
  59878. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  59879. import { Matrix } from "babylonjs/Maths/math.vector";
  59880. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59881. import { Mesh } from "babylonjs/Meshes/mesh";
  59882. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  59883. import { Effect } from "babylonjs/Materials/effect";
  59884. import { Scene } from "babylonjs/scene";
  59885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59886. import "babylonjs/Shaders/geometry.fragment";
  59887. import "babylonjs/Shaders/geometry.vertex";
  59888. /** @hidden */
  59889. interface ISavedTransformationMatrix {
  59890. world: Matrix;
  59891. viewProjection: Matrix;
  59892. }
  59893. /**
  59894. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59895. */
  59896. export class GeometryBufferRenderer {
  59897. /**
  59898. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59899. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59900. */
  59901. static readonly POSITION_TEXTURE_TYPE: number;
  59902. /**
  59903. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59904. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59905. */
  59906. static readonly VELOCITY_TEXTURE_TYPE: number;
  59907. /**
  59908. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59909. * in order to compute objects velocities when enableVelocity is set to "true"
  59910. * @hidden
  59911. */
  59912. _previousTransformationMatrices: {
  59913. [index: number]: ISavedTransformationMatrix;
  59914. };
  59915. /**
  59916. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59917. * in order to compute objects velocities when enableVelocity is set to "true"
  59918. * @hidden
  59919. */
  59920. _previousBonesTransformationMatrices: {
  59921. [index: number]: Float32Array;
  59922. };
  59923. /**
  59924. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59925. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59926. */
  59927. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59928. private _scene;
  59929. private _multiRenderTarget;
  59930. private _ratio;
  59931. private _enablePosition;
  59932. private _enableVelocity;
  59933. private _positionIndex;
  59934. private _velocityIndex;
  59935. protected _effect: Effect;
  59936. protected _cachedDefines: string;
  59937. /**
  59938. * Set the render list (meshes to be rendered) used in the G buffer.
  59939. */
  59940. renderList: Mesh[];
  59941. /**
  59942. * Gets wether or not G buffer are supported by the running hardware.
  59943. * This requires draw buffer supports
  59944. */
  59945. readonly isSupported: boolean;
  59946. /**
  59947. * Returns the index of the given texture type in the G-Buffer textures array
  59948. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59949. * @returns the index of the given texture type in the G-Buffer textures array
  59950. */
  59951. getTextureIndex(textureType: number): number;
  59952. /**
  59953. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59954. */
  59955. /**
  59956. * Sets whether or not objects positions are enabled for the G buffer.
  59957. */
  59958. enablePosition: boolean;
  59959. /**
  59960. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59961. */
  59962. /**
  59963. * Sets wether or not objects velocities are enabled for the G buffer.
  59964. */
  59965. enableVelocity: boolean;
  59966. /**
  59967. * Gets the scene associated with the buffer.
  59968. */
  59969. readonly scene: Scene;
  59970. /**
  59971. * Gets the ratio used by the buffer during its creation.
  59972. * How big is the buffer related to the main canvas.
  59973. */
  59974. readonly ratio: number;
  59975. /** @hidden */
  59976. static _SceneComponentInitialization: (scene: Scene) => void;
  59977. /**
  59978. * Creates a new G Buffer for the scene
  59979. * @param scene The scene the buffer belongs to
  59980. * @param ratio How big is the buffer related to the main canvas.
  59981. */
  59982. constructor(scene: Scene, ratio?: number);
  59983. /**
  59984. * Checks wether everything is ready to render a submesh to the G buffer.
  59985. * @param subMesh the submesh to check readiness for
  59986. * @param useInstances is the mesh drawn using instance or not
  59987. * @returns true if ready otherwise false
  59988. */
  59989. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59990. /**
  59991. * Gets the current underlying G Buffer.
  59992. * @returns the buffer
  59993. */
  59994. getGBuffer(): MultiRenderTarget;
  59995. /**
  59996. * Gets the number of samples used to render the buffer (anti aliasing).
  59997. */
  59998. /**
  59999. * Sets the number of samples used to render the buffer (anti aliasing).
  60000. */
  60001. samples: number;
  60002. /**
  60003. * Disposes the renderer and frees up associated resources.
  60004. */
  60005. dispose(): void;
  60006. protected _createRenderTargets(): void;
  60007. private _copyBonesTransformationMatrices;
  60008. }
  60009. }
  60010. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  60011. import { Nullable } from "babylonjs/types";
  60012. import { Scene } from "babylonjs/scene";
  60013. import { ISceneComponent } from "babylonjs/sceneComponent";
  60014. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  60015. module "babylonjs/scene" {
  60016. interface Scene {
  60017. /** @hidden (Backing field) */
  60018. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60019. /**
  60020. * Gets or Sets the current geometry buffer associated to the scene.
  60021. */
  60022. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60023. /**
  60024. * Enables a GeometryBufferRender and associates it with the scene
  60025. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60026. * @returns the GeometryBufferRenderer
  60027. */
  60028. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60029. /**
  60030. * Disables the GeometryBufferRender associated with the scene
  60031. */
  60032. disableGeometryBufferRenderer(): void;
  60033. }
  60034. }
  60035. /**
  60036. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60037. * in several rendering techniques.
  60038. */
  60039. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60040. /**
  60041. * The component name helpful to identify the component in the list of scene components.
  60042. */
  60043. readonly name: string;
  60044. /**
  60045. * The scene the component belongs to.
  60046. */
  60047. scene: Scene;
  60048. /**
  60049. * Creates a new instance of the component for the given scene
  60050. * @param scene Defines the scene to register the component in
  60051. */
  60052. constructor(scene: Scene);
  60053. /**
  60054. * Registers the component in a given scene
  60055. */
  60056. register(): void;
  60057. /**
  60058. * Rebuilds the elements related to this component in case of
  60059. * context lost for instance.
  60060. */
  60061. rebuild(): void;
  60062. /**
  60063. * Disposes the component and the associated ressources
  60064. */
  60065. dispose(): void;
  60066. private _gatherRenderTargets;
  60067. }
  60068. }
  60069. declare module "babylonjs/Shaders/motionBlur.fragment" {
  60070. /** @hidden */
  60071. export var motionBlurPixelShader: {
  60072. name: string;
  60073. shader: string;
  60074. };
  60075. }
  60076. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  60077. import { Nullable } from "babylonjs/types";
  60078. import { Camera } from "babylonjs/Cameras/camera";
  60079. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60080. import { Scene } from "babylonjs/scene";
  60081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60082. import "babylonjs/Animations/animatable";
  60083. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60084. import "babylonjs/Shaders/motionBlur.fragment";
  60085. import { Engine } from "babylonjs/Engines/engine";
  60086. /**
  60087. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60088. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60089. * As an example, all you have to do is to create the post-process:
  60090. * var mb = new BABYLON.MotionBlurPostProcess(
  60091. * 'mb', // The name of the effect.
  60092. * scene, // The scene containing the objects to blur according to their velocity.
  60093. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60094. * camera // The camera to apply the render pass to.
  60095. * );
  60096. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60097. */
  60098. export class MotionBlurPostProcess extends PostProcess {
  60099. /**
  60100. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60101. */
  60102. motionStrength: number;
  60103. /**
  60104. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60105. */
  60106. /**
  60107. * Sets the number of iterations to be used for motion blur quality
  60108. */
  60109. motionBlurSamples: number;
  60110. private _motionBlurSamples;
  60111. private _geometryBufferRenderer;
  60112. /**
  60113. * Creates a new instance MotionBlurPostProcess
  60114. * @param name The name of the effect.
  60115. * @param scene The scene containing the objects to blur according to their velocity.
  60116. * @param options The required width/height ratio to downsize to before computing the render pass.
  60117. * @param camera The camera to apply the render pass to.
  60118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60119. * @param engine The engine which the post process will be applied. (default: current engine)
  60120. * @param reusable If the post process can be reused on the same frame. (default: false)
  60121. * @param textureType Type of textures used when performing the post process. (default: 0)
  60122. * @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)
  60123. */
  60124. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60125. /**
  60126. * Excludes the given skinned mesh from computing bones velocities.
  60127. * 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.
  60128. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60129. */
  60130. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60131. /**
  60132. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60133. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60134. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60135. */
  60136. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60137. /**
  60138. * Disposes the post process.
  60139. * @param camera The camera to dispose the post process on.
  60140. */
  60141. dispose(camera?: Camera): void;
  60142. }
  60143. }
  60144. declare module "babylonjs/Shaders/refraction.fragment" {
  60145. /** @hidden */
  60146. export var refractionPixelShader: {
  60147. name: string;
  60148. shader: string;
  60149. };
  60150. }
  60151. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  60152. import { Color3 } from "babylonjs/Maths/math.color";
  60153. import { Camera } from "babylonjs/Cameras/camera";
  60154. import { Texture } from "babylonjs/Materials/Textures/texture";
  60155. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60156. import { Engine } from "babylonjs/Engines/engine";
  60157. import "babylonjs/Shaders/refraction.fragment";
  60158. /**
  60159. * Post process which applies a refractin texture
  60160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60161. */
  60162. export class RefractionPostProcess extends PostProcess {
  60163. /** the base color of the refraction (used to taint the rendering) */
  60164. color: Color3;
  60165. /** simulated refraction depth */
  60166. depth: number;
  60167. /** the coefficient of the base color (0 to remove base color tainting) */
  60168. colorLevel: number;
  60169. private _refTexture;
  60170. private _ownRefractionTexture;
  60171. /**
  60172. * Gets or sets the refraction texture
  60173. * Please note that you are responsible for disposing the texture if you set it manually
  60174. */
  60175. refractionTexture: Texture;
  60176. /**
  60177. * Initializes the RefractionPostProcess
  60178. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60179. * @param name The name of the effect.
  60180. * @param refractionTextureUrl Url of the refraction texture to use
  60181. * @param color the base color of the refraction (used to taint the rendering)
  60182. * @param depth simulated refraction depth
  60183. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60184. * @param camera The camera to apply the render pass to.
  60185. * @param options The required width/height ratio to downsize to before computing the render pass.
  60186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60187. * @param engine The engine which the post process will be applied. (default: current engine)
  60188. * @param reusable If the post process can be reused on the same frame. (default: false)
  60189. */
  60190. constructor(name: string, refractionTextureUrl: string,
  60191. /** the base color of the refraction (used to taint the rendering) */
  60192. color: Color3,
  60193. /** simulated refraction depth */
  60194. depth: number,
  60195. /** the coefficient of the base color (0 to remove base color tainting) */
  60196. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60197. /**
  60198. * Disposes of the post process
  60199. * @param camera Camera to dispose post process on
  60200. */
  60201. dispose(camera: Camera): void;
  60202. }
  60203. }
  60204. declare module "babylonjs/Shaders/sharpen.fragment" {
  60205. /** @hidden */
  60206. export var sharpenPixelShader: {
  60207. name: string;
  60208. shader: string;
  60209. };
  60210. }
  60211. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  60212. import { Nullable } from "babylonjs/types";
  60213. import { Camera } from "babylonjs/Cameras/camera";
  60214. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60215. import "babylonjs/Shaders/sharpen.fragment";
  60216. import { Engine } from "babylonjs/Engines/engine";
  60217. /**
  60218. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60219. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60220. */
  60221. export class SharpenPostProcess extends PostProcess {
  60222. /**
  60223. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60224. */
  60225. colorAmount: number;
  60226. /**
  60227. * How much sharpness should be applied (default: 0.3)
  60228. */
  60229. edgeAmount: number;
  60230. /**
  60231. * Creates a new instance ConvolutionPostProcess
  60232. * @param name The name of the effect.
  60233. * @param options The required width/height ratio to downsize to before computing the render pass.
  60234. * @param camera The camera to apply the render pass to.
  60235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60236. * @param engine The engine which the post process will be applied. (default: current engine)
  60237. * @param reusable If the post process can be reused on the same frame. (default: false)
  60238. * @param textureType Type of textures used when performing the post process. (default: 0)
  60239. * @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)
  60240. */
  60241. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60242. }
  60243. }
  60244. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  60245. import { Nullable } from "babylonjs/types";
  60246. import { Camera } from "babylonjs/Cameras/camera";
  60247. import { Engine } from "babylonjs/Engines/engine";
  60248. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60249. import { IInspectable } from "babylonjs/Misc/iInspectable";
  60250. /**
  60251. * PostProcessRenderPipeline
  60252. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60253. */
  60254. export class PostProcessRenderPipeline {
  60255. private engine;
  60256. private _renderEffects;
  60257. private _renderEffectsForIsolatedPass;
  60258. /**
  60259. * List of inspectable custom properties (used by the Inspector)
  60260. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60261. */
  60262. inspectableCustomProperties: IInspectable[];
  60263. /**
  60264. * @hidden
  60265. */
  60266. protected _cameras: Camera[];
  60267. /** @hidden */
  60268. _name: string;
  60269. /**
  60270. * Gets pipeline name
  60271. */
  60272. readonly name: string;
  60273. /**
  60274. * Initializes a PostProcessRenderPipeline
  60275. * @param engine engine to add the pipeline to
  60276. * @param name name of the pipeline
  60277. */
  60278. constructor(engine: Engine, name: string);
  60279. /**
  60280. * Gets the class name
  60281. * @returns "PostProcessRenderPipeline"
  60282. */
  60283. getClassName(): string;
  60284. /**
  60285. * If all the render effects in the pipeline are supported
  60286. */
  60287. readonly isSupported: boolean;
  60288. /**
  60289. * Adds an effect to the pipeline
  60290. * @param renderEffect the effect to add
  60291. */
  60292. addEffect(renderEffect: PostProcessRenderEffect): void;
  60293. /** @hidden */
  60294. _rebuild(): void;
  60295. /** @hidden */
  60296. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60297. /** @hidden */
  60298. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60299. /** @hidden */
  60300. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60301. /** @hidden */
  60302. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60303. /** @hidden */
  60304. _attachCameras(cameras: Camera, unique: boolean): void;
  60305. /** @hidden */
  60306. _attachCameras(cameras: Camera[], unique: boolean): void;
  60307. /** @hidden */
  60308. _detachCameras(cameras: Camera): void;
  60309. /** @hidden */
  60310. _detachCameras(cameras: Nullable<Camera[]>): void;
  60311. /** @hidden */
  60312. _update(): void;
  60313. /** @hidden */
  60314. _reset(): void;
  60315. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60316. /**
  60317. * Disposes of the pipeline
  60318. */
  60319. dispose(): void;
  60320. }
  60321. }
  60322. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  60323. import { Camera } from "babylonjs/Cameras/camera";
  60324. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60325. /**
  60326. * PostProcessRenderPipelineManager class
  60327. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60328. */
  60329. export class PostProcessRenderPipelineManager {
  60330. private _renderPipelines;
  60331. /**
  60332. * Initializes a PostProcessRenderPipelineManager
  60333. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60334. */
  60335. constructor();
  60336. /**
  60337. * Gets the list of supported render pipelines
  60338. */
  60339. readonly supportedPipelines: PostProcessRenderPipeline[];
  60340. /**
  60341. * Adds a pipeline to the manager
  60342. * @param renderPipeline The pipeline to add
  60343. */
  60344. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60345. /**
  60346. * Attaches a camera to the pipeline
  60347. * @param renderPipelineName The name of the pipeline to attach to
  60348. * @param cameras the camera to attach
  60349. * @param unique if the camera can be attached multiple times to the pipeline
  60350. */
  60351. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60352. /**
  60353. * Detaches a camera from the pipeline
  60354. * @param renderPipelineName The name of the pipeline to detach from
  60355. * @param cameras the camera to detach
  60356. */
  60357. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60358. /**
  60359. * Enables an effect by name on a pipeline
  60360. * @param renderPipelineName the name of the pipeline to enable the effect in
  60361. * @param renderEffectName the name of the effect to enable
  60362. * @param cameras the cameras that the effect should be enabled on
  60363. */
  60364. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60365. /**
  60366. * Disables an effect by name on a pipeline
  60367. * @param renderPipelineName the name of the pipeline to disable the effect in
  60368. * @param renderEffectName the name of the effect to disable
  60369. * @param cameras the cameras that the effect should be disabled on
  60370. */
  60371. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60372. /**
  60373. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60374. */
  60375. update(): void;
  60376. /** @hidden */
  60377. _rebuild(): void;
  60378. /**
  60379. * Disposes of the manager and pipelines
  60380. */
  60381. dispose(): void;
  60382. }
  60383. }
  60384. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  60385. import { ISceneComponent } from "babylonjs/sceneComponent";
  60386. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60387. import { Scene } from "babylonjs/scene";
  60388. module "babylonjs/scene" {
  60389. interface Scene {
  60390. /** @hidden (Backing field) */
  60391. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60392. /**
  60393. * Gets the postprocess render pipeline manager
  60394. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60395. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60396. */
  60397. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60398. }
  60399. }
  60400. /**
  60401. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60402. */
  60403. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60404. /**
  60405. * The component name helpfull to identify the component in the list of scene components.
  60406. */
  60407. readonly name: string;
  60408. /**
  60409. * The scene the component belongs to.
  60410. */
  60411. scene: Scene;
  60412. /**
  60413. * Creates a new instance of the component for the given scene
  60414. * @param scene Defines the scene to register the component in
  60415. */
  60416. constructor(scene: Scene);
  60417. /**
  60418. * Registers the component in a given scene
  60419. */
  60420. register(): void;
  60421. /**
  60422. * Rebuilds the elements related to this component in case of
  60423. * context lost for instance.
  60424. */
  60425. rebuild(): void;
  60426. /**
  60427. * Disposes the component and the associated ressources
  60428. */
  60429. dispose(): void;
  60430. private _gatherRenderTargets;
  60431. }
  60432. }
  60433. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  60434. import { Nullable } from "babylonjs/types";
  60435. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60436. import { Camera } from "babylonjs/Cameras/camera";
  60437. import { IDisposable } from "babylonjs/scene";
  60438. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  60439. import { Scene } from "babylonjs/scene";
  60440. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  60441. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60442. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60443. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  60444. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  60445. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60446. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  60447. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60448. import { Animation } from "babylonjs/Animations/animation";
  60449. /**
  60450. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60451. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60452. */
  60453. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60454. private _scene;
  60455. private _camerasToBeAttached;
  60456. /**
  60457. * ID of the sharpen post process,
  60458. */
  60459. private readonly SharpenPostProcessId;
  60460. /**
  60461. * @ignore
  60462. * ID of the image processing post process;
  60463. */
  60464. readonly ImageProcessingPostProcessId: string;
  60465. /**
  60466. * @ignore
  60467. * ID of the Fast Approximate Anti-Aliasing post process;
  60468. */
  60469. readonly FxaaPostProcessId: string;
  60470. /**
  60471. * ID of the chromatic aberration post process,
  60472. */
  60473. private readonly ChromaticAberrationPostProcessId;
  60474. /**
  60475. * ID of the grain post process
  60476. */
  60477. private readonly GrainPostProcessId;
  60478. /**
  60479. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60480. */
  60481. sharpen: SharpenPostProcess;
  60482. private _sharpenEffect;
  60483. private bloom;
  60484. /**
  60485. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60486. */
  60487. depthOfField: DepthOfFieldEffect;
  60488. /**
  60489. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60490. */
  60491. fxaa: FxaaPostProcess;
  60492. /**
  60493. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60494. */
  60495. imageProcessing: ImageProcessingPostProcess;
  60496. /**
  60497. * Chromatic aberration post process which will shift rgb colors in the image
  60498. */
  60499. chromaticAberration: ChromaticAberrationPostProcess;
  60500. private _chromaticAberrationEffect;
  60501. /**
  60502. * Grain post process which add noise to the image
  60503. */
  60504. grain: GrainPostProcess;
  60505. private _grainEffect;
  60506. /**
  60507. * Glow post process which adds a glow to emissive areas of the image
  60508. */
  60509. private _glowLayer;
  60510. /**
  60511. * Animations which can be used to tweak settings over a period of time
  60512. */
  60513. animations: Animation[];
  60514. private _imageProcessingConfigurationObserver;
  60515. private _sharpenEnabled;
  60516. private _bloomEnabled;
  60517. private _depthOfFieldEnabled;
  60518. private _depthOfFieldBlurLevel;
  60519. private _fxaaEnabled;
  60520. private _imageProcessingEnabled;
  60521. private _defaultPipelineTextureType;
  60522. private _bloomScale;
  60523. private _chromaticAberrationEnabled;
  60524. private _grainEnabled;
  60525. private _buildAllowed;
  60526. /**
  60527. * Gets active scene
  60528. */
  60529. readonly scene: Scene;
  60530. /**
  60531. * Enable or disable the sharpen process from the pipeline
  60532. */
  60533. sharpenEnabled: boolean;
  60534. private _resizeObserver;
  60535. private _hardwareScaleLevel;
  60536. private _bloomKernel;
  60537. /**
  60538. * Specifies the size of the bloom blur kernel, relative to the final output size
  60539. */
  60540. bloomKernel: number;
  60541. /**
  60542. * Specifies the weight of the bloom in the final rendering
  60543. */
  60544. private _bloomWeight;
  60545. /**
  60546. * Specifies the luma threshold for the area that will be blurred by the bloom
  60547. */
  60548. private _bloomThreshold;
  60549. private _hdr;
  60550. /**
  60551. * The strength of the bloom.
  60552. */
  60553. bloomWeight: number;
  60554. /**
  60555. * The strength of the bloom.
  60556. */
  60557. bloomThreshold: number;
  60558. /**
  60559. * The scale of the bloom, lower value will provide better performance.
  60560. */
  60561. bloomScale: number;
  60562. /**
  60563. * Enable or disable the bloom from the pipeline
  60564. */
  60565. bloomEnabled: boolean;
  60566. private _rebuildBloom;
  60567. /**
  60568. * If the depth of field is enabled.
  60569. */
  60570. depthOfFieldEnabled: boolean;
  60571. /**
  60572. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60573. */
  60574. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60575. /**
  60576. * If the anti aliasing is enabled.
  60577. */
  60578. fxaaEnabled: boolean;
  60579. private _samples;
  60580. /**
  60581. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60582. */
  60583. samples: number;
  60584. /**
  60585. * If image processing is enabled.
  60586. */
  60587. imageProcessingEnabled: boolean;
  60588. /**
  60589. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60590. */
  60591. glowLayerEnabled: boolean;
  60592. /**
  60593. * Gets the glow layer (or null if not defined)
  60594. */
  60595. readonly glowLayer: Nullable<GlowLayer>;
  60596. /**
  60597. * Enable or disable the chromaticAberration process from the pipeline
  60598. */
  60599. chromaticAberrationEnabled: boolean;
  60600. /**
  60601. * Enable or disable the grain process from the pipeline
  60602. */
  60603. grainEnabled: boolean;
  60604. /**
  60605. * @constructor
  60606. * @param name - The rendering pipeline name (default: "")
  60607. * @param hdr - If high dynamic range textures should be used (default: true)
  60608. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60609. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60610. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60611. */
  60612. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60613. /**
  60614. * Get the class name
  60615. * @returns "DefaultRenderingPipeline"
  60616. */
  60617. getClassName(): string;
  60618. /**
  60619. * Force the compilation of the entire pipeline.
  60620. */
  60621. prepare(): void;
  60622. private _hasCleared;
  60623. private _prevPostProcess;
  60624. private _prevPrevPostProcess;
  60625. private _setAutoClearAndTextureSharing;
  60626. private _depthOfFieldSceneObserver;
  60627. private _buildPipeline;
  60628. private _disposePostProcesses;
  60629. /**
  60630. * Adds a camera to the pipeline
  60631. * @param camera the camera to be added
  60632. */
  60633. addCamera(camera: Camera): void;
  60634. /**
  60635. * Removes a camera from the pipeline
  60636. * @param camera the camera to remove
  60637. */
  60638. removeCamera(camera: Camera): void;
  60639. /**
  60640. * Dispose of the pipeline and stop all post processes
  60641. */
  60642. dispose(): void;
  60643. /**
  60644. * Serialize the rendering pipeline (Used when exporting)
  60645. * @returns the serialized object
  60646. */
  60647. serialize(): any;
  60648. /**
  60649. * Parse the serialized pipeline
  60650. * @param source Source pipeline.
  60651. * @param scene The scene to load the pipeline to.
  60652. * @param rootUrl The URL of the serialized pipeline.
  60653. * @returns An instantiated pipeline from the serialized object.
  60654. */
  60655. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60656. }
  60657. }
  60658. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  60659. /** @hidden */
  60660. export var lensHighlightsPixelShader: {
  60661. name: string;
  60662. shader: string;
  60663. };
  60664. }
  60665. declare module "babylonjs/Shaders/depthOfField.fragment" {
  60666. /** @hidden */
  60667. export var depthOfFieldPixelShader: {
  60668. name: string;
  60669. shader: string;
  60670. };
  60671. }
  60672. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  60673. import { Camera } from "babylonjs/Cameras/camera";
  60674. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60675. import { Scene } from "babylonjs/scene";
  60676. import "babylonjs/Shaders/chromaticAberration.fragment";
  60677. import "babylonjs/Shaders/lensHighlights.fragment";
  60678. import "babylonjs/Shaders/depthOfField.fragment";
  60679. /**
  60680. * BABYLON.JS Chromatic Aberration GLSL Shader
  60681. * Author: Olivier Guyot
  60682. * Separates very slightly R, G and B colors on the edges of the screen
  60683. * Inspired by Francois Tarlier & Martins Upitis
  60684. */
  60685. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60686. /**
  60687. * @ignore
  60688. * The chromatic aberration PostProcess id in the pipeline
  60689. */
  60690. LensChromaticAberrationEffect: string;
  60691. /**
  60692. * @ignore
  60693. * The highlights enhancing PostProcess id in the pipeline
  60694. */
  60695. HighlightsEnhancingEffect: string;
  60696. /**
  60697. * @ignore
  60698. * The depth-of-field PostProcess id in the pipeline
  60699. */
  60700. LensDepthOfFieldEffect: string;
  60701. private _scene;
  60702. private _depthTexture;
  60703. private _grainTexture;
  60704. private _chromaticAberrationPostProcess;
  60705. private _highlightsPostProcess;
  60706. private _depthOfFieldPostProcess;
  60707. private _edgeBlur;
  60708. private _grainAmount;
  60709. private _chromaticAberration;
  60710. private _distortion;
  60711. private _highlightsGain;
  60712. private _highlightsThreshold;
  60713. private _dofDistance;
  60714. private _dofAperture;
  60715. private _dofDarken;
  60716. private _dofPentagon;
  60717. private _blurNoise;
  60718. /**
  60719. * @constructor
  60720. *
  60721. * Effect parameters are as follow:
  60722. * {
  60723. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60724. * edge_blur: number; // from 0 to x (1 for realism)
  60725. * distortion: number; // from 0 to x (1 for realism)
  60726. * grain_amount: number; // from 0 to 1
  60727. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60728. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60729. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60730. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60731. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60732. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60733. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60734. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60735. * }
  60736. * Note: if an effect parameter is unset, effect is disabled
  60737. *
  60738. * @param name The rendering pipeline name
  60739. * @param parameters - An object containing all parameters (see above)
  60740. * @param scene The scene linked to this pipeline
  60741. * @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)
  60742. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60743. */
  60744. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60745. /**
  60746. * Get the class name
  60747. * @returns "LensRenderingPipeline"
  60748. */
  60749. getClassName(): string;
  60750. /**
  60751. * Gets associated scene
  60752. */
  60753. readonly scene: Scene;
  60754. /**
  60755. * Gets or sets the edge blur
  60756. */
  60757. edgeBlur: number;
  60758. /**
  60759. * Gets or sets the grain amount
  60760. */
  60761. grainAmount: number;
  60762. /**
  60763. * Gets or sets the chromatic aberration amount
  60764. */
  60765. chromaticAberration: number;
  60766. /**
  60767. * Gets or sets the depth of field aperture
  60768. */
  60769. dofAperture: number;
  60770. /**
  60771. * Gets or sets the edge distortion
  60772. */
  60773. edgeDistortion: number;
  60774. /**
  60775. * Gets or sets the depth of field distortion
  60776. */
  60777. dofDistortion: number;
  60778. /**
  60779. * Gets or sets the darken out of focus amount
  60780. */
  60781. darkenOutOfFocus: number;
  60782. /**
  60783. * Gets or sets a boolean indicating if blur noise is enabled
  60784. */
  60785. blurNoise: boolean;
  60786. /**
  60787. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60788. */
  60789. pentagonBokeh: boolean;
  60790. /**
  60791. * Gets or sets the highlight grain amount
  60792. */
  60793. highlightsGain: number;
  60794. /**
  60795. * Gets or sets the highlight threshold
  60796. */
  60797. highlightsThreshold: number;
  60798. /**
  60799. * Sets the amount of blur at the edges
  60800. * @param amount blur amount
  60801. */
  60802. setEdgeBlur(amount: number): void;
  60803. /**
  60804. * Sets edge blur to 0
  60805. */
  60806. disableEdgeBlur(): void;
  60807. /**
  60808. * Sets the amout of grain
  60809. * @param amount Amount of grain
  60810. */
  60811. setGrainAmount(amount: number): void;
  60812. /**
  60813. * Set grain amount to 0
  60814. */
  60815. disableGrain(): void;
  60816. /**
  60817. * Sets the chromatic aberration amount
  60818. * @param amount amount of chromatic aberration
  60819. */
  60820. setChromaticAberration(amount: number): void;
  60821. /**
  60822. * Sets chromatic aberration amount to 0
  60823. */
  60824. disableChromaticAberration(): void;
  60825. /**
  60826. * Sets the EdgeDistortion amount
  60827. * @param amount amount of EdgeDistortion
  60828. */
  60829. setEdgeDistortion(amount: number): void;
  60830. /**
  60831. * Sets edge distortion to 0
  60832. */
  60833. disableEdgeDistortion(): void;
  60834. /**
  60835. * Sets the FocusDistance amount
  60836. * @param amount amount of FocusDistance
  60837. */
  60838. setFocusDistance(amount: number): void;
  60839. /**
  60840. * Disables depth of field
  60841. */
  60842. disableDepthOfField(): void;
  60843. /**
  60844. * Sets the Aperture amount
  60845. * @param amount amount of Aperture
  60846. */
  60847. setAperture(amount: number): void;
  60848. /**
  60849. * Sets the DarkenOutOfFocus amount
  60850. * @param amount amount of DarkenOutOfFocus
  60851. */
  60852. setDarkenOutOfFocus(amount: number): void;
  60853. private _pentagonBokehIsEnabled;
  60854. /**
  60855. * Creates a pentagon bokeh effect
  60856. */
  60857. enablePentagonBokeh(): void;
  60858. /**
  60859. * Disables the pentagon bokeh effect
  60860. */
  60861. disablePentagonBokeh(): void;
  60862. /**
  60863. * Enables noise blur
  60864. */
  60865. enableNoiseBlur(): void;
  60866. /**
  60867. * Disables noise blur
  60868. */
  60869. disableNoiseBlur(): void;
  60870. /**
  60871. * Sets the HighlightsGain amount
  60872. * @param amount amount of HighlightsGain
  60873. */
  60874. setHighlightsGain(amount: number): void;
  60875. /**
  60876. * Sets the HighlightsThreshold amount
  60877. * @param amount amount of HighlightsThreshold
  60878. */
  60879. setHighlightsThreshold(amount: number): void;
  60880. /**
  60881. * Disables highlights
  60882. */
  60883. disableHighlights(): void;
  60884. /**
  60885. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60886. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60887. */
  60888. dispose(disableDepthRender?: boolean): void;
  60889. private _createChromaticAberrationPostProcess;
  60890. private _createHighlightsPostProcess;
  60891. private _createDepthOfFieldPostProcess;
  60892. private _createGrainTexture;
  60893. }
  60894. }
  60895. declare module "babylonjs/Shaders/ssao2.fragment" {
  60896. /** @hidden */
  60897. export var ssao2PixelShader: {
  60898. name: string;
  60899. shader: string;
  60900. };
  60901. }
  60902. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  60903. /** @hidden */
  60904. export var ssaoCombinePixelShader: {
  60905. name: string;
  60906. shader: string;
  60907. };
  60908. }
  60909. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  60910. import { Camera } from "babylonjs/Cameras/camera";
  60911. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60912. import { Scene } from "babylonjs/scene";
  60913. import "babylonjs/Shaders/ssao2.fragment";
  60914. import "babylonjs/Shaders/ssaoCombine.fragment";
  60915. /**
  60916. * Render pipeline to produce ssao effect
  60917. */
  60918. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60919. /**
  60920. * @ignore
  60921. * The PassPostProcess id in the pipeline that contains the original scene color
  60922. */
  60923. SSAOOriginalSceneColorEffect: string;
  60924. /**
  60925. * @ignore
  60926. * The SSAO PostProcess id in the pipeline
  60927. */
  60928. SSAORenderEffect: string;
  60929. /**
  60930. * @ignore
  60931. * The horizontal blur PostProcess id in the pipeline
  60932. */
  60933. SSAOBlurHRenderEffect: string;
  60934. /**
  60935. * @ignore
  60936. * The vertical blur PostProcess id in the pipeline
  60937. */
  60938. SSAOBlurVRenderEffect: string;
  60939. /**
  60940. * @ignore
  60941. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60942. */
  60943. SSAOCombineRenderEffect: string;
  60944. /**
  60945. * The output strength of the SSAO post-process. Default value is 1.0.
  60946. */
  60947. totalStrength: number;
  60948. /**
  60949. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60950. */
  60951. maxZ: number;
  60952. /**
  60953. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60954. */
  60955. minZAspect: number;
  60956. private _samples;
  60957. /**
  60958. * Number of samples used for the SSAO calculations. Default value is 8
  60959. */
  60960. samples: number;
  60961. private _textureSamples;
  60962. /**
  60963. * Number of samples to use for antialiasing
  60964. */
  60965. textureSamples: number;
  60966. /**
  60967. * Ratio object used for SSAO ratio and blur ratio
  60968. */
  60969. private _ratio;
  60970. /**
  60971. * Dynamically generated sphere sampler.
  60972. */
  60973. private _sampleSphere;
  60974. /**
  60975. * Blur filter offsets
  60976. */
  60977. private _samplerOffsets;
  60978. private _expensiveBlur;
  60979. /**
  60980. * If bilateral blur should be used
  60981. */
  60982. expensiveBlur: boolean;
  60983. /**
  60984. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60985. */
  60986. radius: number;
  60987. /**
  60988. * The base color of the SSAO post-process
  60989. * The final result is "base + ssao" between [0, 1]
  60990. */
  60991. base: number;
  60992. /**
  60993. * Support test.
  60994. */
  60995. static readonly IsSupported: boolean;
  60996. private _scene;
  60997. private _depthTexture;
  60998. private _normalTexture;
  60999. private _randomTexture;
  61000. private _originalColorPostProcess;
  61001. private _ssaoPostProcess;
  61002. private _blurHPostProcess;
  61003. private _blurVPostProcess;
  61004. private _ssaoCombinePostProcess;
  61005. private _firstUpdate;
  61006. /**
  61007. * Gets active scene
  61008. */
  61009. readonly scene: Scene;
  61010. /**
  61011. * @constructor
  61012. * @param name The rendering pipeline name
  61013. * @param scene The scene linked to this pipeline
  61014. * @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 }
  61015. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61016. */
  61017. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61018. /**
  61019. * Get the class name
  61020. * @returns "SSAO2RenderingPipeline"
  61021. */
  61022. getClassName(): string;
  61023. /**
  61024. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61025. */
  61026. dispose(disableGeometryBufferRenderer?: boolean): void;
  61027. private _createBlurPostProcess;
  61028. /** @hidden */
  61029. _rebuild(): void;
  61030. private _bits;
  61031. private _radicalInverse_VdC;
  61032. private _hammersley;
  61033. private _hemisphereSample_uniform;
  61034. private _generateHemisphere;
  61035. private _createSSAOPostProcess;
  61036. private _createSSAOCombinePostProcess;
  61037. private _createRandomTexture;
  61038. /**
  61039. * Serialize the rendering pipeline (Used when exporting)
  61040. * @returns the serialized object
  61041. */
  61042. serialize(): any;
  61043. /**
  61044. * Parse the serialized pipeline
  61045. * @param source Source pipeline.
  61046. * @param scene The scene to load the pipeline to.
  61047. * @param rootUrl The URL of the serialized pipeline.
  61048. * @returns An instantiated pipeline from the serialized object.
  61049. */
  61050. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61051. }
  61052. }
  61053. declare module "babylonjs/Shaders/ssao.fragment" {
  61054. /** @hidden */
  61055. export var ssaoPixelShader: {
  61056. name: string;
  61057. shader: string;
  61058. };
  61059. }
  61060. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  61061. import { Camera } from "babylonjs/Cameras/camera";
  61062. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61063. import { Scene } from "babylonjs/scene";
  61064. import "babylonjs/Shaders/ssao.fragment";
  61065. import "babylonjs/Shaders/ssaoCombine.fragment";
  61066. /**
  61067. * Render pipeline to produce ssao effect
  61068. */
  61069. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61070. /**
  61071. * @ignore
  61072. * The PassPostProcess id in the pipeline that contains the original scene color
  61073. */
  61074. SSAOOriginalSceneColorEffect: string;
  61075. /**
  61076. * @ignore
  61077. * The SSAO PostProcess id in the pipeline
  61078. */
  61079. SSAORenderEffect: string;
  61080. /**
  61081. * @ignore
  61082. * The horizontal blur PostProcess id in the pipeline
  61083. */
  61084. SSAOBlurHRenderEffect: string;
  61085. /**
  61086. * @ignore
  61087. * The vertical blur PostProcess id in the pipeline
  61088. */
  61089. SSAOBlurVRenderEffect: string;
  61090. /**
  61091. * @ignore
  61092. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61093. */
  61094. SSAOCombineRenderEffect: string;
  61095. /**
  61096. * The output strength of the SSAO post-process. Default value is 1.0.
  61097. */
  61098. totalStrength: number;
  61099. /**
  61100. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61101. */
  61102. radius: number;
  61103. /**
  61104. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61105. * Must not be equal to fallOff and superior to fallOff.
  61106. * Default value is 0.0075
  61107. */
  61108. area: number;
  61109. /**
  61110. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61111. * Must not be equal to area and inferior to area.
  61112. * Default value is 0.000001
  61113. */
  61114. fallOff: number;
  61115. /**
  61116. * The base color of the SSAO post-process
  61117. * The final result is "base + ssao" between [0, 1]
  61118. */
  61119. base: number;
  61120. private _scene;
  61121. private _depthTexture;
  61122. private _randomTexture;
  61123. private _originalColorPostProcess;
  61124. private _ssaoPostProcess;
  61125. private _blurHPostProcess;
  61126. private _blurVPostProcess;
  61127. private _ssaoCombinePostProcess;
  61128. private _firstUpdate;
  61129. /**
  61130. * Gets active scene
  61131. */
  61132. readonly scene: Scene;
  61133. /**
  61134. * @constructor
  61135. * @param name - The rendering pipeline name
  61136. * @param scene - The scene linked to this pipeline
  61137. * @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 }
  61138. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61139. */
  61140. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61141. /**
  61142. * Get the class name
  61143. * @returns "SSAORenderingPipeline"
  61144. */
  61145. getClassName(): string;
  61146. /**
  61147. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61148. */
  61149. dispose(disableDepthRender?: boolean): void;
  61150. private _createBlurPostProcess;
  61151. /** @hidden */
  61152. _rebuild(): void;
  61153. private _createSSAOPostProcess;
  61154. private _createSSAOCombinePostProcess;
  61155. private _createRandomTexture;
  61156. }
  61157. }
  61158. declare module "babylonjs/Shaders/standard.fragment" {
  61159. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61160. /** @hidden */
  61161. export var standardPixelShader: {
  61162. name: string;
  61163. shader: string;
  61164. };
  61165. }
  61166. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  61167. import { Nullable } from "babylonjs/types";
  61168. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61169. import { Camera } from "babylonjs/Cameras/camera";
  61170. import { Texture } from "babylonjs/Materials/Textures/texture";
  61171. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61172. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61173. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61174. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61175. import { IDisposable } from "babylonjs/scene";
  61176. import { SpotLight } from "babylonjs/Lights/spotLight";
  61177. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61178. import { Scene } from "babylonjs/scene";
  61179. import { Animation } from "babylonjs/Animations/animation";
  61180. import "babylonjs/Shaders/standard.fragment";
  61181. /**
  61182. * Standard rendering pipeline
  61183. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61184. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61185. */
  61186. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61187. /**
  61188. * Public members
  61189. */
  61190. /**
  61191. * Post-process which contains the original scene color before the pipeline applies all the effects
  61192. */
  61193. originalPostProcess: Nullable<PostProcess>;
  61194. /**
  61195. * Post-process used to down scale an image x4
  61196. */
  61197. downSampleX4PostProcess: Nullable<PostProcess>;
  61198. /**
  61199. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61200. */
  61201. brightPassPostProcess: Nullable<PostProcess>;
  61202. /**
  61203. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61204. */
  61205. blurHPostProcesses: PostProcess[];
  61206. /**
  61207. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61208. */
  61209. blurVPostProcesses: PostProcess[];
  61210. /**
  61211. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61212. */
  61213. textureAdderPostProcess: Nullable<PostProcess>;
  61214. /**
  61215. * Post-process used to create volumetric lighting effect
  61216. */
  61217. volumetricLightPostProcess: Nullable<PostProcess>;
  61218. /**
  61219. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61220. */
  61221. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61222. /**
  61223. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61224. */
  61225. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61226. /**
  61227. * Post-process used to merge the volumetric light effect and the real scene color
  61228. */
  61229. volumetricLightMergePostProces: Nullable<PostProcess>;
  61230. /**
  61231. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61232. */
  61233. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61234. /**
  61235. * Base post-process used to calculate the average luminance of the final image for HDR
  61236. */
  61237. luminancePostProcess: Nullable<PostProcess>;
  61238. /**
  61239. * Post-processes used to create down sample post-processes in order to get
  61240. * the average luminance of the final image for HDR
  61241. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61242. */
  61243. luminanceDownSamplePostProcesses: PostProcess[];
  61244. /**
  61245. * Post-process used to create a HDR effect (light adaptation)
  61246. */
  61247. hdrPostProcess: Nullable<PostProcess>;
  61248. /**
  61249. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61250. */
  61251. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61252. /**
  61253. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61254. */
  61255. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61256. /**
  61257. * Post-process used to merge the final HDR post-process and the real scene color
  61258. */
  61259. hdrFinalPostProcess: Nullable<PostProcess>;
  61260. /**
  61261. * Post-process used to create a lens flare effect
  61262. */
  61263. lensFlarePostProcess: Nullable<PostProcess>;
  61264. /**
  61265. * Post-process that merges the result of the lens flare post-process and the real scene color
  61266. */
  61267. lensFlareComposePostProcess: Nullable<PostProcess>;
  61268. /**
  61269. * Post-process used to create a motion blur effect
  61270. */
  61271. motionBlurPostProcess: Nullable<PostProcess>;
  61272. /**
  61273. * Post-process used to create a depth of field effect
  61274. */
  61275. depthOfFieldPostProcess: Nullable<PostProcess>;
  61276. /**
  61277. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61278. */
  61279. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61280. /**
  61281. * Represents the brightness threshold in order to configure the illuminated surfaces
  61282. */
  61283. brightThreshold: number;
  61284. /**
  61285. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61286. */
  61287. blurWidth: number;
  61288. /**
  61289. * Sets if the blur for highlighted surfaces must be only horizontal
  61290. */
  61291. horizontalBlur: boolean;
  61292. /**
  61293. * Gets the overall exposure used by the pipeline
  61294. */
  61295. /**
  61296. * Sets the overall exposure used by the pipeline
  61297. */
  61298. exposure: number;
  61299. /**
  61300. * Texture used typically to simulate "dirty" on camera lens
  61301. */
  61302. lensTexture: Nullable<Texture>;
  61303. /**
  61304. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61305. */
  61306. volumetricLightCoefficient: number;
  61307. /**
  61308. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61309. */
  61310. volumetricLightPower: number;
  61311. /**
  61312. * Used the set the blur intensity to smooth the volumetric lights
  61313. */
  61314. volumetricLightBlurScale: number;
  61315. /**
  61316. * Light (spot or directional) used to generate the volumetric lights rays
  61317. * The source light must have a shadow generate so the pipeline can get its
  61318. * depth map
  61319. */
  61320. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61321. /**
  61322. * For eye adaptation, represents the minimum luminance the eye can see
  61323. */
  61324. hdrMinimumLuminance: number;
  61325. /**
  61326. * For eye adaptation, represents the decrease luminance speed
  61327. */
  61328. hdrDecreaseRate: number;
  61329. /**
  61330. * For eye adaptation, represents the increase luminance speed
  61331. */
  61332. hdrIncreaseRate: number;
  61333. /**
  61334. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61335. */
  61336. /**
  61337. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61338. */
  61339. hdrAutoExposure: boolean;
  61340. /**
  61341. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61342. */
  61343. lensColorTexture: Nullable<Texture>;
  61344. /**
  61345. * The overall strengh for the lens flare effect
  61346. */
  61347. lensFlareStrength: number;
  61348. /**
  61349. * Dispersion coefficient for lens flare ghosts
  61350. */
  61351. lensFlareGhostDispersal: number;
  61352. /**
  61353. * Main lens flare halo width
  61354. */
  61355. lensFlareHaloWidth: number;
  61356. /**
  61357. * Based on the lens distortion effect, defines how much the lens flare result
  61358. * is distorted
  61359. */
  61360. lensFlareDistortionStrength: number;
  61361. /**
  61362. * Lens star texture must be used to simulate rays on the flares and is available
  61363. * in the documentation
  61364. */
  61365. lensStarTexture: Nullable<Texture>;
  61366. /**
  61367. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61368. * flare effect by taking account of the dirt texture
  61369. */
  61370. lensFlareDirtTexture: Nullable<Texture>;
  61371. /**
  61372. * Represents the focal length for the depth of field effect
  61373. */
  61374. depthOfFieldDistance: number;
  61375. /**
  61376. * Represents the blur intensity for the blurred part of the depth of field effect
  61377. */
  61378. depthOfFieldBlurWidth: number;
  61379. /**
  61380. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61381. */
  61382. /**
  61383. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61384. */
  61385. motionStrength: number;
  61386. /**
  61387. * Gets wether or not the motion blur post-process is object based or screen based.
  61388. */
  61389. /**
  61390. * Sets wether or not the motion blur post-process should be object based or screen based
  61391. */
  61392. objectBasedMotionBlur: boolean;
  61393. /**
  61394. * List of animations for the pipeline (IAnimatable implementation)
  61395. */
  61396. animations: Animation[];
  61397. /**
  61398. * Private members
  61399. */
  61400. private _scene;
  61401. private _currentDepthOfFieldSource;
  61402. private _basePostProcess;
  61403. private _fixedExposure;
  61404. private _currentExposure;
  61405. private _hdrAutoExposure;
  61406. private _hdrCurrentLuminance;
  61407. private _motionStrength;
  61408. private _isObjectBasedMotionBlur;
  61409. private _floatTextureType;
  61410. private _ratio;
  61411. private _bloomEnabled;
  61412. private _depthOfFieldEnabled;
  61413. private _vlsEnabled;
  61414. private _lensFlareEnabled;
  61415. private _hdrEnabled;
  61416. private _motionBlurEnabled;
  61417. private _fxaaEnabled;
  61418. private _motionBlurSamples;
  61419. private _volumetricLightStepsCount;
  61420. private _samples;
  61421. /**
  61422. * @ignore
  61423. * Specifies if the bloom pipeline is enabled
  61424. */
  61425. BloomEnabled: boolean;
  61426. /**
  61427. * @ignore
  61428. * Specifies if the depth of field pipeline is enabed
  61429. */
  61430. DepthOfFieldEnabled: boolean;
  61431. /**
  61432. * @ignore
  61433. * Specifies if the lens flare pipeline is enabed
  61434. */
  61435. LensFlareEnabled: boolean;
  61436. /**
  61437. * @ignore
  61438. * Specifies if the HDR pipeline is enabled
  61439. */
  61440. HDREnabled: boolean;
  61441. /**
  61442. * @ignore
  61443. * Specifies if the volumetric lights scattering effect is enabled
  61444. */
  61445. VLSEnabled: boolean;
  61446. /**
  61447. * @ignore
  61448. * Specifies if the motion blur effect is enabled
  61449. */
  61450. MotionBlurEnabled: boolean;
  61451. /**
  61452. * Specifies if anti-aliasing is enabled
  61453. */
  61454. fxaaEnabled: boolean;
  61455. /**
  61456. * Specifies the number of steps used to calculate the volumetric lights
  61457. * Typically in interval [50, 200]
  61458. */
  61459. volumetricLightStepsCount: number;
  61460. /**
  61461. * Specifies the number of samples used for the motion blur effect
  61462. * Typically in interval [16, 64]
  61463. */
  61464. motionBlurSamples: number;
  61465. /**
  61466. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61467. */
  61468. samples: number;
  61469. /**
  61470. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61471. * @constructor
  61472. * @param name The rendering pipeline name
  61473. * @param scene The scene linked to this pipeline
  61474. * @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)
  61475. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61476. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61477. */
  61478. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61479. private _buildPipeline;
  61480. private _createDownSampleX4PostProcess;
  61481. private _createBrightPassPostProcess;
  61482. private _createBlurPostProcesses;
  61483. private _createTextureAdderPostProcess;
  61484. private _createVolumetricLightPostProcess;
  61485. private _createLuminancePostProcesses;
  61486. private _createHdrPostProcess;
  61487. private _createLensFlarePostProcess;
  61488. private _createDepthOfFieldPostProcess;
  61489. private _createMotionBlurPostProcess;
  61490. private _getDepthTexture;
  61491. private _disposePostProcesses;
  61492. /**
  61493. * Dispose of the pipeline and stop all post processes
  61494. */
  61495. dispose(): void;
  61496. /**
  61497. * Serialize the rendering pipeline (Used when exporting)
  61498. * @returns the serialized object
  61499. */
  61500. serialize(): any;
  61501. /**
  61502. * Parse the serialized pipeline
  61503. * @param source Source pipeline.
  61504. * @param scene The scene to load the pipeline to.
  61505. * @param rootUrl The URL of the serialized pipeline.
  61506. * @returns An instantiated pipeline from the serialized object.
  61507. */
  61508. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61509. /**
  61510. * Luminance steps
  61511. */
  61512. static LuminanceSteps: number;
  61513. }
  61514. }
  61515. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  61516. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  61517. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  61518. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  61519. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  61520. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  61521. }
  61522. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  61523. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  61524. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61525. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61526. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61527. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61528. }
  61529. declare module "babylonjs/Shaders/tonemap.fragment" {
  61530. /** @hidden */
  61531. export var tonemapPixelShader: {
  61532. name: string;
  61533. shader: string;
  61534. };
  61535. }
  61536. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  61537. import { Camera } from "babylonjs/Cameras/camera";
  61538. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61539. import "babylonjs/Shaders/tonemap.fragment";
  61540. import { Engine } from "babylonjs/Engines/engine";
  61541. /** Defines operator used for tonemapping */
  61542. export enum TonemappingOperator {
  61543. /** Hable */
  61544. Hable = 0,
  61545. /** Reinhard */
  61546. Reinhard = 1,
  61547. /** HejiDawson */
  61548. HejiDawson = 2,
  61549. /** Photographic */
  61550. Photographic = 3
  61551. }
  61552. /**
  61553. * Defines a post process to apply tone mapping
  61554. */
  61555. export class TonemapPostProcess extends PostProcess {
  61556. private _operator;
  61557. /** Defines the required exposure adjustement */
  61558. exposureAdjustment: number;
  61559. /**
  61560. * Creates a new TonemapPostProcess
  61561. * @param name defines the name of the postprocess
  61562. * @param _operator defines the operator to use
  61563. * @param exposureAdjustment defines the required exposure adjustement
  61564. * @param camera defines the camera to use (can be null)
  61565. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61566. * @param engine defines the hosting engine (can be ignore if camera is set)
  61567. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61568. */
  61569. constructor(name: string, _operator: TonemappingOperator,
  61570. /** Defines the required exposure adjustement */
  61571. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61572. }
  61573. }
  61574. declare module "babylonjs/Shaders/depth.vertex" {
  61575. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61576. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61577. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61578. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61579. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61580. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61581. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61582. /** @hidden */
  61583. export var depthVertexShader: {
  61584. name: string;
  61585. shader: string;
  61586. };
  61587. }
  61588. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  61589. /** @hidden */
  61590. export var volumetricLightScatteringPixelShader: {
  61591. name: string;
  61592. shader: string;
  61593. };
  61594. }
  61595. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  61596. /** @hidden */
  61597. export var volumetricLightScatteringPassPixelShader: {
  61598. name: string;
  61599. shader: string;
  61600. };
  61601. }
  61602. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  61603. import { Vector3 } from "babylonjs/Maths/math.vector";
  61604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61605. import { Mesh } from "babylonjs/Meshes/mesh";
  61606. import { Camera } from "babylonjs/Cameras/camera";
  61607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61608. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61609. import { Scene } from "babylonjs/scene";
  61610. import "babylonjs/Meshes/Builders/planeBuilder";
  61611. import "babylonjs/Shaders/depth.vertex";
  61612. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  61613. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  61614. import { Engine } from "babylonjs/Engines/engine";
  61615. /**
  61616. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61617. */
  61618. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61619. private _volumetricLightScatteringPass;
  61620. private _volumetricLightScatteringRTT;
  61621. private _viewPort;
  61622. private _screenCoordinates;
  61623. private _cachedDefines;
  61624. /**
  61625. * If not undefined, the mesh position is computed from the attached node position
  61626. */
  61627. attachedNode: {
  61628. position: Vector3;
  61629. };
  61630. /**
  61631. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61632. */
  61633. customMeshPosition: Vector3;
  61634. /**
  61635. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61636. */
  61637. useCustomMeshPosition: boolean;
  61638. /**
  61639. * If the post-process should inverse the light scattering direction
  61640. */
  61641. invert: boolean;
  61642. /**
  61643. * The internal mesh used by the post-process
  61644. */
  61645. mesh: Mesh;
  61646. /**
  61647. * @hidden
  61648. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61649. */
  61650. useDiffuseColor: boolean;
  61651. /**
  61652. * Array containing the excluded meshes not rendered in the internal pass
  61653. */
  61654. excludedMeshes: AbstractMesh[];
  61655. /**
  61656. * Controls the overall intensity of the post-process
  61657. */
  61658. exposure: number;
  61659. /**
  61660. * Dissipates each sample's contribution in range [0, 1]
  61661. */
  61662. decay: number;
  61663. /**
  61664. * Controls the overall intensity of each sample
  61665. */
  61666. weight: number;
  61667. /**
  61668. * Controls the density of each sample
  61669. */
  61670. density: number;
  61671. /**
  61672. * @constructor
  61673. * @param name The post-process name
  61674. * @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)
  61675. * @param camera The camera that the post-process will be attached to
  61676. * @param mesh The mesh used to create the light scattering
  61677. * @param samples The post-process quality, default 100
  61678. * @param samplingModeThe post-process filtering mode
  61679. * @param engine The babylon engine
  61680. * @param reusable If the post-process is reusable
  61681. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61682. */
  61683. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61684. /**
  61685. * Returns the string "VolumetricLightScatteringPostProcess"
  61686. * @returns "VolumetricLightScatteringPostProcess"
  61687. */
  61688. getClassName(): string;
  61689. private _isReady;
  61690. /**
  61691. * Sets the new light position for light scattering effect
  61692. * @param position The new custom light position
  61693. */
  61694. setCustomMeshPosition(position: Vector3): void;
  61695. /**
  61696. * Returns the light position for light scattering effect
  61697. * @return Vector3 The custom light position
  61698. */
  61699. getCustomMeshPosition(): Vector3;
  61700. /**
  61701. * Disposes the internal assets and detaches the post-process from the camera
  61702. */
  61703. dispose(camera: Camera): void;
  61704. /**
  61705. * Returns the render target texture used by the post-process
  61706. * @return the render target texture used by the post-process
  61707. */
  61708. getPass(): RenderTargetTexture;
  61709. private _meshExcluded;
  61710. private _createPass;
  61711. private _updateMeshScreenCoordinates;
  61712. /**
  61713. * Creates a default mesh for the Volumeric Light Scattering post-process
  61714. * @param name The mesh name
  61715. * @param scene The scene where to create the mesh
  61716. * @return the default mesh
  61717. */
  61718. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61719. }
  61720. }
  61721. declare module "babylonjs/PostProcesses/index" {
  61722. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  61723. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  61724. export * from "babylonjs/PostProcesses/bloomEffect";
  61725. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  61726. export * from "babylonjs/PostProcesses/blurPostProcess";
  61727. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61728. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  61729. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  61730. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  61731. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61732. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  61733. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  61734. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  61735. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61736. export * from "babylonjs/PostProcesses/filterPostProcess";
  61737. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  61738. export * from "babylonjs/PostProcesses/grainPostProcess";
  61739. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  61740. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61741. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  61742. export * from "babylonjs/PostProcesses/passPostProcess";
  61743. export * from "babylonjs/PostProcesses/postProcess";
  61744. export * from "babylonjs/PostProcesses/postProcessManager";
  61745. export * from "babylonjs/PostProcesses/refractionPostProcess";
  61746. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  61747. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  61748. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  61749. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  61750. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  61751. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  61752. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  61753. }
  61754. declare module "babylonjs/Probes/index" {
  61755. export * from "babylonjs/Probes/reflectionProbe";
  61756. }
  61757. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  61758. import { Scene } from "babylonjs/scene";
  61759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61760. import { SmartArray } from "babylonjs/Misc/smartArray";
  61761. import { ISceneComponent } from "babylonjs/sceneComponent";
  61762. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  61763. import "babylonjs/Meshes/Builders/boxBuilder";
  61764. import "babylonjs/Shaders/color.fragment";
  61765. import "babylonjs/Shaders/color.vertex";
  61766. import { Color3 } from "babylonjs/Maths/math.color";
  61767. module "babylonjs/scene" {
  61768. interface Scene {
  61769. /** @hidden (Backing field) */
  61770. _boundingBoxRenderer: BoundingBoxRenderer;
  61771. /** @hidden (Backing field) */
  61772. _forceShowBoundingBoxes: boolean;
  61773. /**
  61774. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61775. */
  61776. forceShowBoundingBoxes: boolean;
  61777. /**
  61778. * Gets the bounding box renderer associated with the scene
  61779. * @returns a BoundingBoxRenderer
  61780. */
  61781. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61782. }
  61783. }
  61784. module "babylonjs/Meshes/abstractMesh" {
  61785. interface AbstractMesh {
  61786. /** @hidden (Backing field) */
  61787. _showBoundingBox: boolean;
  61788. /**
  61789. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61790. */
  61791. showBoundingBox: boolean;
  61792. }
  61793. }
  61794. /**
  61795. * Component responsible of rendering the bounding box of the meshes in a scene.
  61796. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61797. */
  61798. export class BoundingBoxRenderer implements ISceneComponent {
  61799. /**
  61800. * The component name helpfull to identify the component in the list of scene components.
  61801. */
  61802. readonly name: string;
  61803. /**
  61804. * The scene the component belongs to.
  61805. */
  61806. scene: Scene;
  61807. /**
  61808. * Color of the bounding box lines placed in front of an object
  61809. */
  61810. frontColor: Color3;
  61811. /**
  61812. * Color of the bounding box lines placed behind an object
  61813. */
  61814. backColor: Color3;
  61815. /**
  61816. * Defines if the renderer should show the back lines or not
  61817. */
  61818. showBackLines: boolean;
  61819. /**
  61820. * @hidden
  61821. */
  61822. renderList: SmartArray<BoundingBox>;
  61823. private _colorShader;
  61824. private _vertexBuffers;
  61825. private _indexBuffer;
  61826. private _fillIndexBuffer;
  61827. private _fillIndexData;
  61828. /**
  61829. * Instantiates a new bounding box renderer in a scene.
  61830. * @param scene the scene the renderer renders in
  61831. */
  61832. constructor(scene: Scene);
  61833. /**
  61834. * Registers the component in a given scene
  61835. */
  61836. register(): void;
  61837. private _evaluateSubMesh;
  61838. private _activeMesh;
  61839. private _prepareRessources;
  61840. private _createIndexBuffer;
  61841. /**
  61842. * Rebuilds the elements related to this component in case of
  61843. * context lost for instance.
  61844. */
  61845. rebuild(): void;
  61846. /**
  61847. * @hidden
  61848. */
  61849. reset(): void;
  61850. /**
  61851. * Render the bounding boxes of a specific rendering group
  61852. * @param renderingGroupId defines the rendering group to render
  61853. */
  61854. render(renderingGroupId: number): void;
  61855. /**
  61856. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61857. * @param mesh Define the mesh to render the occlusion bounding box for
  61858. */
  61859. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61860. /**
  61861. * Dispose and release the resources attached to this renderer.
  61862. */
  61863. dispose(): void;
  61864. }
  61865. }
  61866. declare module "babylonjs/Shaders/depth.fragment" {
  61867. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61868. /** @hidden */
  61869. export var depthPixelShader: {
  61870. name: string;
  61871. shader: string;
  61872. };
  61873. }
  61874. declare module "babylonjs/Rendering/depthRenderer" {
  61875. import { Nullable } from "babylonjs/types";
  61876. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61877. import { Scene } from "babylonjs/scene";
  61878. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61879. import { Camera } from "babylonjs/Cameras/camera";
  61880. import "babylonjs/Shaders/depth.fragment";
  61881. import "babylonjs/Shaders/depth.vertex";
  61882. /**
  61883. * This represents a depth renderer in Babylon.
  61884. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61885. */
  61886. export class DepthRenderer {
  61887. private _scene;
  61888. private _depthMap;
  61889. private _effect;
  61890. private readonly _storeNonLinearDepth;
  61891. private readonly _clearColor;
  61892. /** Get if the depth renderer is using packed depth or not */
  61893. readonly isPacked: boolean;
  61894. private _cachedDefines;
  61895. private _camera;
  61896. /**
  61897. * Specifiess that the depth renderer will only be used within
  61898. * the camera it is created for.
  61899. * This can help forcing its rendering during the camera processing.
  61900. */
  61901. useOnlyInActiveCamera: boolean;
  61902. /** @hidden */
  61903. static _SceneComponentInitialization: (scene: Scene) => void;
  61904. /**
  61905. * Instantiates a depth renderer
  61906. * @param scene The scene the renderer belongs to
  61907. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61908. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61909. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61910. */
  61911. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61912. /**
  61913. * Creates the depth rendering effect and checks if the effect is ready.
  61914. * @param subMesh The submesh to be used to render the depth map of
  61915. * @param useInstances If multiple world instances should be used
  61916. * @returns if the depth renderer is ready to render the depth map
  61917. */
  61918. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61919. /**
  61920. * Gets the texture which the depth map will be written to.
  61921. * @returns The depth map texture
  61922. */
  61923. getDepthMap(): RenderTargetTexture;
  61924. /**
  61925. * Disposes of the depth renderer.
  61926. */
  61927. dispose(): void;
  61928. }
  61929. }
  61930. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  61931. import { Nullable } from "babylonjs/types";
  61932. import { Scene } from "babylonjs/scene";
  61933. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61934. import { Camera } from "babylonjs/Cameras/camera";
  61935. import { ISceneComponent } from "babylonjs/sceneComponent";
  61936. module "babylonjs/scene" {
  61937. interface Scene {
  61938. /** @hidden (Backing field) */
  61939. _depthRenderer: {
  61940. [id: string]: DepthRenderer;
  61941. };
  61942. /**
  61943. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61944. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61945. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61946. * @returns the created depth renderer
  61947. */
  61948. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61949. /**
  61950. * Disables a depth renderer for a given camera
  61951. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61952. */
  61953. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61954. }
  61955. }
  61956. /**
  61957. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61958. * in several rendering techniques.
  61959. */
  61960. export class DepthRendererSceneComponent implements ISceneComponent {
  61961. /**
  61962. * The component name helpfull to identify the component in the list of scene components.
  61963. */
  61964. readonly name: string;
  61965. /**
  61966. * The scene the component belongs to.
  61967. */
  61968. scene: Scene;
  61969. /**
  61970. * Creates a new instance of the component for the given scene
  61971. * @param scene Defines the scene to register the component in
  61972. */
  61973. constructor(scene: Scene);
  61974. /**
  61975. * Registers the component in a given scene
  61976. */
  61977. register(): void;
  61978. /**
  61979. * Rebuilds the elements related to this component in case of
  61980. * context lost for instance.
  61981. */
  61982. rebuild(): void;
  61983. /**
  61984. * Disposes the component and the associated ressources
  61985. */
  61986. dispose(): void;
  61987. private _gatherRenderTargets;
  61988. private _gatherActiveCameraRenderTargets;
  61989. }
  61990. }
  61991. declare module "babylonjs/Shaders/outline.fragment" {
  61992. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  61993. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  61994. /** @hidden */
  61995. export var outlinePixelShader: {
  61996. name: string;
  61997. shader: string;
  61998. };
  61999. }
  62000. declare module "babylonjs/Shaders/outline.vertex" {
  62001. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62002. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62003. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62004. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62005. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62006. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62007. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62008. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62009. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  62010. /** @hidden */
  62011. export var outlineVertexShader: {
  62012. name: string;
  62013. shader: string;
  62014. };
  62015. }
  62016. declare module "babylonjs/Rendering/outlineRenderer" {
  62017. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62018. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  62019. import { Scene } from "babylonjs/scene";
  62020. import { ISceneComponent } from "babylonjs/sceneComponent";
  62021. import "babylonjs/Shaders/outline.fragment";
  62022. import "babylonjs/Shaders/outline.vertex";
  62023. module "babylonjs/scene" {
  62024. interface Scene {
  62025. /** @hidden */
  62026. _outlineRenderer: OutlineRenderer;
  62027. /**
  62028. * Gets the outline renderer associated with the scene
  62029. * @returns a OutlineRenderer
  62030. */
  62031. getOutlineRenderer(): OutlineRenderer;
  62032. }
  62033. }
  62034. module "babylonjs/Meshes/abstractMesh" {
  62035. interface AbstractMesh {
  62036. /** @hidden (Backing field) */
  62037. _renderOutline: boolean;
  62038. /**
  62039. * Gets or sets a boolean indicating if the outline must be rendered as well
  62040. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62041. */
  62042. renderOutline: boolean;
  62043. /** @hidden (Backing field) */
  62044. _renderOverlay: boolean;
  62045. /**
  62046. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62047. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62048. */
  62049. renderOverlay: boolean;
  62050. }
  62051. }
  62052. /**
  62053. * This class is responsible to draw bothe outline/overlay of meshes.
  62054. * It should not be used directly but through the available method on mesh.
  62055. */
  62056. export class OutlineRenderer implements ISceneComponent {
  62057. /**
  62058. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62059. */
  62060. private static _StencilReference;
  62061. /**
  62062. * The name of the component. Each component must have a unique name.
  62063. */
  62064. name: string;
  62065. /**
  62066. * The scene the component belongs to.
  62067. */
  62068. scene: Scene;
  62069. /**
  62070. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62071. */
  62072. zOffset: number;
  62073. private _engine;
  62074. private _effect;
  62075. private _cachedDefines;
  62076. private _savedDepthWrite;
  62077. /**
  62078. * Instantiates a new outline renderer. (There could be only one per scene).
  62079. * @param scene Defines the scene it belongs to
  62080. */
  62081. constructor(scene: Scene);
  62082. /**
  62083. * Register the component to one instance of a scene.
  62084. */
  62085. register(): void;
  62086. /**
  62087. * Rebuilds the elements related to this component in case of
  62088. * context lost for instance.
  62089. */
  62090. rebuild(): void;
  62091. /**
  62092. * Disposes the component and the associated ressources.
  62093. */
  62094. dispose(): void;
  62095. /**
  62096. * Renders the outline in the canvas.
  62097. * @param subMesh Defines the sumesh to render
  62098. * @param batch Defines the batch of meshes in case of instances
  62099. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62100. */
  62101. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62102. /**
  62103. * Returns whether or not the outline renderer is ready for a given submesh.
  62104. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62105. * @param subMesh Defines the submesh to check readyness for
  62106. * @param useInstances Defines wheter wee are trying to render instances or not
  62107. * @returns true if ready otherwise false
  62108. */
  62109. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62110. private _beforeRenderingMesh;
  62111. private _afterRenderingMesh;
  62112. }
  62113. }
  62114. declare module "babylonjs/Rendering/index" {
  62115. export * from "babylonjs/Rendering/boundingBoxRenderer";
  62116. export * from "babylonjs/Rendering/depthRenderer";
  62117. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  62118. export * from "babylonjs/Rendering/edgesRenderer";
  62119. export * from "babylonjs/Rendering/geometryBufferRenderer";
  62120. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62121. export * from "babylonjs/Rendering/outlineRenderer";
  62122. export * from "babylonjs/Rendering/renderingGroup";
  62123. export * from "babylonjs/Rendering/renderingManager";
  62124. export * from "babylonjs/Rendering/utilityLayerRenderer";
  62125. }
  62126. declare module "babylonjs/Sprites/index" {
  62127. export * from "babylonjs/Sprites/sprite";
  62128. export * from "babylonjs/Sprites/spriteManager";
  62129. export * from "babylonjs/Sprites/spriteSceneComponent";
  62130. }
  62131. declare module "babylonjs/Misc/assetsManager" {
  62132. import { Scene } from "babylonjs/scene";
  62133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62134. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62135. import { Skeleton } from "babylonjs/Bones/skeleton";
  62136. import { Observable } from "babylonjs/Misc/observable";
  62137. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62138. import { Texture } from "babylonjs/Materials/Textures/texture";
  62139. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  62140. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  62141. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  62142. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  62143. /**
  62144. * Defines the list of states available for a task inside a AssetsManager
  62145. */
  62146. export enum AssetTaskState {
  62147. /**
  62148. * Initialization
  62149. */
  62150. INIT = 0,
  62151. /**
  62152. * Running
  62153. */
  62154. RUNNING = 1,
  62155. /**
  62156. * Done
  62157. */
  62158. DONE = 2,
  62159. /**
  62160. * Error
  62161. */
  62162. ERROR = 3
  62163. }
  62164. /**
  62165. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62166. */
  62167. export abstract class AbstractAssetTask {
  62168. /**
  62169. * Task name
  62170. */ name: string;
  62171. /**
  62172. * Callback called when the task is successful
  62173. */
  62174. onSuccess: (task: any) => void;
  62175. /**
  62176. * Callback called when the task is not successful
  62177. */
  62178. onError: (task: any, message?: string, exception?: any) => void;
  62179. /**
  62180. * Creates a new AssetsManager
  62181. * @param name defines the name of the task
  62182. */
  62183. constructor(
  62184. /**
  62185. * Task name
  62186. */ name: string);
  62187. private _isCompleted;
  62188. private _taskState;
  62189. private _errorObject;
  62190. /**
  62191. * Get if the task is completed
  62192. */
  62193. readonly isCompleted: boolean;
  62194. /**
  62195. * Gets the current state of the task
  62196. */
  62197. readonly taskState: AssetTaskState;
  62198. /**
  62199. * Gets the current error object (if task is in error)
  62200. */
  62201. readonly errorObject: {
  62202. message?: string;
  62203. exception?: any;
  62204. };
  62205. /**
  62206. * Internal only
  62207. * @hidden
  62208. */
  62209. _setErrorObject(message?: string, exception?: any): void;
  62210. /**
  62211. * Execute the current task
  62212. * @param scene defines the scene where you want your assets to be loaded
  62213. * @param onSuccess is a callback called when the task is successfully executed
  62214. * @param onError is a callback called if an error occurs
  62215. */
  62216. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62217. /**
  62218. * Execute the current task
  62219. * @param scene defines the scene where you want your assets to be loaded
  62220. * @param onSuccess is a callback called when the task is successfully executed
  62221. * @param onError is a callback called if an error occurs
  62222. */
  62223. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62224. /**
  62225. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62226. * This can be used with failed tasks that have the reason for failure fixed.
  62227. */
  62228. reset(): void;
  62229. private onErrorCallback;
  62230. private onDoneCallback;
  62231. }
  62232. /**
  62233. * Define the interface used by progress events raised during assets loading
  62234. */
  62235. export interface IAssetsProgressEvent {
  62236. /**
  62237. * Defines the number of remaining tasks to process
  62238. */
  62239. remainingCount: number;
  62240. /**
  62241. * Defines the total number of tasks
  62242. */
  62243. totalCount: number;
  62244. /**
  62245. * Defines the task that was just processed
  62246. */
  62247. task: AbstractAssetTask;
  62248. }
  62249. /**
  62250. * Class used to share progress information about assets loading
  62251. */
  62252. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62253. /**
  62254. * Defines the number of remaining tasks to process
  62255. */
  62256. remainingCount: number;
  62257. /**
  62258. * Defines the total number of tasks
  62259. */
  62260. totalCount: number;
  62261. /**
  62262. * Defines the task that was just processed
  62263. */
  62264. task: AbstractAssetTask;
  62265. /**
  62266. * Creates a AssetsProgressEvent
  62267. * @param remainingCount defines the number of remaining tasks to process
  62268. * @param totalCount defines the total number of tasks
  62269. * @param task defines the task that was just processed
  62270. */
  62271. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62272. }
  62273. /**
  62274. * Define a task used by AssetsManager to load meshes
  62275. */
  62276. export class MeshAssetTask extends AbstractAssetTask {
  62277. /**
  62278. * Defines the name of the task
  62279. */
  62280. name: string;
  62281. /**
  62282. * Defines the list of mesh's names you want to load
  62283. */
  62284. meshesNames: any;
  62285. /**
  62286. * Defines the root url to use as a base to load your meshes and associated resources
  62287. */
  62288. rootUrl: string;
  62289. /**
  62290. * Defines the filename of the scene to load from
  62291. */
  62292. sceneFilename: string;
  62293. /**
  62294. * Gets the list of loaded meshes
  62295. */
  62296. loadedMeshes: Array<AbstractMesh>;
  62297. /**
  62298. * Gets the list of loaded particle systems
  62299. */
  62300. loadedParticleSystems: Array<IParticleSystem>;
  62301. /**
  62302. * Gets the list of loaded skeletons
  62303. */
  62304. loadedSkeletons: Array<Skeleton>;
  62305. /**
  62306. * Gets the list of loaded animation groups
  62307. */
  62308. loadedAnimationGroups: Array<AnimationGroup>;
  62309. /**
  62310. * Callback called when the task is successful
  62311. */
  62312. onSuccess: (task: MeshAssetTask) => void;
  62313. /**
  62314. * Callback called when the task is successful
  62315. */
  62316. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62317. /**
  62318. * Creates a new MeshAssetTask
  62319. * @param name defines the name of the task
  62320. * @param meshesNames defines the list of mesh's names you want to load
  62321. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62322. * @param sceneFilename defines the filename of the scene to load from
  62323. */
  62324. constructor(
  62325. /**
  62326. * Defines the name of the task
  62327. */
  62328. name: string,
  62329. /**
  62330. * Defines the list of mesh's names you want to load
  62331. */
  62332. meshesNames: any,
  62333. /**
  62334. * Defines the root url to use as a base to load your meshes and associated resources
  62335. */
  62336. rootUrl: string,
  62337. /**
  62338. * Defines the filename of the scene to load from
  62339. */
  62340. sceneFilename: string);
  62341. /**
  62342. * Execute the current task
  62343. * @param scene defines the scene where you want your assets to be loaded
  62344. * @param onSuccess is a callback called when the task is successfully executed
  62345. * @param onError is a callback called if an error occurs
  62346. */
  62347. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62348. }
  62349. /**
  62350. * Define a task used by AssetsManager to load text content
  62351. */
  62352. export class TextFileAssetTask extends AbstractAssetTask {
  62353. /**
  62354. * Defines the name of the task
  62355. */
  62356. name: string;
  62357. /**
  62358. * Defines the location of the file to load
  62359. */
  62360. url: string;
  62361. /**
  62362. * Gets the loaded text string
  62363. */
  62364. text: string;
  62365. /**
  62366. * Callback called when the task is successful
  62367. */
  62368. onSuccess: (task: TextFileAssetTask) => void;
  62369. /**
  62370. * Callback called when the task is successful
  62371. */
  62372. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62373. /**
  62374. * Creates a new TextFileAssetTask object
  62375. * @param name defines the name of the task
  62376. * @param url defines the location of the file to load
  62377. */
  62378. constructor(
  62379. /**
  62380. * Defines the name of the task
  62381. */
  62382. name: string,
  62383. /**
  62384. * Defines the location of the file to load
  62385. */
  62386. url: string);
  62387. /**
  62388. * Execute the current task
  62389. * @param scene defines the scene where you want your assets to be loaded
  62390. * @param onSuccess is a callback called when the task is successfully executed
  62391. * @param onError is a callback called if an error occurs
  62392. */
  62393. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62394. }
  62395. /**
  62396. * Define a task used by AssetsManager to load binary data
  62397. */
  62398. export class BinaryFileAssetTask extends AbstractAssetTask {
  62399. /**
  62400. * Defines the name of the task
  62401. */
  62402. name: string;
  62403. /**
  62404. * Defines the location of the file to load
  62405. */
  62406. url: string;
  62407. /**
  62408. * Gets the lodaded data (as an array buffer)
  62409. */
  62410. data: ArrayBuffer;
  62411. /**
  62412. * Callback called when the task is successful
  62413. */
  62414. onSuccess: (task: BinaryFileAssetTask) => void;
  62415. /**
  62416. * Callback called when the task is successful
  62417. */
  62418. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62419. /**
  62420. * Creates a new BinaryFileAssetTask object
  62421. * @param name defines the name of the new task
  62422. * @param url defines the location of the file to load
  62423. */
  62424. constructor(
  62425. /**
  62426. * Defines the name of the task
  62427. */
  62428. name: string,
  62429. /**
  62430. * Defines the location of the file to load
  62431. */
  62432. url: string);
  62433. /**
  62434. * Execute the current task
  62435. * @param scene defines the scene where you want your assets to be loaded
  62436. * @param onSuccess is a callback called when the task is successfully executed
  62437. * @param onError is a callback called if an error occurs
  62438. */
  62439. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62440. }
  62441. /**
  62442. * Define a task used by AssetsManager to load images
  62443. */
  62444. export class ImageAssetTask extends AbstractAssetTask {
  62445. /**
  62446. * Defines the name of the task
  62447. */
  62448. name: string;
  62449. /**
  62450. * Defines the location of the image to load
  62451. */
  62452. url: string;
  62453. /**
  62454. * Gets the loaded images
  62455. */
  62456. image: HTMLImageElement;
  62457. /**
  62458. * Callback called when the task is successful
  62459. */
  62460. onSuccess: (task: ImageAssetTask) => void;
  62461. /**
  62462. * Callback called when the task is successful
  62463. */
  62464. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62465. /**
  62466. * Creates a new ImageAssetTask
  62467. * @param name defines the name of the task
  62468. * @param url defines the location of the image to load
  62469. */
  62470. constructor(
  62471. /**
  62472. * Defines the name of the task
  62473. */
  62474. name: string,
  62475. /**
  62476. * Defines the location of the image to load
  62477. */
  62478. url: string);
  62479. /**
  62480. * Execute the current task
  62481. * @param scene defines the scene where you want your assets to be loaded
  62482. * @param onSuccess is a callback called when the task is successfully executed
  62483. * @param onError is a callback called if an error occurs
  62484. */
  62485. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62486. }
  62487. /**
  62488. * Defines the interface used by texture loading tasks
  62489. */
  62490. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62491. /**
  62492. * Gets the loaded texture
  62493. */
  62494. texture: TEX;
  62495. }
  62496. /**
  62497. * Define a task used by AssetsManager to load 2D textures
  62498. */
  62499. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62500. /**
  62501. * Defines the name of the task
  62502. */
  62503. name: string;
  62504. /**
  62505. * Defines the location of the file to load
  62506. */
  62507. url: string;
  62508. /**
  62509. * Defines if mipmap should not be generated (default is false)
  62510. */
  62511. noMipmap?: boolean | undefined;
  62512. /**
  62513. * Defines if texture must be inverted on Y axis (default is false)
  62514. */
  62515. invertY?: boolean | undefined;
  62516. /**
  62517. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62518. */
  62519. samplingMode: number;
  62520. /**
  62521. * Gets the loaded texture
  62522. */
  62523. texture: Texture;
  62524. /**
  62525. * Callback called when the task is successful
  62526. */
  62527. onSuccess: (task: TextureAssetTask) => void;
  62528. /**
  62529. * Callback called when the task is successful
  62530. */
  62531. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62532. /**
  62533. * Creates a new TextureAssetTask object
  62534. * @param name defines the name of the task
  62535. * @param url defines the location of the file to load
  62536. * @param noMipmap defines if mipmap should not be generated (default is false)
  62537. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62538. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62539. */
  62540. constructor(
  62541. /**
  62542. * Defines the name of the task
  62543. */
  62544. name: string,
  62545. /**
  62546. * Defines the location of the file to load
  62547. */
  62548. url: string,
  62549. /**
  62550. * Defines if mipmap should not be generated (default is false)
  62551. */
  62552. noMipmap?: boolean | undefined,
  62553. /**
  62554. * Defines if texture must be inverted on Y axis (default is false)
  62555. */
  62556. invertY?: boolean | undefined,
  62557. /**
  62558. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62559. */
  62560. samplingMode?: number);
  62561. /**
  62562. * Execute the current task
  62563. * @param scene defines the scene where you want your assets to be loaded
  62564. * @param onSuccess is a callback called when the task is successfully executed
  62565. * @param onError is a callback called if an error occurs
  62566. */
  62567. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62568. }
  62569. /**
  62570. * Define a task used by AssetsManager to load cube textures
  62571. */
  62572. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62573. /**
  62574. * Defines the name of the task
  62575. */
  62576. name: string;
  62577. /**
  62578. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62579. */
  62580. url: string;
  62581. /**
  62582. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62583. */
  62584. extensions?: string[] | undefined;
  62585. /**
  62586. * Defines if mipmaps should not be generated (default is false)
  62587. */
  62588. noMipmap?: boolean | undefined;
  62589. /**
  62590. * Defines the explicit list of files (undefined by default)
  62591. */
  62592. files?: string[] | undefined;
  62593. /**
  62594. * Gets the loaded texture
  62595. */
  62596. texture: CubeTexture;
  62597. /**
  62598. * Callback called when the task is successful
  62599. */
  62600. onSuccess: (task: CubeTextureAssetTask) => void;
  62601. /**
  62602. * Callback called when the task is successful
  62603. */
  62604. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62605. /**
  62606. * Creates a new CubeTextureAssetTask
  62607. * @param name defines the name of the task
  62608. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62609. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62610. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62611. * @param files defines the explicit list of files (undefined by default)
  62612. */
  62613. constructor(
  62614. /**
  62615. * Defines the name of the task
  62616. */
  62617. name: string,
  62618. /**
  62619. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62620. */
  62621. url: string,
  62622. /**
  62623. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62624. */
  62625. extensions?: string[] | undefined,
  62626. /**
  62627. * Defines if mipmaps should not be generated (default is false)
  62628. */
  62629. noMipmap?: boolean | undefined,
  62630. /**
  62631. * Defines the explicit list of files (undefined by default)
  62632. */
  62633. files?: string[] | undefined);
  62634. /**
  62635. * Execute the current task
  62636. * @param scene defines the scene where you want your assets to be loaded
  62637. * @param onSuccess is a callback called when the task is successfully executed
  62638. * @param onError is a callback called if an error occurs
  62639. */
  62640. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62641. }
  62642. /**
  62643. * Define a task used by AssetsManager to load HDR cube textures
  62644. */
  62645. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62646. /**
  62647. * Defines the name of the task
  62648. */
  62649. name: string;
  62650. /**
  62651. * Defines the location of the file to load
  62652. */
  62653. url: string;
  62654. /**
  62655. * Defines the desired size (the more it increases the longer the generation will be)
  62656. */
  62657. size: number;
  62658. /**
  62659. * Defines if mipmaps should not be generated (default is false)
  62660. */
  62661. noMipmap: boolean;
  62662. /**
  62663. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62664. */
  62665. generateHarmonics: boolean;
  62666. /**
  62667. * 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)
  62668. */
  62669. gammaSpace: boolean;
  62670. /**
  62671. * Internal Use Only
  62672. */
  62673. reserved: boolean;
  62674. /**
  62675. * Gets the loaded texture
  62676. */
  62677. texture: HDRCubeTexture;
  62678. /**
  62679. * Callback called when the task is successful
  62680. */
  62681. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62682. /**
  62683. * Callback called when the task is successful
  62684. */
  62685. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62686. /**
  62687. * Creates a new HDRCubeTextureAssetTask object
  62688. * @param name defines the name of the task
  62689. * @param url defines the location of the file to load
  62690. * @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.
  62691. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62692. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62693. * @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)
  62694. * @param reserved Internal use only
  62695. */
  62696. constructor(
  62697. /**
  62698. * Defines the name of the task
  62699. */
  62700. name: string,
  62701. /**
  62702. * Defines the location of the file to load
  62703. */
  62704. url: string,
  62705. /**
  62706. * Defines the desired size (the more it increases the longer the generation will be)
  62707. */
  62708. size: number,
  62709. /**
  62710. * Defines if mipmaps should not be generated (default is false)
  62711. */
  62712. noMipmap?: boolean,
  62713. /**
  62714. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62715. */
  62716. generateHarmonics?: boolean,
  62717. /**
  62718. * 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)
  62719. */
  62720. gammaSpace?: boolean,
  62721. /**
  62722. * Internal Use Only
  62723. */
  62724. reserved?: boolean);
  62725. /**
  62726. * Execute the current task
  62727. * @param scene defines the scene where you want your assets to be loaded
  62728. * @param onSuccess is a callback called when the task is successfully executed
  62729. * @param onError is a callback called if an error occurs
  62730. */
  62731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62732. }
  62733. /**
  62734. * Define a task used by AssetsManager to load Equirectangular cube textures
  62735. */
  62736. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62737. /**
  62738. * Defines the name of the task
  62739. */
  62740. name: string;
  62741. /**
  62742. * Defines the location of the file to load
  62743. */
  62744. url: string;
  62745. /**
  62746. * Defines the desired size (the more it increases the longer the generation will be)
  62747. */
  62748. size: number;
  62749. /**
  62750. * Defines if mipmaps should not be generated (default is false)
  62751. */
  62752. noMipmap: boolean;
  62753. /**
  62754. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62755. * but the standard material would require them in Gamma space) (default is true)
  62756. */
  62757. gammaSpace: boolean;
  62758. /**
  62759. * Gets the loaded texture
  62760. */
  62761. texture: EquiRectangularCubeTexture;
  62762. /**
  62763. * Callback called when the task is successful
  62764. */
  62765. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62766. /**
  62767. * Callback called when the task is successful
  62768. */
  62769. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62770. /**
  62771. * Creates a new EquiRectangularCubeTextureAssetTask object
  62772. * @param name defines the name of the task
  62773. * @param url defines the location of the file to load
  62774. * @param size defines the desired size (the more it increases the longer the generation will be)
  62775. * If the size is omitted this implies you are using a preprocessed cubemap.
  62776. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62777. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62778. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62779. * (default is true)
  62780. */
  62781. constructor(
  62782. /**
  62783. * Defines the name of the task
  62784. */
  62785. name: string,
  62786. /**
  62787. * Defines the location of the file to load
  62788. */
  62789. url: string,
  62790. /**
  62791. * Defines the desired size (the more it increases the longer the generation will be)
  62792. */
  62793. size: number,
  62794. /**
  62795. * Defines if mipmaps should not be generated (default is false)
  62796. */
  62797. noMipmap?: boolean,
  62798. /**
  62799. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62800. * but the standard material would require them in Gamma space) (default is true)
  62801. */
  62802. gammaSpace?: boolean);
  62803. /**
  62804. * Execute the current task
  62805. * @param scene defines the scene where you want your assets to be loaded
  62806. * @param onSuccess is a callback called when the task is successfully executed
  62807. * @param onError is a callback called if an error occurs
  62808. */
  62809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62810. }
  62811. /**
  62812. * This class can be used to easily import assets into a scene
  62813. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62814. */
  62815. export class AssetsManager {
  62816. private _scene;
  62817. private _isLoading;
  62818. protected _tasks: AbstractAssetTask[];
  62819. protected _waitingTasksCount: number;
  62820. protected _totalTasksCount: number;
  62821. /**
  62822. * Callback called when all tasks are processed
  62823. */
  62824. onFinish: (tasks: AbstractAssetTask[]) => void;
  62825. /**
  62826. * Callback called when a task is successful
  62827. */
  62828. onTaskSuccess: (task: AbstractAssetTask) => void;
  62829. /**
  62830. * Callback called when a task had an error
  62831. */
  62832. onTaskError: (task: AbstractAssetTask) => void;
  62833. /**
  62834. * Callback called when a task is done (whatever the result is)
  62835. */
  62836. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62837. /**
  62838. * Observable called when all tasks are processed
  62839. */
  62840. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62841. /**
  62842. * Observable called when a task had an error
  62843. */
  62844. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62845. /**
  62846. * Observable called when all tasks were executed
  62847. */
  62848. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62849. /**
  62850. * Observable called when a task is done (whatever the result is)
  62851. */
  62852. onProgressObservable: Observable<IAssetsProgressEvent>;
  62853. /**
  62854. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62856. */
  62857. useDefaultLoadingScreen: boolean;
  62858. /**
  62859. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62860. * when all assets have been downloaded.
  62861. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62862. */
  62863. autoHideLoadingUI: boolean;
  62864. /**
  62865. * Creates a new AssetsManager
  62866. * @param scene defines the scene to work on
  62867. */
  62868. constructor(scene: Scene);
  62869. /**
  62870. * Add a MeshAssetTask to the list of active tasks
  62871. * @param taskName defines the name of the new task
  62872. * @param meshesNames defines the name of meshes to load
  62873. * @param rootUrl defines the root url to use to locate files
  62874. * @param sceneFilename defines the filename of the scene file
  62875. * @returns a new MeshAssetTask object
  62876. */
  62877. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62878. /**
  62879. * Add a TextFileAssetTask to the list of active tasks
  62880. * @param taskName defines the name of the new task
  62881. * @param url defines the url of the file to load
  62882. * @returns a new TextFileAssetTask object
  62883. */
  62884. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62885. /**
  62886. * Add a BinaryFileAssetTask to the list of active tasks
  62887. * @param taskName defines the name of the new task
  62888. * @param url defines the url of the file to load
  62889. * @returns a new BinaryFileAssetTask object
  62890. */
  62891. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62892. /**
  62893. * Add a ImageAssetTask to the list of active tasks
  62894. * @param taskName defines the name of the new task
  62895. * @param url defines the url of the file to load
  62896. * @returns a new ImageAssetTask object
  62897. */
  62898. addImageTask(taskName: string, url: string): ImageAssetTask;
  62899. /**
  62900. * Add a TextureAssetTask to the list of active tasks
  62901. * @param taskName defines the name of the new task
  62902. * @param url defines the url of the file to load
  62903. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62904. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62905. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62906. * @returns a new TextureAssetTask object
  62907. */
  62908. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62909. /**
  62910. * Add a CubeTextureAssetTask to the list of active tasks
  62911. * @param taskName defines the name of the new task
  62912. * @param url defines the url of the file to load
  62913. * @param extensions defines the extension to use to load the cube map (can be null)
  62914. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62915. * @param files defines the list of files to load (can be null)
  62916. * @returns a new CubeTextureAssetTask object
  62917. */
  62918. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62919. /**
  62920. *
  62921. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62922. * @param taskName defines the name of the new task
  62923. * @param url defines the url of the file to load
  62924. * @param size defines the size you want for the cubemap (can be null)
  62925. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62926. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62927. * @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)
  62928. * @param reserved Internal use only
  62929. * @returns a new HDRCubeTextureAssetTask object
  62930. */
  62931. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62932. /**
  62933. *
  62934. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62935. * @param taskName defines the name of the new task
  62936. * @param url defines the url of the file to load
  62937. * @param size defines the size you want for the cubemap (can be null)
  62938. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62939. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62940. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62941. * @returns a new EquiRectangularCubeTextureAssetTask object
  62942. */
  62943. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62944. /**
  62945. * Remove a task from the assets manager.
  62946. * @param task the task to remove
  62947. */
  62948. removeTask(task: AbstractAssetTask): void;
  62949. private _decreaseWaitingTasksCount;
  62950. private _runTask;
  62951. /**
  62952. * Reset the AssetsManager and remove all tasks
  62953. * @return the current instance of the AssetsManager
  62954. */
  62955. reset(): AssetsManager;
  62956. /**
  62957. * Start the loading process
  62958. * @return the current instance of the AssetsManager
  62959. */
  62960. load(): AssetsManager;
  62961. /**
  62962. * Start the loading process as an async operation
  62963. * @return a promise returning the list of failed tasks
  62964. */
  62965. loadAsync(): Promise<void>;
  62966. }
  62967. }
  62968. declare module "babylonjs/Misc/deferred" {
  62969. /**
  62970. * Wrapper class for promise with external resolve and reject.
  62971. */
  62972. export class Deferred<T> {
  62973. /**
  62974. * The promise associated with this deferred object.
  62975. */
  62976. readonly promise: Promise<T>;
  62977. private _resolve;
  62978. private _reject;
  62979. /**
  62980. * The resolve method of the promise associated with this deferred object.
  62981. */
  62982. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62983. /**
  62984. * The reject method of the promise associated with this deferred object.
  62985. */
  62986. readonly reject: (reason?: any) => void;
  62987. /**
  62988. * Constructor for this deferred object.
  62989. */
  62990. constructor();
  62991. }
  62992. }
  62993. declare module "babylonjs/Misc/meshExploder" {
  62994. import { Mesh } from "babylonjs/Meshes/mesh";
  62995. /**
  62996. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62997. */
  62998. export class MeshExploder {
  62999. private _centerMesh;
  63000. private _meshes;
  63001. private _meshesOrigins;
  63002. private _toCenterVectors;
  63003. private _scaledDirection;
  63004. private _newPosition;
  63005. private _centerPosition;
  63006. /**
  63007. * Explodes meshes from a center mesh.
  63008. * @param meshes The meshes to explode.
  63009. * @param centerMesh The mesh to be center of explosion.
  63010. */
  63011. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63012. private _setCenterMesh;
  63013. /**
  63014. * Get class name
  63015. * @returns "MeshExploder"
  63016. */
  63017. getClassName(): string;
  63018. /**
  63019. * "Exploded meshes"
  63020. * @returns Array of meshes with the centerMesh at index 0.
  63021. */
  63022. getMeshes(): Array<Mesh>;
  63023. /**
  63024. * Explodes meshes giving a specific direction
  63025. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63026. */
  63027. explode(direction?: number): void;
  63028. }
  63029. }
  63030. declare module "babylonjs/Misc/filesInput" {
  63031. import { Engine } from "babylonjs/Engines/engine";
  63032. import { Scene } from "babylonjs/scene";
  63033. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  63034. /**
  63035. * Class used to help managing file picking and drag'n'drop
  63036. */
  63037. export class FilesInput {
  63038. /**
  63039. * List of files ready to be loaded
  63040. */
  63041. static readonly FilesToLoad: {
  63042. [key: string]: File;
  63043. };
  63044. /**
  63045. * Callback called when a file is processed
  63046. */
  63047. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63048. private _engine;
  63049. private _currentScene;
  63050. private _sceneLoadedCallback;
  63051. private _progressCallback;
  63052. private _additionalRenderLoopLogicCallback;
  63053. private _textureLoadingCallback;
  63054. private _startingProcessingFilesCallback;
  63055. private _onReloadCallback;
  63056. private _errorCallback;
  63057. private _elementToMonitor;
  63058. private _sceneFileToLoad;
  63059. private _filesToLoad;
  63060. /**
  63061. * Creates a new FilesInput
  63062. * @param engine defines the rendering engine
  63063. * @param scene defines the hosting scene
  63064. * @param sceneLoadedCallback callback called when scene is loaded
  63065. * @param progressCallback callback called to track progress
  63066. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63067. * @param textureLoadingCallback callback called when a texture is loading
  63068. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63069. * @param onReloadCallback callback called when a reload is requested
  63070. * @param errorCallback callback call if an error occurs
  63071. */
  63072. 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);
  63073. private _dragEnterHandler;
  63074. private _dragOverHandler;
  63075. private _dropHandler;
  63076. /**
  63077. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63078. * @param elementToMonitor defines the DOM element to track
  63079. */
  63080. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63081. /**
  63082. * Release all associated resources
  63083. */
  63084. dispose(): void;
  63085. private renderFunction;
  63086. private drag;
  63087. private drop;
  63088. private _traverseFolder;
  63089. private _processFiles;
  63090. /**
  63091. * Load files from a drop event
  63092. * @param event defines the drop event to use as source
  63093. */
  63094. loadFiles(event: any): void;
  63095. private _processReload;
  63096. /**
  63097. * Reload the current scene from the loaded files
  63098. */
  63099. reload(): void;
  63100. }
  63101. }
  63102. declare module "babylonjs/Misc/HighDynamicRange/index" {
  63103. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  63104. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  63105. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63106. }
  63107. declare module "babylonjs/Misc/sceneOptimizer" {
  63108. import { Scene, IDisposable } from "babylonjs/scene";
  63109. import { Observable } from "babylonjs/Misc/observable";
  63110. /**
  63111. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63112. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63113. */
  63114. export class SceneOptimization {
  63115. /**
  63116. * Defines the priority of this optimization (0 by default which means first in the list)
  63117. */
  63118. priority: number;
  63119. /**
  63120. * Gets a string describing the action executed by the current optimization
  63121. * @returns description string
  63122. */
  63123. getDescription(): string;
  63124. /**
  63125. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63126. * @param scene defines the current scene where to apply this optimization
  63127. * @param optimizer defines the current optimizer
  63128. * @returns true if everything that can be done was applied
  63129. */
  63130. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63131. /**
  63132. * Creates the SceneOptimization object
  63133. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63134. * @param desc defines the description associated with the optimization
  63135. */
  63136. constructor(
  63137. /**
  63138. * Defines the priority of this optimization (0 by default which means first in the list)
  63139. */
  63140. priority?: number);
  63141. }
  63142. /**
  63143. * Defines an optimization used to reduce the size of render target textures
  63144. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63145. */
  63146. export class TextureOptimization extends SceneOptimization {
  63147. /**
  63148. * Defines the priority of this optimization (0 by default which means first in the list)
  63149. */
  63150. priority: number;
  63151. /**
  63152. * 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
  63153. */
  63154. maximumSize: number;
  63155. /**
  63156. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63157. */
  63158. step: number;
  63159. /**
  63160. * Gets a string describing the action executed by the current optimization
  63161. * @returns description string
  63162. */
  63163. getDescription(): string;
  63164. /**
  63165. * Creates the TextureOptimization object
  63166. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63167. * @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
  63168. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63169. */
  63170. constructor(
  63171. /**
  63172. * Defines the priority of this optimization (0 by default which means first in the list)
  63173. */
  63174. priority?: number,
  63175. /**
  63176. * 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
  63177. */
  63178. maximumSize?: number,
  63179. /**
  63180. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63181. */
  63182. step?: number);
  63183. /**
  63184. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63185. * @param scene defines the current scene where to apply this optimization
  63186. * @param optimizer defines the current optimizer
  63187. * @returns true if everything that can be done was applied
  63188. */
  63189. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63190. }
  63191. /**
  63192. * Defines an optimization used to increase or decrease the rendering resolution
  63193. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63194. */
  63195. export class HardwareScalingOptimization extends SceneOptimization {
  63196. /**
  63197. * Defines the priority of this optimization (0 by default which means first in the list)
  63198. */
  63199. priority: number;
  63200. /**
  63201. * Defines the maximum scale to use (2 by default)
  63202. */
  63203. maximumScale: number;
  63204. /**
  63205. * Defines the step to use between two passes (0.5 by default)
  63206. */
  63207. step: number;
  63208. private _currentScale;
  63209. private _directionOffset;
  63210. /**
  63211. * Gets a string describing the action executed by the current optimization
  63212. * @return description string
  63213. */
  63214. getDescription(): string;
  63215. /**
  63216. * Creates the HardwareScalingOptimization object
  63217. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63218. * @param maximumScale defines the maximum scale to use (2 by default)
  63219. * @param step defines the step to use between two passes (0.5 by default)
  63220. */
  63221. constructor(
  63222. /**
  63223. * Defines the priority of this optimization (0 by default which means first in the list)
  63224. */
  63225. priority?: number,
  63226. /**
  63227. * Defines the maximum scale to use (2 by default)
  63228. */
  63229. maximumScale?: number,
  63230. /**
  63231. * Defines the step to use between two passes (0.5 by default)
  63232. */
  63233. step?: number);
  63234. /**
  63235. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63236. * @param scene defines the current scene where to apply this optimization
  63237. * @param optimizer defines the current optimizer
  63238. * @returns true if everything that can be done was applied
  63239. */
  63240. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63241. }
  63242. /**
  63243. * Defines an optimization used to remove shadows
  63244. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63245. */
  63246. export class ShadowsOptimization extends SceneOptimization {
  63247. /**
  63248. * Gets a string describing the action executed by the current optimization
  63249. * @return description string
  63250. */
  63251. getDescription(): string;
  63252. /**
  63253. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63254. * @param scene defines the current scene where to apply this optimization
  63255. * @param optimizer defines the current optimizer
  63256. * @returns true if everything that can be done was applied
  63257. */
  63258. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63259. }
  63260. /**
  63261. * Defines an optimization used to turn post-processes off
  63262. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63263. */
  63264. export class PostProcessesOptimization extends SceneOptimization {
  63265. /**
  63266. * Gets a string describing the action executed by the current optimization
  63267. * @return description string
  63268. */
  63269. getDescription(): string;
  63270. /**
  63271. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63272. * @param scene defines the current scene where to apply this optimization
  63273. * @param optimizer defines the current optimizer
  63274. * @returns true if everything that can be done was applied
  63275. */
  63276. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63277. }
  63278. /**
  63279. * Defines an optimization used to turn lens flares off
  63280. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63281. */
  63282. export class LensFlaresOptimization extends SceneOptimization {
  63283. /**
  63284. * Gets a string describing the action executed by the current optimization
  63285. * @return description string
  63286. */
  63287. getDescription(): string;
  63288. /**
  63289. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63290. * @param scene defines the current scene where to apply this optimization
  63291. * @param optimizer defines the current optimizer
  63292. * @returns true if everything that can be done was applied
  63293. */
  63294. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63295. }
  63296. /**
  63297. * Defines an optimization based on user defined callback.
  63298. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63299. */
  63300. export class CustomOptimization extends SceneOptimization {
  63301. /**
  63302. * Callback called to apply the custom optimization.
  63303. */
  63304. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63305. /**
  63306. * Callback called to get custom description
  63307. */
  63308. onGetDescription: () => string;
  63309. /**
  63310. * Gets a string describing the action executed by the current optimization
  63311. * @returns description string
  63312. */
  63313. getDescription(): string;
  63314. /**
  63315. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63316. * @param scene defines the current scene where to apply this optimization
  63317. * @param optimizer defines the current optimizer
  63318. * @returns true if everything that can be done was applied
  63319. */
  63320. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63321. }
  63322. /**
  63323. * Defines an optimization used to turn particles off
  63324. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63325. */
  63326. export class ParticlesOptimization extends SceneOptimization {
  63327. /**
  63328. * Gets a string describing the action executed by the current optimization
  63329. * @return description string
  63330. */
  63331. getDescription(): string;
  63332. /**
  63333. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63334. * @param scene defines the current scene where to apply this optimization
  63335. * @param optimizer defines the current optimizer
  63336. * @returns true if everything that can be done was applied
  63337. */
  63338. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63339. }
  63340. /**
  63341. * Defines an optimization used to turn render targets off
  63342. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63343. */
  63344. export class RenderTargetsOptimization extends SceneOptimization {
  63345. /**
  63346. * Gets a string describing the action executed by the current optimization
  63347. * @return description string
  63348. */
  63349. getDescription(): string;
  63350. /**
  63351. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63352. * @param scene defines the current scene where to apply this optimization
  63353. * @param optimizer defines the current optimizer
  63354. * @returns true if everything that can be done was applied
  63355. */
  63356. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63357. }
  63358. /**
  63359. * Defines an optimization used to merge meshes with compatible materials
  63360. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63361. */
  63362. export class MergeMeshesOptimization extends SceneOptimization {
  63363. private static _UpdateSelectionTree;
  63364. /**
  63365. * Gets or sets a boolean which defines if optimization octree has to be updated
  63366. */
  63367. /**
  63368. * Gets or sets a boolean which defines if optimization octree has to be updated
  63369. */
  63370. static UpdateSelectionTree: boolean;
  63371. /**
  63372. * Gets a string describing the action executed by the current optimization
  63373. * @return description string
  63374. */
  63375. getDescription(): string;
  63376. private _canBeMerged;
  63377. /**
  63378. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63379. * @param scene defines the current scene where to apply this optimization
  63380. * @param optimizer defines the current optimizer
  63381. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63382. * @returns true if everything that can be done was applied
  63383. */
  63384. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63385. }
  63386. /**
  63387. * Defines a list of options used by SceneOptimizer
  63388. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63389. */
  63390. export class SceneOptimizerOptions {
  63391. /**
  63392. * Defines the target frame rate to reach (60 by default)
  63393. */
  63394. targetFrameRate: number;
  63395. /**
  63396. * Defines the interval between two checkes (2000ms by default)
  63397. */
  63398. trackerDuration: number;
  63399. /**
  63400. * Gets the list of optimizations to apply
  63401. */
  63402. optimizations: SceneOptimization[];
  63403. /**
  63404. * Creates a new list of options used by SceneOptimizer
  63405. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63406. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63407. */
  63408. constructor(
  63409. /**
  63410. * Defines the target frame rate to reach (60 by default)
  63411. */
  63412. targetFrameRate?: number,
  63413. /**
  63414. * Defines the interval between two checkes (2000ms by default)
  63415. */
  63416. trackerDuration?: number);
  63417. /**
  63418. * Add a new optimization
  63419. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63420. * @returns the current SceneOptimizerOptions
  63421. */
  63422. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63423. /**
  63424. * Add a new custom optimization
  63425. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63426. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63427. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63428. * @returns the current SceneOptimizerOptions
  63429. */
  63430. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63431. /**
  63432. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63433. * @param targetFrameRate defines the target frame rate (60 by default)
  63434. * @returns a SceneOptimizerOptions object
  63435. */
  63436. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63437. /**
  63438. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63439. * @param targetFrameRate defines the target frame rate (60 by default)
  63440. * @returns a SceneOptimizerOptions object
  63441. */
  63442. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63443. /**
  63444. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63445. * @param targetFrameRate defines the target frame rate (60 by default)
  63446. * @returns a SceneOptimizerOptions object
  63447. */
  63448. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63449. }
  63450. /**
  63451. * Class used to run optimizations in order to reach a target frame rate
  63452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63453. */
  63454. export class SceneOptimizer implements IDisposable {
  63455. private _isRunning;
  63456. private _options;
  63457. private _scene;
  63458. private _currentPriorityLevel;
  63459. private _targetFrameRate;
  63460. private _trackerDuration;
  63461. private _currentFrameRate;
  63462. private _sceneDisposeObserver;
  63463. private _improvementMode;
  63464. /**
  63465. * Defines an observable called when the optimizer reaches the target frame rate
  63466. */
  63467. onSuccessObservable: Observable<SceneOptimizer>;
  63468. /**
  63469. * Defines an observable called when the optimizer enables an optimization
  63470. */
  63471. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63472. /**
  63473. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63474. */
  63475. onFailureObservable: Observable<SceneOptimizer>;
  63476. /**
  63477. * Gets a boolean indicating if the optimizer is in improvement mode
  63478. */
  63479. readonly isInImprovementMode: boolean;
  63480. /**
  63481. * Gets the current priority level (0 at start)
  63482. */
  63483. readonly currentPriorityLevel: number;
  63484. /**
  63485. * Gets the current frame rate checked by the SceneOptimizer
  63486. */
  63487. readonly currentFrameRate: number;
  63488. /**
  63489. * Gets or sets the current target frame rate (60 by default)
  63490. */
  63491. /**
  63492. * Gets or sets the current target frame rate (60 by default)
  63493. */
  63494. targetFrameRate: number;
  63495. /**
  63496. * Gets or sets the current interval between two checks (every 2000ms by default)
  63497. */
  63498. /**
  63499. * Gets or sets the current interval between two checks (every 2000ms by default)
  63500. */
  63501. trackerDuration: number;
  63502. /**
  63503. * Gets the list of active optimizations
  63504. */
  63505. readonly optimizations: SceneOptimization[];
  63506. /**
  63507. * Creates a new SceneOptimizer
  63508. * @param scene defines the scene to work on
  63509. * @param options defines the options to use with the SceneOptimizer
  63510. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63511. * @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)
  63512. */
  63513. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63514. /**
  63515. * Stops the current optimizer
  63516. */
  63517. stop(): void;
  63518. /**
  63519. * Reset the optimizer to initial step (current priority level = 0)
  63520. */
  63521. reset(): void;
  63522. /**
  63523. * Start the optimizer. By default it will try to reach a specific framerate
  63524. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63525. */
  63526. start(): void;
  63527. private _checkCurrentState;
  63528. /**
  63529. * Release all resources
  63530. */
  63531. dispose(): void;
  63532. /**
  63533. * Helper function to create a SceneOptimizer with one single line of code
  63534. * @param scene defines the scene to work on
  63535. * @param options defines the options to use with the SceneOptimizer
  63536. * @param onSuccess defines a callback to call on success
  63537. * @param onFailure defines a callback to call on failure
  63538. * @returns the new SceneOptimizer object
  63539. */
  63540. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63541. }
  63542. }
  63543. declare module "babylonjs/Misc/sceneSerializer" {
  63544. import { Scene } from "babylonjs/scene";
  63545. /**
  63546. * Class used to serialize a scene into a string
  63547. */
  63548. export class SceneSerializer {
  63549. /**
  63550. * Clear cache used by a previous serialization
  63551. */
  63552. static ClearCache(): void;
  63553. /**
  63554. * Serialize a scene into a JSON compatible object
  63555. * @param scene defines the scene to serialize
  63556. * @returns a JSON compatible object
  63557. */
  63558. static Serialize(scene: Scene): any;
  63559. /**
  63560. * Serialize a mesh into a JSON compatible object
  63561. * @param toSerialize defines the mesh to serialize
  63562. * @param withParents defines if parents must be serialized as well
  63563. * @param withChildren defines if children must be serialized as well
  63564. * @returns a JSON compatible object
  63565. */
  63566. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63567. }
  63568. }
  63569. declare module "babylonjs/Misc/textureTools" {
  63570. import { Texture } from "babylonjs/Materials/Textures/texture";
  63571. /**
  63572. * Class used to host texture specific utilities
  63573. */
  63574. export class TextureTools {
  63575. /**
  63576. * Uses the GPU to create a copy texture rescaled at a given size
  63577. * @param texture Texture to copy from
  63578. * @param width defines the desired width
  63579. * @param height defines the desired height
  63580. * @param useBilinearMode defines if bilinear mode has to be used
  63581. * @return the generated texture
  63582. */
  63583. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63584. }
  63585. }
  63586. declare module "babylonjs/Misc/videoRecorder" {
  63587. import { Nullable } from "babylonjs/types";
  63588. import { Engine } from "babylonjs/Engines/engine";
  63589. /**
  63590. * This represents the different options available for the video capture.
  63591. */
  63592. export interface VideoRecorderOptions {
  63593. /** Defines the mime type of the video. */
  63594. mimeType: string;
  63595. /** Defines the FPS the video should be recorded at. */
  63596. fps: number;
  63597. /** Defines the chunk size for the recording data. */
  63598. recordChunckSize: number;
  63599. /** The audio tracks to attach to the recording. */
  63600. audioTracks?: MediaStreamTrack[];
  63601. }
  63602. /**
  63603. * This can help with recording videos from BabylonJS.
  63604. * This is based on the available WebRTC functionalities of the browser.
  63605. *
  63606. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63607. */
  63608. export class VideoRecorder {
  63609. private static readonly _defaultOptions;
  63610. /**
  63611. * Returns whether or not the VideoRecorder is available in your browser.
  63612. * @param engine Defines the Babylon Engine.
  63613. * @returns true if supported otherwise false.
  63614. */
  63615. static IsSupported(engine: Engine): boolean;
  63616. private readonly _options;
  63617. private _canvas;
  63618. private _mediaRecorder;
  63619. private _recordedChunks;
  63620. private _fileName;
  63621. private _resolve;
  63622. private _reject;
  63623. /**
  63624. * True when a recording is already in progress.
  63625. */
  63626. readonly isRecording: boolean;
  63627. /**
  63628. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63629. * @param engine Defines the BabylonJS Engine you wish to record.
  63630. * @param options Defines options that can be used to customize the capture.
  63631. */
  63632. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63633. /**
  63634. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63635. */
  63636. stopRecording(): void;
  63637. /**
  63638. * Starts recording the canvas for a max duration specified in parameters.
  63639. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63640. * If null no automatic download will start and you can rely on the promise to get the data back.
  63641. * @param maxDuration Defines the maximum recording time in seconds.
  63642. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63643. * @return A promise callback at the end of the recording with the video data in Blob.
  63644. */
  63645. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63646. /**
  63647. * Releases internal resources used during the recording.
  63648. */
  63649. dispose(): void;
  63650. private _handleDataAvailable;
  63651. private _handleError;
  63652. private _handleStop;
  63653. }
  63654. }
  63655. declare module "babylonjs/Misc/screenshotTools" {
  63656. import { Camera } from "babylonjs/Cameras/camera";
  63657. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  63658. import { Engine } from "babylonjs/Engines/engine";
  63659. /**
  63660. * Class containing a set of static utilities functions for screenshots
  63661. */
  63662. export class ScreenshotTools {
  63663. /**
  63664. * Captures a screenshot of the current rendering
  63665. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63666. * @param engine defines the rendering engine
  63667. * @param camera defines the source camera
  63668. * @param size This parameter can be set to a single number or to an object with the
  63669. * following (optional) properties: precision, width, height. If a single number is passed,
  63670. * it will be used for both width and height. If an object is passed, the screenshot size
  63671. * will be derived from the parameters. The precision property is a multiplier allowing
  63672. * rendering at a higher or lower resolution
  63673. * @param successCallback defines the callback receives a single parameter which contains the
  63674. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63675. * src parameter of an <img> to display it
  63676. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63677. * Check your browser for supported MIME types
  63678. */
  63679. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63680. /**
  63681. * Captures a screenshot of the current rendering
  63682. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63683. * @param engine defines the rendering engine
  63684. * @param camera defines the source camera
  63685. * @param size This parameter can be set to a single number or to an object with the
  63686. * following (optional) properties: precision, width, height. If a single number is passed,
  63687. * it will be used for both width and height. If an object is passed, the screenshot size
  63688. * will be derived from the parameters. The precision property is a multiplier allowing
  63689. * rendering at a higher or lower resolution
  63690. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63691. * Check your browser for supported MIME types
  63692. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63693. * to the src parameter of an <img> to display it
  63694. */
  63695. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63696. /**
  63697. * Generates an image screenshot from the specified camera.
  63698. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63699. * @param engine The engine to use for rendering
  63700. * @param camera The camera to use for rendering
  63701. * @param size This parameter can be set to a single number or to an object with the
  63702. * following (optional) properties: precision, width, height. If a single number is passed,
  63703. * it will be used for both width and height. If an object is passed, the screenshot size
  63704. * will be derived from the parameters. The precision property is a multiplier allowing
  63705. * rendering at a higher or lower resolution
  63706. * @param successCallback The callback receives a single parameter which contains the
  63707. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63708. * src parameter of an <img> to display it
  63709. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63710. * Check your browser for supported MIME types
  63711. * @param samples Texture samples (default: 1)
  63712. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63713. * @param fileName A name for for the downloaded file.
  63714. */
  63715. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63716. /**
  63717. * Generates an image screenshot from the specified camera.
  63718. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63719. * @param engine The engine to use for rendering
  63720. * @param camera The camera to use for rendering
  63721. * @param size This parameter can be set to a single number or to an object with the
  63722. * following (optional) properties: precision, width, height. If a single number is passed,
  63723. * it will be used for both width and height. If an object is passed, the screenshot size
  63724. * will be derived from the parameters. The precision property is a multiplier allowing
  63725. * rendering at a higher or lower resolution
  63726. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63727. * Check your browser for supported MIME types
  63728. * @param samples Texture samples (default: 1)
  63729. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63730. * @param fileName A name for for the downloaded file.
  63731. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63732. * to the src parameter of an <img> to display it
  63733. */
  63734. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63735. }
  63736. }
  63737. declare module "babylonjs/Misc/index" {
  63738. export * from "babylonjs/Misc/andOrNotEvaluator";
  63739. export * from "babylonjs/Misc/assetsManager";
  63740. export * from "babylonjs/Misc/dds";
  63741. export * from "babylonjs/Misc/decorators";
  63742. export * from "babylonjs/Misc/deferred";
  63743. export * from "babylonjs/Misc/environmentTextureTools";
  63744. export * from "babylonjs/Misc/meshExploder";
  63745. export * from "babylonjs/Misc/filesInput";
  63746. export * from "babylonjs/Misc/HighDynamicRange/index";
  63747. export * from "babylonjs/Misc/khronosTextureContainer";
  63748. export * from "babylonjs/Misc/observable";
  63749. export * from "babylonjs/Misc/performanceMonitor";
  63750. export * from "babylonjs/Misc/promise";
  63751. export * from "babylonjs/Misc/sceneOptimizer";
  63752. export * from "babylonjs/Misc/sceneSerializer";
  63753. export * from "babylonjs/Misc/smartArray";
  63754. export * from "babylonjs/Misc/stringDictionary";
  63755. export * from "babylonjs/Misc/tags";
  63756. export * from "babylonjs/Misc/textureTools";
  63757. export * from "babylonjs/Misc/tga";
  63758. export * from "babylonjs/Misc/tools";
  63759. export * from "babylonjs/Misc/videoRecorder";
  63760. export * from "babylonjs/Misc/virtualJoystick";
  63761. export * from "babylonjs/Misc/workerPool";
  63762. export * from "babylonjs/Misc/logger";
  63763. export * from "babylonjs/Misc/typeStore";
  63764. export * from "babylonjs/Misc/filesInputStore";
  63765. export * from "babylonjs/Misc/deepCopier";
  63766. export * from "babylonjs/Misc/pivotTools";
  63767. export * from "babylonjs/Misc/precisionDate";
  63768. export * from "babylonjs/Misc/screenshotTools";
  63769. export * from "babylonjs/Misc/typeStore";
  63770. export * from "babylonjs/Misc/webRequest";
  63771. export * from "babylonjs/Misc/iInspectable";
  63772. export * from "babylonjs/Misc/brdfTextureTools";
  63773. export * from "babylonjs/Misc/gradients";
  63774. export * from "babylonjs/Misc/perfCounter";
  63775. export * from "babylonjs/Misc/fileRequest";
  63776. export * from "babylonjs/Misc/customAnimationFrameRequester";
  63777. export * from "babylonjs/Misc/retryStrategy";
  63778. export * from "babylonjs/Misc/loadFileError";
  63779. }
  63780. declare module "babylonjs/index" {
  63781. export * from "babylonjs/abstractScene";
  63782. export * from "babylonjs/Actions/index";
  63783. export * from "babylonjs/Animations/index";
  63784. export * from "babylonjs/assetContainer";
  63785. export * from "babylonjs/Audio/index";
  63786. export * from "babylonjs/Behaviors/index";
  63787. export * from "babylonjs/Bones/index";
  63788. export * from "babylonjs/Cameras/index";
  63789. export * from "babylonjs/Collisions/index";
  63790. export * from "babylonjs/Culling/index";
  63791. export * from "babylonjs/Debug/index";
  63792. export * from "babylonjs/Engines/index";
  63793. export * from "babylonjs/Events/index";
  63794. export * from "babylonjs/Gamepads/index";
  63795. export * from "babylonjs/Gizmos/index";
  63796. export * from "babylonjs/Helpers/index";
  63797. export * from "babylonjs/Instrumentation/index";
  63798. export * from "babylonjs/Layers/index";
  63799. export * from "babylonjs/LensFlares/index";
  63800. export * from "babylonjs/Lights/index";
  63801. export * from "babylonjs/Loading/index";
  63802. export * from "babylonjs/Materials/index";
  63803. export * from "babylonjs/Maths/index";
  63804. export * from "babylonjs/Meshes/index";
  63805. export * from "babylonjs/Morph/index";
  63806. export * from "babylonjs/Navigation/index";
  63807. export * from "babylonjs/node";
  63808. export * from "babylonjs/Offline/index";
  63809. export * from "babylonjs/Particles/index";
  63810. export * from "babylonjs/Physics/index";
  63811. export * from "babylonjs/PostProcesses/index";
  63812. export * from "babylonjs/Probes/index";
  63813. export * from "babylonjs/Rendering/index";
  63814. export * from "babylonjs/scene";
  63815. export * from "babylonjs/sceneComponent";
  63816. export * from "babylonjs/Sprites/index";
  63817. export * from "babylonjs/States/index";
  63818. export * from "babylonjs/Misc/index";
  63819. export * from "babylonjs/types";
  63820. }
  63821. declare module "babylonjs/Animations/pathCursor" {
  63822. import { Vector3 } from "babylonjs/Maths/math.vector";
  63823. import { Path2 } from "babylonjs/Maths/math.path";
  63824. /**
  63825. * A cursor which tracks a point on a path
  63826. */
  63827. export class PathCursor {
  63828. private path;
  63829. /**
  63830. * Stores path cursor callbacks for when an onchange event is triggered
  63831. */
  63832. private _onchange;
  63833. /**
  63834. * The value of the path cursor
  63835. */
  63836. value: number;
  63837. /**
  63838. * The animation array of the path cursor
  63839. */
  63840. animations: Animation[];
  63841. /**
  63842. * Initializes the path cursor
  63843. * @param path The path to track
  63844. */
  63845. constructor(path: Path2);
  63846. /**
  63847. * Gets the cursor point on the path
  63848. * @returns A point on the path cursor at the cursor location
  63849. */
  63850. getPoint(): Vector3;
  63851. /**
  63852. * Moves the cursor ahead by the step amount
  63853. * @param step The amount to move the cursor forward
  63854. * @returns This path cursor
  63855. */
  63856. moveAhead(step?: number): PathCursor;
  63857. /**
  63858. * Moves the cursor behind by the step amount
  63859. * @param step The amount to move the cursor back
  63860. * @returns This path cursor
  63861. */
  63862. moveBack(step?: number): PathCursor;
  63863. /**
  63864. * Moves the cursor by the step amount
  63865. * If the step amount is greater than one, an exception is thrown
  63866. * @param step The amount to move the cursor
  63867. * @returns This path cursor
  63868. */
  63869. move(step: number): PathCursor;
  63870. /**
  63871. * Ensures that the value is limited between zero and one
  63872. * @returns This path cursor
  63873. */
  63874. private ensureLimits;
  63875. /**
  63876. * Runs onchange callbacks on change (used by the animation engine)
  63877. * @returns This path cursor
  63878. */
  63879. private raiseOnChange;
  63880. /**
  63881. * Executes a function on change
  63882. * @param f A path cursor onchange callback
  63883. * @returns This path cursor
  63884. */
  63885. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63886. }
  63887. }
  63888. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  63889. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  63890. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  63891. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  63892. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  63893. }
  63894. declare module "babylonjs/Engines/Processors/Expressions/index" {
  63895. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  63896. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  63897. }
  63898. declare module "babylonjs/Engines/Processors/index" {
  63899. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  63900. export * from "babylonjs/Engines/Processors/Expressions/index";
  63901. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  63902. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  63903. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  63904. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  63905. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  63906. export * from "babylonjs/Engines/Processors/shaderProcessor";
  63907. }
  63908. declare module "babylonjs/Legacy/legacy" {
  63909. import * as Babylon from "babylonjs/index";
  63910. export * from "babylonjs/index";
  63911. }
  63912. declare module "babylonjs/Shaders/blur.fragment" {
  63913. /** @hidden */
  63914. export var blurPixelShader: {
  63915. name: string;
  63916. shader: string;
  63917. };
  63918. }
  63919. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  63920. /** @hidden */
  63921. export var pointCloudVertexDeclaration: {
  63922. name: string;
  63923. shader: string;
  63924. };
  63925. }
  63926. declare module "babylonjs" {
  63927. export * from "babylonjs/Legacy/legacy";
  63928. }
  63929. declare module BABYLON {
  63930. /** Alias type for value that can be null */
  63931. export type Nullable<T> = T | null;
  63932. /**
  63933. * Alias type for number that are floats
  63934. * @ignorenaming
  63935. */
  63936. export type float = number;
  63937. /**
  63938. * Alias type for number that are doubles.
  63939. * @ignorenaming
  63940. */
  63941. export type double = number;
  63942. /**
  63943. * Alias type for number that are integer
  63944. * @ignorenaming
  63945. */
  63946. export type int = number;
  63947. /** Alias type for number array or Float32Array */
  63948. export type FloatArray = number[] | Float32Array;
  63949. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  63950. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  63951. /**
  63952. * Alias for types that can be used by a Buffer or VertexBuffer.
  63953. */
  63954. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  63955. /**
  63956. * Alias type for primitive types
  63957. * @ignorenaming
  63958. */
  63959. type Primitive = undefined | null | boolean | string | number | Function;
  63960. /**
  63961. * Type modifier to make all the properties of an object Readonly
  63962. */
  63963. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  63964. /**
  63965. * Type modifier to make all the properties of an object Readonly recursively
  63966. */
  63967. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  63968. /** @hidden */
  63969. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  63970. }
  63971. /** @hidden */
  63972. /** @hidden */
  63973. type DeepImmutableObject<T> = {
  63974. readonly [K in keyof T]: DeepImmutable<T[K]>;
  63975. };
  63976. }
  63977. declare module BABYLON {
  63978. /**
  63979. * A class serves as a medium between the observable and its observers
  63980. */
  63981. export class EventState {
  63982. /**
  63983. * Create a new EventState
  63984. * @param mask defines the mask associated with this state
  63985. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63986. * @param target defines the original target of the state
  63987. * @param currentTarget defines the current target of the state
  63988. */
  63989. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63990. /**
  63991. * Initialize the current event state
  63992. * @param mask defines the mask associated with this state
  63993. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63994. * @param target defines the original target of the state
  63995. * @param currentTarget defines the current target of the state
  63996. * @returns the current event state
  63997. */
  63998. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63999. /**
  64000. * An Observer can set this property to true to prevent subsequent observers of being notified
  64001. */
  64002. skipNextObservers: boolean;
  64003. /**
  64004. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64005. */
  64006. mask: number;
  64007. /**
  64008. * The object that originally notified the event
  64009. */
  64010. target?: any;
  64011. /**
  64012. * The current object in the bubbling phase
  64013. */
  64014. currentTarget?: any;
  64015. /**
  64016. * This will be populated with the return value of the last function that was executed.
  64017. * If it is the first function in the callback chain it will be the event data.
  64018. */
  64019. lastReturnValue?: any;
  64020. }
  64021. /**
  64022. * Represent an Observer registered to a given Observable object.
  64023. */
  64024. export class Observer<T> {
  64025. /**
  64026. * Defines the callback to call when the observer is notified
  64027. */
  64028. callback: (eventData: T, eventState: EventState) => void;
  64029. /**
  64030. * Defines the mask of the observer (used to filter notifications)
  64031. */
  64032. mask: number;
  64033. /**
  64034. * Defines the current scope used to restore the JS context
  64035. */
  64036. scope: any;
  64037. /** @hidden */
  64038. _willBeUnregistered: boolean;
  64039. /**
  64040. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64041. */
  64042. unregisterOnNextCall: boolean;
  64043. /**
  64044. * Creates a new observer
  64045. * @param callback defines the callback to call when the observer is notified
  64046. * @param mask defines the mask of the observer (used to filter notifications)
  64047. * @param scope defines the current scope used to restore the JS context
  64048. */
  64049. constructor(
  64050. /**
  64051. * Defines the callback to call when the observer is notified
  64052. */
  64053. callback: (eventData: T, eventState: EventState) => void,
  64054. /**
  64055. * Defines the mask of the observer (used to filter notifications)
  64056. */
  64057. mask: number,
  64058. /**
  64059. * Defines the current scope used to restore the JS context
  64060. */
  64061. scope?: any);
  64062. }
  64063. /**
  64064. * Represent a list of observers registered to multiple Observables object.
  64065. */
  64066. export class MultiObserver<T> {
  64067. private _observers;
  64068. private _observables;
  64069. /**
  64070. * Release associated resources
  64071. */
  64072. dispose(): void;
  64073. /**
  64074. * Raise a callback when one of the observable will notify
  64075. * @param observables defines a list of observables to watch
  64076. * @param callback defines the callback to call on notification
  64077. * @param mask defines the mask used to filter notifications
  64078. * @param scope defines the current scope used to restore the JS context
  64079. * @returns the new MultiObserver
  64080. */
  64081. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64082. }
  64083. /**
  64084. * The Observable class is a simple implementation of the Observable pattern.
  64085. *
  64086. * 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.
  64087. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64088. * 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).
  64089. * 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.
  64090. */
  64091. export class Observable<T> {
  64092. private _observers;
  64093. private _eventState;
  64094. private _onObserverAdded;
  64095. /**
  64096. * Gets the list of observers
  64097. */
  64098. readonly observers: Array<Observer<T>>;
  64099. /**
  64100. * Creates a new observable
  64101. * @param onObserverAdded defines a callback to call when a new observer is added
  64102. */
  64103. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64104. /**
  64105. * Create a new Observer with the specified callback
  64106. * @param callback the callback that will be executed for that Observer
  64107. * @param mask the mask used to filter observers
  64108. * @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.
  64109. * @param scope optional scope for the callback to be called from
  64110. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64111. * @returns the new observer created for the callback
  64112. */
  64113. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64114. /**
  64115. * Create a new Observer with the specified callback and unregisters after the next notification
  64116. * @param callback the callback that will be executed for that Observer
  64117. * @returns the new observer created for the callback
  64118. */
  64119. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64120. /**
  64121. * Remove an Observer from the Observable object
  64122. * @param observer the instance of the Observer to remove
  64123. * @returns false if it doesn't belong to this Observable
  64124. */
  64125. remove(observer: Nullable<Observer<T>>): boolean;
  64126. /**
  64127. * Remove a callback from the Observable object
  64128. * @param callback the callback to remove
  64129. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64130. * @returns false if it doesn't belong to this Observable
  64131. */
  64132. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64133. private _deferUnregister;
  64134. private _remove;
  64135. /**
  64136. * Moves the observable to the top of the observer list making it get called first when notified
  64137. * @param observer the observer to move
  64138. */
  64139. makeObserverTopPriority(observer: Observer<T>): void;
  64140. /**
  64141. * Moves the observable to the bottom of the observer list making it get called last when notified
  64142. * @param observer the observer to move
  64143. */
  64144. makeObserverBottomPriority(observer: Observer<T>): void;
  64145. /**
  64146. * Notify all Observers by calling their respective callback with the given data
  64147. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64148. * @param eventData defines the data to send to all observers
  64149. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64150. * @param target defines the original target of the state
  64151. * @param currentTarget defines the current target of the state
  64152. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64153. */
  64154. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64155. /**
  64156. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64157. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64158. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64159. * and it is crucial that all callbacks will be executed.
  64160. * The order of the callbacks is kept, callbacks are not executed parallel.
  64161. *
  64162. * @param eventData The data to be sent to each callback
  64163. * @param mask is used to filter observers defaults to -1
  64164. * @param target defines the callback target (see EventState)
  64165. * @param currentTarget defines he current object in the bubbling phase
  64166. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64167. */
  64168. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64169. /**
  64170. * Notify a specific observer
  64171. * @param observer defines the observer to notify
  64172. * @param eventData defines the data to be sent to each callback
  64173. * @param mask is used to filter observers defaults to -1
  64174. */
  64175. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64176. /**
  64177. * Gets a boolean indicating if the observable has at least one observer
  64178. * @returns true is the Observable has at least one Observer registered
  64179. */
  64180. hasObservers(): boolean;
  64181. /**
  64182. * Clear the list of observers
  64183. */
  64184. clear(): void;
  64185. /**
  64186. * Clone the current observable
  64187. * @returns a new observable
  64188. */
  64189. clone(): Observable<T>;
  64190. /**
  64191. * Does this observable handles observer registered with a given mask
  64192. * @param mask defines the mask to be tested
  64193. * @return whether or not one observer registered with the given mask is handeled
  64194. **/
  64195. hasSpecificMask(mask?: number): boolean;
  64196. }
  64197. }
  64198. declare module BABYLON {
  64199. /**
  64200. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64201. * Babylon.js
  64202. */
  64203. export class DomManagement {
  64204. /**
  64205. * Checks if the window object exists
  64206. * @returns true if the window object exists
  64207. */
  64208. static IsWindowObjectExist(): boolean;
  64209. /**
  64210. * Extracts text content from a DOM element hierarchy
  64211. * @param element defines the root element
  64212. * @returns a string
  64213. */
  64214. static GetDOMTextContent(element: HTMLElement): string;
  64215. }
  64216. }
  64217. declare module BABYLON {
  64218. /**
  64219. * Logger used througouht the application to allow configuration of
  64220. * the log level required for the messages.
  64221. */
  64222. export class Logger {
  64223. /**
  64224. * No log
  64225. */
  64226. static readonly NoneLogLevel: number;
  64227. /**
  64228. * Only message logs
  64229. */
  64230. static readonly MessageLogLevel: number;
  64231. /**
  64232. * Only warning logs
  64233. */
  64234. static readonly WarningLogLevel: number;
  64235. /**
  64236. * Only error logs
  64237. */
  64238. static readonly ErrorLogLevel: number;
  64239. /**
  64240. * All logs
  64241. */
  64242. static readonly AllLogLevel: number;
  64243. private static _LogCache;
  64244. /**
  64245. * Gets a value indicating the number of loading errors
  64246. * @ignorenaming
  64247. */
  64248. static errorsCount: number;
  64249. /**
  64250. * Callback called when a new log is added
  64251. */
  64252. static OnNewCacheEntry: (entry: string) => void;
  64253. private static _AddLogEntry;
  64254. private static _FormatMessage;
  64255. private static _LogDisabled;
  64256. private static _LogEnabled;
  64257. private static _WarnDisabled;
  64258. private static _WarnEnabled;
  64259. private static _ErrorDisabled;
  64260. private static _ErrorEnabled;
  64261. /**
  64262. * Log a message to the console
  64263. */
  64264. static Log: (message: string) => void;
  64265. /**
  64266. * Write a warning message to the console
  64267. */
  64268. static Warn: (message: string) => void;
  64269. /**
  64270. * Write an error message to the console
  64271. */
  64272. static Error: (message: string) => void;
  64273. /**
  64274. * Gets current log cache (list of logs)
  64275. */
  64276. static readonly LogCache: string;
  64277. /**
  64278. * Clears the log cache
  64279. */
  64280. static ClearLogCache(): void;
  64281. /**
  64282. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64283. */
  64284. static LogLevels: number;
  64285. }
  64286. }
  64287. declare module BABYLON {
  64288. /** @hidden */
  64289. export class _TypeStore {
  64290. /** @hidden */
  64291. static RegisteredTypes: {
  64292. [key: string]: Object;
  64293. };
  64294. /** @hidden */
  64295. static GetClass(fqdn: string): any;
  64296. }
  64297. }
  64298. declare module BABYLON {
  64299. /**
  64300. * Class containing a set of static utilities functions for deep copy.
  64301. */
  64302. export class DeepCopier {
  64303. /**
  64304. * Tries to copy an object by duplicating every property
  64305. * @param source defines the source object
  64306. * @param destination defines the target object
  64307. * @param doNotCopyList defines a list of properties to avoid
  64308. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64309. */
  64310. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64311. }
  64312. }
  64313. declare module BABYLON {
  64314. /**
  64315. * Class containing a set of static utilities functions for precision date
  64316. */
  64317. export class PrecisionDate {
  64318. /**
  64319. * Gets either window.performance.now() if supported or Date.now() else
  64320. */
  64321. static readonly Now: number;
  64322. }
  64323. }
  64324. declare module BABYLON {
  64325. /** @hidden */
  64326. export class _DevTools {
  64327. static WarnImport(name: string): string;
  64328. }
  64329. }
  64330. declare module BABYLON {
  64331. /**
  64332. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64333. */
  64334. export class WebRequest {
  64335. private _xhr;
  64336. /**
  64337. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64338. * i.e. when loading files, where the server/service expects an Authorization header
  64339. */
  64340. static CustomRequestHeaders: {
  64341. [key: string]: string;
  64342. };
  64343. /**
  64344. * Add callback functions in this array to update all the requests before they get sent to the network
  64345. */
  64346. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  64347. private _injectCustomRequestHeaders;
  64348. /**
  64349. * Gets or sets a function to be called when loading progress changes
  64350. */
  64351. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64352. /**
  64353. * Returns client's state
  64354. */
  64355. readonly readyState: number;
  64356. /**
  64357. * Returns client's status
  64358. */
  64359. readonly status: number;
  64360. /**
  64361. * Returns client's status as a text
  64362. */
  64363. readonly statusText: string;
  64364. /**
  64365. * Returns client's response
  64366. */
  64367. readonly response: any;
  64368. /**
  64369. * Returns client's response url
  64370. */
  64371. readonly responseURL: string;
  64372. /**
  64373. * Returns client's response as text
  64374. */
  64375. readonly responseText: string;
  64376. /**
  64377. * Gets or sets the expected response type
  64378. */
  64379. responseType: XMLHttpRequestResponseType;
  64380. /** @hidden */
  64381. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64382. /** @hidden */
  64383. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64384. /**
  64385. * Cancels any network activity
  64386. */
  64387. abort(): void;
  64388. /**
  64389. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64390. * @param body defines an optional request body
  64391. */
  64392. send(body?: Document | BodyInit | null): void;
  64393. /**
  64394. * Sets the request method, request URL
  64395. * @param method defines the method to use (GET, POST, etc..)
  64396. * @param url defines the url to connect with
  64397. */
  64398. open(method: string, url: string): void;
  64399. }
  64400. }
  64401. declare module BABYLON {
  64402. /**
  64403. * File request interface
  64404. */
  64405. export interface IFileRequest {
  64406. /**
  64407. * Raised when the request is complete (success or error).
  64408. */
  64409. onCompleteObservable: Observable<IFileRequest>;
  64410. /**
  64411. * Aborts the request for a file.
  64412. */
  64413. abort: () => void;
  64414. }
  64415. }
  64416. declare module BABYLON {
  64417. /**
  64418. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64419. */
  64420. export class PerformanceMonitor {
  64421. private _enabled;
  64422. private _rollingFrameTime;
  64423. private _lastFrameTimeMs;
  64424. /**
  64425. * constructor
  64426. * @param frameSampleSize The number of samples required to saturate the sliding window
  64427. */
  64428. constructor(frameSampleSize?: number);
  64429. /**
  64430. * Samples current frame
  64431. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64432. */
  64433. sampleFrame(timeMs?: number): void;
  64434. /**
  64435. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64436. */
  64437. readonly averageFrameTime: number;
  64438. /**
  64439. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64440. */
  64441. readonly averageFrameTimeVariance: number;
  64442. /**
  64443. * Returns the frame time of the most recent frame
  64444. */
  64445. readonly instantaneousFrameTime: number;
  64446. /**
  64447. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64448. */
  64449. readonly averageFPS: number;
  64450. /**
  64451. * Returns the average framerate in frames per second using the most recent frame time
  64452. */
  64453. readonly instantaneousFPS: number;
  64454. /**
  64455. * Returns true if enough samples have been taken to completely fill the sliding window
  64456. */
  64457. readonly isSaturated: boolean;
  64458. /**
  64459. * Enables contributions to the sliding window sample set
  64460. */
  64461. enable(): void;
  64462. /**
  64463. * Disables contributions to the sliding window sample set
  64464. * Samples will not be interpolated over the disabled period
  64465. */
  64466. disable(): void;
  64467. /**
  64468. * Returns true if sampling is enabled
  64469. */
  64470. readonly isEnabled: boolean;
  64471. /**
  64472. * Resets performance monitor
  64473. */
  64474. reset(): void;
  64475. }
  64476. /**
  64477. * RollingAverage
  64478. *
  64479. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64480. */
  64481. export class RollingAverage {
  64482. /**
  64483. * Current average
  64484. */
  64485. average: number;
  64486. /**
  64487. * Current variance
  64488. */
  64489. variance: number;
  64490. protected _samples: Array<number>;
  64491. protected _sampleCount: number;
  64492. protected _pos: number;
  64493. protected _m2: number;
  64494. /**
  64495. * constructor
  64496. * @param length The number of samples required to saturate the sliding window
  64497. */
  64498. constructor(length: number);
  64499. /**
  64500. * Adds a sample to the sample set
  64501. * @param v The sample value
  64502. */
  64503. add(v: number): void;
  64504. /**
  64505. * Returns previously added values or null if outside of history or outside the sliding window domain
  64506. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64507. * @return Value previously recorded with add() or null if outside of range
  64508. */
  64509. history(i: number): number;
  64510. /**
  64511. * Returns true if enough samples have been taken to completely fill the sliding window
  64512. * @return true if sample-set saturated
  64513. */
  64514. isSaturated(): boolean;
  64515. /**
  64516. * Resets the rolling average (equivalent to 0 samples taken so far)
  64517. */
  64518. reset(): void;
  64519. /**
  64520. * Wraps a value around the sample range boundaries
  64521. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64522. * @return Wrapped position in sample range
  64523. */
  64524. protected _wrapPosition(i: number): number;
  64525. }
  64526. }
  64527. declare module BABYLON {
  64528. /**
  64529. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64530. * The underlying implementation relies on an associative array to ensure the best performances.
  64531. * The value can be anything including 'null' but except 'undefined'
  64532. */
  64533. export class StringDictionary<T> {
  64534. /**
  64535. * This will clear this dictionary and copy the content from the 'source' one.
  64536. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64537. * @param source the dictionary to take the content from and copy to this dictionary
  64538. */
  64539. copyFrom(source: StringDictionary<T>): void;
  64540. /**
  64541. * Get a value based from its key
  64542. * @param key the given key to get the matching value from
  64543. * @return the value if found, otherwise undefined is returned
  64544. */
  64545. get(key: string): T | undefined;
  64546. /**
  64547. * Get a value from its key or add it if it doesn't exist.
  64548. * This method will ensure you that a given key/data will be present in the dictionary.
  64549. * @param key the given key to get the matching value from
  64550. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64551. * The factory will only be invoked if there's no data for the given key.
  64552. * @return the value corresponding to the key.
  64553. */
  64554. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64555. /**
  64556. * Get a value from its key if present in the dictionary otherwise add it
  64557. * @param key the key to get the value from
  64558. * @param val if there's no such key/value pair in the dictionary add it with this value
  64559. * @return the value corresponding to the key
  64560. */
  64561. getOrAdd(key: string, val: T): T;
  64562. /**
  64563. * Check if there's a given key in the dictionary
  64564. * @param key the key to check for
  64565. * @return true if the key is present, false otherwise
  64566. */
  64567. contains(key: string): boolean;
  64568. /**
  64569. * Add a new key and its corresponding value
  64570. * @param key the key to add
  64571. * @param value the value corresponding to the key
  64572. * @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
  64573. */
  64574. add(key: string, value: T): boolean;
  64575. /**
  64576. * Update a specific value associated to a key
  64577. * @param key defines the key to use
  64578. * @param value defines the value to store
  64579. * @returns true if the value was updated (or false if the key was not found)
  64580. */
  64581. set(key: string, value: T): boolean;
  64582. /**
  64583. * Get the element of the given key and remove it from the dictionary
  64584. * @param key defines the key to search
  64585. * @returns the value associated with the key or null if not found
  64586. */
  64587. getAndRemove(key: string): Nullable<T>;
  64588. /**
  64589. * Remove a key/value from the dictionary.
  64590. * @param key the key to remove
  64591. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64592. */
  64593. remove(key: string): boolean;
  64594. /**
  64595. * Clear the whole content of the dictionary
  64596. */
  64597. clear(): void;
  64598. /**
  64599. * Gets the current count
  64600. */
  64601. readonly count: number;
  64602. /**
  64603. * Execute a callback on each key/val of the dictionary.
  64604. * Note that you can remove any element in this dictionary in the callback implementation
  64605. * @param callback the callback to execute on a given key/value pair
  64606. */
  64607. forEach(callback: (key: string, val: T) => void): void;
  64608. /**
  64609. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64610. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64611. * Note that you can remove any element in this dictionary in the callback implementation
  64612. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64613. * @returns the first item
  64614. */
  64615. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64616. private _count;
  64617. private _data;
  64618. }
  64619. }
  64620. declare module BABYLON {
  64621. /**
  64622. * Class used to store gfx data (like WebGLBuffer)
  64623. */
  64624. export class DataBuffer {
  64625. /**
  64626. * Gets or sets the number of objects referencing this buffer
  64627. */
  64628. references: number;
  64629. /** Gets or sets the size of the underlying buffer */
  64630. capacity: number;
  64631. /**
  64632. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  64633. */
  64634. is32Bits: boolean;
  64635. /**
  64636. * Gets the underlying buffer
  64637. */
  64638. readonly underlyingResource: any;
  64639. }
  64640. }
  64641. declare module BABYLON {
  64642. /**
  64643. * Class used to store data that will be store in GPU memory
  64644. */
  64645. export class Buffer {
  64646. private _engine;
  64647. private _buffer;
  64648. /** @hidden */
  64649. _data: Nullable<DataArray>;
  64650. private _updatable;
  64651. private _instanced;
  64652. /**
  64653. * Gets the byte stride.
  64654. */
  64655. readonly byteStride: number;
  64656. /**
  64657. * Constructor
  64658. * @param engine the engine
  64659. * @param data the data to use for this buffer
  64660. * @param updatable whether the data is updatable
  64661. * @param stride the stride (optional)
  64662. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64663. * @param instanced whether the buffer is instanced (optional)
  64664. * @param useBytes set to true if the stride in in bytes (optional)
  64665. */
  64666. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64667. /**
  64668. * Create a new VertexBuffer based on the current buffer
  64669. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64670. * @param offset defines offset in the buffer (0 by default)
  64671. * @param size defines the size in floats of attributes (position is 3 for instance)
  64672. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64673. * @param instanced defines if the vertex buffer contains indexed data
  64674. * @param useBytes defines if the offset and stride are in bytes
  64675. * @returns the new vertex buffer
  64676. */
  64677. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64678. /**
  64679. * Gets a boolean indicating if the Buffer is updatable?
  64680. * @returns true if the buffer is updatable
  64681. */
  64682. isUpdatable(): boolean;
  64683. /**
  64684. * Gets current buffer's data
  64685. * @returns a DataArray or null
  64686. */
  64687. getData(): Nullable<DataArray>;
  64688. /**
  64689. * Gets underlying native buffer
  64690. * @returns underlying native buffer
  64691. */
  64692. getBuffer(): Nullable<DataBuffer>;
  64693. /**
  64694. * Gets the stride in float32 units (i.e. byte stride / 4).
  64695. * May not be an integer if the byte stride is not divisible by 4.
  64696. * DEPRECATED. Use byteStride instead.
  64697. * @returns the stride in float32 units
  64698. */
  64699. getStrideSize(): number;
  64700. /**
  64701. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64702. * @param data defines the data to store
  64703. */
  64704. create(data?: Nullable<DataArray>): void;
  64705. /** @hidden */
  64706. _rebuild(): void;
  64707. /**
  64708. * Update current buffer data
  64709. * @param data defines the data to store
  64710. */
  64711. update(data: DataArray): void;
  64712. /**
  64713. * Updates the data directly.
  64714. * @param data the new data
  64715. * @param offset the new offset
  64716. * @param vertexCount the vertex count (optional)
  64717. * @param useBytes set to true if the offset is in bytes
  64718. */
  64719. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64720. /**
  64721. * Release all resources
  64722. */
  64723. dispose(): void;
  64724. }
  64725. /**
  64726. * Specialized buffer used to store vertex data
  64727. */
  64728. export class VertexBuffer {
  64729. /** @hidden */
  64730. _buffer: Buffer;
  64731. private _kind;
  64732. private _size;
  64733. private _ownsBuffer;
  64734. private _instanced;
  64735. private _instanceDivisor;
  64736. /**
  64737. * The byte type.
  64738. */
  64739. static readonly BYTE: number;
  64740. /**
  64741. * The unsigned byte type.
  64742. */
  64743. static readonly UNSIGNED_BYTE: number;
  64744. /**
  64745. * The short type.
  64746. */
  64747. static readonly SHORT: number;
  64748. /**
  64749. * The unsigned short type.
  64750. */
  64751. static readonly UNSIGNED_SHORT: number;
  64752. /**
  64753. * The integer type.
  64754. */
  64755. static readonly INT: number;
  64756. /**
  64757. * The unsigned integer type.
  64758. */
  64759. static readonly UNSIGNED_INT: number;
  64760. /**
  64761. * The float type.
  64762. */
  64763. static readonly FLOAT: number;
  64764. /**
  64765. * Gets or sets the instance divisor when in instanced mode
  64766. */
  64767. instanceDivisor: number;
  64768. /**
  64769. * Gets the byte stride.
  64770. */
  64771. readonly byteStride: number;
  64772. /**
  64773. * Gets the byte offset.
  64774. */
  64775. readonly byteOffset: number;
  64776. /**
  64777. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64778. */
  64779. readonly normalized: boolean;
  64780. /**
  64781. * Gets the data type of each component in the array.
  64782. */
  64783. readonly type: number;
  64784. /**
  64785. * Constructor
  64786. * @param engine the engine
  64787. * @param data the data to use for this vertex buffer
  64788. * @param kind the vertex buffer kind
  64789. * @param updatable whether the data is updatable
  64790. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64791. * @param stride the stride (optional)
  64792. * @param instanced whether the buffer is instanced (optional)
  64793. * @param offset the offset of the data (optional)
  64794. * @param size the number of components (optional)
  64795. * @param type the type of the component (optional)
  64796. * @param normalized whether the data contains normalized data (optional)
  64797. * @param useBytes set to true if stride and offset are in bytes (optional)
  64798. */
  64799. 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);
  64800. /** @hidden */
  64801. _rebuild(): void;
  64802. /**
  64803. * Returns the kind of the VertexBuffer (string)
  64804. * @returns a string
  64805. */
  64806. getKind(): string;
  64807. /**
  64808. * Gets a boolean indicating if the VertexBuffer is updatable?
  64809. * @returns true if the buffer is updatable
  64810. */
  64811. isUpdatable(): boolean;
  64812. /**
  64813. * Gets current buffer's data
  64814. * @returns a DataArray or null
  64815. */
  64816. getData(): Nullable<DataArray>;
  64817. /**
  64818. * Gets underlying native buffer
  64819. * @returns underlying native buffer
  64820. */
  64821. getBuffer(): Nullable<DataBuffer>;
  64822. /**
  64823. * Gets the stride in float32 units (i.e. byte stride / 4).
  64824. * May not be an integer if the byte stride is not divisible by 4.
  64825. * DEPRECATED. Use byteStride instead.
  64826. * @returns the stride in float32 units
  64827. */
  64828. getStrideSize(): number;
  64829. /**
  64830. * Returns the offset as a multiple of the type byte length.
  64831. * DEPRECATED. Use byteOffset instead.
  64832. * @returns the offset in bytes
  64833. */
  64834. getOffset(): number;
  64835. /**
  64836. * Returns the number of components per vertex attribute (integer)
  64837. * @returns the size in float
  64838. */
  64839. getSize(): number;
  64840. /**
  64841. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64842. * @returns true if this buffer is instanced
  64843. */
  64844. getIsInstanced(): boolean;
  64845. /**
  64846. * Returns the instancing divisor, zero for non-instanced (integer).
  64847. * @returns a number
  64848. */
  64849. getInstanceDivisor(): number;
  64850. /**
  64851. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64852. * @param data defines the data to store
  64853. */
  64854. create(data?: DataArray): void;
  64855. /**
  64856. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64857. * This function will create a new buffer if the current one is not updatable
  64858. * @param data defines the data to store
  64859. */
  64860. update(data: DataArray): void;
  64861. /**
  64862. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64863. * Returns the directly updated WebGLBuffer.
  64864. * @param data the new data
  64865. * @param offset the new offset
  64866. * @param useBytes set to true if the offset is in bytes
  64867. */
  64868. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64869. /**
  64870. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64871. */
  64872. dispose(): void;
  64873. /**
  64874. * Enumerates each value of this vertex buffer as numbers.
  64875. * @param count the number of values to enumerate
  64876. * @param callback the callback function called for each value
  64877. */
  64878. forEach(count: number, callback: (value: number, index: number) => void): void;
  64879. /**
  64880. * Positions
  64881. */
  64882. static readonly PositionKind: string;
  64883. /**
  64884. * Normals
  64885. */
  64886. static readonly NormalKind: string;
  64887. /**
  64888. * Tangents
  64889. */
  64890. static readonly TangentKind: string;
  64891. /**
  64892. * Texture coordinates
  64893. */
  64894. static readonly UVKind: string;
  64895. /**
  64896. * Texture coordinates 2
  64897. */
  64898. static readonly UV2Kind: string;
  64899. /**
  64900. * Texture coordinates 3
  64901. */
  64902. static readonly UV3Kind: string;
  64903. /**
  64904. * Texture coordinates 4
  64905. */
  64906. static readonly UV4Kind: string;
  64907. /**
  64908. * Texture coordinates 5
  64909. */
  64910. static readonly UV5Kind: string;
  64911. /**
  64912. * Texture coordinates 6
  64913. */
  64914. static readonly UV6Kind: string;
  64915. /**
  64916. * Colors
  64917. */
  64918. static readonly ColorKind: string;
  64919. /**
  64920. * Matrix indices (for bones)
  64921. */
  64922. static readonly MatricesIndicesKind: string;
  64923. /**
  64924. * Matrix weights (for bones)
  64925. */
  64926. static readonly MatricesWeightsKind: string;
  64927. /**
  64928. * Additional matrix indices (for bones)
  64929. */
  64930. static readonly MatricesIndicesExtraKind: string;
  64931. /**
  64932. * Additional matrix weights (for bones)
  64933. */
  64934. static readonly MatricesWeightsExtraKind: string;
  64935. /**
  64936. * Deduces the stride given a kind.
  64937. * @param kind The kind string to deduce
  64938. * @returns The deduced stride
  64939. */
  64940. static DeduceStride(kind: string): number;
  64941. /**
  64942. * Gets the byte length of the given type.
  64943. * @param type the type
  64944. * @returns the number of bytes
  64945. */
  64946. static GetTypeByteLength(type: number): number;
  64947. /**
  64948. * Enumerates each value of the given parameters as numbers.
  64949. * @param data the data to enumerate
  64950. * @param byteOffset the byte offset of the data
  64951. * @param byteStride the byte stride of the data
  64952. * @param componentCount the number of components per element
  64953. * @param componentType the type of the component
  64954. * @param count the number of values to enumerate
  64955. * @param normalized whether the data is normalized
  64956. * @param callback the callback function called for each value
  64957. */
  64958. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64959. private static _GetFloatValue;
  64960. }
  64961. }
  64962. declare module BABYLON {
  64963. /**
  64964. * Scalar computation library
  64965. */
  64966. export class Scalar {
  64967. /**
  64968. * Two pi constants convenient for computation.
  64969. */
  64970. static TwoPi: number;
  64971. /**
  64972. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  64973. * @param a number
  64974. * @param b number
  64975. * @param epsilon (default = 1.401298E-45)
  64976. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  64977. */
  64978. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  64979. /**
  64980. * Returns a string : the upper case translation of the number i to hexadecimal.
  64981. * @param i number
  64982. * @returns the upper case translation of the number i to hexadecimal.
  64983. */
  64984. static ToHex(i: number): string;
  64985. /**
  64986. * Returns -1 if value is negative and +1 is value is positive.
  64987. * @param value the value
  64988. * @returns the value itself if it's equal to zero.
  64989. */
  64990. static Sign(value: number): number;
  64991. /**
  64992. * Returns the value itself if it's between min and max.
  64993. * Returns min if the value is lower than min.
  64994. * Returns max if the value is greater than max.
  64995. * @param value the value to clmap
  64996. * @param min the min value to clamp to (default: 0)
  64997. * @param max the max value to clamp to (default: 1)
  64998. * @returns the clamped value
  64999. */
  65000. static Clamp(value: number, min?: number, max?: number): number;
  65001. /**
  65002. * the log2 of value.
  65003. * @param value the value to compute log2 of
  65004. * @returns the log2 of value.
  65005. */
  65006. static Log2(value: number): number;
  65007. /**
  65008. * Loops the value, so that it is never larger than length and never smaller than 0.
  65009. *
  65010. * This is similar to the modulo operator but it works with floating point numbers.
  65011. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  65012. * With t = 5 and length = 2.5, the result would be 0.0.
  65013. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  65014. * @param value the value
  65015. * @param length the length
  65016. * @returns the looped value
  65017. */
  65018. static Repeat(value: number, length: number): number;
  65019. /**
  65020. * Normalize the value between 0.0 and 1.0 using min and max values
  65021. * @param value value to normalize
  65022. * @param min max to normalize between
  65023. * @param max min to normalize between
  65024. * @returns the normalized value
  65025. */
  65026. static Normalize(value: number, min: number, max: number): number;
  65027. /**
  65028. * Denormalize the value from 0.0 and 1.0 using min and max values
  65029. * @param normalized value to denormalize
  65030. * @param min max to denormalize between
  65031. * @param max min to denormalize between
  65032. * @returns the denormalized value
  65033. */
  65034. static Denormalize(normalized: number, min: number, max: number): number;
  65035. /**
  65036. * Calculates the shortest difference between two given angles given in degrees.
  65037. * @param current current angle in degrees
  65038. * @param target target angle in degrees
  65039. * @returns the delta
  65040. */
  65041. static DeltaAngle(current: number, target: number): number;
  65042. /**
  65043. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  65044. * @param tx value
  65045. * @param length length
  65046. * @returns The returned value will move back and forth between 0 and length
  65047. */
  65048. static PingPong(tx: number, length: number): number;
  65049. /**
  65050. * Interpolates between min and max with smoothing at the limits.
  65051. *
  65052. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  65053. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  65054. * @param from from
  65055. * @param to to
  65056. * @param tx value
  65057. * @returns the smooth stepped value
  65058. */
  65059. static SmoothStep(from: number, to: number, tx: number): number;
  65060. /**
  65061. * Moves a value current towards target.
  65062. *
  65063. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  65064. * Negative values of maxDelta pushes the value away from target.
  65065. * @param current current value
  65066. * @param target target value
  65067. * @param maxDelta max distance to move
  65068. * @returns resulting value
  65069. */
  65070. static MoveTowards(current: number, target: number, maxDelta: number): number;
  65071. /**
  65072. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65073. *
  65074. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  65075. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  65076. * @param current current value
  65077. * @param target target value
  65078. * @param maxDelta max distance to move
  65079. * @returns resulting angle
  65080. */
  65081. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  65082. /**
  65083. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  65084. * @param start start value
  65085. * @param end target value
  65086. * @param amount amount to lerp between
  65087. * @returns the lerped value
  65088. */
  65089. static Lerp(start: number, end: number, amount: number): number;
  65090. /**
  65091. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65092. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  65093. * @param start start value
  65094. * @param end target value
  65095. * @param amount amount to lerp between
  65096. * @returns the lerped value
  65097. */
  65098. static LerpAngle(start: number, end: number, amount: number): number;
  65099. /**
  65100. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  65101. * @param a start value
  65102. * @param b target value
  65103. * @param value value between a and b
  65104. * @returns the inverseLerp value
  65105. */
  65106. static InverseLerp(a: number, b: number, value: number): number;
  65107. /**
  65108. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  65109. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  65110. * @param value1 spline value
  65111. * @param tangent1 spline value
  65112. * @param value2 spline value
  65113. * @param tangent2 spline value
  65114. * @param amount input value
  65115. * @returns hermite result
  65116. */
  65117. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  65118. /**
  65119. * Returns a random float number between and min and max values
  65120. * @param min min value of random
  65121. * @param max max value of random
  65122. * @returns random value
  65123. */
  65124. static RandomRange(min: number, max: number): number;
  65125. /**
  65126. * This function returns percentage of a number in a given range.
  65127. *
  65128. * RangeToPercent(40,20,60) will return 0.5 (50%)
  65129. * RangeToPercent(34,0,100) will return 0.34 (34%)
  65130. * @param number to convert to percentage
  65131. * @param min min range
  65132. * @param max max range
  65133. * @returns the percentage
  65134. */
  65135. static RangeToPercent(number: number, min: number, max: number): number;
  65136. /**
  65137. * This function returns number that corresponds to the percentage in a given range.
  65138. *
  65139. * PercentToRange(0.34,0,100) will return 34.
  65140. * @param percent to convert to number
  65141. * @param min min range
  65142. * @param max max range
  65143. * @returns the number
  65144. */
  65145. static PercentToRange(percent: number, min: number, max: number): number;
  65146. /**
  65147. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  65148. * @param angle The angle to normalize in radian.
  65149. * @return The converted angle.
  65150. */
  65151. static NormalizeRadians(angle: number): number;
  65152. }
  65153. }
  65154. declare module BABYLON {
  65155. /**
  65156. * Constant used to convert a value to gamma space
  65157. * @ignorenaming
  65158. */
  65159. export const ToGammaSpace: number;
  65160. /**
  65161. * Constant used to convert a value to linear space
  65162. * @ignorenaming
  65163. */
  65164. export const ToLinearSpace = 2.2;
  65165. /**
  65166. * Constant used to define the minimal number value in Babylon.js
  65167. * @ignorenaming
  65168. */
  65169. let Epsilon: number;
  65170. }
  65171. declare module BABYLON {
  65172. /**
  65173. * Class used to represent a viewport on screen
  65174. */
  65175. export class Viewport {
  65176. /** viewport left coordinate */
  65177. x: number;
  65178. /** viewport top coordinate */
  65179. y: number;
  65180. /**viewport width */
  65181. width: number;
  65182. /** viewport height */
  65183. height: number;
  65184. /**
  65185. * Creates a Viewport object located at (x, y) and sized (width, height)
  65186. * @param x defines viewport left coordinate
  65187. * @param y defines viewport top coordinate
  65188. * @param width defines the viewport width
  65189. * @param height defines the viewport height
  65190. */
  65191. constructor(
  65192. /** viewport left coordinate */
  65193. x: number,
  65194. /** viewport top coordinate */
  65195. y: number,
  65196. /**viewport width */
  65197. width: number,
  65198. /** viewport height */
  65199. height: number);
  65200. /**
  65201. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  65202. * @param renderWidth defines the rendering width
  65203. * @param renderHeight defines the rendering height
  65204. * @returns a new Viewport
  65205. */
  65206. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  65207. /**
  65208. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  65209. * @param renderWidth defines the rendering width
  65210. * @param renderHeight defines the rendering height
  65211. * @param ref defines the target viewport
  65212. * @returns the current viewport
  65213. */
  65214. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  65215. /**
  65216. * Returns a new Viewport copied from the current one
  65217. * @returns a new Viewport
  65218. */
  65219. clone(): Viewport;
  65220. }
  65221. }
  65222. declare module BABYLON {
  65223. /**
  65224. * Class containing a set of static utilities functions for arrays.
  65225. */
  65226. export class ArrayTools {
  65227. /**
  65228. * Returns an array of the given size filled with element built from the given constructor and the paramters
  65229. * @param size the number of element to construct and put in the array
  65230. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  65231. * @returns a new array filled with new objects
  65232. */
  65233. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  65234. }
  65235. }
  65236. declare module BABYLON {
  65237. /**
  65238. * @hidden
  65239. */
  65240. export interface IColor4Like {
  65241. r: float;
  65242. g: float;
  65243. b: float;
  65244. a: float;
  65245. }
  65246. /**
  65247. * @hidden
  65248. */
  65249. export interface IColor3Like {
  65250. r: float;
  65251. g: float;
  65252. b: float;
  65253. }
  65254. /**
  65255. * @hidden
  65256. */
  65257. export interface IVector4Like {
  65258. x: float;
  65259. y: float;
  65260. z: float;
  65261. w: float;
  65262. }
  65263. /**
  65264. * @hidden
  65265. */
  65266. export interface IVector3Like {
  65267. x: float;
  65268. y: float;
  65269. z: float;
  65270. }
  65271. /**
  65272. * @hidden
  65273. */
  65274. export interface IVector2Like {
  65275. x: float;
  65276. y: float;
  65277. }
  65278. /**
  65279. * @hidden
  65280. */
  65281. export interface IMatrixLike {
  65282. toArray(): DeepImmutable<Float32Array>;
  65283. updateFlag: int;
  65284. }
  65285. /**
  65286. * @hidden
  65287. */
  65288. export interface IViewportLike {
  65289. x: float;
  65290. y: float;
  65291. width: float;
  65292. height: float;
  65293. }
  65294. /**
  65295. * @hidden
  65296. */
  65297. export interface IPlaneLike {
  65298. normal: IVector3Like;
  65299. d: float;
  65300. normalize(): void;
  65301. }
  65302. }
  65303. declare module BABYLON {
  65304. /**
  65305. * Class representing a vector containing 2 coordinates
  65306. */
  65307. export class Vector2 {
  65308. /** defines the first coordinate */
  65309. x: number;
  65310. /** defines the second coordinate */
  65311. y: number;
  65312. /**
  65313. * Creates a new Vector2 from the given x and y coordinates
  65314. * @param x defines the first coordinate
  65315. * @param y defines the second coordinate
  65316. */
  65317. constructor(
  65318. /** defines the first coordinate */
  65319. x?: number,
  65320. /** defines the second coordinate */
  65321. y?: number);
  65322. /**
  65323. * Gets a string with the Vector2 coordinates
  65324. * @returns a string with the Vector2 coordinates
  65325. */
  65326. toString(): string;
  65327. /**
  65328. * Gets class name
  65329. * @returns the string "Vector2"
  65330. */
  65331. getClassName(): string;
  65332. /**
  65333. * Gets current vector hash code
  65334. * @returns the Vector2 hash code as a number
  65335. */
  65336. getHashCode(): number;
  65337. /**
  65338. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  65339. * @param array defines the source array
  65340. * @param index defines the offset in source array
  65341. * @returns the current Vector2
  65342. */
  65343. toArray(array: FloatArray, index?: number): Vector2;
  65344. /**
  65345. * Copy the current vector to an array
  65346. * @returns a new array with 2 elements: the Vector2 coordinates.
  65347. */
  65348. asArray(): number[];
  65349. /**
  65350. * Sets the Vector2 coordinates with the given Vector2 coordinates
  65351. * @param source defines the source Vector2
  65352. * @returns the current updated Vector2
  65353. */
  65354. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  65355. /**
  65356. * Sets the Vector2 coordinates with the given floats
  65357. * @param x defines the first coordinate
  65358. * @param y defines the second coordinate
  65359. * @returns the current updated Vector2
  65360. */
  65361. copyFromFloats(x: number, y: number): Vector2;
  65362. /**
  65363. * Sets the Vector2 coordinates with the given floats
  65364. * @param x defines the first coordinate
  65365. * @param y defines the second coordinate
  65366. * @returns the current updated Vector2
  65367. */
  65368. set(x: number, y: number): Vector2;
  65369. /**
  65370. * Add another vector with the current one
  65371. * @param otherVector defines the other vector
  65372. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  65373. */
  65374. add(otherVector: DeepImmutable<Vector2>): Vector2;
  65375. /**
  65376. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  65377. * @param otherVector defines the other vector
  65378. * @param result defines the target vector
  65379. * @returns the unmodified current Vector2
  65380. */
  65381. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65382. /**
  65383. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  65384. * @param otherVector defines the other vector
  65385. * @returns the current updated Vector2
  65386. */
  65387. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65388. /**
  65389. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  65390. * @param otherVector defines the other vector
  65391. * @returns a new Vector2
  65392. */
  65393. addVector3(otherVector: Vector3): Vector2;
  65394. /**
  65395. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  65396. * @param otherVector defines the other vector
  65397. * @returns a new Vector2
  65398. */
  65399. subtract(otherVector: Vector2): Vector2;
  65400. /**
  65401. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  65402. * @param otherVector defines the other vector
  65403. * @param result defines the target vector
  65404. * @returns the unmodified current Vector2
  65405. */
  65406. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65407. /**
  65408. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  65409. * @param otherVector defines the other vector
  65410. * @returns the current updated Vector2
  65411. */
  65412. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65413. /**
  65414. * Multiplies in place the current Vector2 coordinates by the given ones
  65415. * @param otherVector defines the other vector
  65416. * @returns the current updated Vector2
  65417. */
  65418. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65419. /**
  65420. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  65421. * @param otherVector defines the other vector
  65422. * @returns a new Vector2
  65423. */
  65424. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  65425. /**
  65426. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  65427. * @param otherVector defines the other vector
  65428. * @param result defines the target vector
  65429. * @returns the unmodified current Vector2
  65430. */
  65431. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65432. /**
  65433. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  65434. * @param x defines the first coordinate
  65435. * @param y defines the second coordinate
  65436. * @returns a new Vector2
  65437. */
  65438. multiplyByFloats(x: number, y: number): Vector2;
  65439. /**
  65440. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  65441. * @param otherVector defines the other vector
  65442. * @returns a new Vector2
  65443. */
  65444. divide(otherVector: Vector2): Vector2;
  65445. /**
  65446. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  65447. * @param otherVector defines the other vector
  65448. * @param result defines the target vector
  65449. * @returns the unmodified current Vector2
  65450. */
  65451. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65452. /**
  65453. * Divides the current Vector2 coordinates by the given ones
  65454. * @param otherVector defines the other vector
  65455. * @returns the current updated Vector2
  65456. */
  65457. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65458. /**
  65459. * Gets a new Vector2 with current Vector2 negated coordinates
  65460. * @returns a new Vector2
  65461. */
  65462. negate(): Vector2;
  65463. /**
  65464. * Multiply the Vector2 coordinates by scale
  65465. * @param scale defines the scaling factor
  65466. * @returns the current updated Vector2
  65467. */
  65468. scaleInPlace(scale: number): Vector2;
  65469. /**
  65470. * Returns a new Vector2 scaled by "scale" from the current Vector2
  65471. * @param scale defines the scaling factor
  65472. * @returns a new Vector2
  65473. */
  65474. scale(scale: number): Vector2;
  65475. /**
  65476. * Scale the current Vector2 values by a factor to a given Vector2
  65477. * @param scale defines the scale factor
  65478. * @param result defines the Vector2 object where to store the result
  65479. * @returns the unmodified current Vector2
  65480. */
  65481. scaleToRef(scale: number, result: Vector2): Vector2;
  65482. /**
  65483. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  65484. * @param scale defines the scale factor
  65485. * @param result defines the Vector2 object where to store the result
  65486. * @returns the unmodified current Vector2
  65487. */
  65488. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  65489. /**
  65490. * Gets a boolean if two vectors are equals
  65491. * @param otherVector defines the other vector
  65492. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  65493. */
  65494. equals(otherVector: DeepImmutable<Vector2>): boolean;
  65495. /**
  65496. * Gets a boolean if two vectors are equals (using an epsilon value)
  65497. * @param otherVector defines the other vector
  65498. * @param epsilon defines the minimal distance to consider equality
  65499. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  65500. */
  65501. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  65502. /**
  65503. * Gets a new Vector2 from current Vector2 floored values
  65504. * @returns a new Vector2
  65505. */
  65506. floor(): Vector2;
  65507. /**
  65508. * Gets a new Vector2 from current Vector2 floored values
  65509. * @returns a new Vector2
  65510. */
  65511. fract(): Vector2;
  65512. /**
  65513. * Gets the length of the vector
  65514. * @returns the vector length (float)
  65515. */
  65516. length(): number;
  65517. /**
  65518. * Gets the vector squared length
  65519. * @returns the vector squared length (float)
  65520. */
  65521. lengthSquared(): number;
  65522. /**
  65523. * Normalize the vector
  65524. * @returns the current updated Vector2
  65525. */
  65526. normalize(): Vector2;
  65527. /**
  65528. * Gets a new Vector2 copied from the Vector2
  65529. * @returns a new Vector2
  65530. */
  65531. clone(): Vector2;
  65532. /**
  65533. * Gets a new Vector2(0, 0)
  65534. * @returns a new Vector2
  65535. */
  65536. static Zero(): Vector2;
  65537. /**
  65538. * Gets a new Vector2(1, 1)
  65539. * @returns a new Vector2
  65540. */
  65541. static One(): Vector2;
  65542. /**
  65543. * Gets a new Vector2 set from the given index element of the given array
  65544. * @param array defines the data source
  65545. * @param offset defines the offset in the data source
  65546. * @returns a new Vector2
  65547. */
  65548. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  65549. /**
  65550. * Sets "result" from the given index element of the given array
  65551. * @param array defines the data source
  65552. * @param offset defines the offset in the data source
  65553. * @param result defines the target vector
  65554. */
  65555. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  65556. /**
  65557. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  65558. * @param value1 defines 1st point of control
  65559. * @param value2 defines 2nd point of control
  65560. * @param value3 defines 3rd point of control
  65561. * @param value4 defines 4th point of control
  65562. * @param amount defines the interpolation factor
  65563. * @returns a new Vector2
  65564. */
  65565. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  65566. /**
  65567. * 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".
  65568. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  65569. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  65570. * @param value defines the value to clamp
  65571. * @param min defines the lower limit
  65572. * @param max defines the upper limit
  65573. * @returns a new Vector2
  65574. */
  65575. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  65576. /**
  65577. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  65578. * @param value1 defines the 1st control point
  65579. * @param tangent1 defines the outgoing tangent
  65580. * @param value2 defines the 2nd control point
  65581. * @param tangent2 defines the incoming tangent
  65582. * @param amount defines the interpolation factor
  65583. * @returns a new Vector2
  65584. */
  65585. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  65586. /**
  65587. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  65588. * @param start defines the start vector
  65589. * @param end defines the end vector
  65590. * @param amount defines the interpolation factor
  65591. * @returns a new Vector2
  65592. */
  65593. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  65594. /**
  65595. * Gets the dot product of the vector "left" and the vector "right"
  65596. * @param left defines first vector
  65597. * @param right defines second vector
  65598. * @returns the dot product (float)
  65599. */
  65600. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  65601. /**
  65602. * Returns a new Vector2 equal to the normalized given vector
  65603. * @param vector defines the vector to normalize
  65604. * @returns a new Vector2
  65605. */
  65606. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  65607. /**
  65608. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  65609. * @param left defines 1st vector
  65610. * @param right defines 2nd vector
  65611. * @returns a new Vector2
  65612. */
  65613. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65614. /**
  65615. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  65616. * @param left defines 1st vector
  65617. * @param right defines 2nd vector
  65618. * @returns a new Vector2
  65619. */
  65620. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65621. /**
  65622. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  65623. * @param vector defines the vector to transform
  65624. * @param transformation defines the matrix to apply
  65625. * @returns a new Vector2
  65626. */
  65627. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  65628. /**
  65629. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  65630. * @param vector defines the vector to transform
  65631. * @param transformation defines the matrix to apply
  65632. * @param result defines the target vector
  65633. */
  65634. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  65635. /**
  65636. * Determines if a given vector is included in a triangle
  65637. * @param p defines the vector to test
  65638. * @param p0 defines 1st triangle point
  65639. * @param p1 defines 2nd triangle point
  65640. * @param p2 defines 3rd triangle point
  65641. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  65642. */
  65643. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  65644. /**
  65645. * Gets the distance between the vectors "value1" and "value2"
  65646. * @param value1 defines first vector
  65647. * @param value2 defines second vector
  65648. * @returns the distance between vectors
  65649. */
  65650. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65651. /**
  65652. * Returns the squared distance between the vectors "value1" and "value2"
  65653. * @param value1 defines first vector
  65654. * @param value2 defines second vector
  65655. * @returns the squared distance between vectors
  65656. */
  65657. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65658. /**
  65659. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  65660. * @param value1 defines first vector
  65661. * @param value2 defines second vector
  65662. * @returns a new Vector2
  65663. */
  65664. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  65665. /**
  65666. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  65667. * @param p defines the middle point
  65668. * @param segA defines one point of the segment
  65669. * @param segB defines the other point of the segment
  65670. * @returns the shortest distance
  65671. */
  65672. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  65673. }
  65674. /**
  65675. * Classed used to store (x,y,z) vector representation
  65676. * A Vector3 is the main object used in 3D geometry
  65677. * It can represent etiher the coordinates of a point the space, either a direction
  65678. * Reminder: js uses a left handed forward facing system
  65679. */
  65680. export class Vector3 {
  65681. /**
  65682. * Defines the first coordinates (on X axis)
  65683. */
  65684. x: number;
  65685. /**
  65686. * Defines the second coordinates (on Y axis)
  65687. */
  65688. y: number;
  65689. /**
  65690. * Defines the third coordinates (on Z axis)
  65691. */
  65692. z: number;
  65693. private static _UpReadOnly;
  65694. private static _ZeroReadOnly;
  65695. /**
  65696. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  65697. * @param x defines the first coordinates (on X axis)
  65698. * @param y defines the second coordinates (on Y axis)
  65699. * @param z defines the third coordinates (on Z axis)
  65700. */
  65701. constructor(
  65702. /**
  65703. * Defines the first coordinates (on X axis)
  65704. */
  65705. x?: number,
  65706. /**
  65707. * Defines the second coordinates (on Y axis)
  65708. */
  65709. y?: number,
  65710. /**
  65711. * Defines the third coordinates (on Z axis)
  65712. */
  65713. z?: number);
  65714. /**
  65715. * Creates a string representation of the Vector3
  65716. * @returns a string with the Vector3 coordinates.
  65717. */
  65718. toString(): string;
  65719. /**
  65720. * Gets the class name
  65721. * @returns the string "Vector3"
  65722. */
  65723. getClassName(): string;
  65724. /**
  65725. * Creates the Vector3 hash code
  65726. * @returns a number which tends to be unique between Vector3 instances
  65727. */
  65728. getHashCode(): number;
  65729. /**
  65730. * Creates an array containing three elements : the coordinates of the Vector3
  65731. * @returns a new array of numbers
  65732. */
  65733. asArray(): number[];
  65734. /**
  65735. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  65736. * @param array defines the destination array
  65737. * @param index defines the offset in the destination array
  65738. * @returns the current Vector3
  65739. */
  65740. toArray(array: FloatArray, index?: number): Vector3;
  65741. /**
  65742. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  65743. * @returns a new Quaternion object, computed from the Vector3 coordinates
  65744. */
  65745. toQuaternion(): Quaternion;
  65746. /**
  65747. * Adds the given vector to the current Vector3
  65748. * @param otherVector defines the second operand
  65749. * @returns the current updated Vector3
  65750. */
  65751. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65752. /**
  65753. * Adds the given coordinates to the current Vector3
  65754. * @param x defines the x coordinate of the operand
  65755. * @param y defines the y coordinate of the operand
  65756. * @param z defines the z coordinate of the operand
  65757. * @returns the current updated Vector3
  65758. */
  65759. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65760. /**
  65761. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  65762. * @param otherVector defines the second operand
  65763. * @returns the resulting Vector3
  65764. */
  65765. add(otherVector: DeepImmutable<Vector3>): Vector3;
  65766. /**
  65767. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  65768. * @param otherVector defines the second operand
  65769. * @param result defines the Vector3 object where to store the result
  65770. * @returns the current Vector3
  65771. */
  65772. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65773. /**
  65774. * Subtract the given vector from the current Vector3
  65775. * @param otherVector defines the second operand
  65776. * @returns the current updated Vector3
  65777. */
  65778. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65779. /**
  65780. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  65781. * @param otherVector defines the second operand
  65782. * @returns the resulting Vector3
  65783. */
  65784. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  65785. /**
  65786. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  65787. * @param otherVector defines the second operand
  65788. * @param result defines the Vector3 object where to store the result
  65789. * @returns the current Vector3
  65790. */
  65791. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65792. /**
  65793. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  65794. * @param x defines the x coordinate of the operand
  65795. * @param y defines the y coordinate of the operand
  65796. * @param z defines the z coordinate of the operand
  65797. * @returns the resulting Vector3
  65798. */
  65799. subtractFromFloats(x: number, y: number, z: number): Vector3;
  65800. /**
  65801. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  65802. * @param x defines the x coordinate of the operand
  65803. * @param y defines the y coordinate of the operand
  65804. * @param z defines the z coordinate of the operand
  65805. * @param result defines the Vector3 object where to store the result
  65806. * @returns the current Vector3
  65807. */
  65808. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  65809. /**
  65810. * Gets a new Vector3 set with the current Vector3 negated coordinates
  65811. * @returns a new Vector3
  65812. */
  65813. negate(): Vector3;
  65814. /**
  65815. * Multiplies the Vector3 coordinates by the float "scale"
  65816. * @param scale defines the multiplier factor
  65817. * @returns the current updated Vector3
  65818. */
  65819. scaleInPlace(scale: number): Vector3;
  65820. /**
  65821. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  65822. * @param scale defines the multiplier factor
  65823. * @returns a new Vector3
  65824. */
  65825. scale(scale: number): Vector3;
  65826. /**
  65827. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  65828. * @param scale defines the multiplier factor
  65829. * @param result defines the Vector3 object where to store the result
  65830. * @returns the current Vector3
  65831. */
  65832. scaleToRef(scale: number, result: Vector3): Vector3;
  65833. /**
  65834. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  65835. * @param scale defines the scale factor
  65836. * @param result defines the Vector3 object where to store the result
  65837. * @returns the unmodified current Vector3
  65838. */
  65839. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  65840. /**
  65841. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  65842. * @param otherVector defines the second operand
  65843. * @returns true if both vectors are equals
  65844. */
  65845. equals(otherVector: DeepImmutable<Vector3>): boolean;
  65846. /**
  65847. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  65848. * @param otherVector defines the second operand
  65849. * @param epsilon defines the minimal distance to define values as equals
  65850. * @returns true if both vectors are distant less than epsilon
  65851. */
  65852. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  65853. /**
  65854. * Returns true if the current Vector3 coordinates equals the given floats
  65855. * @param x defines the x coordinate of the operand
  65856. * @param y defines the y coordinate of the operand
  65857. * @param z defines the z coordinate of the operand
  65858. * @returns true if both vectors are equals
  65859. */
  65860. equalsToFloats(x: number, y: number, z: number): boolean;
  65861. /**
  65862. * Multiplies the current Vector3 coordinates by the given ones
  65863. * @param otherVector defines the second operand
  65864. * @returns the current updated Vector3
  65865. */
  65866. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65867. /**
  65868. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  65869. * @param otherVector defines the second operand
  65870. * @returns the new Vector3
  65871. */
  65872. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  65873. /**
  65874. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  65875. * @param otherVector defines the second operand
  65876. * @param result defines the Vector3 object where to store the result
  65877. * @returns the current Vector3
  65878. */
  65879. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65880. /**
  65881. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  65882. * @param x defines the x coordinate of the operand
  65883. * @param y defines the y coordinate of the operand
  65884. * @param z defines the z coordinate of the operand
  65885. * @returns the new Vector3
  65886. */
  65887. multiplyByFloats(x: number, y: number, z: number): Vector3;
  65888. /**
  65889. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  65890. * @param otherVector defines the second operand
  65891. * @returns the new Vector3
  65892. */
  65893. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  65894. /**
  65895. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  65896. * @param otherVector defines the second operand
  65897. * @param result defines the Vector3 object where to store the result
  65898. * @returns the current Vector3
  65899. */
  65900. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65901. /**
  65902. * Divides the current Vector3 coordinates by the given ones.
  65903. * @param otherVector defines the second operand
  65904. * @returns the current updated Vector3
  65905. */
  65906. divideInPlace(otherVector: Vector3): Vector3;
  65907. /**
  65908. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  65909. * @param other defines the second operand
  65910. * @returns the current updated Vector3
  65911. */
  65912. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65913. /**
  65914. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  65915. * @param other defines the second operand
  65916. * @returns the current updated Vector3
  65917. */
  65918. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65919. /**
  65920. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  65921. * @param x defines the x coordinate of the operand
  65922. * @param y defines the y coordinate of the operand
  65923. * @param z defines the z coordinate of the operand
  65924. * @returns the current updated Vector3
  65925. */
  65926. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65927. /**
  65928. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  65929. * @param x defines the x coordinate of the operand
  65930. * @param y defines the y coordinate of the operand
  65931. * @param z defines the z coordinate of the operand
  65932. * @returns the current updated Vector3
  65933. */
  65934. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65935. /**
  65936. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  65937. * Check if is non uniform within a certain amount of decimal places to account for this
  65938. * @param epsilon the amount the values can differ
  65939. * @returns if the the vector is non uniform to a certain number of decimal places
  65940. */
  65941. isNonUniformWithinEpsilon(epsilon: number): boolean;
  65942. /**
  65943. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  65944. */
  65945. readonly isNonUniform: boolean;
  65946. /**
  65947. * Gets a new Vector3 from current Vector3 floored values
  65948. * @returns a new Vector3
  65949. */
  65950. floor(): Vector3;
  65951. /**
  65952. * Gets a new Vector3 from current Vector3 floored values
  65953. * @returns a new Vector3
  65954. */
  65955. fract(): Vector3;
  65956. /**
  65957. * Gets the length of the Vector3
  65958. * @returns the length of the Vector3
  65959. */
  65960. length(): number;
  65961. /**
  65962. * Gets the squared length of the Vector3
  65963. * @returns squared length of the Vector3
  65964. */
  65965. lengthSquared(): number;
  65966. /**
  65967. * Normalize the current Vector3.
  65968. * Please note that this is an in place operation.
  65969. * @returns the current updated Vector3
  65970. */
  65971. normalize(): Vector3;
  65972. /**
  65973. * Reorders the x y z properties of the vector in place
  65974. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  65975. * @returns the current updated vector
  65976. */
  65977. reorderInPlace(order: string): this;
  65978. /**
  65979. * Rotates the vector around 0,0,0 by a quaternion
  65980. * @param quaternion the rotation quaternion
  65981. * @param result vector to store the result
  65982. * @returns the resulting vector
  65983. */
  65984. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  65985. /**
  65986. * Rotates a vector around a given point
  65987. * @param quaternion the rotation quaternion
  65988. * @param point the point to rotate around
  65989. * @param result vector to store the result
  65990. * @returns the resulting vector
  65991. */
  65992. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  65993. /**
  65994. * Normalize the current Vector3 with the given input length.
  65995. * Please note that this is an in place operation.
  65996. * @param len the length of the vector
  65997. * @returns the current updated Vector3
  65998. */
  65999. normalizeFromLength(len: number): Vector3;
  66000. /**
  66001. * Normalize the current Vector3 to a new vector
  66002. * @returns the new Vector3
  66003. */
  66004. normalizeToNew(): Vector3;
  66005. /**
  66006. * Normalize the current Vector3 to the reference
  66007. * @param reference define the Vector3 to update
  66008. * @returns the updated Vector3
  66009. */
  66010. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  66011. /**
  66012. * Creates a new Vector3 copied from the current Vector3
  66013. * @returns the new Vector3
  66014. */
  66015. clone(): Vector3;
  66016. /**
  66017. * Copies the given vector coordinates to the current Vector3 ones
  66018. * @param source defines the source Vector3
  66019. * @returns the current updated Vector3
  66020. */
  66021. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  66022. /**
  66023. * Copies the given floats to the current Vector3 coordinates
  66024. * @param x defines the x coordinate of the operand
  66025. * @param y defines the y coordinate of the operand
  66026. * @param z defines the z coordinate of the operand
  66027. * @returns the current updated Vector3
  66028. */
  66029. copyFromFloats(x: number, y: number, z: number): Vector3;
  66030. /**
  66031. * Copies the given floats to the current Vector3 coordinates
  66032. * @param x defines the x coordinate of the operand
  66033. * @param y defines the y coordinate of the operand
  66034. * @param z defines the z coordinate of the operand
  66035. * @returns the current updated Vector3
  66036. */
  66037. set(x: number, y: number, z: number): Vector3;
  66038. /**
  66039. * Copies the given float to the current Vector3 coordinates
  66040. * @param v defines the x, y and z coordinates of the operand
  66041. * @returns the current updated Vector3
  66042. */
  66043. setAll(v: number): Vector3;
  66044. /**
  66045. * Get the clip factor between two vectors
  66046. * @param vector0 defines the first operand
  66047. * @param vector1 defines the second operand
  66048. * @param axis defines the axis to use
  66049. * @param size defines the size along the axis
  66050. * @returns the clip factor
  66051. */
  66052. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  66053. /**
  66054. * Get angle between two vectors
  66055. * @param vector0 angle between vector0 and vector1
  66056. * @param vector1 angle between vector0 and vector1
  66057. * @param normal direction of the normal
  66058. * @return the angle between vector0 and vector1
  66059. */
  66060. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  66061. /**
  66062. * Returns a new Vector3 set from the index "offset" of the given array
  66063. * @param array defines the source array
  66064. * @param offset defines the offset in the source array
  66065. * @returns the new Vector3
  66066. */
  66067. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  66068. /**
  66069. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  66070. * This function is deprecated. Use FromArray instead
  66071. * @param array defines the source array
  66072. * @param offset defines the offset in the source array
  66073. * @returns the new Vector3
  66074. */
  66075. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  66076. /**
  66077. * Sets the given vector "result" with the element values from the index "offset" of the given array
  66078. * @param array defines the source array
  66079. * @param offset defines the offset in the source array
  66080. * @param result defines the Vector3 where to store the result
  66081. */
  66082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  66083. /**
  66084. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  66085. * This function is deprecated. Use FromArrayToRef instead.
  66086. * @param array defines the source array
  66087. * @param offset defines the offset in the source array
  66088. * @param result defines the Vector3 where to store the result
  66089. */
  66090. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  66091. /**
  66092. * Sets the given vector "result" with the given floats.
  66093. * @param x defines the x coordinate of the source
  66094. * @param y defines the y coordinate of the source
  66095. * @param z defines the z coordinate of the source
  66096. * @param result defines the Vector3 where to store the result
  66097. */
  66098. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  66099. /**
  66100. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  66101. * @returns a new empty Vector3
  66102. */
  66103. static Zero(): Vector3;
  66104. /**
  66105. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  66106. * @returns a new unit Vector3
  66107. */
  66108. static One(): Vector3;
  66109. /**
  66110. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  66111. * @returns a new up Vector3
  66112. */
  66113. static Up(): Vector3;
  66114. /**
  66115. * Gets a up Vector3 that must not be updated
  66116. */
  66117. static readonly UpReadOnly: DeepImmutable<Vector3>;
  66118. /**
  66119. * Gets a zero Vector3 that must not be updated
  66120. */
  66121. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  66122. /**
  66123. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  66124. * @returns a new down Vector3
  66125. */
  66126. static Down(): Vector3;
  66127. /**
  66128. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  66129. * @returns a new forward Vector3
  66130. */
  66131. static Forward(): Vector3;
  66132. /**
  66133. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  66134. * @returns a new forward Vector3
  66135. */
  66136. static Backward(): Vector3;
  66137. /**
  66138. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  66139. * @returns a new right Vector3
  66140. */
  66141. static Right(): Vector3;
  66142. /**
  66143. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  66144. * @returns a new left Vector3
  66145. */
  66146. static Left(): Vector3;
  66147. /**
  66148. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  66149. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66150. * @param vector defines the Vector3 to transform
  66151. * @param transformation defines the transformation matrix
  66152. * @returns the transformed Vector3
  66153. */
  66154. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66155. /**
  66156. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  66157. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66158. * @param vector defines the Vector3 to transform
  66159. * @param transformation defines the transformation matrix
  66160. * @param result defines the Vector3 where to store the result
  66161. */
  66162. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66163. /**
  66164. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  66165. * This method computes tranformed coordinates only, not transformed direction vectors
  66166. * @param x define the x coordinate of the source vector
  66167. * @param y define the y coordinate of the source vector
  66168. * @param z define the z coordinate of the source vector
  66169. * @param transformation defines the transformation matrix
  66170. * @param result defines the Vector3 where to store the result
  66171. */
  66172. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66173. /**
  66174. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  66175. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66176. * @param vector defines the Vector3 to transform
  66177. * @param transformation defines the transformation matrix
  66178. * @returns the new Vector3
  66179. */
  66180. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66181. /**
  66182. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  66183. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66184. * @param vector defines the Vector3 to transform
  66185. * @param transformation defines the transformation matrix
  66186. * @param result defines the Vector3 where to store the result
  66187. */
  66188. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66189. /**
  66190. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  66191. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66192. * @param x define the x coordinate of the source vector
  66193. * @param y define the y coordinate of the source vector
  66194. * @param z define the z coordinate of the source vector
  66195. * @param transformation defines the transformation matrix
  66196. * @param result defines the Vector3 where to store the result
  66197. */
  66198. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66199. /**
  66200. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  66201. * @param value1 defines the first control point
  66202. * @param value2 defines the second control point
  66203. * @param value3 defines the third control point
  66204. * @param value4 defines the fourth control point
  66205. * @param amount defines the amount on the spline to use
  66206. * @returns the new Vector3
  66207. */
  66208. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  66209. /**
  66210. * 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"
  66211. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66212. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66213. * @param value defines the current value
  66214. * @param min defines the lower range value
  66215. * @param max defines the upper range value
  66216. * @returns the new Vector3
  66217. */
  66218. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  66219. /**
  66220. * 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"
  66221. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66222. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66223. * @param value defines the current value
  66224. * @param min defines the lower range value
  66225. * @param max defines the upper range value
  66226. * @param result defines the Vector3 where to store the result
  66227. */
  66228. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  66229. /**
  66230. * Checks if a given vector is inside a specific range
  66231. * @param v defines the vector to test
  66232. * @param min defines the minimum range
  66233. * @param max defines the maximum range
  66234. */
  66235. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  66236. /**
  66237. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  66238. * @param value1 defines the first control point
  66239. * @param tangent1 defines the first tangent vector
  66240. * @param value2 defines the second control point
  66241. * @param tangent2 defines the second tangent vector
  66242. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  66243. * @returns the new Vector3
  66244. */
  66245. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  66246. /**
  66247. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  66248. * @param start defines the start value
  66249. * @param end defines the end value
  66250. * @param amount max defines amount between both (between 0 and 1)
  66251. * @returns the new Vector3
  66252. */
  66253. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  66254. /**
  66255. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  66256. * @param start defines the start value
  66257. * @param end defines the end value
  66258. * @param amount max defines amount between both (between 0 and 1)
  66259. * @param result defines the Vector3 where to store the result
  66260. */
  66261. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  66262. /**
  66263. * Returns the dot product (float) between the vectors "left" and "right"
  66264. * @param left defines the left operand
  66265. * @param right defines the right operand
  66266. * @returns the dot product
  66267. */
  66268. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  66269. /**
  66270. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  66271. * The cross product is then orthogonal to both "left" and "right"
  66272. * @param left defines the left operand
  66273. * @param right defines the right operand
  66274. * @returns the cross product
  66275. */
  66276. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66277. /**
  66278. * Sets the given vector "result" with the cross product of "left" and "right"
  66279. * The cross product is then orthogonal to both "left" and "right"
  66280. * @param left defines the left operand
  66281. * @param right defines the right operand
  66282. * @param result defines the Vector3 where to store the result
  66283. */
  66284. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  66285. /**
  66286. * Returns a new Vector3 as the normalization of the given vector
  66287. * @param vector defines the Vector3 to normalize
  66288. * @returns the new Vector3
  66289. */
  66290. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  66291. /**
  66292. * Sets the given vector "result" with the normalization of the given first vector
  66293. * @param vector defines the Vector3 to normalize
  66294. * @param result defines the Vector3 where to store the result
  66295. */
  66296. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  66297. /**
  66298. * Project a Vector3 onto screen space
  66299. * @param vector defines the Vector3 to project
  66300. * @param world defines the world matrix to use
  66301. * @param transform defines the transform (view x projection) matrix to use
  66302. * @param viewport defines the screen viewport to use
  66303. * @returns the new Vector3
  66304. */
  66305. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  66306. /** @hidden */
  66307. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  66308. /**
  66309. * Unproject from screen space to object space
  66310. * @param source defines the screen space Vector3 to use
  66311. * @param viewportWidth defines the current width of the viewport
  66312. * @param viewportHeight defines the current height of the viewport
  66313. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66314. * @param transform defines the transform (view x projection) matrix to use
  66315. * @returns the new Vector3
  66316. */
  66317. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  66318. /**
  66319. * Unproject from screen space to object space
  66320. * @param source defines the screen space Vector3 to use
  66321. * @param viewportWidth defines the current width of the viewport
  66322. * @param viewportHeight defines the current height of the viewport
  66323. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66324. * @param view defines the view matrix to use
  66325. * @param projection defines the projection matrix to use
  66326. * @returns the new Vector3
  66327. */
  66328. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  66329. /**
  66330. * Unproject from screen space to object space
  66331. * @param source defines the screen space Vector3 to use
  66332. * @param viewportWidth defines the current width of the viewport
  66333. * @param viewportHeight defines the current height of the viewport
  66334. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66335. * @param view defines the view matrix to use
  66336. * @param projection defines the projection matrix to use
  66337. * @param result defines the Vector3 where to store the result
  66338. */
  66339. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66340. /**
  66341. * Unproject from screen space to object space
  66342. * @param sourceX defines the screen space x coordinate to use
  66343. * @param sourceY defines the screen space y coordinate to use
  66344. * @param sourceZ defines the screen space z coordinate to use
  66345. * @param viewportWidth defines the current width of the viewport
  66346. * @param viewportHeight defines the current height of the viewport
  66347. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66348. * @param view defines the view matrix to use
  66349. * @param projection defines the projection matrix to use
  66350. * @param result defines the Vector3 where to store the result
  66351. */
  66352. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66353. /**
  66354. * Gets the minimal coordinate values between two Vector3
  66355. * @param left defines the first operand
  66356. * @param right defines the second operand
  66357. * @returns the new Vector3
  66358. */
  66359. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66360. /**
  66361. * Gets the maximal coordinate values between two Vector3
  66362. * @param left defines the first operand
  66363. * @param right defines the second operand
  66364. * @returns the new Vector3
  66365. */
  66366. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66367. /**
  66368. * Returns the distance between the vectors "value1" and "value2"
  66369. * @param value1 defines the first operand
  66370. * @param value2 defines the second operand
  66371. * @returns the distance
  66372. */
  66373. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66374. /**
  66375. * Returns the squared distance between the vectors "value1" and "value2"
  66376. * @param value1 defines the first operand
  66377. * @param value2 defines the second operand
  66378. * @returns the squared distance
  66379. */
  66380. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66381. /**
  66382. * Returns a new Vector3 located at the center between "value1" and "value2"
  66383. * @param value1 defines the first operand
  66384. * @param value2 defines the second operand
  66385. * @returns the new Vector3
  66386. */
  66387. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  66388. /**
  66389. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  66390. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  66391. * to something in order to rotate it from its local system to the given target system
  66392. * Note: axis1, axis2 and axis3 are normalized during this operation
  66393. * @param axis1 defines the first axis
  66394. * @param axis2 defines the second axis
  66395. * @param axis3 defines the third axis
  66396. * @returns a new Vector3
  66397. */
  66398. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  66399. /**
  66400. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  66401. * @param axis1 defines the first axis
  66402. * @param axis2 defines the second axis
  66403. * @param axis3 defines the third axis
  66404. * @param ref defines the Vector3 where to store the result
  66405. */
  66406. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  66407. }
  66408. /**
  66409. * Vector4 class created for EulerAngle class conversion to Quaternion
  66410. */
  66411. export class Vector4 {
  66412. /** x value of the vector */
  66413. x: number;
  66414. /** y value of the vector */
  66415. y: number;
  66416. /** z value of the vector */
  66417. z: number;
  66418. /** w value of the vector */
  66419. w: number;
  66420. /**
  66421. * Creates a Vector4 object from the given floats.
  66422. * @param x x value of the vector
  66423. * @param y y value of the vector
  66424. * @param z z value of the vector
  66425. * @param w w value of the vector
  66426. */
  66427. constructor(
  66428. /** x value of the vector */
  66429. x: number,
  66430. /** y value of the vector */
  66431. y: number,
  66432. /** z value of the vector */
  66433. z: number,
  66434. /** w value of the vector */
  66435. w: number);
  66436. /**
  66437. * Returns the string with the Vector4 coordinates.
  66438. * @returns a string containing all the vector values
  66439. */
  66440. toString(): string;
  66441. /**
  66442. * Returns the string "Vector4".
  66443. * @returns "Vector4"
  66444. */
  66445. getClassName(): string;
  66446. /**
  66447. * Returns the Vector4 hash code.
  66448. * @returns a unique hash code
  66449. */
  66450. getHashCode(): number;
  66451. /**
  66452. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  66453. * @returns the resulting array
  66454. */
  66455. asArray(): number[];
  66456. /**
  66457. * Populates the given array from the given index with the Vector4 coordinates.
  66458. * @param array array to populate
  66459. * @param index index of the array to start at (default: 0)
  66460. * @returns the Vector4.
  66461. */
  66462. toArray(array: FloatArray, index?: number): Vector4;
  66463. /**
  66464. * Adds the given vector to the current Vector4.
  66465. * @param otherVector the vector to add
  66466. * @returns the updated Vector4.
  66467. */
  66468. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66469. /**
  66470. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  66471. * @param otherVector the vector to add
  66472. * @returns the resulting vector
  66473. */
  66474. add(otherVector: DeepImmutable<Vector4>): Vector4;
  66475. /**
  66476. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  66477. * @param otherVector the vector to add
  66478. * @param result the vector to store the result
  66479. * @returns the current Vector4.
  66480. */
  66481. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66482. /**
  66483. * Subtract in place the given vector from the current Vector4.
  66484. * @param otherVector the vector to subtract
  66485. * @returns the updated Vector4.
  66486. */
  66487. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66488. /**
  66489. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  66490. * @param otherVector the vector to add
  66491. * @returns the new vector with the result
  66492. */
  66493. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  66494. /**
  66495. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  66496. * @param otherVector the vector to subtract
  66497. * @param result the vector to store the result
  66498. * @returns the current Vector4.
  66499. */
  66500. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66501. /**
  66502. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66503. */
  66504. /**
  66505. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66506. * @param x value to subtract
  66507. * @param y value to subtract
  66508. * @param z value to subtract
  66509. * @param w value to subtract
  66510. * @returns new vector containing the result
  66511. */
  66512. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66513. /**
  66514. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66515. * @param x value to subtract
  66516. * @param y value to subtract
  66517. * @param z value to subtract
  66518. * @param w value to subtract
  66519. * @param result the vector to store the result in
  66520. * @returns the current Vector4.
  66521. */
  66522. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  66523. /**
  66524. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  66525. * @returns a new vector with the negated values
  66526. */
  66527. negate(): Vector4;
  66528. /**
  66529. * Multiplies the current Vector4 coordinates by scale (float).
  66530. * @param scale the number to scale with
  66531. * @returns the updated Vector4.
  66532. */
  66533. scaleInPlace(scale: number): Vector4;
  66534. /**
  66535. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  66536. * @param scale the number to scale with
  66537. * @returns a new vector with the result
  66538. */
  66539. scale(scale: number): Vector4;
  66540. /**
  66541. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  66542. * @param scale the number to scale with
  66543. * @param result a vector to store the result in
  66544. * @returns the current Vector4.
  66545. */
  66546. scaleToRef(scale: number, result: Vector4): Vector4;
  66547. /**
  66548. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  66549. * @param scale defines the scale factor
  66550. * @param result defines the Vector4 object where to store the result
  66551. * @returns the unmodified current Vector4
  66552. */
  66553. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  66554. /**
  66555. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  66556. * @param otherVector the vector to compare against
  66557. * @returns true if they are equal
  66558. */
  66559. equals(otherVector: DeepImmutable<Vector4>): boolean;
  66560. /**
  66561. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  66562. * @param otherVector vector to compare against
  66563. * @param epsilon (Default: very small number)
  66564. * @returns true if they are equal
  66565. */
  66566. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  66567. /**
  66568. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  66569. * @param x x value to compare against
  66570. * @param y y value to compare against
  66571. * @param z z value to compare against
  66572. * @param w w value to compare against
  66573. * @returns true if equal
  66574. */
  66575. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  66576. /**
  66577. * Multiplies in place the current Vector4 by the given one.
  66578. * @param otherVector vector to multiple with
  66579. * @returns the updated Vector4.
  66580. */
  66581. multiplyInPlace(otherVector: Vector4): Vector4;
  66582. /**
  66583. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  66584. * @param otherVector vector to multiple with
  66585. * @returns resulting new vector
  66586. */
  66587. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  66588. /**
  66589. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  66590. * @param otherVector vector to multiple with
  66591. * @param result vector to store the result
  66592. * @returns the current Vector4.
  66593. */
  66594. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66595. /**
  66596. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  66597. * @param x x value multiply with
  66598. * @param y y value multiply with
  66599. * @param z z value multiply with
  66600. * @param w w value multiply with
  66601. * @returns resulting new vector
  66602. */
  66603. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  66604. /**
  66605. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  66606. * @param otherVector vector to devide with
  66607. * @returns resulting new vector
  66608. */
  66609. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  66610. /**
  66611. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  66612. * @param otherVector vector to devide with
  66613. * @param result vector to store the result
  66614. * @returns the current Vector4.
  66615. */
  66616. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66617. /**
  66618. * Divides the current Vector3 coordinates by the given ones.
  66619. * @param otherVector vector to devide with
  66620. * @returns the updated Vector3.
  66621. */
  66622. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66623. /**
  66624. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  66625. * @param other defines the second operand
  66626. * @returns the current updated Vector4
  66627. */
  66628. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66629. /**
  66630. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  66631. * @param other defines the second operand
  66632. * @returns the current updated Vector4
  66633. */
  66634. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66635. /**
  66636. * Gets a new Vector4 from current Vector4 floored values
  66637. * @returns a new Vector4
  66638. */
  66639. floor(): Vector4;
  66640. /**
  66641. * Gets a new Vector4 from current Vector3 floored values
  66642. * @returns a new Vector4
  66643. */
  66644. fract(): Vector4;
  66645. /**
  66646. * Returns the Vector4 length (float).
  66647. * @returns the length
  66648. */
  66649. length(): number;
  66650. /**
  66651. * Returns the Vector4 squared length (float).
  66652. * @returns the length squared
  66653. */
  66654. lengthSquared(): number;
  66655. /**
  66656. * Normalizes in place the Vector4.
  66657. * @returns the updated Vector4.
  66658. */
  66659. normalize(): Vector4;
  66660. /**
  66661. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  66662. * @returns this converted to a new vector3
  66663. */
  66664. toVector3(): Vector3;
  66665. /**
  66666. * Returns a new Vector4 copied from the current one.
  66667. * @returns the new cloned vector
  66668. */
  66669. clone(): Vector4;
  66670. /**
  66671. * Updates the current Vector4 with the given one coordinates.
  66672. * @param source the source vector to copy from
  66673. * @returns the updated Vector4.
  66674. */
  66675. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  66676. /**
  66677. * Updates the current Vector4 coordinates with the given floats.
  66678. * @param x float to copy from
  66679. * @param y float to copy from
  66680. * @param z float to copy from
  66681. * @param w float to copy from
  66682. * @returns the updated Vector4.
  66683. */
  66684. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66685. /**
  66686. * Updates the current Vector4 coordinates with the given floats.
  66687. * @param x float to set from
  66688. * @param y float to set from
  66689. * @param z float to set from
  66690. * @param w float to set from
  66691. * @returns the updated Vector4.
  66692. */
  66693. set(x: number, y: number, z: number, w: number): Vector4;
  66694. /**
  66695. * Copies the given float to the current Vector3 coordinates
  66696. * @param v defines the x, y, z and w coordinates of the operand
  66697. * @returns the current updated Vector3
  66698. */
  66699. setAll(v: number): Vector4;
  66700. /**
  66701. * Returns a new Vector4 set from the starting index of the given array.
  66702. * @param array the array to pull values from
  66703. * @param offset the offset into the array to start at
  66704. * @returns the new vector
  66705. */
  66706. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  66707. /**
  66708. * Updates the given vector "result" from the starting index of the given array.
  66709. * @param array the array to pull values from
  66710. * @param offset the offset into the array to start at
  66711. * @param result the vector to store the result in
  66712. */
  66713. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  66714. /**
  66715. * Updates the given vector "result" from the starting index of the given Float32Array.
  66716. * @param array the array to pull values from
  66717. * @param offset the offset into the array to start at
  66718. * @param result the vector to store the result in
  66719. */
  66720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  66721. /**
  66722. * Updates the given vector "result" coordinates from the given floats.
  66723. * @param x float to set from
  66724. * @param y float to set from
  66725. * @param z float to set from
  66726. * @param w float to set from
  66727. * @param result the vector to the floats in
  66728. */
  66729. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  66730. /**
  66731. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  66732. * @returns the new vector
  66733. */
  66734. static Zero(): Vector4;
  66735. /**
  66736. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  66737. * @returns the new vector
  66738. */
  66739. static One(): Vector4;
  66740. /**
  66741. * Returns a new normalized Vector4 from the given one.
  66742. * @param vector the vector to normalize
  66743. * @returns the vector
  66744. */
  66745. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  66746. /**
  66747. * Updates the given vector "result" from the normalization of the given one.
  66748. * @param vector the vector to normalize
  66749. * @param result the vector to store the result in
  66750. */
  66751. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  66752. /**
  66753. * Returns a vector with the minimum values from the left and right vectors
  66754. * @param left left vector to minimize
  66755. * @param right right vector to minimize
  66756. * @returns a new vector with the minimum of the left and right vector values
  66757. */
  66758. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66759. /**
  66760. * Returns a vector with the maximum values from the left and right vectors
  66761. * @param left left vector to maximize
  66762. * @param right right vector to maximize
  66763. * @returns a new vector with the maximum of the left and right vector values
  66764. */
  66765. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66766. /**
  66767. * Returns the distance (float) between the vectors "value1" and "value2".
  66768. * @param value1 value to calulate the distance between
  66769. * @param value2 value to calulate the distance between
  66770. * @return the distance between the two vectors
  66771. */
  66772. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66773. /**
  66774. * Returns the squared distance (float) between the vectors "value1" and "value2".
  66775. * @param value1 value to calulate the distance between
  66776. * @param value2 value to calulate the distance between
  66777. * @return the distance between the two vectors squared
  66778. */
  66779. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66780. /**
  66781. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  66782. * @param value1 value to calulate the center between
  66783. * @param value2 value to calulate the center between
  66784. * @return the center between the two vectors
  66785. */
  66786. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  66787. /**
  66788. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  66789. * This methods computes transformed normalized direction vectors only.
  66790. * @param vector the vector to transform
  66791. * @param transformation the transformation matrix to apply
  66792. * @returns the new vector
  66793. */
  66794. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  66795. /**
  66796. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  66797. * This methods computes transformed normalized direction vectors only.
  66798. * @param vector the vector to transform
  66799. * @param transformation the transformation matrix to apply
  66800. * @param result the vector to store the result in
  66801. */
  66802. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66803. /**
  66804. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  66805. * This methods computes transformed normalized direction vectors only.
  66806. * @param x value to transform
  66807. * @param y value to transform
  66808. * @param z value to transform
  66809. * @param w value to transform
  66810. * @param transformation the transformation matrix to apply
  66811. * @param result the vector to store the results in
  66812. */
  66813. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66814. /**
  66815. * Creates a new Vector4 from a Vector3
  66816. * @param source defines the source data
  66817. * @param w defines the 4th component (default is 0)
  66818. * @returns a new Vector4
  66819. */
  66820. static FromVector3(source: Vector3, w?: number): Vector4;
  66821. }
  66822. /**
  66823. * Class used to store quaternion data
  66824. * @see https://en.wikipedia.org/wiki/Quaternion
  66825. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  66826. */
  66827. export class Quaternion {
  66828. /** defines the first component (0 by default) */
  66829. x: number;
  66830. /** defines the second component (0 by default) */
  66831. y: number;
  66832. /** defines the third component (0 by default) */
  66833. z: number;
  66834. /** defines the fourth component (1.0 by default) */
  66835. w: number;
  66836. /**
  66837. * Creates a new Quaternion from the given floats
  66838. * @param x defines the first component (0 by default)
  66839. * @param y defines the second component (0 by default)
  66840. * @param z defines the third component (0 by default)
  66841. * @param w defines the fourth component (1.0 by default)
  66842. */
  66843. constructor(
  66844. /** defines the first component (0 by default) */
  66845. x?: number,
  66846. /** defines the second component (0 by default) */
  66847. y?: number,
  66848. /** defines the third component (0 by default) */
  66849. z?: number,
  66850. /** defines the fourth component (1.0 by default) */
  66851. w?: number);
  66852. /**
  66853. * Gets a string representation for the current quaternion
  66854. * @returns a string with the Quaternion coordinates
  66855. */
  66856. toString(): string;
  66857. /**
  66858. * Gets the class name of the quaternion
  66859. * @returns the string "Quaternion"
  66860. */
  66861. getClassName(): string;
  66862. /**
  66863. * Gets a hash code for this quaternion
  66864. * @returns the quaternion hash code
  66865. */
  66866. getHashCode(): number;
  66867. /**
  66868. * Copy the quaternion to an array
  66869. * @returns a new array populated with 4 elements from the quaternion coordinates
  66870. */
  66871. asArray(): number[];
  66872. /**
  66873. * Check if two quaternions are equals
  66874. * @param otherQuaternion defines the second operand
  66875. * @return true if the current quaternion and the given one coordinates are strictly equals
  66876. */
  66877. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  66878. /**
  66879. * Clone the current quaternion
  66880. * @returns a new quaternion copied from the current one
  66881. */
  66882. clone(): Quaternion;
  66883. /**
  66884. * Copy a quaternion to the current one
  66885. * @param other defines the other quaternion
  66886. * @returns the updated current quaternion
  66887. */
  66888. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  66889. /**
  66890. * Updates the current quaternion with the given float coordinates
  66891. * @param x defines the x coordinate
  66892. * @param y defines the y coordinate
  66893. * @param z defines the z coordinate
  66894. * @param w defines the w coordinate
  66895. * @returns the updated current quaternion
  66896. */
  66897. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  66898. /**
  66899. * Updates the current quaternion from the given float coordinates
  66900. * @param x defines the x coordinate
  66901. * @param y defines the y coordinate
  66902. * @param z defines the z coordinate
  66903. * @param w defines the w coordinate
  66904. * @returns the updated current quaternion
  66905. */
  66906. set(x: number, y: number, z: number, w: number): Quaternion;
  66907. /**
  66908. * Adds two quaternions
  66909. * @param other defines the second operand
  66910. * @returns a new quaternion as the addition result of the given one and the current quaternion
  66911. */
  66912. add(other: DeepImmutable<Quaternion>): Quaternion;
  66913. /**
  66914. * Add a quaternion to the current one
  66915. * @param other defines the quaternion to add
  66916. * @returns the current quaternion
  66917. */
  66918. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  66919. /**
  66920. * Subtract two quaternions
  66921. * @param other defines the second operand
  66922. * @returns a new quaternion as the subtraction result of the given one from the current one
  66923. */
  66924. subtract(other: Quaternion): Quaternion;
  66925. /**
  66926. * Multiplies the current quaternion by a scale factor
  66927. * @param value defines the scale factor
  66928. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  66929. */
  66930. scale(value: number): Quaternion;
  66931. /**
  66932. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  66933. * @param scale defines the scale factor
  66934. * @param result defines the Quaternion object where to store the result
  66935. * @returns the unmodified current quaternion
  66936. */
  66937. scaleToRef(scale: number, result: Quaternion): Quaternion;
  66938. /**
  66939. * Multiplies in place the current quaternion by a scale factor
  66940. * @param value defines the scale factor
  66941. * @returns the current modified quaternion
  66942. */
  66943. scaleInPlace(value: number): Quaternion;
  66944. /**
  66945. * Scale the current quaternion values by a factor and add the result to a given quaternion
  66946. * @param scale defines the scale factor
  66947. * @param result defines the Quaternion object where to store the result
  66948. * @returns the unmodified current quaternion
  66949. */
  66950. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  66951. /**
  66952. * Multiplies two quaternions
  66953. * @param q1 defines the second operand
  66954. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  66955. */
  66956. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  66957. /**
  66958. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  66959. * @param q1 defines the second operand
  66960. * @param result defines the target quaternion
  66961. * @returns the current quaternion
  66962. */
  66963. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  66964. /**
  66965. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  66966. * @param q1 defines the second operand
  66967. * @returns the currentupdated quaternion
  66968. */
  66969. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  66970. /**
  66971. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  66972. * @param ref defines the target quaternion
  66973. * @returns the current quaternion
  66974. */
  66975. conjugateToRef(ref: Quaternion): Quaternion;
  66976. /**
  66977. * Conjugates in place (1-q) the current quaternion
  66978. * @returns the current updated quaternion
  66979. */
  66980. conjugateInPlace(): Quaternion;
  66981. /**
  66982. * Conjugates in place (1-q) the current quaternion
  66983. * @returns a new quaternion
  66984. */
  66985. conjugate(): Quaternion;
  66986. /**
  66987. * Gets length of current quaternion
  66988. * @returns the quaternion length (float)
  66989. */
  66990. length(): number;
  66991. /**
  66992. * Normalize in place the current quaternion
  66993. * @returns the current updated quaternion
  66994. */
  66995. normalize(): Quaternion;
  66996. /**
  66997. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  66998. * @param order is a reserved parameter and is ignore for now
  66999. * @returns a new Vector3 containing the Euler angles
  67000. */
  67001. toEulerAngles(order?: string): Vector3;
  67002. /**
  67003. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  67004. * @param result defines the vector which will be filled with the Euler angles
  67005. * @param order is a reserved parameter and is ignore for now
  67006. * @returns the current unchanged quaternion
  67007. */
  67008. toEulerAnglesToRef(result: Vector3): Quaternion;
  67009. /**
  67010. * Updates the given rotation matrix with the current quaternion values
  67011. * @param result defines the target matrix
  67012. * @returns the current unchanged quaternion
  67013. */
  67014. toRotationMatrix(result: Matrix): Quaternion;
  67015. /**
  67016. * Updates the current quaternion from the given rotation matrix values
  67017. * @param matrix defines the source matrix
  67018. * @returns the current updated quaternion
  67019. */
  67020. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67021. /**
  67022. * Creates a new quaternion from a rotation matrix
  67023. * @param matrix defines the source matrix
  67024. * @returns a new quaternion created from the given rotation matrix values
  67025. */
  67026. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67027. /**
  67028. * Updates the given quaternion with the given rotation matrix values
  67029. * @param matrix defines the source matrix
  67030. * @param result defines the target quaternion
  67031. */
  67032. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  67033. /**
  67034. * Returns the dot product (float) between the quaternions "left" and "right"
  67035. * @param left defines the left operand
  67036. * @param right defines the right operand
  67037. * @returns the dot product
  67038. */
  67039. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  67040. /**
  67041. * Checks if the two quaternions are close to each other
  67042. * @param quat0 defines the first quaternion to check
  67043. * @param quat1 defines the second quaternion to check
  67044. * @returns true if the two quaternions are close to each other
  67045. */
  67046. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  67047. /**
  67048. * Creates an empty quaternion
  67049. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  67050. */
  67051. static Zero(): Quaternion;
  67052. /**
  67053. * Inverse a given quaternion
  67054. * @param q defines the source quaternion
  67055. * @returns a new quaternion as the inverted current quaternion
  67056. */
  67057. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  67058. /**
  67059. * Inverse a given quaternion
  67060. * @param q defines the source quaternion
  67061. * @param result the quaternion the result will be stored in
  67062. * @returns the result quaternion
  67063. */
  67064. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  67065. /**
  67066. * Creates an identity quaternion
  67067. * @returns the identity quaternion
  67068. */
  67069. static Identity(): Quaternion;
  67070. /**
  67071. * Gets a boolean indicating if the given quaternion is identity
  67072. * @param quaternion defines the quaternion to check
  67073. * @returns true if the quaternion is identity
  67074. */
  67075. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  67076. /**
  67077. * Creates a quaternion from a rotation around an axis
  67078. * @param axis defines the axis to use
  67079. * @param angle defines the angle to use
  67080. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  67081. */
  67082. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  67083. /**
  67084. * Creates a rotation around an axis and stores it into the given quaternion
  67085. * @param axis defines the axis to use
  67086. * @param angle defines the angle to use
  67087. * @param result defines the target quaternion
  67088. * @returns the target quaternion
  67089. */
  67090. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  67091. /**
  67092. * Creates a new quaternion from data stored into an array
  67093. * @param array defines the data source
  67094. * @param offset defines the offset in the source array where the data starts
  67095. * @returns a new quaternion
  67096. */
  67097. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  67098. /**
  67099. * Create a quaternion from Euler rotation angles
  67100. * @param x Pitch
  67101. * @param y Yaw
  67102. * @param z Roll
  67103. * @returns the new Quaternion
  67104. */
  67105. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  67106. /**
  67107. * Updates a quaternion from Euler rotation angles
  67108. * @param x Pitch
  67109. * @param y Yaw
  67110. * @param z Roll
  67111. * @param result the quaternion to store the result
  67112. * @returns the updated quaternion
  67113. */
  67114. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  67115. /**
  67116. * Create a quaternion from Euler rotation vector
  67117. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67118. * @returns the new Quaternion
  67119. */
  67120. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  67121. /**
  67122. * Updates a quaternion from Euler rotation vector
  67123. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67124. * @param result the quaternion to store the result
  67125. * @returns the updated quaternion
  67126. */
  67127. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  67128. /**
  67129. * Creates a new quaternion from the given Euler float angles (y, x, z)
  67130. * @param yaw defines the rotation around Y axis
  67131. * @param pitch defines the rotation around X axis
  67132. * @param roll defines the rotation around Z axis
  67133. * @returns the new quaternion
  67134. */
  67135. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  67136. /**
  67137. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  67138. * @param yaw defines the rotation around Y axis
  67139. * @param pitch defines the rotation around X axis
  67140. * @param roll defines the rotation around Z axis
  67141. * @param result defines the target quaternion
  67142. */
  67143. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  67144. /**
  67145. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  67146. * @param alpha defines the rotation around first axis
  67147. * @param beta defines the rotation around second axis
  67148. * @param gamma defines the rotation around third axis
  67149. * @returns the new quaternion
  67150. */
  67151. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  67152. /**
  67153. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  67154. * @param alpha defines the rotation around first axis
  67155. * @param beta defines the rotation around second axis
  67156. * @param gamma defines the rotation around third axis
  67157. * @param result defines the target quaternion
  67158. */
  67159. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  67160. /**
  67161. * 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)
  67162. * @param axis1 defines the first axis
  67163. * @param axis2 defines the second axis
  67164. * @param axis3 defines the third axis
  67165. * @returns the new quaternion
  67166. */
  67167. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  67168. /**
  67169. * 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
  67170. * @param axis1 defines the first axis
  67171. * @param axis2 defines the second axis
  67172. * @param axis3 defines the third axis
  67173. * @param ref defines the target quaternion
  67174. */
  67175. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  67176. /**
  67177. * Interpolates between two quaternions
  67178. * @param left defines first quaternion
  67179. * @param right defines second quaternion
  67180. * @param amount defines the gradient to use
  67181. * @returns the new interpolated quaternion
  67182. */
  67183. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67184. /**
  67185. * Interpolates between two quaternions and stores it into a target quaternion
  67186. * @param left defines first quaternion
  67187. * @param right defines second quaternion
  67188. * @param amount defines the gradient to use
  67189. * @param result defines the target quaternion
  67190. */
  67191. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  67192. /**
  67193. * Interpolate between two quaternions using Hermite interpolation
  67194. * @param value1 defines first quaternion
  67195. * @param tangent1 defines the incoming tangent
  67196. * @param value2 defines second quaternion
  67197. * @param tangent2 defines the outgoing tangent
  67198. * @param amount defines the target quaternion
  67199. * @returns the new interpolated quaternion
  67200. */
  67201. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67202. }
  67203. /**
  67204. * Class used to store matrix data (4x4)
  67205. */
  67206. export class Matrix {
  67207. private static _updateFlagSeed;
  67208. private static _identityReadOnly;
  67209. private _isIdentity;
  67210. private _isIdentityDirty;
  67211. private _isIdentity3x2;
  67212. private _isIdentity3x2Dirty;
  67213. /**
  67214. * Gets the update flag of the matrix which is an unique number for the matrix.
  67215. * It will be incremented every time the matrix data change.
  67216. * You can use it to speed the comparison between two versions of the same matrix.
  67217. */
  67218. updateFlag: number;
  67219. private readonly _m;
  67220. /**
  67221. * Gets the internal data of the matrix
  67222. */
  67223. readonly m: DeepImmutable<Float32Array>;
  67224. /** @hidden */
  67225. _markAsUpdated(): void;
  67226. /** @hidden */
  67227. private _updateIdentityStatus;
  67228. /**
  67229. * Creates an empty matrix (filled with zeros)
  67230. */
  67231. constructor();
  67232. /**
  67233. * Check if the current matrix is identity
  67234. * @returns true is the matrix is the identity matrix
  67235. */
  67236. isIdentity(): boolean;
  67237. /**
  67238. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  67239. * @returns true is the matrix is the identity matrix
  67240. */
  67241. isIdentityAs3x2(): boolean;
  67242. /**
  67243. * Gets the determinant of the matrix
  67244. * @returns the matrix determinant
  67245. */
  67246. determinant(): number;
  67247. /**
  67248. * Returns the matrix as a Float32Array
  67249. * @returns the matrix underlying array
  67250. */
  67251. toArray(): DeepImmutable<Float32Array>;
  67252. /**
  67253. * Returns the matrix as a Float32Array
  67254. * @returns the matrix underlying array.
  67255. */
  67256. asArray(): DeepImmutable<Float32Array>;
  67257. /**
  67258. * Inverts the current matrix in place
  67259. * @returns the current inverted matrix
  67260. */
  67261. invert(): Matrix;
  67262. /**
  67263. * Sets all the matrix elements to zero
  67264. * @returns the current matrix
  67265. */
  67266. reset(): Matrix;
  67267. /**
  67268. * Adds the current matrix with a second one
  67269. * @param other defines the matrix to add
  67270. * @returns a new matrix as the addition of the current matrix and the given one
  67271. */
  67272. add(other: DeepImmutable<Matrix>): Matrix;
  67273. /**
  67274. * Sets the given matrix "result" to the addition of the current matrix and the given one
  67275. * @param other defines the matrix to add
  67276. * @param result defines the target matrix
  67277. * @returns the current matrix
  67278. */
  67279. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67280. /**
  67281. * Adds in place the given matrix to the current matrix
  67282. * @param other defines the second operand
  67283. * @returns the current updated matrix
  67284. */
  67285. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  67286. /**
  67287. * Sets the given matrix to the current inverted Matrix
  67288. * @param other defines the target matrix
  67289. * @returns the unmodified current matrix
  67290. */
  67291. invertToRef(other: Matrix): Matrix;
  67292. /**
  67293. * add a value at the specified position in the current Matrix
  67294. * @param index the index of the value within the matrix. between 0 and 15.
  67295. * @param value the value to be added
  67296. * @returns the current updated matrix
  67297. */
  67298. addAtIndex(index: number, value: number): Matrix;
  67299. /**
  67300. * mutiply the specified position in the current Matrix by a value
  67301. * @param index the index of the value within the matrix. between 0 and 15.
  67302. * @param value the value to be added
  67303. * @returns the current updated matrix
  67304. */
  67305. multiplyAtIndex(index: number, value: number): Matrix;
  67306. /**
  67307. * Inserts the translation vector (using 3 floats) in the current matrix
  67308. * @param x defines the 1st component of the translation
  67309. * @param y defines the 2nd component of the translation
  67310. * @param z defines the 3rd component of the translation
  67311. * @returns the current updated matrix
  67312. */
  67313. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67314. /**
  67315. * Adds the translation vector (using 3 floats) in the current matrix
  67316. * @param x defines the 1st component of the translation
  67317. * @param y defines the 2nd component of the translation
  67318. * @param z defines the 3rd component of the translation
  67319. * @returns the current updated matrix
  67320. */
  67321. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67322. /**
  67323. * Inserts the translation vector in the current matrix
  67324. * @param vector3 defines the translation to insert
  67325. * @returns the current updated matrix
  67326. */
  67327. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  67328. /**
  67329. * Gets the translation value of the current matrix
  67330. * @returns a new Vector3 as the extracted translation from the matrix
  67331. */
  67332. getTranslation(): Vector3;
  67333. /**
  67334. * Fill a Vector3 with the extracted translation from the matrix
  67335. * @param result defines the Vector3 where to store the translation
  67336. * @returns the current matrix
  67337. */
  67338. getTranslationToRef(result: Vector3): Matrix;
  67339. /**
  67340. * Remove rotation and scaling part from the matrix
  67341. * @returns the updated matrix
  67342. */
  67343. removeRotationAndScaling(): Matrix;
  67344. /**
  67345. * Multiply two matrices
  67346. * @param other defines the second operand
  67347. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  67348. */
  67349. multiply(other: DeepImmutable<Matrix>): Matrix;
  67350. /**
  67351. * Copy the current matrix from the given one
  67352. * @param other defines the source matrix
  67353. * @returns the current updated matrix
  67354. */
  67355. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  67356. /**
  67357. * Populates the given array from the starting index with the current matrix values
  67358. * @param array defines the target array
  67359. * @param offset defines the offset in the target array where to start storing values
  67360. * @returns the current matrix
  67361. */
  67362. copyToArray(array: Float32Array, offset?: number): Matrix;
  67363. /**
  67364. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  67365. * @param other defines the second operand
  67366. * @param result defines the matrix where to store the multiplication
  67367. * @returns the current matrix
  67368. */
  67369. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67370. /**
  67371. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  67372. * @param other defines the second operand
  67373. * @param result defines the array where to store the multiplication
  67374. * @param offset defines the offset in the target array where to start storing values
  67375. * @returns the current matrix
  67376. */
  67377. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  67378. /**
  67379. * Check equality between this matrix and a second one
  67380. * @param value defines the second matrix to compare
  67381. * @returns true is the current matrix and the given one values are strictly equal
  67382. */
  67383. equals(value: DeepImmutable<Matrix>): boolean;
  67384. /**
  67385. * Clone the current matrix
  67386. * @returns a new matrix from the current matrix
  67387. */
  67388. clone(): Matrix;
  67389. /**
  67390. * Returns the name of the current matrix class
  67391. * @returns the string "Matrix"
  67392. */
  67393. getClassName(): string;
  67394. /**
  67395. * Gets the hash code of the current matrix
  67396. * @returns the hash code
  67397. */
  67398. getHashCode(): number;
  67399. /**
  67400. * Decomposes the current Matrix into a translation, rotation and scaling components
  67401. * @param scale defines the scale vector3 given as a reference to update
  67402. * @param rotation defines the rotation quaternion given as a reference to update
  67403. * @param translation defines the translation vector3 given as a reference to update
  67404. * @returns true if operation was successful
  67405. */
  67406. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  67407. /**
  67408. * Gets specific row of the matrix
  67409. * @param index defines the number of the row to get
  67410. * @returns the index-th row of the current matrix as a new Vector4
  67411. */
  67412. getRow(index: number): Nullable<Vector4>;
  67413. /**
  67414. * Sets the index-th row of the current matrix to the vector4 values
  67415. * @param index defines the number of the row to set
  67416. * @param row defines the target vector4
  67417. * @returns the updated current matrix
  67418. */
  67419. setRow(index: number, row: Vector4): Matrix;
  67420. /**
  67421. * Compute the transpose of the matrix
  67422. * @returns the new transposed matrix
  67423. */
  67424. transpose(): Matrix;
  67425. /**
  67426. * Compute the transpose of the matrix and store it in a given matrix
  67427. * @param result defines the target matrix
  67428. * @returns the current matrix
  67429. */
  67430. transposeToRef(result: Matrix): Matrix;
  67431. /**
  67432. * Sets the index-th row of the current matrix with the given 4 x float values
  67433. * @param index defines the row index
  67434. * @param x defines the x component to set
  67435. * @param y defines the y component to set
  67436. * @param z defines the z component to set
  67437. * @param w defines the w component to set
  67438. * @returns the updated current matrix
  67439. */
  67440. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  67441. /**
  67442. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  67443. * @param scale defines the scale factor
  67444. * @returns a new matrix
  67445. */
  67446. scale(scale: number): Matrix;
  67447. /**
  67448. * Scale the current matrix values by a factor to a given result matrix
  67449. * @param scale defines the scale factor
  67450. * @param result defines the matrix to store the result
  67451. * @returns the current matrix
  67452. */
  67453. scaleToRef(scale: number, result: Matrix): Matrix;
  67454. /**
  67455. * Scale the current matrix values by a factor and add the result to a given matrix
  67456. * @param scale defines the scale factor
  67457. * @param result defines the Matrix to store the result
  67458. * @returns the current matrix
  67459. */
  67460. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  67461. /**
  67462. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  67463. * @param ref matrix to store the result
  67464. */
  67465. toNormalMatrix(ref: Matrix): void;
  67466. /**
  67467. * Gets only rotation part of the current matrix
  67468. * @returns a new matrix sets to the extracted rotation matrix from the current one
  67469. */
  67470. getRotationMatrix(): Matrix;
  67471. /**
  67472. * Extracts the rotation matrix from the current one and sets it as the given "result"
  67473. * @param result defines the target matrix to store data to
  67474. * @returns the current matrix
  67475. */
  67476. getRotationMatrixToRef(result: Matrix): Matrix;
  67477. /**
  67478. * Toggles model matrix from being right handed to left handed in place and vice versa
  67479. */
  67480. toggleModelMatrixHandInPlace(): void;
  67481. /**
  67482. * Toggles projection matrix from being right handed to left handed in place and vice versa
  67483. */
  67484. toggleProjectionMatrixHandInPlace(): void;
  67485. /**
  67486. * Creates a matrix from an array
  67487. * @param array defines the source array
  67488. * @param offset defines an offset in the source array
  67489. * @returns a new Matrix set from the starting index of the given array
  67490. */
  67491. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  67492. /**
  67493. * Copy the content of an array into a given matrix
  67494. * @param array defines the source array
  67495. * @param offset defines an offset in the source array
  67496. * @param result defines the target matrix
  67497. */
  67498. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  67499. /**
  67500. * Stores an array into a matrix after having multiplied each component by a given factor
  67501. * @param array defines the source array
  67502. * @param offset defines the offset in the source array
  67503. * @param scale defines the scaling factor
  67504. * @param result defines the target matrix
  67505. */
  67506. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  67507. /**
  67508. * Gets an identity matrix that must not be updated
  67509. */
  67510. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  67511. /**
  67512. * Stores a list of values (16) inside a given matrix
  67513. * @param initialM11 defines 1st value of 1st row
  67514. * @param initialM12 defines 2nd value of 1st row
  67515. * @param initialM13 defines 3rd value of 1st row
  67516. * @param initialM14 defines 4th value of 1st row
  67517. * @param initialM21 defines 1st value of 2nd row
  67518. * @param initialM22 defines 2nd value of 2nd row
  67519. * @param initialM23 defines 3rd value of 2nd row
  67520. * @param initialM24 defines 4th value of 2nd row
  67521. * @param initialM31 defines 1st value of 3rd row
  67522. * @param initialM32 defines 2nd value of 3rd row
  67523. * @param initialM33 defines 3rd value of 3rd row
  67524. * @param initialM34 defines 4th value of 3rd row
  67525. * @param initialM41 defines 1st value of 4th row
  67526. * @param initialM42 defines 2nd value of 4th row
  67527. * @param initialM43 defines 3rd value of 4th row
  67528. * @param initialM44 defines 4th value of 4th row
  67529. * @param result defines the target matrix
  67530. */
  67531. 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;
  67532. /**
  67533. * Creates new matrix from a list of values (16)
  67534. * @param initialM11 defines 1st value of 1st row
  67535. * @param initialM12 defines 2nd value of 1st row
  67536. * @param initialM13 defines 3rd value of 1st row
  67537. * @param initialM14 defines 4th value of 1st row
  67538. * @param initialM21 defines 1st value of 2nd row
  67539. * @param initialM22 defines 2nd value of 2nd row
  67540. * @param initialM23 defines 3rd value of 2nd row
  67541. * @param initialM24 defines 4th value of 2nd row
  67542. * @param initialM31 defines 1st value of 3rd row
  67543. * @param initialM32 defines 2nd value of 3rd row
  67544. * @param initialM33 defines 3rd value of 3rd row
  67545. * @param initialM34 defines 4th value of 3rd row
  67546. * @param initialM41 defines 1st value of 4th row
  67547. * @param initialM42 defines 2nd value of 4th row
  67548. * @param initialM43 defines 3rd value of 4th row
  67549. * @param initialM44 defines 4th value of 4th row
  67550. * @returns the new matrix
  67551. */
  67552. 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;
  67553. /**
  67554. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67555. * @param scale defines the scale vector3
  67556. * @param rotation defines the rotation quaternion
  67557. * @param translation defines the translation vector3
  67558. * @returns a new matrix
  67559. */
  67560. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  67561. /**
  67562. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67563. * @param scale defines the scale vector3
  67564. * @param rotation defines the rotation quaternion
  67565. * @param translation defines the translation vector3
  67566. * @param result defines the target matrix
  67567. */
  67568. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  67569. /**
  67570. * Creates a new identity matrix
  67571. * @returns a new identity matrix
  67572. */
  67573. static Identity(): Matrix;
  67574. /**
  67575. * Creates a new identity matrix and stores the result in a given matrix
  67576. * @param result defines the target matrix
  67577. */
  67578. static IdentityToRef(result: Matrix): void;
  67579. /**
  67580. * Creates a new zero matrix
  67581. * @returns a new zero matrix
  67582. */
  67583. static Zero(): Matrix;
  67584. /**
  67585. * Creates a new rotation matrix for "angle" radians around the X axis
  67586. * @param angle defines the angle (in radians) to use
  67587. * @return the new matrix
  67588. */
  67589. static RotationX(angle: number): Matrix;
  67590. /**
  67591. * Creates a new matrix as the invert of a given matrix
  67592. * @param source defines the source matrix
  67593. * @returns the new matrix
  67594. */
  67595. static Invert(source: DeepImmutable<Matrix>): Matrix;
  67596. /**
  67597. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  67598. * @param angle defines the angle (in radians) to use
  67599. * @param result defines the target matrix
  67600. */
  67601. static RotationXToRef(angle: number, result: Matrix): void;
  67602. /**
  67603. * Creates a new rotation matrix for "angle" radians around the Y axis
  67604. * @param angle defines the angle (in radians) to use
  67605. * @return the new matrix
  67606. */
  67607. static RotationY(angle: number): Matrix;
  67608. /**
  67609. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  67610. * @param angle defines the angle (in radians) to use
  67611. * @param result defines the target matrix
  67612. */
  67613. static RotationYToRef(angle: number, result: Matrix): void;
  67614. /**
  67615. * Creates a new rotation matrix for "angle" radians around the Z axis
  67616. * @param angle defines the angle (in radians) to use
  67617. * @return the new matrix
  67618. */
  67619. static RotationZ(angle: number): Matrix;
  67620. /**
  67621. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  67622. * @param angle defines the angle (in radians) to use
  67623. * @param result defines the target matrix
  67624. */
  67625. static RotationZToRef(angle: number, result: Matrix): void;
  67626. /**
  67627. * Creates a new rotation matrix for "angle" radians around the given axis
  67628. * @param axis defines the axis to use
  67629. * @param angle defines the angle (in radians) to use
  67630. * @return the new matrix
  67631. */
  67632. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  67633. /**
  67634. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  67635. * @param axis defines the axis to use
  67636. * @param angle defines the angle (in radians) to use
  67637. * @param result defines the target matrix
  67638. */
  67639. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  67640. /**
  67641. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  67642. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  67643. * @param from defines the vector to align
  67644. * @param to defines the vector to align to
  67645. * @param result defines the target matrix
  67646. */
  67647. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  67648. /**
  67649. * Creates a rotation matrix
  67650. * @param yaw defines the yaw angle in radians (Y axis)
  67651. * @param pitch defines the pitch angle in radians (X axis)
  67652. * @param roll defines the roll angle in radians (X axis)
  67653. * @returns the new rotation matrix
  67654. */
  67655. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  67656. /**
  67657. * Creates a rotation matrix and stores it in a given matrix
  67658. * @param yaw defines the yaw angle in radians (Y axis)
  67659. * @param pitch defines the pitch angle in radians (X axis)
  67660. * @param roll defines the roll angle in radians (X axis)
  67661. * @param result defines the target matrix
  67662. */
  67663. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  67664. /**
  67665. * Creates a scaling matrix
  67666. * @param x defines the scale factor on X axis
  67667. * @param y defines the scale factor on Y axis
  67668. * @param z defines the scale factor on Z axis
  67669. * @returns the new matrix
  67670. */
  67671. static Scaling(x: number, y: number, z: number): Matrix;
  67672. /**
  67673. * Creates a scaling matrix and stores it in a given matrix
  67674. * @param x defines the scale factor on X axis
  67675. * @param y defines the scale factor on Y axis
  67676. * @param z defines the scale factor on Z axis
  67677. * @param result defines the target matrix
  67678. */
  67679. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  67680. /**
  67681. * Creates a translation matrix
  67682. * @param x defines the translation on X axis
  67683. * @param y defines the translation on Y axis
  67684. * @param z defines the translationon Z axis
  67685. * @returns the new matrix
  67686. */
  67687. static Translation(x: number, y: number, z: number): Matrix;
  67688. /**
  67689. * Creates a translation matrix and stores it in a given matrix
  67690. * @param x defines the translation on X axis
  67691. * @param y defines the translation on Y axis
  67692. * @param z defines the translationon Z axis
  67693. * @param result defines the target matrix
  67694. */
  67695. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  67696. /**
  67697. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67698. * @param startValue defines the start value
  67699. * @param endValue defines the end value
  67700. * @param gradient defines the gradient factor
  67701. * @returns the new matrix
  67702. */
  67703. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67704. /**
  67705. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67706. * @param startValue defines the start value
  67707. * @param endValue defines the end value
  67708. * @param gradient defines the gradient factor
  67709. * @param result defines the Matrix object where to store data
  67710. */
  67711. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67712. /**
  67713. * Builds a new matrix whose values are computed by:
  67714. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  67715. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  67716. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  67717. * @param startValue defines the first matrix
  67718. * @param endValue defines the second matrix
  67719. * @param gradient defines the gradient between the two matrices
  67720. * @returns the new matrix
  67721. */
  67722. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67723. /**
  67724. * Update a matrix to values which are computed by:
  67725. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  67726. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  67727. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  67728. * @param startValue defines the first matrix
  67729. * @param endValue defines the second matrix
  67730. * @param gradient defines the gradient between the two matrices
  67731. * @param result defines the target matrix
  67732. */
  67733. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67734. /**
  67735. * 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"
  67736. * This function works in left handed mode
  67737. * @param eye defines the final position of the entity
  67738. * @param target defines where the entity should look at
  67739. * @param up defines the up vector for the entity
  67740. * @returns the new matrix
  67741. */
  67742. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  67743. /**
  67744. * 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".
  67745. * This function works in left handed mode
  67746. * @param eye defines the final position of the entity
  67747. * @param target defines where the entity should look at
  67748. * @param up defines the up vector for the entity
  67749. * @param result defines the target matrix
  67750. */
  67751. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67752. /**
  67753. * 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"
  67754. * This function works in right handed mode
  67755. * @param eye defines the final position of the entity
  67756. * @param target defines where the entity should look at
  67757. * @param up defines the up vector for the entity
  67758. * @returns the new matrix
  67759. */
  67760. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  67761. /**
  67762. * 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".
  67763. * This function works in right handed mode
  67764. * @param eye defines the final position of the entity
  67765. * @param target defines where the entity should look at
  67766. * @param up defines the up vector for the entity
  67767. * @param result defines the target matrix
  67768. */
  67769. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67770. /**
  67771. * Create a left-handed orthographic projection matrix
  67772. * @param width defines the viewport width
  67773. * @param height defines the viewport height
  67774. * @param znear defines the near clip plane
  67775. * @param zfar defines the far clip plane
  67776. * @returns a new matrix as a left-handed orthographic projection matrix
  67777. */
  67778. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67779. /**
  67780. * Store a left-handed orthographic projection to a given matrix
  67781. * @param width defines the viewport width
  67782. * @param height defines the viewport height
  67783. * @param znear defines the near clip plane
  67784. * @param zfar defines the far clip plane
  67785. * @param result defines the target matrix
  67786. */
  67787. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  67788. /**
  67789. * Create a left-handed orthographic projection matrix
  67790. * @param left defines the viewport left coordinate
  67791. * @param right defines the viewport right coordinate
  67792. * @param bottom defines the viewport bottom coordinate
  67793. * @param top defines the viewport top coordinate
  67794. * @param znear defines the near clip plane
  67795. * @param zfar defines the far clip plane
  67796. * @returns a new matrix as a left-handed orthographic projection matrix
  67797. */
  67798. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67799. /**
  67800. * Stores a left-handed orthographic projection into a given matrix
  67801. * @param left defines the viewport left coordinate
  67802. * @param right defines the viewport right coordinate
  67803. * @param bottom defines the viewport bottom coordinate
  67804. * @param top defines the viewport top coordinate
  67805. * @param znear defines the near clip plane
  67806. * @param zfar defines the far clip plane
  67807. * @param result defines the target matrix
  67808. */
  67809. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67810. /**
  67811. * Creates a right-handed orthographic projection matrix
  67812. * @param left defines the viewport left coordinate
  67813. * @param right defines the viewport right coordinate
  67814. * @param bottom defines the viewport bottom coordinate
  67815. * @param top defines the viewport top coordinate
  67816. * @param znear defines the near clip plane
  67817. * @param zfar defines the far clip plane
  67818. * @returns a new matrix as a right-handed orthographic projection matrix
  67819. */
  67820. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67821. /**
  67822. * Stores a right-handed orthographic projection into a given matrix
  67823. * @param left defines the viewport left coordinate
  67824. * @param right defines the viewport right coordinate
  67825. * @param bottom defines the viewport bottom coordinate
  67826. * @param top defines the viewport top coordinate
  67827. * @param znear defines the near clip plane
  67828. * @param zfar defines the far clip plane
  67829. * @param result defines the target matrix
  67830. */
  67831. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67832. /**
  67833. * Creates a left-handed perspective projection matrix
  67834. * @param width defines the viewport width
  67835. * @param height defines the viewport height
  67836. * @param znear defines the near clip plane
  67837. * @param zfar defines the far clip plane
  67838. * @returns a new matrix as a left-handed perspective projection matrix
  67839. */
  67840. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67841. /**
  67842. * Creates a left-handed perspective projection matrix
  67843. * @param fov defines the horizontal field of view
  67844. * @param aspect defines the aspect ratio
  67845. * @param znear defines the near clip plane
  67846. * @param zfar defines the far clip plane
  67847. * @returns a new matrix as a left-handed perspective projection matrix
  67848. */
  67849. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67850. /**
  67851. * Stores a left-handed perspective projection into a given matrix
  67852. * @param fov defines the horizontal field of view
  67853. * @param aspect defines the aspect ratio
  67854. * @param znear defines the near clip plane
  67855. * @param zfar defines the far clip plane
  67856. * @param result defines the target matrix
  67857. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67858. */
  67859. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67860. /**
  67861. * Creates a right-handed perspective projection matrix
  67862. * @param fov defines the horizontal field of view
  67863. * @param aspect defines the aspect ratio
  67864. * @param znear defines the near clip plane
  67865. * @param zfar defines the far clip plane
  67866. * @returns a new matrix as a right-handed perspective projection matrix
  67867. */
  67868. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67869. /**
  67870. * Stores a right-handed perspective projection into a given matrix
  67871. * @param fov defines the horizontal field of view
  67872. * @param aspect defines the aspect ratio
  67873. * @param znear defines the near clip plane
  67874. * @param zfar defines the far clip plane
  67875. * @param result defines the target matrix
  67876. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67877. */
  67878. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67879. /**
  67880. * Stores a perspective projection for WebVR info a given matrix
  67881. * @param fov defines the field of view
  67882. * @param znear defines the near clip plane
  67883. * @param zfar defines the far clip plane
  67884. * @param result defines the target matrix
  67885. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  67886. */
  67887. static PerspectiveFovWebVRToRef(fov: {
  67888. upDegrees: number;
  67889. downDegrees: number;
  67890. leftDegrees: number;
  67891. rightDegrees: number;
  67892. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  67893. /**
  67894. * Computes a complete transformation matrix
  67895. * @param viewport defines the viewport to use
  67896. * @param world defines the world matrix
  67897. * @param view defines the view matrix
  67898. * @param projection defines the projection matrix
  67899. * @param zmin defines the near clip plane
  67900. * @param zmax defines the far clip plane
  67901. * @returns the transformation matrix
  67902. */
  67903. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  67904. /**
  67905. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  67906. * @param matrix defines the matrix to use
  67907. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  67908. */
  67909. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  67910. /**
  67911. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  67912. * @param matrix defines the matrix to use
  67913. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  67914. */
  67915. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  67916. /**
  67917. * Compute the transpose of a given matrix
  67918. * @param matrix defines the matrix to transpose
  67919. * @returns the new matrix
  67920. */
  67921. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  67922. /**
  67923. * Compute the transpose of a matrix and store it in a target matrix
  67924. * @param matrix defines the matrix to transpose
  67925. * @param result defines the target matrix
  67926. */
  67927. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  67928. /**
  67929. * Computes a reflection matrix from a plane
  67930. * @param plane defines the reflection plane
  67931. * @returns a new matrix
  67932. */
  67933. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  67934. /**
  67935. * Computes a reflection matrix from a plane
  67936. * @param plane defines the reflection plane
  67937. * @param result defines the target matrix
  67938. */
  67939. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  67940. /**
  67941. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  67942. * @param xaxis defines the value of the 1st axis
  67943. * @param yaxis defines the value of the 2nd axis
  67944. * @param zaxis defines the value of the 3rd axis
  67945. * @param result defines the target matrix
  67946. */
  67947. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  67948. /**
  67949. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  67950. * @param quat defines the quaternion to use
  67951. * @param result defines the target matrix
  67952. */
  67953. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  67954. }
  67955. /**
  67956. * @hidden
  67957. */
  67958. export class TmpVectors {
  67959. static Vector2: Vector2[];
  67960. static Vector3: Vector3[];
  67961. static Vector4: Vector4[];
  67962. static Quaternion: Quaternion[];
  67963. static Matrix: Matrix[];
  67964. }
  67965. }
  67966. declare module BABYLON {
  67967. /** Defines the cross module used constants to avoid circular dependncies */
  67968. export class Constants {
  67969. /** Defines that alpha blending is disabled */
  67970. static readonly ALPHA_DISABLE: number;
  67971. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67972. static readonly ALPHA_ADD: number;
  67973. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67974. static readonly ALPHA_COMBINE: number;
  67975. /** Defines that alpha blending to DEST - SRC * DEST */
  67976. static readonly ALPHA_SUBTRACT: number;
  67977. /** Defines that alpha blending to SRC * DEST */
  67978. static readonly ALPHA_MULTIPLY: number;
  67979. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67980. static readonly ALPHA_MAXIMIZED: number;
  67981. /** Defines that alpha blending to SRC + DEST */
  67982. static readonly ALPHA_ONEONE: number;
  67983. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67984. static readonly ALPHA_PREMULTIPLIED: number;
  67985. /**
  67986. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67987. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67988. */
  67989. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67990. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67991. static readonly ALPHA_INTERPOLATE: number;
  67992. /**
  67993. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67994. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67995. */
  67996. static readonly ALPHA_SCREENMODE: number;
  67997. /** Defines that the ressource is not delayed*/
  67998. static readonly DELAYLOADSTATE_NONE: number;
  67999. /** Defines that the ressource was successfully delay loaded */
  68000. static readonly DELAYLOADSTATE_LOADED: number;
  68001. /** Defines that the ressource is currently delay loading */
  68002. static readonly DELAYLOADSTATE_LOADING: number;
  68003. /** Defines that the ressource is delayed and has not started loading */
  68004. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68005. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68006. static readonly NEVER: number;
  68007. /** 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 */
  68008. static readonly ALWAYS: number;
  68009. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68010. static readonly LESS: number;
  68011. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68012. static readonly EQUAL: number;
  68013. /** 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 */
  68014. static readonly LEQUAL: number;
  68015. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68016. static readonly GREATER: number;
  68017. /** 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 */
  68018. static readonly GEQUAL: number;
  68019. /** 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 */
  68020. static readonly NOTEQUAL: number;
  68021. /** Passed to stencilOperation to specify that stencil value must be kept */
  68022. static readonly KEEP: number;
  68023. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68024. static readonly REPLACE: number;
  68025. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68026. static readonly INCR: number;
  68027. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68028. static readonly DECR: number;
  68029. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68030. static readonly INVERT: number;
  68031. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68032. static readonly INCR_WRAP: number;
  68033. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68034. static readonly DECR_WRAP: number;
  68035. /** Texture is not repeating outside of 0..1 UVs */
  68036. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68037. /** Texture is repeating outside of 0..1 UVs */
  68038. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68039. /** Texture is repeating and mirrored */
  68040. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68041. /** ALPHA */
  68042. static readonly TEXTUREFORMAT_ALPHA: number;
  68043. /** LUMINANCE */
  68044. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68045. /** LUMINANCE_ALPHA */
  68046. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68047. /** RGB */
  68048. static readonly TEXTUREFORMAT_RGB: number;
  68049. /** RGBA */
  68050. static readonly TEXTUREFORMAT_RGBA: number;
  68051. /** RED */
  68052. static readonly TEXTUREFORMAT_RED: number;
  68053. /** RED (2nd reference) */
  68054. static readonly TEXTUREFORMAT_R: number;
  68055. /** RG */
  68056. static readonly TEXTUREFORMAT_RG: number;
  68057. /** RED_INTEGER */
  68058. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68059. /** RED_INTEGER (2nd reference) */
  68060. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68061. /** RG_INTEGER */
  68062. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68063. /** RGB_INTEGER */
  68064. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68065. /** RGBA_INTEGER */
  68066. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68067. /** UNSIGNED_BYTE */
  68068. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68069. /** UNSIGNED_BYTE (2nd reference) */
  68070. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68071. /** FLOAT */
  68072. static readonly TEXTURETYPE_FLOAT: number;
  68073. /** HALF_FLOAT */
  68074. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68075. /** BYTE */
  68076. static readonly TEXTURETYPE_BYTE: number;
  68077. /** SHORT */
  68078. static readonly TEXTURETYPE_SHORT: number;
  68079. /** UNSIGNED_SHORT */
  68080. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68081. /** INT */
  68082. static readonly TEXTURETYPE_INT: number;
  68083. /** UNSIGNED_INT */
  68084. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68085. /** UNSIGNED_SHORT_4_4_4_4 */
  68086. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68087. /** UNSIGNED_SHORT_5_5_5_1 */
  68088. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68089. /** UNSIGNED_SHORT_5_6_5 */
  68090. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68091. /** UNSIGNED_INT_2_10_10_10_REV */
  68092. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68093. /** UNSIGNED_INT_24_8 */
  68094. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68095. /** UNSIGNED_INT_10F_11F_11F_REV */
  68096. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68097. /** UNSIGNED_INT_5_9_9_9_REV */
  68098. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68099. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68100. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68101. /** nearest is mag = nearest and min = nearest and mip = linear */
  68102. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68103. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68104. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68105. /** Trilinear is mag = linear and min = linear and mip = linear */
  68106. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68107. /** nearest is mag = nearest and min = nearest and mip = linear */
  68108. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68109. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68110. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68111. /** Trilinear is mag = linear and min = linear and mip = linear */
  68112. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68113. /** mag = nearest and min = nearest and mip = nearest */
  68114. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68115. /** mag = nearest and min = linear and mip = nearest */
  68116. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68117. /** mag = nearest and min = linear and mip = linear */
  68118. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68119. /** mag = nearest and min = linear and mip = none */
  68120. static readonly TEXTURE_NEAREST_LINEAR: number;
  68121. /** mag = nearest and min = nearest and mip = none */
  68122. static readonly TEXTURE_NEAREST_NEAREST: number;
  68123. /** mag = linear and min = nearest and mip = nearest */
  68124. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68125. /** mag = linear and min = nearest and mip = linear */
  68126. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68127. /** mag = linear and min = linear and mip = none */
  68128. static readonly TEXTURE_LINEAR_LINEAR: number;
  68129. /** mag = linear and min = nearest and mip = none */
  68130. static readonly TEXTURE_LINEAR_NEAREST: number;
  68131. /** Explicit coordinates mode */
  68132. static readonly TEXTURE_EXPLICIT_MODE: number;
  68133. /** Spherical coordinates mode */
  68134. static readonly TEXTURE_SPHERICAL_MODE: number;
  68135. /** Planar coordinates mode */
  68136. static readonly TEXTURE_PLANAR_MODE: number;
  68137. /** Cubic coordinates mode */
  68138. static readonly TEXTURE_CUBIC_MODE: number;
  68139. /** Projection coordinates mode */
  68140. static readonly TEXTURE_PROJECTION_MODE: number;
  68141. /** Skybox coordinates mode */
  68142. static readonly TEXTURE_SKYBOX_MODE: number;
  68143. /** Inverse Cubic coordinates mode */
  68144. static readonly TEXTURE_INVCUBIC_MODE: number;
  68145. /** Equirectangular coordinates mode */
  68146. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68147. /** Equirectangular Fixed coordinates mode */
  68148. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68149. /** Equirectangular Fixed Mirrored coordinates mode */
  68150. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68151. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68152. static readonly SCALEMODE_FLOOR: number;
  68153. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68154. static readonly SCALEMODE_NEAREST: number;
  68155. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68156. static readonly SCALEMODE_CEILING: number;
  68157. /**
  68158. * The dirty texture flag value
  68159. */
  68160. static readonly MATERIAL_TextureDirtyFlag: number;
  68161. /**
  68162. * The dirty light flag value
  68163. */
  68164. static readonly MATERIAL_LightDirtyFlag: number;
  68165. /**
  68166. * The dirty fresnel flag value
  68167. */
  68168. static readonly MATERIAL_FresnelDirtyFlag: number;
  68169. /**
  68170. * The dirty attribute flag value
  68171. */
  68172. static readonly MATERIAL_AttributesDirtyFlag: number;
  68173. /**
  68174. * The dirty misc flag value
  68175. */
  68176. static readonly MATERIAL_MiscDirtyFlag: number;
  68177. /**
  68178. * The all dirty flag value
  68179. */
  68180. static readonly MATERIAL_AllDirtyFlag: number;
  68181. /**
  68182. * Returns the triangle fill mode
  68183. */
  68184. static readonly MATERIAL_TriangleFillMode: number;
  68185. /**
  68186. * Returns the wireframe mode
  68187. */
  68188. static readonly MATERIAL_WireFrameFillMode: number;
  68189. /**
  68190. * Returns the point fill mode
  68191. */
  68192. static readonly MATERIAL_PointFillMode: number;
  68193. /**
  68194. * Returns the point list draw mode
  68195. */
  68196. static readonly MATERIAL_PointListDrawMode: number;
  68197. /**
  68198. * Returns the line list draw mode
  68199. */
  68200. static readonly MATERIAL_LineListDrawMode: number;
  68201. /**
  68202. * Returns the line loop draw mode
  68203. */
  68204. static readonly MATERIAL_LineLoopDrawMode: number;
  68205. /**
  68206. * Returns the line strip draw mode
  68207. */
  68208. static readonly MATERIAL_LineStripDrawMode: number;
  68209. /**
  68210. * Returns the triangle strip draw mode
  68211. */
  68212. static readonly MATERIAL_TriangleStripDrawMode: number;
  68213. /**
  68214. * Returns the triangle fan draw mode
  68215. */
  68216. static readonly MATERIAL_TriangleFanDrawMode: number;
  68217. /**
  68218. * Stores the clock-wise side orientation
  68219. */
  68220. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68221. /**
  68222. * Stores the counter clock-wise side orientation
  68223. */
  68224. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68225. /**
  68226. * Nothing
  68227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68228. */
  68229. static readonly ACTION_NothingTrigger: number;
  68230. /**
  68231. * On pick
  68232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68233. */
  68234. static readonly ACTION_OnPickTrigger: number;
  68235. /**
  68236. * On left pick
  68237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68238. */
  68239. static readonly ACTION_OnLeftPickTrigger: number;
  68240. /**
  68241. * On right pick
  68242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68243. */
  68244. static readonly ACTION_OnRightPickTrigger: number;
  68245. /**
  68246. * On center pick
  68247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68248. */
  68249. static readonly ACTION_OnCenterPickTrigger: number;
  68250. /**
  68251. * On pick down
  68252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68253. */
  68254. static readonly ACTION_OnPickDownTrigger: number;
  68255. /**
  68256. * On double pick
  68257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68258. */
  68259. static readonly ACTION_OnDoublePickTrigger: number;
  68260. /**
  68261. * On pick up
  68262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68263. */
  68264. static readonly ACTION_OnPickUpTrigger: number;
  68265. /**
  68266. * On pick out.
  68267. * This trigger will only be raised if you also declared a OnPickDown
  68268. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68269. */
  68270. static readonly ACTION_OnPickOutTrigger: number;
  68271. /**
  68272. * On long press
  68273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68274. */
  68275. static readonly ACTION_OnLongPressTrigger: number;
  68276. /**
  68277. * On pointer over
  68278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68279. */
  68280. static readonly ACTION_OnPointerOverTrigger: number;
  68281. /**
  68282. * On pointer out
  68283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68284. */
  68285. static readonly ACTION_OnPointerOutTrigger: number;
  68286. /**
  68287. * On every frame
  68288. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68289. */
  68290. static readonly ACTION_OnEveryFrameTrigger: number;
  68291. /**
  68292. * On intersection enter
  68293. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68294. */
  68295. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68296. /**
  68297. * On intersection exit
  68298. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68299. */
  68300. static readonly ACTION_OnIntersectionExitTrigger: number;
  68301. /**
  68302. * On key down
  68303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68304. */
  68305. static readonly ACTION_OnKeyDownTrigger: number;
  68306. /**
  68307. * On key up
  68308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68309. */
  68310. static readonly ACTION_OnKeyUpTrigger: number;
  68311. /**
  68312. * Billboard mode will only apply to Y axis
  68313. */
  68314. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68315. /**
  68316. * Billboard mode will apply to all axes
  68317. */
  68318. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68319. /**
  68320. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68321. */
  68322. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68323. /**
  68324. * Gets or sets base Assets URL
  68325. */
  68326. static PARTICLES_BaseAssetsUrl: string;
  68327. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68328. * Test order :
  68329. * Is the bounding sphere outside the frustum ?
  68330. * If not, are the bounding box vertices outside the frustum ?
  68331. * It not, then the cullable object is in the frustum.
  68332. */
  68333. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68334. /** Culling strategy : Bounding Sphere Only.
  68335. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68336. * It's also less accurate than the standard because some not visible objects can still be selected.
  68337. * Test : is the bounding sphere outside the frustum ?
  68338. * If not, then the cullable object is in the frustum.
  68339. */
  68340. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68341. /** Culling strategy : Optimistic Inclusion.
  68342. * This in an inclusion test first, then the standard exclusion test.
  68343. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68344. * 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.
  68345. * Anyway, it's as accurate as the standard strategy.
  68346. * Test :
  68347. * Is the cullable object bounding sphere center in the frustum ?
  68348. * If not, apply the default culling strategy.
  68349. */
  68350. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68351. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68352. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68353. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68354. * 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.
  68355. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68356. * Test :
  68357. * Is the cullable object bounding sphere center in the frustum ?
  68358. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68359. */
  68360. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68361. /**
  68362. * No logging while loading
  68363. */
  68364. static readonly SCENELOADER_NO_LOGGING: number;
  68365. /**
  68366. * Minimal logging while loading
  68367. */
  68368. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68369. /**
  68370. * Summary logging while loading
  68371. */
  68372. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68373. /**
  68374. * Detailled logging while loading
  68375. */
  68376. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68377. }
  68378. }
  68379. declare module BABYLON {
  68380. /**
  68381. * Class used to store and describe the pipeline context associated with an effect
  68382. */
  68383. export interface IPipelineContext {
  68384. /**
  68385. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68386. */
  68387. isAsync: boolean;
  68388. /**
  68389. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68390. */
  68391. isReady: boolean;
  68392. /** @hidden */
  68393. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68394. }
  68395. }
  68396. declare module BABYLON {
  68397. /** @hidden */
  68398. export interface IShaderProcessor {
  68399. attributeProcessor?: (attribute: string) => string;
  68400. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68401. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68402. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68403. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68404. lineProcessor?: (line: string, isFragment: boolean) => string;
  68405. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68406. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68407. }
  68408. }
  68409. declare module BABYLON {
  68410. /** @hidden */
  68411. export interface ProcessingOptions {
  68412. defines: string[];
  68413. indexParameters: any;
  68414. isFragment: boolean;
  68415. shouldUseHighPrecisionShader: boolean;
  68416. supportsUniformBuffers: boolean;
  68417. shadersRepository: string;
  68418. includesShadersStore: {
  68419. [key: string]: string;
  68420. };
  68421. processor?: IShaderProcessor;
  68422. version: string;
  68423. platformName: string;
  68424. lookForClosingBracketForUniformBuffer?: boolean;
  68425. }
  68426. }
  68427. declare module BABYLON {
  68428. /**
  68429. * Helper to manipulate strings
  68430. */
  68431. export class StringTools {
  68432. /**
  68433. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68434. * @param str Source string
  68435. * @param suffix Suffix to search for in the source string
  68436. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68437. */
  68438. static EndsWith(str: string, suffix: string): boolean;
  68439. /**
  68440. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68441. * @param str Source string
  68442. * @param suffix Suffix to search for in the source string
  68443. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68444. */
  68445. static StartsWith(str: string, suffix: string): boolean;
  68446. }
  68447. }
  68448. declare module BABYLON {
  68449. /** @hidden */
  68450. export class ShaderCodeNode {
  68451. line: string;
  68452. children: ShaderCodeNode[];
  68453. additionalDefineKey?: string;
  68454. additionalDefineValue?: string;
  68455. isValid(preprocessors: {
  68456. [key: string]: string;
  68457. }): boolean;
  68458. process(preprocessors: {
  68459. [key: string]: string;
  68460. }, options: ProcessingOptions): string;
  68461. }
  68462. }
  68463. declare module BABYLON {
  68464. /** @hidden */
  68465. export class ShaderCodeCursor {
  68466. private _lines;
  68467. lineIndex: number;
  68468. readonly currentLine: string;
  68469. readonly canRead: boolean;
  68470. lines: string[];
  68471. }
  68472. }
  68473. declare module BABYLON {
  68474. /** @hidden */
  68475. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68476. process(preprocessors: {
  68477. [key: string]: string;
  68478. }, options: ProcessingOptions): string;
  68479. }
  68480. }
  68481. declare module BABYLON {
  68482. /** @hidden */
  68483. export class ShaderDefineExpression {
  68484. isTrue(preprocessors: {
  68485. [key: string]: string;
  68486. }): boolean;
  68487. }
  68488. }
  68489. declare module BABYLON {
  68490. /** @hidden */
  68491. export class ShaderCodeTestNode extends ShaderCodeNode {
  68492. testExpression: ShaderDefineExpression;
  68493. isValid(preprocessors: {
  68494. [key: string]: string;
  68495. }): boolean;
  68496. }
  68497. }
  68498. declare module BABYLON {
  68499. /** @hidden */
  68500. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68501. define: string;
  68502. not: boolean;
  68503. constructor(define: string, not?: boolean);
  68504. isTrue(preprocessors: {
  68505. [key: string]: string;
  68506. }): boolean;
  68507. }
  68508. }
  68509. declare module BABYLON {
  68510. /** @hidden */
  68511. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68512. leftOperand: ShaderDefineExpression;
  68513. rightOperand: ShaderDefineExpression;
  68514. isTrue(preprocessors: {
  68515. [key: string]: string;
  68516. }): boolean;
  68517. }
  68518. }
  68519. declare module BABYLON {
  68520. /** @hidden */
  68521. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68522. leftOperand: ShaderDefineExpression;
  68523. rightOperand: ShaderDefineExpression;
  68524. isTrue(preprocessors: {
  68525. [key: string]: string;
  68526. }): boolean;
  68527. }
  68528. }
  68529. declare module BABYLON {
  68530. /** @hidden */
  68531. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68532. define: string;
  68533. operand: string;
  68534. testValue: string;
  68535. constructor(define: string, operand: string, testValue: string);
  68536. isTrue(preprocessors: {
  68537. [key: string]: string;
  68538. }): boolean;
  68539. }
  68540. }
  68541. declare module BABYLON {
  68542. /**
  68543. * @ignore
  68544. * Application error to support additional information when loading a file
  68545. */
  68546. export class LoadFileError extends Error {
  68547. /** defines the optional web request */
  68548. request?: WebRequest | undefined;
  68549. private static _setPrototypeOf;
  68550. /**
  68551. * Creates a new LoadFileError
  68552. * @param message defines the message of the error
  68553. * @param request defines the optional web request
  68554. */
  68555. constructor(message: string,
  68556. /** defines the optional web request */
  68557. request?: WebRequest | undefined);
  68558. }
  68559. }
  68560. declare module BABYLON {
  68561. /**
  68562. * Class used to enable access to offline support
  68563. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68564. */
  68565. export interface IOfflineProvider {
  68566. /**
  68567. * Gets a boolean indicating if scene must be saved in the database
  68568. */
  68569. enableSceneOffline: boolean;
  68570. /**
  68571. * Gets a boolean indicating if textures must be saved in the database
  68572. */
  68573. enableTexturesOffline: boolean;
  68574. /**
  68575. * Open the offline support and make it available
  68576. * @param successCallback defines the callback to call on success
  68577. * @param errorCallback defines the callback to call on error
  68578. */
  68579. open(successCallback: () => void, errorCallback: () => void): void;
  68580. /**
  68581. * Loads an image from the offline support
  68582. * @param url defines the url to load from
  68583. * @param image defines the target DOM image
  68584. */
  68585. loadImage(url: string, image: HTMLImageElement): void;
  68586. /**
  68587. * Loads a file from offline support
  68588. * @param url defines the URL to load from
  68589. * @param sceneLoaded defines a callback to call on success
  68590. * @param progressCallBack defines a callback to call when progress changed
  68591. * @param errorCallback defines a callback to call on error
  68592. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68593. */
  68594. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68595. }
  68596. }
  68597. declare module BABYLON {
  68598. /**
  68599. * Class used to help managing file picking and drag'n'drop
  68600. * File Storage
  68601. */
  68602. export class FilesInputStore {
  68603. /**
  68604. * List of files ready to be loaded
  68605. */
  68606. static FilesToLoad: {
  68607. [key: string]: File;
  68608. };
  68609. }
  68610. }
  68611. declare module BABYLON {
  68612. /**
  68613. * Class used to define a retry strategy when error happens while loading assets
  68614. */
  68615. export class RetryStrategy {
  68616. /**
  68617. * Function used to defines an exponential back off strategy
  68618. * @param maxRetries defines the maximum number of retries (3 by default)
  68619. * @param baseInterval defines the interval between retries
  68620. * @returns the strategy function to use
  68621. */
  68622. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68623. }
  68624. }
  68625. declare module BABYLON {
  68626. /**
  68627. * @hidden
  68628. */
  68629. export class FileTools {
  68630. /**
  68631. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68632. */
  68633. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68634. /**
  68635. * Gets or sets the base URL to use to load assets
  68636. */
  68637. static BaseUrl: string;
  68638. /**
  68639. * Default behaviour for cors in the application.
  68640. * It can be a string if the expected behavior is identical in the entire app.
  68641. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68642. */
  68643. static CorsBehavior: string | ((url: string | string[]) => string);
  68644. /**
  68645. * Gets or sets a function used to pre-process url before using them to load assets
  68646. */
  68647. static PreprocessUrl: (url: string) => string;
  68648. /**
  68649. * Removes unwanted characters from an url
  68650. * @param url defines the url to clean
  68651. * @returns the cleaned url
  68652. */
  68653. private static _CleanUrl;
  68654. /**
  68655. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68656. * @param url define the url we are trying
  68657. * @param element define the dom element where to configure the cors policy
  68658. */
  68659. static SetCorsBehavior(url: string | string[], element: {
  68660. crossOrigin: string | null;
  68661. }): void;
  68662. /**
  68663. * Loads an image as an HTMLImageElement.
  68664. * @param input url string, ArrayBuffer, or Blob to load
  68665. * @param onLoad callback called when the image successfully loads
  68666. * @param onError callback called when the image fails to load
  68667. * @param offlineProvider offline provider for caching
  68668. * @returns the HTMLImageElement of the loaded image
  68669. */
  68670. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  68671. /**
  68672. * Loads a file
  68673. * @param fileToLoad defines the file to load
  68674. * @param callback defines the callback to call when data is loaded
  68675. * @param progressCallBack defines the callback to call during loading process
  68676. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68677. * @returns a file request object
  68678. */
  68679. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68680. /**
  68681. * Loads a file
  68682. * @param url url string, ArrayBuffer, or Blob to load
  68683. * @param onSuccess callback called when the file successfully loads
  68684. * @param onProgress callback called while file is loading (if the server supports this mode)
  68685. * @param offlineProvider defines the offline provider for caching
  68686. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68687. * @param onError callback called when the file fails to load
  68688. * @returns a file request object
  68689. */
  68690. 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;
  68691. /**
  68692. * Checks if the loaded document was accessed via `file:`-Protocol.
  68693. * @returns boolean
  68694. */
  68695. static IsFileURL(): boolean;
  68696. }
  68697. }
  68698. declare module BABYLON {
  68699. /** @hidden */
  68700. export class ShaderProcessor {
  68701. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68702. private static _ProcessPrecision;
  68703. private static _ExtractOperation;
  68704. private static _BuildSubExpression;
  68705. private static _BuildExpression;
  68706. private static _MoveCursorWithinIf;
  68707. private static _MoveCursor;
  68708. private static _EvaluatePreProcessors;
  68709. private static _PreparePreProcessors;
  68710. private static _ProcessShaderConversion;
  68711. private static _ProcessIncludes;
  68712. }
  68713. }
  68714. declare module BABYLON {
  68715. /**
  68716. * Class used to hold a RBG color
  68717. */
  68718. export class Color3 {
  68719. /**
  68720. * Defines the red component (between 0 and 1, default is 0)
  68721. */
  68722. r: number;
  68723. /**
  68724. * Defines the green component (between 0 and 1, default is 0)
  68725. */
  68726. g: number;
  68727. /**
  68728. * Defines the blue component (between 0 and 1, default is 0)
  68729. */
  68730. b: number;
  68731. /**
  68732. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  68733. * @param r defines the red component (between 0 and 1, default is 0)
  68734. * @param g defines the green component (between 0 and 1, default is 0)
  68735. * @param b defines the blue component (between 0 and 1, default is 0)
  68736. */
  68737. constructor(
  68738. /**
  68739. * Defines the red component (between 0 and 1, default is 0)
  68740. */
  68741. r?: number,
  68742. /**
  68743. * Defines the green component (between 0 and 1, default is 0)
  68744. */
  68745. g?: number,
  68746. /**
  68747. * Defines the blue component (between 0 and 1, default is 0)
  68748. */
  68749. b?: number);
  68750. /**
  68751. * Creates a string with the Color3 current values
  68752. * @returns the string representation of the Color3 object
  68753. */
  68754. toString(): string;
  68755. /**
  68756. * Returns the string "Color3"
  68757. * @returns "Color3"
  68758. */
  68759. getClassName(): string;
  68760. /**
  68761. * Compute the Color3 hash code
  68762. * @returns an unique number that can be used to hash Color3 objects
  68763. */
  68764. getHashCode(): number;
  68765. /**
  68766. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  68767. * @param array defines the array where to store the r,g,b components
  68768. * @param index defines an optional index in the target array to define where to start storing values
  68769. * @returns the current Color3 object
  68770. */
  68771. toArray(array: FloatArray, index?: number): Color3;
  68772. /**
  68773. * Returns a new Color4 object from the current Color3 and the given alpha
  68774. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  68775. * @returns a new Color4 object
  68776. */
  68777. toColor4(alpha?: number): Color4;
  68778. /**
  68779. * Returns a new array populated with 3 numeric elements : red, green and blue values
  68780. * @returns the new array
  68781. */
  68782. asArray(): number[];
  68783. /**
  68784. * Returns the luminance value
  68785. * @returns a float value
  68786. */
  68787. toLuminance(): number;
  68788. /**
  68789. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  68790. * @param otherColor defines the second operand
  68791. * @returns the new Color3 object
  68792. */
  68793. multiply(otherColor: DeepImmutable<Color3>): Color3;
  68794. /**
  68795. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  68796. * @param otherColor defines the second operand
  68797. * @param result defines the Color3 object where to store the result
  68798. * @returns the current Color3
  68799. */
  68800. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68801. /**
  68802. * Determines equality between Color3 objects
  68803. * @param otherColor defines the second operand
  68804. * @returns true if the rgb values are equal to the given ones
  68805. */
  68806. equals(otherColor: DeepImmutable<Color3>): boolean;
  68807. /**
  68808. * Determines equality between the current Color3 object and a set of r,b,g values
  68809. * @param r defines the red component to check
  68810. * @param g defines the green component to check
  68811. * @param b defines the blue component to check
  68812. * @returns true if the rgb values are equal to the given ones
  68813. */
  68814. equalsFloats(r: number, g: number, b: number): boolean;
  68815. /**
  68816. * Multiplies in place each rgb value by scale
  68817. * @param scale defines the scaling factor
  68818. * @returns the updated Color3
  68819. */
  68820. scale(scale: number): Color3;
  68821. /**
  68822. * Multiplies the rgb values by scale and stores the result into "result"
  68823. * @param scale defines the scaling factor
  68824. * @param result defines the Color3 object where to store the result
  68825. * @returns the unmodified current Color3
  68826. */
  68827. scaleToRef(scale: number, result: Color3): Color3;
  68828. /**
  68829. * Scale the current Color3 values by a factor and add the result to a given Color3
  68830. * @param scale defines the scale factor
  68831. * @param result defines color to store the result into
  68832. * @returns the unmodified current Color3
  68833. */
  68834. scaleAndAddToRef(scale: number, result: Color3): Color3;
  68835. /**
  68836. * Clamps the rgb values by the min and max values and stores the result into "result"
  68837. * @param min defines minimum clamping value (default is 0)
  68838. * @param max defines maximum clamping value (default is 1)
  68839. * @param result defines color to store the result into
  68840. * @returns the original Color3
  68841. */
  68842. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  68843. /**
  68844. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  68845. * @param otherColor defines the second operand
  68846. * @returns the new Color3
  68847. */
  68848. add(otherColor: DeepImmutable<Color3>): Color3;
  68849. /**
  68850. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  68851. * @param otherColor defines the second operand
  68852. * @param result defines Color3 object to store the result into
  68853. * @returns the unmodified current Color3
  68854. */
  68855. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68856. /**
  68857. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  68858. * @param otherColor defines the second operand
  68859. * @returns the new Color3
  68860. */
  68861. subtract(otherColor: DeepImmutable<Color3>): Color3;
  68862. /**
  68863. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  68864. * @param otherColor defines the second operand
  68865. * @param result defines Color3 object to store the result into
  68866. * @returns the unmodified current Color3
  68867. */
  68868. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68869. /**
  68870. * Copy the current object
  68871. * @returns a new Color3 copied the current one
  68872. */
  68873. clone(): Color3;
  68874. /**
  68875. * Copies the rgb values from the source in the current Color3
  68876. * @param source defines the source Color3 object
  68877. * @returns the updated Color3 object
  68878. */
  68879. copyFrom(source: DeepImmutable<Color3>): Color3;
  68880. /**
  68881. * Updates the Color3 rgb values from the given floats
  68882. * @param r defines the red component to read from
  68883. * @param g defines the green component to read from
  68884. * @param b defines the blue component to read from
  68885. * @returns the current Color3 object
  68886. */
  68887. copyFromFloats(r: number, g: number, b: number): Color3;
  68888. /**
  68889. * Updates the Color3 rgb values from the given floats
  68890. * @param r defines the red component to read from
  68891. * @param g defines the green component to read from
  68892. * @param b defines the blue component to read from
  68893. * @returns the current Color3 object
  68894. */
  68895. set(r: number, g: number, b: number): Color3;
  68896. /**
  68897. * Compute the Color3 hexadecimal code as a string
  68898. * @returns a string containing the hexadecimal representation of the Color3 object
  68899. */
  68900. toHexString(): string;
  68901. /**
  68902. * Computes a new Color3 converted from the current one to linear space
  68903. * @returns a new Color3 object
  68904. */
  68905. toLinearSpace(): Color3;
  68906. /**
  68907. * Converts current color in rgb space to HSV values
  68908. * @returns a new color3 representing the HSV values
  68909. */
  68910. toHSV(): Color3;
  68911. /**
  68912. * Converts current color in rgb space to HSV values
  68913. * @param result defines the Color3 where to store the HSV values
  68914. */
  68915. toHSVToRef(result: Color3): void;
  68916. /**
  68917. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  68918. * @param convertedColor defines the Color3 object where to store the linear space version
  68919. * @returns the unmodified Color3
  68920. */
  68921. toLinearSpaceToRef(convertedColor: Color3): Color3;
  68922. /**
  68923. * Computes a new Color3 converted from the current one to gamma space
  68924. * @returns a new Color3 object
  68925. */
  68926. toGammaSpace(): Color3;
  68927. /**
  68928. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  68929. * @param convertedColor defines the Color3 object where to store the gamma space version
  68930. * @returns the unmodified Color3
  68931. */
  68932. toGammaSpaceToRef(convertedColor: Color3): Color3;
  68933. private static _BlackReadOnly;
  68934. /**
  68935. * Convert Hue, saturation and value to a Color3 (RGB)
  68936. * @param hue defines the hue
  68937. * @param saturation defines the saturation
  68938. * @param value defines the value
  68939. * @param result defines the Color3 where to store the RGB values
  68940. */
  68941. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  68942. /**
  68943. * Creates a new Color3 from the string containing valid hexadecimal values
  68944. * @param hex defines a string containing valid hexadecimal values
  68945. * @returns a new Color3 object
  68946. */
  68947. static FromHexString(hex: string): Color3;
  68948. /**
  68949. * Creates a new Color3 from the starting index of the given array
  68950. * @param array defines the source array
  68951. * @param offset defines an offset in the source array
  68952. * @returns a new Color3 object
  68953. */
  68954. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  68955. /**
  68956. * Creates a new Color3 from integer values (< 256)
  68957. * @param r defines the red component to read from (value between 0 and 255)
  68958. * @param g defines the green component to read from (value between 0 and 255)
  68959. * @param b defines the blue component to read from (value between 0 and 255)
  68960. * @returns a new Color3 object
  68961. */
  68962. static FromInts(r: number, g: number, b: number): Color3;
  68963. /**
  68964. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68965. * @param start defines the start Color3 value
  68966. * @param end defines the end Color3 value
  68967. * @param amount defines the gradient value between start and end
  68968. * @returns a new Color3 object
  68969. */
  68970. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  68971. /**
  68972. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68973. * @param left defines the start value
  68974. * @param right defines the end value
  68975. * @param amount defines the gradient factor
  68976. * @param result defines the Color3 object where to store the result
  68977. */
  68978. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  68979. /**
  68980. * Returns a Color3 value containing a red color
  68981. * @returns a new Color3 object
  68982. */
  68983. static Red(): Color3;
  68984. /**
  68985. * Returns a Color3 value containing a green color
  68986. * @returns a new Color3 object
  68987. */
  68988. static Green(): Color3;
  68989. /**
  68990. * Returns a Color3 value containing a blue color
  68991. * @returns a new Color3 object
  68992. */
  68993. static Blue(): Color3;
  68994. /**
  68995. * Returns a Color3 value containing a black color
  68996. * @returns a new Color3 object
  68997. */
  68998. static Black(): Color3;
  68999. /**
  69000. * Gets a Color3 value containing a black color that must not be updated
  69001. */
  69002. static readonly BlackReadOnly: DeepImmutable<Color3>;
  69003. /**
  69004. * Returns a Color3 value containing a white color
  69005. * @returns a new Color3 object
  69006. */
  69007. static White(): Color3;
  69008. /**
  69009. * Returns a Color3 value containing a purple color
  69010. * @returns a new Color3 object
  69011. */
  69012. static Purple(): Color3;
  69013. /**
  69014. * Returns a Color3 value containing a magenta color
  69015. * @returns a new Color3 object
  69016. */
  69017. static Magenta(): Color3;
  69018. /**
  69019. * Returns a Color3 value containing a yellow color
  69020. * @returns a new Color3 object
  69021. */
  69022. static Yellow(): Color3;
  69023. /**
  69024. * Returns a Color3 value containing a gray color
  69025. * @returns a new Color3 object
  69026. */
  69027. static Gray(): Color3;
  69028. /**
  69029. * Returns a Color3 value containing a teal color
  69030. * @returns a new Color3 object
  69031. */
  69032. static Teal(): Color3;
  69033. /**
  69034. * Returns a Color3 value containing a random color
  69035. * @returns a new Color3 object
  69036. */
  69037. static Random(): Color3;
  69038. }
  69039. /**
  69040. * Class used to hold a RBGA color
  69041. */
  69042. export class Color4 {
  69043. /**
  69044. * Defines the red component (between 0 and 1, default is 0)
  69045. */
  69046. r: number;
  69047. /**
  69048. * Defines the green component (between 0 and 1, default is 0)
  69049. */
  69050. g: number;
  69051. /**
  69052. * Defines the blue component (between 0 and 1, default is 0)
  69053. */
  69054. b: number;
  69055. /**
  69056. * Defines the alpha component (between 0 and 1, default is 1)
  69057. */
  69058. a: number;
  69059. /**
  69060. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  69061. * @param r defines the red component (between 0 and 1, default is 0)
  69062. * @param g defines the green component (between 0 and 1, default is 0)
  69063. * @param b defines the blue component (between 0 and 1, default is 0)
  69064. * @param a defines the alpha component (between 0 and 1, default is 1)
  69065. */
  69066. constructor(
  69067. /**
  69068. * Defines the red component (between 0 and 1, default is 0)
  69069. */
  69070. r?: number,
  69071. /**
  69072. * Defines the green component (between 0 and 1, default is 0)
  69073. */
  69074. g?: number,
  69075. /**
  69076. * Defines the blue component (between 0 and 1, default is 0)
  69077. */
  69078. b?: number,
  69079. /**
  69080. * Defines the alpha component (between 0 and 1, default is 1)
  69081. */
  69082. a?: number);
  69083. /**
  69084. * Adds in place the given Color4 values to the current Color4 object
  69085. * @param right defines the second operand
  69086. * @returns the current updated Color4 object
  69087. */
  69088. addInPlace(right: DeepImmutable<Color4>): Color4;
  69089. /**
  69090. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  69091. * @returns the new array
  69092. */
  69093. asArray(): number[];
  69094. /**
  69095. * Stores from the starting index in the given array the Color4 successive values
  69096. * @param array defines the array where to store the r,g,b components
  69097. * @param index defines an optional index in the target array to define where to start storing values
  69098. * @returns the current Color4 object
  69099. */
  69100. toArray(array: number[], index?: number): Color4;
  69101. /**
  69102. * Determines equality between Color4 objects
  69103. * @param otherColor defines the second operand
  69104. * @returns true if the rgba values are equal to the given ones
  69105. */
  69106. equals(otherColor: DeepImmutable<Color4>): boolean;
  69107. /**
  69108. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  69109. * @param right defines the second operand
  69110. * @returns a new Color4 object
  69111. */
  69112. add(right: DeepImmutable<Color4>): Color4;
  69113. /**
  69114. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  69115. * @param right defines the second operand
  69116. * @returns a new Color4 object
  69117. */
  69118. subtract(right: DeepImmutable<Color4>): Color4;
  69119. /**
  69120. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  69121. * @param right defines the second operand
  69122. * @param result defines the Color4 object where to store the result
  69123. * @returns the current Color4 object
  69124. */
  69125. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  69126. /**
  69127. * Creates a new Color4 with the current Color4 values multiplied by scale
  69128. * @param scale defines the scaling factor to apply
  69129. * @returns a new Color4 object
  69130. */
  69131. scale(scale: number): Color4;
  69132. /**
  69133. * Multiplies the current Color4 values by scale and stores the result in "result"
  69134. * @param scale defines the scaling factor to apply
  69135. * @param result defines the Color4 object where to store the result
  69136. * @returns the current unmodified Color4
  69137. */
  69138. scaleToRef(scale: number, result: Color4): Color4;
  69139. /**
  69140. * Scale the current Color4 values by a factor and add the result to a given Color4
  69141. * @param scale defines the scale factor
  69142. * @param result defines the Color4 object where to store the result
  69143. * @returns the unmodified current Color4
  69144. */
  69145. scaleAndAddToRef(scale: number, result: Color4): Color4;
  69146. /**
  69147. * Clamps the rgb values by the min and max values and stores the result into "result"
  69148. * @param min defines minimum clamping value (default is 0)
  69149. * @param max defines maximum clamping value (default is 1)
  69150. * @param result defines color to store the result into.
  69151. * @returns the cuurent Color4
  69152. */
  69153. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  69154. /**
  69155. * Multipy an Color4 value by another and return a new Color4 object
  69156. * @param color defines the Color4 value to multiply by
  69157. * @returns a new Color4 object
  69158. */
  69159. multiply(color: Color4): Color4;
  69160. /**
  69161. * Multipy a Color4 value by another and push the result in a reference value
  69162. * @param color defines the Color4 value to multiply by
  69163. * @param result defines the Color4 to fill the result in
  69164. * @returns the result Color4
  69165. */
  69166. multiplyToRef(color: Color4, result: Color4): Color4;
  69167. /**
  69168. * Creates a string with the Color4 current values
  69169. * @returns the string representation of the Color4 object
  69170. */
  69171. toString(): string;
  69172. /**
  69173. * Returns the string "Color4"
  69174. * @returns "Color4"
  69175. */
  69176. getClassName(): string;
  69177. /**
  69178. * Compute the Color4 hash code
  69179. * @returns an unique number that can be used to hash Color4 objects
  69180. */
  69181. getHashCode(): number;
  69182. /**
  69183. * Creates a new Color4 copied from the current one
  69184. * @returns a new Color4 object
  69185. */
  69186. clone(): Color4;
  69187. /**
  69188. * Copies the given Color4 values into the current one
  69189. * @param source defines the source Color4 object
  69190. * @returns the current updated Color4 object
  69191. */
  69192. copyFrom(source: Color4): Color4;
  69193. /**
  69194. * Copies the given float values into the current one
  69195. * @param r defines the red component to read from
  69196. * @param g defines the green component to read from
  69197. * @param b defines the blue component to read from
  69198. * @param a defines the alpha component to read from
  69199. * @returns the current updated Color4 object
  69200. */
  69201. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  69202. /**
  69203. * Copies the given float values into the current one
  69204. * @param r defines the red component to read from
  69205. * @param g defines the green component to read from
  69206. * @param b defines the blue component to read from
  69207. * @param a defines the alpha component to read from
  69208. * @returns the current updated Color4 object
  69209. */
  69210. set(r: number, g: number, b: number, a: number): Color4;
  69211. /**
  69212. * Compute the Color4 hexadecimal code as a string
  69213. * @returns a string containing the hexadecimal representation of the Color4 object
  69214. */
  69215. toHexString(): string;
  69216. /**
  69217. * Computes a new Color4 converted from the current one to linear space
  69218. * @returns a new Color4 object
  69219. */
  69220. toLinearSpace(): Color4;
  69221. /**
  69222. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  69223. * @param convertedColor defines the Color4 object where to store the linear space version
  69224. * @returns the unmodified Color4
  69225. */
  69226. toLinearSpaceToRef(convertedColor: Color4): Color4;
  69227. /**
  69228. * Computes a new Color4 converted from the current one to gamma space
  69229. * @returns a new Color4 object
  69230. */
  69231. toGammaSpace(): Color4;
  69232. /**
  69233. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  69234. * @param convertedColor defines the Color4 object where to store the gamma space version
  69235. * @returns the unmodified Color4
  69236. */
  69237. toGammaSpaceToRef(convertedColor: Color4): Color4;
  69238. /**
  69239. * Creates a new Color4 from the string containing valid hexadecimal values
  69240. * @param hex defines a string containing valid hexadecimal values
  69241. * @returns a new Color4 object
  69242. */
  69243. static FromHexString(hex: string): Color4;
  69244. /**
  69245. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69246. * @param left defines the start value
  69247. * @param right defines the end value
  69248. * @param amount defines the gradient factor
  69249. * @returns a new Color4 object
  69250. */
  69251. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  69252. /**
  69253. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69254. * @param left defines the start value
  69255. * @param right defines the end value
  69256. * @param amount defines the gradient factor
  69257. * @param result defines the Color4 object where to store data
  69258. */
  69259. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  69260. /**
  69261. * Creates a new Color4 from a Color3 and an alpha value
  69262. * @param color3 defines the source Color3 to read from
  69263. * @param alpha defines the alpha component (1.0 by default)
  69264. * @returns a new Color4 object
  69265. */
  69266. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  69267. /**
  69268. * Creates a new Color4 from the starting index element of the given array
  69269. * @param array defines the source array to read from
  69270. * @param offset defines the offset in the source array
  69271. * @returns a new Color4 object
  69272. */
  69273. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  69274. /**
  69275. * Creates a new Color3 from integer values (< 256)
  69276. * @param r defines the red component to read from (value between 0 and 255)
  69277. * @param g defines the green component to read from (value between 0 and 255)
  69278. * @param b defines the blue component to read from (value between 0 and 255)
  69279. * @param a defines the alpha component to read from (value between 0 and 255)
  69280. * @returns a new Color3 object
  69281. */
  69282. static FromInts(r: number, g: number, b: number, a: number): Color4;
  69283. /**
  69284. * Check the content of a given array and convert it to an array containing RGBA data
  69285. * If the original array was already containing count * 4 values then it is returned directly
  69286. * @param colors defines the array to check
  69287. * @param count defines the number of RGBA data to expect
  69288. * @returns an array containing count * 4 values (RGBA)
  69289. */
  69290. static CheckColors4(colors: number[], count: number): number[];
  69291. }
  69292. /**
  69293. * @hidden
  69294. */
  69295. export class TmpColors {
  69296. static Color3: Color3[];
  69297. static Color4: Color4[];
  69298. }
  69299. }
  69300. declare module BABYLON {
  69301. /**
  69302. * Class representing spherical harmonics coefficients to the 3rd degree
  69303. */
  69304. export class SphericalHarmonics {
  69305. /**
  69306. * Defines whether or not the harmonics have been prescaled for rendering.
  69307. */
  69308. preScaled: boolean;
  69309. /**
  69310. * The l0,0 coefficients of the spherical harmonics
  69311. */
  69312. l00: Vector3;
  69313. /**
  69314. * The l1,-1 coefficients of the spherical harmonics
  69315. */
  69316. l1_1: Vector3;
  69317. /**
  69318. * The l1,0 coefficients of the spherical harmonics
  69319. */
  69320. l10: Vector3;
  69321. /**
  69322. * The l1,1 coefficients of the spherical harmonics
  69323. */
  69324. l11: Vector3;
  69325. /**
  69326. * The l2,-2 coefficients of the spherical harmonics
  69327. */
  69328. l2_2: Vector3;
  69329. /**
  69330. * The l2,-1 coefficients of the spherical harmonics
  69331. */
  69332. l2_1: Vector3;
  69333. /**
  69334. * The l2,0 coefficients of the spherical harmonics
  69335. */
  69336. l20: Vector3;
  69337. /**
  69338. * The l2,1 coefficients of the spherical harmonics
  69339. */
  69340. l21: Vector3;
  69341. /**
  69342. * The l2,2 coefficients of the spherical harmonics
  69343. */
  69344. l22: Vector3;
  69345. /**
  69346. * Adds a light to the spherical harmonics
  69347. * @param direction the direction of the light
  69348. * @param color the color of the light
  69349. * @param deltaSolidAngle the delta solid angle of the light
  69350. */
  69351. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  69352. /**
  69353. * Scales the spherical harmonics by the given amount
  69354. * @param scale the amount to scale
  69355. */
  69356. scaleInPlace(scale: number): void;
  69357. /**
  69358. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  69359. *
  69360. * ```
  69361. * E_lm = A_l * L_lm
  69362. * ```
  69363. *
  69364. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  69365. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  69366. * the scaling factors are given in equation 9.
  69367. */
  69368. convertIncidentRadianceToIrradiance(): void;
  69369. /**
  69370. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  69371. *
  69372. * ```
  69373. * L = (1/pi) * E * rho
  69374. * ```
  69375. *
  69376. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  69377. */
  69378. convertIrradianceToLambertianRadiance(): void;
  69379. /**
  69380. * Integrates the reconstruction coefficients directly in to the SH preventing further
  69381. * required operations at run time.
  69382. *
  69383. * This is simply done by scaling back the SH with Ylm constants parameter.
  69384. * The trigonometric part being applied by the shader at run time.
  69385. */
  69386. preScaleForRendering(): void;
  69387. /**
  69388. * Constructs a spherical harmonics from an array.
  69389. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  69390. * @returns the spherical harmonics
  69391. */
  69392. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  69393. /**
  69394. * Gets the spherical harmonics from polynomial
  69395. * @param polynomial the spherical polynomial
  69396. * @returns the spherical harmonics
  69397. */
  69398. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  69399. }
  69400. /**
  69401. * Class representing spherical polynomial coefficients to the 3rd degree
  69402. */
  69403. export class SphericalPolynomial {
  69404. private _harmonics;
  69405. /**
  69406. * The spherical harmonics used to create the polynomials.
  69407. */
  69408. readonly preScaledHarmonics: SphericalHarmonics;
  69409. /**
  69410. * The x coefficients of the spherical polynomial
  69411. */
  69412. x: Vector3;
  69413. /**
  69414. * The y coefficients of the spherical polynomial
  69415. */
  69416. y: Vector3;
  69417. /**
  69418. * The z coefficients of the spherical polynomial
  69419. */
  69420. z: Vector3;
  69421. /**
  69422. * The xx coefficients of the spherical polynomial
  69423. */
  69424. xx: Vector3;
  69425. /**
  69426. * The yy coefficients of the spherical polynomial
  69427. */
  69428. yy: Vector3;
  69429. /**
  69430. * The zz coefficients of the spherical polynomial
  69431. */
  69432. zz: Vector3;
  69433. /**
  69434. * The xy coefficients of the spherical polynomial
  69435. */
  69436. xy: Vector3;
  69437. /**
  69438. * The yz coefficients of the spherical polynomial
  69439. */
  69440. yz: Vector3;
  69441. /**
  69442. * The zx coefficients of the spherical polynomial
  69443. */
  69444. zx: Vector3;
  69445. /**
  69446. * Adds an ambient color to the spherical polynomial
  69447. * @param color the color to add
  69448. */
  69449. addAmbient(color: Color3): void;
  69450. /**
  69451. * Scales the spherical polynomial by the given amount
  69452. * @param scale the amount to scale
  69453. */
  69454. scaleInPlace(scale: number): void;
  69455. /**
  69456. * Gets the spherical polynomial from harmonics
  69457. * @param harmonics the spherical harmonics
  69458. * @returns the spherical polynomial
  69459. */
  69460. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69461. /**
  69462. * Constructs a spherical polynomial from an array.
  69463. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69464. * @returns the spherical polynomial
  69465. */
  69466. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69467. }
  69468. }
  69469. declare module BABYLON {
  69470. /**
  69471. * Define options used to create a render target texture
  69472. */
  69473. export class RenderTargetCreationOptions {
  69474. /**
  69475. * Specifies is mipmaps must be generated
  69476. */
  69477. generateMipMaps?: boolean;
  69478. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69479. generateDepthBuffer?: boolean;
  69480. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69481. generateStencilBuffer?: boolean;
  69482. /** Defines texture type (int by default) */
  69483. type?: number;
  69484. /** Defines sampling mode (trilinear by default) */
  69485. samplingMode?: number;
  69486. /** Defines format (RGBA by default) */
  69487. format?: number;
  69488. }
  69489. }
  69490. declare module BABYLON {
  69491. /**
  69492. * @hidden
  69493. **/
  69494. export class _AlphaState {
  69495. private _isAlphaBlendDirty;
  69496. private _isBlendFunctionParametersDirty;
  69497. private _isBlendEquationParametersDirty;
  69498. private _isBlendConstantsDirty;
  69499. private _alphaBlend;
  69500. private _blendFunctionParameters;
  69501. private _blendEquationParameters;
  69502. private _blendConstants;
  69503. /**
  69504. * Initializes the state.
  69505. */
  69506. constructor();
  69507. readonly isDirty: boolean;
  69508. alphaBlend: boolean;
  69509. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69510. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69511. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69512. reset(): void;
  69513. apply(gl: WebGLRenderingContext): void;
  69514. }
  69515. }
  69516. declare module BABYLON {
  69517. /**
  69518. * @hidden
  69519. **/
  69520. export class _DepthCullingState {
  69521. private _isDepthTestDirty;
  69522. private _isDepthMaskDirty;
  69523. private _isDepthFuncDirty;
  69524. private _isCullFaceDirty;
  69525. private _isCullDirty;
  69526. private _isZOffsetDirty;
  69527. private _isFrontFaceDirty;
  69528. private _depthTest;
  69529. private _depthMask;
  69530. private _depthFunc;
  69531. private _cull;
  69532. private _cullFace;
  69533. private _zOffset;
  69534. private _frontFace;
  69535. /**
  69536. * Initializes the state.
  69537. */
  69538. constructor();
  69539. readonly isDirty: boolean;
  69540. zOffset: number;
  69541. cullFace: Nullable<number>;
  69542. cull: Nullable<boolean>;
  69543. depthFunc: Nullable<number>;
  69544. depthMask: boolean;
  69545. depthTest: boolean;
  69546. frontFace: Nullable<number>;
  69547. reset(): void;
  69548. apply(gl: WebGLRenderingContext): void;
  69549. }
  69550. }
  69551. declare module BABYLON {
  69552. /**
  69553. * @hidden
  69554. **/
  69555. export class _StencilState {
  69556. /** 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 */
  69557. static readonly ALWAYS: number;
  69558. /** Passed to stencilOperation to specify that stencil value must be kept */
  69559. static readonly KEEP: number;
  69560. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69561. static readonly REPLACE: number;
  69562. private _isStencilTestDirty;
  69563. private _isStencilMaskDirty;
  69564. private _isStencilFuncDirty;
  69565. private _isStencilOpDirty;
  69566. private _stencilTest;
  69567. private _stencilMask;
  69568. private _stencilFunc;
  69569. private _stencilFuncRef;
  69570. private _stencilFuncMask;
  69571. private _stencilOpStencilFail;
  69572. private _stencilOpDepthFail;
  69573. private _stencilOpStencilDepthPass;
  69574. readonly isDirty: boolean;
  69575. stencilFunc: number;
  69576. stencilFuncRef: number;
  69577. stencilFuncMask: number;
  69578. stencilOpStencilFail: number;
  69579. stencilOpDepthFail: number;
  69580. stencilOpStencilDepthPass: number;
  69581. stencilMask: number;
  69582. stencilTest: boolean;
  69583. constructor();
  69584. reset(): void;
  69585. apply(gl: WebGLRenderingContext): void;
  69586. }
  69587. }
  69588. declare module BABYLON {
  69589. /**
  69590. * @hidden
  69591. **/
  69592. export class _TimeToken {
  69593. _startTimeQuery: Nullable<WebGLQuery>;
  69594. _endTimeQuery: Nullable<WebGLQuery>;
  69595. _timeElapsedQuery: Nullable<WebGLQuery>;
  69596. _timeElapsedQueryEnded: boolean;
  69597. }
  69598. }
  69599. declare module BABYLON {
  69600. /**
  69601. * Class used to evalaute queries containing `and` and `or` operators
  69602. */
  69603. export class AndOrNotEvaluator {
  69604. /**
  69605. * Evaluate a query
  69606. * @param query defines the query to evaluate
  69607. * @param evaluateCallback defines the callback used to filter result
  69608. * @returns true if the query matches
  69609. */
  69610. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69611. private static _HandleParenthesisContent;
  69612. private static _SimplifyNegation;
  69613. }
  69614. }
  69615. declare module BABYLON {
  69616. /**
  69617. * Class used to store custom tags
  69618. */
  69619. export class Tags {
  69620. /**
  69621. * Adds support for tags on the given object
  69622. * @param obj defines the object to use
  69623. */
  69624. static EnableFor(obj: any): void;
  69625. /**
  69626. * Removes tags support
  69627. * @param obj defines the object to use
  69628. */
  69629. static DisableFor(obj: any): void;
  69630. /**
  69631. * Gets a boolean indicating if the given object has tags
  69632. * @param obj defines the object to use
  69633. * @returns a boolean
  69634. */
  69635. static HasTags(obj: any): boolean;
  69636. /**
  69637. * Gets the tags available on a given object
  69638. * @param obj defines the object to use
  69639. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69640. * @returns the tags
  69641. */
  69642. static GetTags(obj: any, asString?: boolean): any;
  69643. /**
  69644. * Adds tags to an object
  69645. * @param obj defines the object to use
  69646. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69647. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69648. */
  69649. static AddTagsTo(obj: any, tagsString: string): void;
  69650. /**
  69651. * @hidden
  69652. */
  69653. static _AddTagTo(obj: any, tag: string): void;
  69654. /**
  69655. * Removes specific tags from a specific object
  69656. * @param obj defines the object to use
  69657. * @param tagsString defines the tags to remove
  69658. */
  69659. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69660. /**
  69661. * @hidden
  69662. */
  69663. static _RemoveTagFrom(obj: any, tag: string): void;
  69664. /**
  69665. * Defines if tags hosted on an object match a given query
  69666. * @param obj defines the object to use
  69667. * @param tagsQuery defines the tag query
  69668. * @returns a boolean
  69669. */
  69670. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69671. }
  69672. }
  69673. declare module BABYLON {
  69674. /**
  69675. * Defines potential orientation for back face culling
  69676. */
  69677. export enum Orientation {
  69678. /**
  69679. * Clockwise
  69680. */
  69681. CW = 0,
  69682. /** Counter clockwise */
  69683. CCW = 1
  69684. }
  69685. /** Class used to represent a Bezier curve */
  69686. export class BezierCurve {
  69687. /**
  69688. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  69689. * @param t defines the time
  69690. * @param x1 defines the left coordinate on X axis
  69691. * @param y1 defines the left coordinate on Y axis
  69692. * @param x2 defines the right coordinate on X axis
  69693. * @param y2 defines the right coordinate on Y axis
  69694. * @returns the interpolated value
  69695. */
  69696. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  69697. }
  69698. /**
  69699. * Defines angle representation
  69700. */
  69701. export class Angle {
  69702. private _radians;
  69703. /**
  69704. * Creates an Angle object of "radians" radians (float).
  69705. * @param radians the angle in radians
  69706. */
  69707. constructor(radians: number);
  69708. /**
  69709. * Get value in degrees
  69710. * @returns the Angle value in degrees (float)
  69711. */
  69712. degrees(): number;
  69713. /**
  69714. * Get value in radians
  69715. * @returns the Angle value in radians (float)
  69716. */
  69717. radians(): number;
  69718. /**
  69719. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  69720. * @param a defines first vector
  69721. * @param b defines second vector
  69722. * @returns a new Angle
  69723. */
  69724. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  69725. /**
  69726. * Gets a new Angle object from the given float in radians
  69727. * @param radians defines the angle value in radians
  69728. * @returns a new Angle
  69729. */
  69730. static FromRadians(radians: number): Angle;
  69731. /**
  69732. * Gets a new Angle object from the given float in degrees
  69733. * @param degrees defines the angle value in degrees
  69734. * @returns a new Angle
  69735. */
  69736. static FromDegrees(degrees: number): Angle;
  69737. }
  69738. /**
  69739. * This represents an arc in a 2d space.
  69740. */
  69741. export class Arc2 {
  69742. /** Defines the start point of the arc */
  69743. startPoint: Vector2;
  69744. /** Defines the mid point of the arc */
  69745. midPoint: Vector2;
  69746. /** Defines the end point of the arc */
  69747. endPoint: Vector2;
  69748. /**
  69749. * Defines the center point of the arc.
  69750. */
  69751. centerPoint: Vector2;
  69752. /**
  69753. * Defines the radius of the arc.
  69754. */
  69755. radius: number;
  69756. /**
  69757. * Defines the angle of the arc (from mid point to end point).
  69758. */
  69759. angle: Angle;
  69760. /**
  69761. * Defines the start angle of the arc (from start point to middle point).
  69762. */
  69763. startAngle: Angle;
  69764. /**
  69765. * Defines the orientation of the arc (clock wise/counter clock wise).
  69766. */
  69767. orientation: Orientation;
  69768. /**
  69769. * Creates an Arc object from the three given points : start, middle and end.
  69770. * @param startPoint Defines the start point of the arc
  69771. * @param midPoint Defines the midlle point of the arc
  69772. * @param endPoint Defines the end point of the arc
  69773. */
  69774. constructor(
  69775. /** Defines the start point of the arc */
  69776. startPoint: Vector2,
  69777. /** Defines the mid point of the arc */
  69778. midPoint: Vector2,
  69779. /** Defines the end point of the arc */
  69780. endPoint: Vector2);
  69781. }
  69782. /**
  69783. * Represents a 2D path made up of multiple 2D points
  69784. */
  69785. export class Path2 {
  69786. private _points;
  69787. private _length;
  69788. /**
  69789. * If the path start and end point are the same
  69790. */
  69791. closed: boolean;
  69792. /**
  69793. * Creates a Path2 object from the starting 2D coordinates x and y.
  69794. * @param x the starting points x value
  69795. * @param y the starting points y value
  69796. */
  69797. constructor(x: number, y: number);
  69798. /**
  69799. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  69800. * @param x the added points x value
  69801. * @param y the added points y value
  69802. * @returns the updated Path2.
  69803. */
  69804. addLineTo(x: number, y: number): Path2;
  69805. /**
  69806. * 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.
  69807. * @param midX middle point x value
  69808. * @param midY middle point y value
  69809. * @param endX end point x value
  69810. * @param endY end point y value
  69811. * @param numberOfSegments (default: 36)
  69812. * @returns the updated Path2.
  69813. */
  69814. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  69815. /**
  69816. * Closes the Path2.
  69817. * @returns the Path2.
  69818. */
  69819. close(): Path2;
  69820. /**
  69821. * Gets the sum of the distance between each sequential point in the path
  69822. * @returns the Path2 total length (float).
  69823. */
  69824. length(): number;
  69825. /**
  69826. * Gets the points which construct the path
  69827. * @returns the Path2 internal array of points.
  69828. */
  69829. getPoints(): Vector2[];
  69830. /**
  69831. * Retreives the point at the distance aways from the starting point
  69832. * @param normalizedLengthPosition the length along the path to retreive the point from
  69833. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  69834. */
  69835. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  69836. /**
  69837. * Creates a new path starting from an x and y position
  69838. * @param x starting x value
  69839. * @param y starting y value
  69840. * @returns a new Path2 starting at the coordinates (x, y).
  69841. */
  69842. static StartingAt(x: number, y: number): Path2;
  69843. }
  69844. /**
  69845. * Represents a 3D path made up of multiple 3D points
  69846. */
  69847. export class Path3D {
  69848. /**
  69849. * an array of Vector3, the curve axis of the Path3D
  69850. */
  69851. path: Vector3[];
  69852. private _curve;
  69853. private _distances;
  69854. private _tangents;
  69855. private _normals;
  69856. private _binormals;
  69857. private _raw;
  69858. /**
  69859. * new Path3D(path, normal, raw)
  69860. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  69861. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  69862. * @param path an array of Vector3, the curve axis of the Path3D
  69863. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  69864. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  69865. */
  69866. constructor(
  69867. /**
  69868. * an array of Vector3, the curve axis of the Path3D
  69869. */
  69870. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  69871. /**
  69872. * Returns the Path3D array of successive Vector3 designing its curve.
  69873. * @returns the Path3D array of successive Vector3 designing its curve.
  69874. */
  69875. getCurve(): Vector3[];
  69876. /**
  69877. * Returns an array populated with tangent vectors on each Path3D curve point.
  69878. * @returns an array populated with tangent vectors on each Path3D curve point.
  69879. */
  69880. getTangents(): Vector3[];
  69881. /**
  69882. * Returns an array populated with normal vectors on each Path3D curve point.
  69883. * @returns an array populated with normal vectors on each Path3D curve point.
  69884. */
  69885. getNormals(): Vector3[];
  69886. /**
  69887. * Returns an array populated with binormal vectors on each Path3D curve point.
  69888. * @returns an array populated with binormal vectors on each Path3D curve point.
  69889. */
  69890. getBinormals(): Vector3[];
  69891. /**
  69892. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  69893. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  69894. */
  69895. getDistances(): number[];
  69896. /**
  69897. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  69898. * @param path path which all values are copied into the curves points
  69899. * @param firstNormal which should be projected onto the curve
  69900. * @returns the same object updated.
  69901. */
  69902. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  69903. private _compute;
  69904. private _getFirstNonNullVector;
  69905. private _getLastNonNullVector;
  69906. private _normalVector;
  69907. }
  69908. /**
  69909. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69910. * A Curve3 is designed from a series of successive Vector3.
  69911. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  69912. */
  69913. export class Curve3 {
  69914. private _points;
  69915. private _length;
  69916. /**
  69917. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  69918. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  69919. * @param v1 (Vector3) the control point
  69920. * @param v2 (Vector3) the end point of the Quadratic Bezier
  69921. * @param nbPoints (integer) the wanted number of points in the curve
  69922. * @returns the created Curve3
  69923. */
  69924. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69925. /**
  69926. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  69927. * @param v0 (Vector3) the origin point of the Cubic Bezier
  69928. * @param v1 (Vector3) the first control point
  69929. * @param v2 (Vector3) the second control point
  69930. * @param v3 (Vector3) the end point of the Cubic Bezier
  69931. * @param nbPoints (integer) the wanted number of points in the curve
  69932. * @returns the created Curve3
  69933. */
  69934. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69935. /**
  69936. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  69937. * @param p1 (Vector3) the origin point of the Hermite Spline
  69938. * @param t1 (Vector3) the tangent vector at the origin point
  69939. * @param p2 (Vector3) the end point of the Hermite Spline
  69940. * @param t2 (Vector3) the tangent vector at the end point
  69941. * @param nbPoints (integer) the wanted number of points in the curve
  69942. * @returns the created Curve3
  69943. */
  69944. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69945. /**
  69946. * Returns a Curve3 object along a CatmullRom Spline curve :
  69947. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  69948. * @param nbPoints (integer) the wanted number of points between each curve control points
  69949. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  69950. * @returns the created Curve3
  69951. */
  69952. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  69953. /**
  69954. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69955. * A Curve3 is designed from a series of successive Vector3.
  69956. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  69957. * @param points points which make up the curve
  69958. */
  69959. constructor(points: Vector3[]);
  69960. /**
  69961. * @returns the Curve3 stored array of successive Vector3
  69962. */
  69963. getPoints(): Vector3[];
  69964. /**
  69965. * @returns the computed length (float) of the curve.
  69966. */
  69967. length(): number;
  69968. /**
  69969. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  69970. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  69971. * curveA and curveB keep unchanged.
  69972. * @param curve the curve to continue from this curve
  69973. * @returns the newly constructed curve
  69974. */
  69975. continue(curve: DeepImmutable<Curve3>): Curve3;
  69976. private _computeLength;
  69977. }
  69978. }
  69979. declare module BABYLON {
  69980. /**
  69981. * This represents the main contract an easing function should follow.
  69982. * Easing functions are used throughout the animation system.
  69983. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69984. */
  69985. export interface IEasingFunction {
  69986. /**
  69987. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69988. * of the easing function.
  69989. * The link below provides some of the most common examples of easing functions.
  69990. * @see https://easings.net/
  69991. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69992. * @returns the corresponding value on the curve defined by the easing function
  69993. */
  69994. ease(gradient: number): number;
  69995. }
  69996. /**
  69997. * Base class used for every default easing function.
  69998. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69999. */
  70000. export class EasingFunction implements IEasingFunction {
  70001. /**
  70002. * Interpolation follows the mathematical formula associated with the easing function.
  70003. */
  70004. static readonly EASINGMODE_EASEIN: number;
  70005. /**
  70006. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  70007. */
  70008. static readonly EASINGMODE_EASEOUT: number;
  70009. /**
  70010. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  70011. */
  70012. static readonly EASINGMODE_EASEINOUT: number;
  70013. private _easingMode;
  70014. /**
  70015. * Sets the easing mode of the current function.
  70016. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  70017. */
  70018. setEasingMode(easingMode: number): void;
  70019. /**
  70020. * Gets the current easing mode.
  70021. * @returns the easing mode
  70022. */
  70023. getEasingMode(): number;
  70024. /**
  70025. * @hidden
  70026. */
  70027. easeInCore(gradient: number): number;
  70028. /**
  70029. * Given an input gradient between 0 and 1, this returns the corresponding value
  70030. * of the easing function.
  70031. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70032. * @returns the corresponding value on the curve defined by the easing function
  70033. */
  70034. ease(gradient: number): number;
  70035. }
  70036. /**
  70037. * Easing function with a circle shape (see link below).
  70038. * @see https://easings.net/#easeInCirc
  70039. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70040. */
  70041. export class CircleEase extends EasingFunction implements IEasingFunction {
  70042. /** @hidden */
  70043. easeInCore(gradient: number): number;
  70044. }
  70045. /**
  70046. * Easing function with a ease back shape (see link below).
  70047. * @see https://easings.net/#easeInBack
  70048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70049. */
  70050. export class BackEase extends EasingFunction implements IEasingFunction {
  70051. /** Defines the amplitude of the function */
  70052. amplitude: number;
  70053. /**
  70054. * Instantiates a back ease easing
  70055. * @see https://easings.net/#easeInBack
  70056. * @param amplitude Defines the amplitude of the function
  70057. */
  70058. constructor(
  70059. /** Defines the amplitude of the function */
  70060. amplitude?: number);
  70061. /** @hidden */
  70062. easeInCore(gradient: number): number;
  70063. }
  70064. /**
  70065. * Easing function with a bouncing shape (see link below).
  70066. * @see https://easings.net/#easeInBounce
  70067. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70068. */
  70069. export class BounceEase extends EasingFunction implements IEasingFunction {
  70070. /** Defines the number of bounces */
  70071. bounces: number;
  70072. /** Defines the amplitude of the bounce */
  70073. bounciness: number;
  70074. /**
  70075. * Instantiates a bounce easing
  70076. * @see https://easings.net/#easeInBounce
  70077. * @param bounces Defines the number of bounces
  70078. * @param bounciness Defines the amplitude of the bounce
  70079. */
  70080. constructor(
  70081. /** Defines the number of bounces */
  70082. bounces?: number,
  70083. /** Defines the amplitude of the bounce */
  70084. bounciness?: number);
  70085. /** @hidden */
  70086. easeInCore(gradient: number): number;
  70087. }
  70088. /**
  70089. * Easing function with a power of 3 shape (see link below).
  70090. * @see https://easings.net/#easeInCubic
  70091. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70092. */
  70093. export class CubicEase extends EasingFunction implements IEasingFunction {
  70094. /** @hidden */
  70095. easeInCore(gradient: number): number;
  70096. }
  70097. /**
  70098. * Easing function with an elastic shape (see link below).
  70099. * @see https://easings.net/#easeInElastic
  70100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70101. */
  70102. export class ElasticEase extends EasingFunction implements IEasingFunction {
  70103. /** Defines the number of oscillations*/
  70104. oscillations: number;
  70105. /** Defines the amplitude of the oscillations*/
  70106. springiness: number;
  70107. /**
  70108. * Instantiates an elastic easing function
  70109. * @see https://easings.net/#easeInElastic
  70110. * @param oscillations Defines the number of oscillations
  70111. * @param springiness Defines the amplitude of the oscillations
  70112. */
  70113. constructor(
  70114. /** Defines the number of oscillations*/
  70115. oscillations?: number,
  70116. /** Defines the amplitude of the oscillations*/
  70117. springiness?: number);
  70118. /** @hidden */
  70119. easeInCore(gradient: number): number;
  70120. }
  70121. /**
  70122. * Easing function with an exponential shape (see link below).
  70123. * @see https://easings.net/#easeInExpo
  70124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70125. */
  70126. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  70127. /** Defines the exponent of the function */
  70128. exponent: number;
  70129. /**
  70130. * Instantiates an exponential easing function
  70131. * @see https://easings.net/#easeInExpo
  70132. * @param exponent Defines the exponent of the function
  70133. */
  70134. constructor(
  70135. /** Defines the exponent of the function */
  70136. exponent?: number);
  70137. /** @hidden */
  70138. easeInCore(gradient: number): number;
  70139. }
  70140. /**
  70141. * Easing function with a power shape (see link below).
  70142. * @see https://easings.net/#easeInQuad
  70143. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70144. */
  70145. export class PowerEase extends EasingFunction implements IEasingFunction {
  70146. /** Defines the power of the function */
  70147. power: number;
  70148. /**
  70149. * Instantiates an power base easing function
  70150. * @see https://easings.net/#easeInQuad
  70151. * @param power Defines the power of the function
  70152. */
  70153. constructor(
  70154. /** Defines the power of the function */
  70155. power?: number);
  70156. /** @hidden */
  70157. easeInCore(gradient: number): number;
  70158. }
  70159. /**
  70160. * Easing function with a power of 2 shape (see link below).
  70161. * @see https://easings.net/#easeInQuad
  70162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70163. */
  70164. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  70165. /** @hidden */
  70166. easeInCore(gradient: number): number;
  70167. }
  70168. /**
  70169. * Easing function with a power of 4 shape (see link below).
  70170. * @see https://easings.net/#easeInQuart
  70171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70172. */
  70173. export class QuarticEase extends EasingFunction implements IEasingFunction {
  70174. /** @hidden */
  70175. easeInCore(gradient: number): number;
  70176. }
  70177. /**
  70178. * Easing function with a power of 5 shape (see link below).
  70179. * @see https://easings.net/#easeInQuint
  70180. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70181. */
  70182. export class QuinticEase extends EasingFunction implements IEasingFunction {
  70183. /** @hidden */
  70184. easeInCore(gradient: number): number;
  70185. }
  70186. /**
  70187. * Easing function with a sin shape (see link below).
  70188. * @see https://easings.net/#easeInSine
  70189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70190. */
  70191. export class SineEase extends EasingFunction implements IEasingFunction {
  70192. /** @hidden */
  70193. easeInCore(gradient: number): number;
  70194. }
  70195. /**
  70196. * Easing function with a bezier shape (see link below).
  70197. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70198. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70199. */
  70200. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  70201. /** Defines the x component of the start tangent in the bezier curve */
  70202. x1: number;
  70203. /** Defines the y component of the start tangent in the bezier curve */
  70204. y1: number;
  70205. /** Defines the x component of the end tangent in the bezier curve */
  70206. x2: number;
  70207. /** Defines the y component of the end tangent in the bezier curve */
  70208. y2: number;
  70209. /**
  70210. * Instantiates a bezier function
  70211. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70212. * @param x1 Defines the x component of the start tangent in the bezier curve
  70213. * @param y1 Defines the y component of the start tangent in the bezier curve
  70214. * @param x2 Defines the x component of the end tangent in the bezier curve
  70215. * @param y2 Defines the y component of the end tangent in the bezier curve
  70216. */
  70217. constructor(
  70218. /** Defines the x component of the start tangent in the bezier curve */
  70219. x1?: number,
  70220. /** Defines the y component of the start tangent in the bezier curve */
  70221. y1?: number,
  70222. /** Defines the x component of the end tangent in the bezier curve */
  70223. x2?: number,
  70224. /** Defines the y component of the end tangent in the bezier curve */
  70225. y2?: number);
  70226. /** @hidden */
  70227. easeInCore(gradient: number): number;
  70228. }
  70229. }
  70230. declare module BABYLON {
  70231. /**
  70232. * Defines an interface which represents an animation key frame
  70233. */
  70234. export interface IAnimationKey {
  70235. /**
  70236. * Frame of the key frame
  70237. */
  70238. frame: number;
  70239. /**
  70240. * Value at the specifies key frame
  70241. */
  70242. value: any;
  70243. /**
  70244. * The input tangent for the cubic hermite spline
  70245. */
  70246. inTangent?: any;
  70247. /**
  70248. * The output tangent for the cubic hermite spline
  70249. */
  70250. outTangent?: any;
  70251. /**
  70252. * The animation interpolation type
  70253. */
  70254. interpolation?: AnimationKeyInterpolation;
  70255. }
  70256. /**
  70257. * Enum for the animation key frame interpolation type
  70258. */
  70259. export enum AnimationKeyInterpolation {
  70260. /**
  70261. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  70262. */
  70263. STEP = 1
  70264. }
  70265. }
  70266. declare module BABYLON {
  70267. /**
  70268. * Represents the range of an animation
  70269. */
  70270. export class AnimationRange {
  70271. /**The name of the animation range**/
  70272. name: string;
  70273. /**The starting frame of the animation */
  70274. from: number;
  70275. /**The ending frame of the animation*/
  70276. to: number;
  70277. /**
  70278. * Initializes the range of an animation
  70279. * @param name The name of the animation range
  70280. * @param from The starting frame of the animation
  70281. * @param to The ending frame of the animation
  70282. */
  70283. constructor(
  70284. /**The name of the animation range**/
  70285. name: string,
  70286. /**The starting frame of the animation */
  70287. from: number,
  70288. /**The ending frame of the animation*/
  70289. to: number);
  70290. /**
  70291. * Makes a copy of the animation range
  70292. * @returns A copy of the animation range
  70293. */
  70294. clone(): AnimationRange;
  70295. }
  70296. }
  70297. declare module BABYLON {
  70298. /**
  70299. * Composed of a frame, and an action function
  70300. */
  70301. export class AnimationEvent {
  70302. /** The frame for which the event is triggered **/
  70303. frame: number;
  70304. /** The event to perform when triggered **/
  70305. action: (currentFrame: number) => void;
  70306. /** Specifies if the event should be triggered only once**/
  70307. onlyOnce?: boolean | undefined;
  70308. /**
  70309. * Specifies if the animation event is done
  70310. */
  70311. isDone: boolean;
  70312. /**
  70313. * Initializes the animation event
  70314. * @param frame The frame for which the event is triggered
  70315. * @param action The event to perform when triggered
  70316. * @param onlyOnce Specifies if the event should be triggered only once
  70317. */
  70318. constructor(
  70319. /** The frame for which the event is triggered **/
  70320. frame: number,
  70321. /** The event to perform when triggered **/
  70322. action: (currentFrame: number) => void,
  70323. /** Specifies if the event should be triggered only once**/
  70324. onlyOnce?: boolean | undefined);
  70325. /** @hidden */
  70326. _clone(): AnimationEvent;
  70327. }
  70328. }
  70329. declare module BABYLON {
  70330. /**
  70331. * Interface used to define a behavior
  70332. */
  70333. export interface Behavior<T> {
  70334. /** gets or sets behavior's name */
  70335. name: string;
  70336. /**
  70337. * Function called when the behavior needs to be initialized (after attaching it to a target)
  70338. */
  70339. init(): void;
  70340. /**
  70341. * Called when the behavior is attached to a target
  70342. * @param target defines the target where the behavior is attached to
  70343. */
  70344. attach(target: T): void;
  70345. /**
  70346. * Called when the behavior is detached from its target
  70347. */
  70348. detach(): void;
  70349. }
  70350. /**
  70351. * Interface implemented by classes supporting behaviors
  70352. */
  70353. export interface IBehaviorAware<T> {
  70354. /**
  70355. * Attach a behavior
  70356. * @param behavior defines the behavior to attach
  70357. * @returns the current host
  70358. */
  70359. addBehavior(behavior: Behavior<T>): T;
  70360. /**
  70361. * Remove a behavior from the current object
  70362. * @param behavior defines the behavior to detach
  70363. * @returns the current host
  70364. */
  70365. removeBehavior(behavior: Behavior<T>): T;
  70366. /**
  70367. * Gets a behavior using its name to search
  70368. * @param name defines the name to search
  70369. * @returns the behavior or null if not found
  70370. */
  70371. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  70372. }
  70373. }
  70374. declare module BABYLON {
  70375. /**
  70376. * Defines an array and its length.
  70377. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70378. */
  70379. export interface ISmartArrayLike<T> {
  70380. /**
  70381. * The data of the array.
  70382. */
  70383. data: Array<T>;
  70384. /**
  70385. * The active length of the array.
  70386. */
  70387. length: number;
  70388. }
  70389. /**
  70390. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70391. */
  70392. export class SmartArray<T> implements ISmartArrayLike<T> {
  70393. /**
  70394. * The full set of data from the array.
  70395. */
  70396. data: Array<T>;
  70397. /**
  70398. * The active length of the array.
  70399. */
  70400. length: number;
  70401. protected _id: number;
  70402. /**
  70403. * Instantiates a Smart Array.
  70404. * @param capacity defines the default capacity of the array.
  70405. */
  70406. constructor(capacity: number);
  70407. /**
  70408. * Pushes a value at the end of the active data.
  70409. * @param value defines the object to push in the array.
  70410. */
  70411. push(value: T): void;
  70412. /**
  70413. * Iterates over the active data and apply the lambda to them.
  70414. * @param func defines the action to apply on each value.
  70415. */
  70416. forEach(func: (content: T) => void): void;
  70417. /**
  70418. * Sorts the full sets of data.
  70419. * @param compareFn defines the comparison function to apply.
  70420. */
  70421. sort(compareFn: (a: T, b: T) => number): void;
  70422. /**
  70423. * Resets the active data to an empty array.
  70424. */
  70425. reset(): void;
  70426. /**
  70427. * Releases all the data from the array as well as the array.
  70428. */
  70429. dispose(): void;
  70430. /**
  70431. * Concats the active data with a given array.
  70432. * @param array defines the data to concatenate with.
  70433. */
  70434. concat(array: any): void;
  70435. /**
  70436. * Returns the position of a value in the active data.
  70437. * @param value defines the value to find the index for
  70438. * @returns the index if found in the active data otherwise -1
  70439. */
  70440. indexOf(value: T): number;
  70441. /**
  70442. * Returns whether an element is part of the active data.
  70443. * @param value defines the value to look for
  70444. * @returns true if found in the active data otherwise false
  70445. */
  70446. contains(value: T): boolean;
  70447. private static _GlobalId;
  70448. }
  70449. /**
  70450. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70451. * The data in this array can only be present once
  70452. */
  70453. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70454. private _duplicateId;
  70455. /**
  70456. * Pushes a value at the end of the active data.
  70457. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70458. * @param value defines the object to push in the array.
  70459. */
  70460. push(value: T): void;
  70461. /**
  70462. * Pushes a value at the end of the active data.
  70463. * If the data is already present, it won t be added again
  70464. * @param value defines the object to push in the array.
  70465. * @returns true if added false if it was already present
  70466. */
  70467. pushNoDuplicate(value: T): boolean;
  70468. /**
  70469. * Resets the active data to an empty array.
  70470. */
  70471. reset(): void;
  70472. /**
  70473. * Concats the active data with a given array.
  70474. * This ensures no dupplicate will be present in the result.
  70475. * @param array defines the data to concatenate with.
  70476. */
  70477. concatWithNoDuplicate(array: any): void;
  70478. }
  70479. }
  70480. declare module BABYLON {
  70481. /**
  70482. * @ignore
  70483. * This is a list of all the different input types that are available in the application.
  70484. * Fo instance: ArcRotateCameraGamepadInput...
  70485. */
  70486. export var CameraInputTypes: {};
  70487. /**
  70488. * This is the contract to implement in order to create a new input class.
  70489. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70490. */
  70491. export interface ICameraInput<TCamera extends Camera> {
  70492. /**
  70493. * Defines the camera the input is attached to.
  70494. */
  70495. camera: Nullable<TCamera>;
  70496. /**
  70497. * Gets the class name of the current intput.
  70498. * @returns the class name
  70499. */
  70500. getClassName(): string;
  70501. /**
  70502. * Get the friendly name associated with the input class.
  70503. * @returns the input friendly name
  70504. */
  70505. getSimpleName(): string;
  70506. /**
  70507. * Attach the input controls to a specific dom element to get the input from.
  70508. * @param element Defines the element the controls should be listened from
  70509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70510. */
  70511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70512. /**
  70513. * Detach the current controls from the specified dom element.
  70514. * @param element Defines the element to stop listening the inputs from
  70515. */
  70516. detachControl(element: Nullable<HTMLElement>): void;
  70517. /**
  70518. * Update the current camera state depending on the inputs that have been used this frame.
  70519. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70520. */
  70521. checkInputs?: () => void;
  70522. }
  70523. /**
  70524. * Represents a map of input types to input instance or input index to input instance.
  70525. */
  70526. export interface CameraInputsMap<TCamera extends Camera> {
  70527. /**
  70528. * Accessor to the input by input type.
  70529. */
  70530. [name: string]: ICameraInput<TCamera>;
  70531. /**
  70532. * Accessor to the input by input index.
  70533. */
  70534. [idx: number]: ICameraInput<TCamera>;
  70535. }
  70536. /**
  70537. * This represents the input manager used within a camera.
  70538. * It helps dealing with all the different kind of input attached to a camera.
  70539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70540. */
  70541. export class CameraInputsManager<TCamera extends Camera> {
  70542. /**
  70543. * Defines the list of inputs attahed to the camera.
  70544. */
  70545. attached: CameraInputsMap<TCamera>;
  70546. /**
  70547. * Defines the dom element the camera is collecting inputs from.
  70548. * This is null if the controls have not been attached.
  70549. */
  70550. attachedElement: Nullable<HTMLElement>;
  70551. /**
  70552. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70553. */
  70554. noPreventDefault: boolean;
  70555. /**
  70556. * Defined the camera the input manager belongs to.
  70557. */
  70558. camera: TCamera;
  70559. /**
  70560. * Update the current camera state depending on the inputs that have been used this frame.
  70561. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70562. */
  70563. checkInputs: () => void;
  70564. /**
  70565. * Instantiate a new Camera Input Manager.
  70566. * @param camera Defines the camera the input manager blongs to
  70567. */
  70568. constructor(camera: TCamera);
  70569. /**
  70570. * Add an input method to a camera
  70571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70572. * @param input camera input method
  70573. */
  70574. add(input: ICameraInput<TCamera>): void;
  70575. /**
  70576. * Remove a specific input method from a camera
  70577. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70578. * @param inputToRemove camera input method
  70579. */
  70580. remove(inputToRemove: ICameraInput<TCamera>): void;
  70581. /**
  70582. * Remove a specific input type from a camera
  70583. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70584. * @param inputType the type of the input to remove
  70585. */
  70586. removeByType(inputType: string): void;
  70587. private _addCheckInputs;
  70588. /**
  70589. * Attach the input controls to the currently attached dom element to listen the events from.
  70590. * @param input Defines the input to attach
  70591. */
  70592. attachInput(input: ICameraInput<TCamera>): void;
  70593. /**
  70594. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70595. * @param element Defines the dom element to collect the events from
  70596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70597. */
  70598. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70599. /**
  70600. * Detach the current manager inputs controls from a specific dom element.
  70601. * @param element Defines the dom element to collect the events from
  70602. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70603. */
  70604. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70605. /**
  70606. * Rebuild the dynamic inputCheck function from the current list of
  70607. * defined inputs in the manager.
  70608. */
  70609. rebuildInputCheck(): void;
  70610. /**
  70611. * Remove all attached input methods from a camera
  70612. */
  70613. clear(): void;
  70614. /**
  70615. * Serialize the current input manager attached to a camera.
  70616. * This ensures than once parsed,
  70617. * the input associated to the camera will be identical to the current ones
  70618. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70619. */
  70620. serialize(serializedCamera: any): void;
  70621. /**
  70622. * Parses an input manager serialized JSON to restore the previous list of inputs
  70623. * and states associated to a camera.
  70624. * @param parsedCamera Defines the JSON to parse
  70625. */
  70626. parse(parsedCamera: any): void;
  70627. }
  70628. }
  70629. declare module BABYLON {
  70630. /**
  70631. * @hidden
  70632. */
  70633. export class IntersectionInfo {
  70634. bu: Nullable<number>;
  70635. bv: Nullable<number>;
  70636. distance: number;
  70637. faceId: number;
  70638. subMeshId: number;
  70639. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  70640. }
  70641. }
  70642. declare module BABYLON {
  70643. /**
  70644. * Represens a plane by the equation ax + by + cz + d = 0
  70645. */
  70646. export class Plane {
  70647. private static _TmpMatrix;
  70648. /**
  70649. * Normal of the plane (a,b,c)
  70650. */
  70651. normal: Vector3;
  70652. /**
  70653. * d component of the plane
  70654. */
  70655. d: number;
  70656. /**
  70657. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  70658. * @param a a component of the plane
  70659. * @param b b component of the plane
  70660. * @param c c component of the plane
  70661. * @param d d component of the plane
  70662. */
  70663. constructor(a: number, b: number, c: number, d: number);
  70664. /**
  70665. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  70666. */
  70667. asArray(): number[];
  70668. /**
  70669. * @returns a new plane copied from the current Plane.
  70670. */
  70671. clone(): Plane;
  70672. /**
  70673. * @returns the string "Plane".
  70674. */
  70675. getClassName(): string;
  70676. /**
  70677. * @returns the Plane hash code.
  70678. */
  70679. getHashCode(): number;
  70680. /**
  70681. * Normalize the current Plane in place.
  70682. * @returns the updated Plane.
  70683. */
  70684. normalize(): Plane;
  70685. /**
  70686. * Applies a transformation the plane and returns the result
  70687. * @param transformation the transformation matrix to be applied to the plane
  70688. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  70689. */
  70690. transform(transformation: DeepImmutable<Matrix>): Plane;
  70691. /**
  70692. * Calcualtte the dot product between the point and the plane normal
  70693. * @param point point to calculate the dot product with
  70694. * @returns the dot product (float) of the point coordinates and the plane normal.
  70695. */
  70696. dotCoordinate(point: DeepImmutable<Vector3>): number;
  70697. /**
  70698. * Updates the current Plane from the plane defined by the three given points.
  70699. * @param point1 one of the points used to contruct the plane
  70700. * @param point2 one of the points used to contruct the plane
  70701. * @param point3 one of the points used to contruct the plane
  70702. * @returns the updated Plane.
  70703. */
  70704. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70705. /**
  70706. * Checks if the plane is facing a given direction
  70707. * @param direction the direction to check if the plane is facing
  70708. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  70709. * @returns True is the vector "direction" is the same side than the plane normal.
  70710. */
  70711. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  70712. /**
  70713. * Calculates the distance to a point
  70714. * @param point point to calculate distance to
  70715. * @returns the signed distance (float) from the given point to the Plane.
  70716. */
  70717. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  70718. /**
  70719. * Creates a plane from an array
  70720. * @param array the array to create a plane from
  70721. * @returns a new Plane from the given array.
  70722. */
  70723. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  70724. /**
  70725. * Creates a plane from three points
  70726. * @param point1 point used to create the plane
  70727. * @param point2 point used to create the plane
  70728. * @param point3 point used to create the plane
  70729. * @returns a new Plane defined by the three given points.
  70730. */
  70731. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70732. /**
  70733. * Creates a plane from an origin point and a normal
  70734. * @param origin origin of the plane to be constructed
  70735. * @param normal normal of the plane to be constructed
  70736. * @returns a new Plane the normal vector to this plane at the given origin point.
  70737. * Note : the vector "normal" is updated because normalized.
  70738. */
  70739. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  70740. /**
  70741. * Calculates the distance from a plane and a point
  70742. * @param origin origin of the plane to be constructed
  70743. * @param normal normal of the plane to be constructed
  70744. * @param point point to calculate distance to
  70745. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  70746. */
  70747. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  70748. }
  70749. }
  70750. declare module BABYLON {
  70751. /**
  70752. * Class used to store bounding sphere information
  70753. */
  70754. export class BoundingSphere {
  70755. /**
  70756. * Gets the center of the bounding sphere in local space
  70757. */
  70758. readonly center: Vector3;
  70759. /**
  70760. * Radius of the bounding sphere in local space
  70761. */
  70762. radius: number;
  70763. /**
  70764. * Gets the center of the bounding sphere in world space
  70765. */
  70766. readonly centerWorld: Vector3;
  70767. /**
  70768. * Radius of the bounding sphere in world space
  70769. */
  70770. radiusWorld: number;
  70771. /**
  70772. * Gets the minimum vector in local space
  70773. */
  70774. readonly minimum: Vector3;
  70775. /**
  70776. * Gets the maximum vector in local space
  70777. */
  70778. readonly maximum: Vector3;
  70779. private _worldMatrix;
  70780. private static readonly TmpVector3;
  70781. /**
  70782. * Creates a new bounding sphere
  70783. * @param min defines the minimum vector (in local space)
  70784. * @param max defines the maximum vector (in local space)
  70785. * @param worldMatrix defines the new world matrix
  70786. */
  70787. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70788. /**
  70789. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  70790. * @param min defines the new minimum vector (in local space)
  70791. * @param max defines the new maximum vector (in local space)
  70792. * @param worldMatrix defines the new world matrix
  70793. */
  70794. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70795. /**
  70796. * Scale the current bounding sphere by applying a scale factor
  70797. * @param factor defines the scale factor to apply
  70798. * @returns the current bounding box
  70799. */
  70800. scale(factor: number): BoundingSphere;
  70801. /**
  70802. * Gets the world matrix of the bounding box
  70803. * @returns a matrix
  70804. */
  70805. getWorldMatrix(): DeepImmutable<Matrix>;
  70806. /** @hidden */
  70807. _update(worldMatrix: DeepImmutable<Matrix>): void;
  70808. /**
  70809. * Tests if the bounding sphere is intersecting the frustum planes
  70810. * @param frustumPlanes defines the frustum planes to test
  70811. * @returns true if there is an intersection
  70812. */
  70813. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70814. /**
  70815. * Tests if the bounding sphere center is in between the frustum planes.
  70816. * Used for optimistic fast inclusion.
  70817. * @param frustumPlanes defines the frustum planes to test
  70818. * @returns true if the sphere center is in between the frustum planes
  70819. */
  70820. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70821. /**
  70822. * Tests if a point is inside the bounding sphere
  70823. * @param point defines the point to test
  70824. * @returns true if the point is inside the bounding sphere
  70825. */
  70826. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70827. /**
  70828. * Checks if two sphere intersct
  70829. * @param sphere0 sphere 0
  70830. * @param sphere1 sphere 1
  70831. * @returns true if the speres intersect
  70832. */
  70833. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  70834. }
  70835. }
  70836. declare module BABYLON {
  70837. /**
  70838. * Class used to store bounding box information
  70839. */
  70840. export class BoundingBox implements ICullable {
  70841. /**
  70842. * Gets the 8 vectors representing the bounding box in local space
  70843. */
  70844. readonly vectors: Vector3[];
  70845. /**
  70846. * Gets the center of the bounding box in local space
  70847. */
  70848. readonly center: Vector3;
  70849. /**
  70850. * Gets the center of the bounding box in world space
  70851. */
  70852. readonly centerWorld: Vector3;
  70853. /**
  70854. * Gets the extend size in local space
  70855. */
  70856. readonly extendSize: Vector3;
  70857. /**
  70858. * Gets the extend size in world space
  70859. */
  70860. readonly extendSizeWorld: Vector3;
  70861. /**
  70862. * Gets the OBB (object bounding box) directions
  70863. */
  70864. readonly directions: Vector3[];
  70865. /**
  70866. * Gets the 8 vectors representing the bounding box in world space
  70867. */
  70868. readonly vectorsWorld: Vector3[];
  70869. /**
  70870. * Gets the minimum vector in world space
  70871. */
  70872. readonly minimumWorld: Vector3;
  70873. /**
  70874. * Gets the maximum vector in world space
  70875. */
  70876. readonly maximumWorld: Vector3;
  70877. /**
  70878. * Gets the minimum vector in local space
  70879. */
  70880. readonly minimum: Vector3;
  70881. /**
  70882. * Gets the maximum vector in local space
  70883. */
  70884. readonly maximum: Vector3;
  70885. private _worldMatrix;
  70886. private static readonly TmpVector3;
  70887. /**
  70888. * @hidden
  70889. */
  70890. _tag: number;
  70891. /**
  70892. * Creates a new bounding box
  70893. * @param min defines the minimum vector (in local space)
  70894. * @param max defines the maximum vector (in local space)
  70895. * @param worldMatrix defines the new world matrix
  70896. */
  70897. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70898. /**
  70899. * Recreates the entire bounding box from scratch as if we call the constructor in place
  70900. * @param min defines the new minimum vector (in local space)
  70901. * @param max defines the new maximum vector (in local space)
  70902. * @param worldMatrix defines the new world matrix
  70903. */
  70904. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70905. /**
  70906. * Scale the current bounding box by applying a scale factor
  70907. * @param factor defines the scale factor to apply
  70908. * @returns the current bounding box
  70909. */
  70910. scale(factor: number): BoundingBox;
  70911. /**
  70912. * Gets the world matrix of the bounding box
  70913. * @returns a matrix
  70914. */
  70915. getWorldMatrix(): DeepImmutable<Matrix>;
  70916. /** @hidden */
  70917. _update(world: DeepImmutable<Matrix>): void;
  70918. /**
  70919. * Tests if the bounding box is intersecting the frustum planes
  70920. * @param frustumPlanes defines the frustum planes to test
  70921. * @returns true if there is an intersection
  70922. */
  70923. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70924. /**
  70925. * Tests if the bounding box is entirely inside the frustum planes
  70926. * @param frustumPlanes defines the frustum planes to test
  70927. * @returns true if there is an inclusion
  70928. */
  70929. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70930. /**
  70931. * Tests if a point is inside the bounding box
  70932. * @param point defines the point to test
  70933. * @returns true if the point is inside the bounding box
  70934. */
  70935. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70936. /**
  70937. * Tests if the bounding box intersects with a bounding sphere
  70938. * @param sphere defines the sphere to test
  70939. * @returns true if there is an intersection
  70940. */
  70941. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  70942. /**
  70943. * Tests if the bounding box intersects with a box defined by a min and max vectors
  70944. * @param min defines the min vector to use
  70945. * @param max defines the max vector to use
  70946. * @returns true if there is an intersection
  70947. */
  70948. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  70949. /**
  70950. * Tests if two bounding boxes are intersections
  70951. * @param box0 defines the first box to test
  70952. * @param box1 defines the second box to test
  70953. * @returns true if there is an intersection
  70954. */
  70955. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  70956. /**
  70957. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  70958. * @param minPoint defines the minimum vector of the bounding box
  70959. * @param maxPoint defines the maximum vector of the bounding box
  70960. * @param sphereCenter defines the sphere center
  70961. * @param sphereRadius defines the sphere radius
  70962. * @returns true if there is an intersection
  70963. */
  70964. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  70965. /**
  70966. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  70967. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70968. * @param frustumPlanes defines the frustum planes to test
  70969. * @return true if there is an inclusion
  70970. */
  70971. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70972. /**
  70973. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  70974. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70975. * @param frustumPlanes defines the frustum planes to test
  70976. * @return true if there is an intersection
  70977. */
  70978. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70979. }
  70980. }
  70981. declare module BABYLON {
  70982. /** @hidden */
  70983. export class Collider {
  70984. /** Define if a collision was found */
  70985. collisionFound: boolean;
  70986. /**
  70987. * Define last intersection point in local space
  70988. */
  70989. intersectionPoint: Vector3;
  70990. /**
  70991. * Define last collided mesh
  70992. */
  70993. collidedMesh: Nullable<AbstractMesh>;
  70994. private _collisionPoint;
  70995. private _planeIntersectionPoint;
  70996. private _tempVector;
  70997. private _tempVector2;
  70998. private _tempVector3;
  70999. private _tempVector4;
  71000. private _edge;
  71001. private _baseToVertex;
  71002. private _destinationPoint;
  71003. private _slidePlaneNormal;
  71004. private _displacementVector;
  71005. /** @hidden */
  71006. _radius: Vector3;
  71007. /** @hidden */
  71008. _retry: number;
  71009. private _velocity;
  71010. private _basePoint;
  71011. private _epsilon;
  71012. /** @hidden */
  71013. _velocityWorldLength: number;
  71014. /** @hidden */
  71015. _basePointWorld: Vector3;
  71016. private _velocityWorld;
  71017. private _normalizedVelocity;
  71018. /** @hidden */
  71019. _initialVelocity: Vector3;
  71020. /** @hidden */
  71021. _initialPosition: Vector3;
  71022. private _nearestDistance;
  71023. private _collisionMask;
  71024. collisionMask: number;
  71025. /**
  71026. * Gets the plane normal used to compute the sliding response (in local space)
  71027. */
  71028. readonly slidePlaneNormal: Vector3;
  71029. /** @hidden */
  71030. _initialize(source: Vector3, dir: Vector3, e: number): void;
  71031. /** @hidden */
  71032. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  71033. /** @hidden */
  71034. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  71035. /** @hidden */
  71036. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71037. /** @hidden */
  71038. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71039. /** @hidden */
  71040. _getResponse(pos: Vector3, vel: Vector3): void;
  71041. }
  71042. }
  71043. declare module BABYLON {
  71044. /**
  71045. * Interface for cullable objects
  71046. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  71047. */
  71048. export interface ICullable {
  71049. /**
  71050. * Checks if the object or part of the object is in the frustum
  71051. * @param frustumPlanes Camera near/planes
  71052. * @returns true if the object is in frustum otherwise false
  71053. */
  71054. isInFrustum(frustumPlanes: Plane[]): boolean;
  71055. /**
  71056. * Checks if a cullable object (mesh...) is in the camera frustum
  71057. * Unlike isInFrustum this cheks the full bounding box
  71058. * @param frustumPlanes Camera near/planes
  71059. * @returns true if the object is in frustum otherwise false
  71060. */
  71061. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  71062. }
  71063. /**
  71064. * Info for a bounding data of a mesh
  71065. */
  71066. export class BoundingInfo implements ICullable {
  71067. /**
  71068. * Bounding box for the mesh
  71069. */
  71070. readonly boundingBox: BoundingBox;
  71071. /**
  71072. * Bounding sphere for the mesh
  71073. */
  71074. readonly boundingSphere: BoundingSphere;
  71075. private _isLocked;
  71076. private static readonly TmpVector3;
  71077. /**
  71078. * Constructs bounding info
  71079. * @param minimum min vector of the bounding box/sphere
  71080. * @param maximum max vector of the bounding box/sphere
  71081. * @param worldMatrix defines the new world matrix
  71082. */
  71083. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71084. /**
  71085. * Recreates the entire bounding info from scratch as if we call the constructor in place
  71086. * @param min defines the new minimum vector (in local space)
  71087. * @param max defines the new maximum vector (in local space)
  71088. * @param worldMatrix defines the new world matrix
  71089. */
  71090. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71091. /**
  71092. * min vector of the bounding box/sphere
  71093. */
  71094. readonly minimum: Vector3;
  71095. /**
  71096. * max vector of the bounding box/sphere
  71097. */
  71098. readonly maximum: Vector3;
  71099. /**
  71100. * If the info is locked and won't be updated to avoid perf overhead
  71101. */
  71102. isLocked: boolean;
  71103. /**
  71104. * Updates the bounding sphere and box
  71105. * @param world world matrix to be used to update
  71106. */
  71107. update(world: DeepImmutable<Matrix>): void;
  71108. /**
  71109. * Recreate the bounding info to be centered around a specific point given a specific extend.
  71110. * @param center New center of the bounding info
  71111. * @param extend New extend of the bounding info
  71112. * @returns the current bounding info
  71113. */
  71114. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  71115. /**
  71116. * Scale the current bounding info by applying a scale factor
  71117. * @param factor defines the scale factor to apply
  71118. * @returns the current bounding info
  71119. */
  71120. scale(factor: number): BoundingInfo;
  71121. /**
  71122. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  71123. * @param frustumPlanes defines the frustum to test
  71124. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  71125. * @returns true if the bounding info is in the frustum planes
  71126. */
  71127. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  71128. /**
  71129. * Gets the world distance between the min and max points of the bounding box
  71130. */
  71131. readonly diagonalLength: number;
  71132. /**
  71133. * Checks if a cullable object (mesh...) is in the camera frustum
  71134. * Unlike isInFrustum this cheks the full bounding box
  71135. * @param frustumPlanes Camera near/planes
  71136. * @returns true if the object is in frustum otherwise false
  71137. */
  71138. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71139. /** @hidden */
  71140. _checkCollision(collider: Collider): boolean;
  71141. /**
  71142. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  71143. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71144. * @param point the point to check intersection with
  71145. * @returns if the point intersects
  71146. */
  71147. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71148. /**
  71149. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  71150. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71151. * @param boundingInfo the bounding info to check intersection with
  71152. * @param precise if the intersection should be done using OBB
  71153. * @returns if the bounding info intersects
  71154. */
  71155. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  71156. }
  71157. }
  71158. declare module BABYLON {
  71159. /**
  71160. * Extracts minimum and maximum values from a list of indexed positions
  71161. * @param positions defines the positions to use
  71162. * @param indices defines the indices to the positions
  71163. * @param indexStart defines the start index
  71164. * @param indexCount defines the end index
  71165. * @param bias defines bias value to add to the result
  71166. * @return minimum and maximum values
  71167. */
  71168. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  71169. minimum: Vector3;
  71170. maximum: Vector3;
  71171. };
  71172. /**
  71173. * Extracts minimum and maximum values from a list of positions
  71174. * @param positions defines the positions to use
  71175. * @param start defines the start index in the positions array
  71176. * @param count defines the number of positions to handle
  71177. * @param bias defines bias value to add to the result
  71178. * @param stride defines the stride size to use (distance between two positions in the positions array)
  71179. * @return minimum and maximum values
  71180. */
  71181. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  71182. minimum: Vector3;
  71183. maximum: Vector3;
  71184. };
  71185. }
  71186. declare module BABYLON {
  71187. /**
  71188. * Enum that determines the text-wrapping mode to use.
  71189. */
  71190. export enum InspectableType {
  71191. /**
  71192. * Checkbox for booleans
  71193. */
  71194. Checkbox = 0,
  71195. /**
  71196. * Sliders for numbers
  71197. */
  71198. Slider = 1,
  71199. /**
  71200. * Vector3
  71201. */
  71202. Vector3 = 2,
  71203. /**
  71204. * Quaternions
  71205. */
  71206. Quaternion = 3,
  71207. /**
  71208. * Color3
  71209. */
  71210. Color3 = 4,
  71211. /**
  71212. * String
  71213. */
  71214. String = 5
  71215. }
  71216. /**
  71217. * Interface used to define custom inspectable properties.
  71218. * This interface is used by the inspector to display custom property grids
  71219. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71220. */
  71221. export interface IInspectable {
  71222. /**
  71223. * Gets the label to display
  71224. */
  71225. label: string;
  71226. /**
  71227. * Gets the name of the property to edit
  71228. */
  71229. propertyName: string;
  71230. /**
  71231. * Gets the type of the editor to use
  71232. */
  71233. type: InspectableType;
  71234. /**
  71235. * Gets the minimum value of the property when using in "slider" mode
  71236. */
  71237. min?: number;
  71238. /**
  71239. * Gets the maximum value of the property when using in "slider" mode
  71240. */
  71241. max?: number;
  71242. /**
  71243. * Gets the setp to use when using in "slider" mode
  71244. */
  71245. step?: number;
  71246. }
  71247. }
  71248. declare module BABYLON {
  71249. /**
  71250. * Class used to provide helper for timing
  71251. */
  71252. export class TimingTools {
  71253. /**
  71254. * Polyfill for setImmediate
  71255. * @param action defines the action to execute after the current execution block
  71256. */
  71257. static SetImmediate(action: () => void): void;
  71258. }
  71259. }
  71260. declare module BABYLON {
  71261. /**
  71262. * Class used to enable instatition of objects by class name
  71263. */
  71264. export class InstantiationTools {
  71265. /**
  71266. * Use this object to register external classes like custom textures or material
  71267. * to allow the laoders to instantiate them
  71268. */
  71269. static RegisteredExternalClasses: {
  71270. [key: string]: Object;
  71271. };
  71272. /**
  71273. * Tries to instantiate a new object from a given class name
  71274. * @param className defines the class name to instantiate
  71275. * @returns the new object or null if the system was not able to do the instantiation
  71276. */
  71277. static Instantiate(className: string): any;
  71278. }
  71279. }
  71280. declare module BABYLON {
  71281. /**
  71282. * This represents the required contract to create a new type of texture loader.
  71283. */
  71284. export interface IInternalTextureLoader {
  71285. /**
  71286. * Defines wether the loader supports cascade loading the different faces.
  71287. */
  71288. supportCascades: boolean;
  71289. /**
  71290. * This returns if the loader support the current file information.
  71291. * @param extension defines the file extension of the file being loaded
  71292. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71293. * @param fallback defines the fallback internal texture if any
  71294. * @param isBase64 defines whether the texture is encoded as a base64
  71295. * @param isBuffer defines whether the texture data are stored as a buffer
  71296. * @returns true if the loader can load the specified file
  71297. */
  71298. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71299. /**
  71300. * Transform the url before loading if required.
  71301. * @param rootUrl the url of the texture
  71302. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71303. * @returns the transformed texture
  71304. */
  71305. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71306. /**
  71307. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71308. * @param rootUrl the url of the texture
  71309. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71310. * @returns the fallback texture
  71311. */
  71312. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71313. /**
  71314. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71315. * @param data contains the texture data
  71316. * @param texture defines the BabylonJS internal texture
  71317. * @param createPolynomials will be true if polynomials have been requested
  71318. * @param onLoad defines the callback to trigger once the texture is ready
  71319. * @param onError defines the callback to trigger in case of error
  71320. */
  71321. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71322. /**
  71323. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71324. * @param data contains the texture data
  71325. * @param texture defines the BabylonJS internal texture
  71326. * @param callback defines the method to call once ready to upload
  71327. */
  71328. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71329. }
  71330. }
  71331. declare module BABYLON {
  71332. interface Engine {
  71333. /**
  71334. * Creates a depth stencil cube texture.
  71335. * This is only available in WebGL 2.
  71336. * @param size The size of face edge in the cube texture.
  71337. * @param options The options defining the cube texture.
  71338. * @returns The cube texture
  71339. */
  71340. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  71341. /**
  71342. * Creates a cube texture
  71343. * @param rootUrl defines the url where the files to load is located
  71344. * @param scene defines the current scene
  71345. * @param files defines the list of files to load (1 per face)
  71346. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71347. * @param onLoad defines an optional callback raised when the texture is loaded
  71348. * @param onError defines an optional callback raised if there is an issue to load the texture
  71349. * @param format defines the format of the data
  71350. * @param forcedExtension defines the extension to use to pick the right loader
  71351. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71352. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71353. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71354. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  71355. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  71356. * @returns the cube texture as an InternalTexture
  71357. */
  71358. 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;
  71359. /**
  71360. * Creates a cube texture
  71361. * @param rootUrl defines the url where the files to load is located
  71362. * @param scene defines the current scene
  71363. * @param files defines the list of files to load (1 per face)
  71364. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71365. * @param onLoad defines an optional callback raised when the texture is loaded
  71366. * @param onError defines an optional callback raised if there is an issue to load the texture
  71367. * @param format defines the format of the data
  71368. * @param forcedExtension defines the extension to use to pick the right loader
  71369. * @returns the cube texture as an InternalTexture
  71370. */
  71371. 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;
  71372. /**
  71373. * Creates a cube texture
  71374. * @param rootUrl defines the url where the files to load is located
  71375. * @param scene defines the current scene
  71376. * @param files defines the list of files to load (1 per face)
  71377. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71378. * @param onLoad defines an optional callback raised when the texture is loaded
  71379. * @param onError defines an optional callback raised if there is an issue to load the texture
  71380. * @param format defines the format of the data
  71381. * @param forcedExtension defines the extension to use to pick the right loader
  71382. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71383. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71384. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71385. * @returns the cube texture as an InternalTexture
  71386. */
  71387. 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;
  71388. /** @hidden */
  71389. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71390. /** @hidden */
  71391. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71392. /** @hidden */
  71393. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71394. /** @hidden */
  71395. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71396. }
  71397. }
  71398. declare module BABYLON {
  71399. /**
  71400. * Class for creating a cube texture
  71401. */
  71402. export class CubeTexture extends BaseTexture {
  71403. private _delayedOnLoad;
  71404. /**
  71405. * The url of the texture
  71406. */
  71407. url: string;
  71408. /**
  71409. * Gets or sets the center of the bounding box associated with the cube texture.
  71410. * It must define where the camera used to render the texture was set
  71411. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71412. */
  71413. boundingBoxPosition: Vector3;
  71414. private _boundingBoxSize;
  71415. /**
  71416. * Gets or sets the size of the bounding box associated with the cube texture
  71417. * When defined, the cubemap will switch to local mode
  71418. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  71419. * @example https://www.babylonjs-playground.com/#RNASML
  71420. */
  71421. /**
  71422. * Returns the bounding box size
  71423. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71424. */
  71425. boundingBoxSize: Vector3;
  71426. protected _rotationY: number;
  71427. /**
  71428. * Sets texture matrix rotation angle around Y axis in radians.
  71429. */
  71430. /**
  71431. * Gets texture matrix rotation angle around Y axis radians.
  71432. */
  71433. rotationY: number;
  71434. /**
  71435. * Are mip maps generated for this texture or not.
  71436. */
  71437. readonly noMipmap: boolean;
  71438. private _noMipmap;
  71439. private _files;
  71440. private _extensions;
  71441. private _textureMatrix;
  71442. private _format;
  71443. private _createPolynomials;
  71444. /** @hidden */
  71445. _prefiltered: boolean;
  71446. /**
  71447. * Creates a cube texture from an array of image urls
  71448. * @param files defines an array of image urls
  71449. * @param scene defines the hosting scene
  71450. * @param noMipmap specifies if mip maps are not used
  71451. * @returns a cube texture
  71452. */
  71453. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  71454. /**
  71455. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  71456. * @param url defines the url of the prefiltered texture
  71457. * @param scene defines the scene the texture is attached to
  71458. * @param forcedExtension defines the extension of the file if different from the url
  71459. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71460. * @return the prefiltered texture
  71461. */
  71462. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  71463. /**
  71464. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  71465. * as prefiltered data.
  71466. * @param rootUrl defines the url of the texture or the root name of the six images
  71467. * @param scene defines the scene the texture is attached to
  71468. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  71469. * @param noMipmap defines if mipmaps should be created or not
  71470. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  71471. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  71472. * @param onError defines a callback triggered in case of error during load
  71473. * @param format defines the internal format to use for the texture once loaded
  71474. * @param prefiltered defines whether or not the texture is created from prefiltered data
  71475. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  71476. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71477. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71478. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71479. * @return the cube texture
  71480. */
  71481. 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);
  71482. /**
  71483. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  71484. */
  71485. readonly isPrefiltered: boolean;
  71486. /**
  71487. * Get the current class name of the texture useful for serialization or dynamic coding.
  71488. * @returns "CubeTexture"
  71489. */
  71490. getClassName(): string;
  71491. /**
  71492. * Update the url (and optional buffer) of this texture if url was null during construction.
  71493. * @param url the url of the texture
  71494. * @param forcedExtension defines the extension to use
  71495. * @param onLoad callback called when the texture is loaded (defaults to null)
  71496. */
  71497. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  71498. /**
  71499. * Delays loading of the cube texture
  71500. * @param forcedExtension defines the extension to use
  71501. */
  71502. delayLoad(forcedExtension?: string): void;
  71503. /**
  71504. * Returns the reflection texture matrix
  71505. * @returns the reflection texture matrix
  71506. */
  71507. getReflectionTextureMatrix(): Matrix;
  71508. /**
  71509. * Sets the reflection texture matrix
  71510. * @param value Reflection texture matrix
  71511. */
  71512. setReflectionTextureMatrix(value: Matrix): void;
  71513. /**
  71514. * Parses text to create a cube texture
  71515. * @param parsedTexture define the serialized text to read from
  71516. * @param scene defines the hosting scene
  71517. * @param rootUrl defines the root url of the cube texture
  71518. * @returns a cube texture
  71519. */
  71520. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  71521. /**
  71522. * Makes a clone, or deep copy, of the cube texture
  71523. * @returns a new cube texture
  71524. */
  71525. clone(): CubeTexture;
  71526. }
  71527. }
  71528. declare module BABYLON {
  71529. /**
  71530. * Manages the defines for the Material
  71531. */
  71532. export class MaterialDefines {
  71533. /** @hidden */
  71534. protected _keys: string[];
  71535. private _isDirty;
  71536. /** @hidden */
  71537. _renderId: number;
  71538. /** @hidden */
  71539. _areLightsDirty: boolean;
  71540. /** @hidden */
  71541. _areAttributesDirty: boolean;
  71542. /** @hidden */
  71543. _areTexturesDirty: boolean;
  71544. /** @hidden */
  71545. _areFresnelDirty: boolean;
  71546. /** @hidden */
  71547. _areMiscDirty: boolean;
  71548. /** @hidden */
  71549. _areImageProcessingDirty: boolean;
  71550. /** @hidden */
  71551. _normals: boolean;
  71552. /** @hidden */
  71553. _uvs: boolean;
  71554. /** @hidden */
  71555. _needNormals: boolean;
  71556. /** @hidden */
  71557. _needUVs: boolean;
  71558. [id: string]: any;
  71559. /**
  71560. * Specifies if the material needs to be re-calculated
  71561. */
  71562. readonly isDirty: boolean;
  71563. /**
  71564. * Marks the material to indicate that it has been re-calculated
  71565. */
  71566. markAsProcessed(): void;
  71567. /**
  71568. * Marks the material to indicate that it needs to be re-calculated
  71569. */
  71570. markAsUnprocessed(): void;
  71571. /**
  71572. * Marks the material to indicate all of its defines need to be re-calculated
  71573. */
  71574. markAllAsDirty(): void;
  71575. /**
  71576. * Marks the material to indicate that image processing needs to be re-calculated
  71577. */
  71578. markAsImageProcessingDirty(): void;
  71579. /**
  71580. * Marks the material to indicate the lights need to be re-calculated
  71581. */
  71582. markAsLightDirty(): void;
  71583. /**
  71584. * Marks the attribute state as changed
  71585. */
  71586. markAsAttributesDirty(): void;
  71587. /**
  71588. * Marks the texture state as changed
  71589. */
  71590. markAsTexturesDirty(): void;
  71591. /**
  71592. * Marks the fresnel state as changed
  71593. */
  71594. markAsFresnelDirty(): void;
  71595. /**
  71596. * Marks the misc state as changed
  71597. */
  71598. markAsMiscDirty(): void;
  71599. /**
  71600. * Rebuilds the material defines
  71601. */
  71602. rebuild(): void;
  71603. /**
  71604. * Specifies if two material defines are equal
  71605. * @param other - A material define instance to compare to
  71606. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  71607. */
  71608. isEqual(other: MaterialDefines): boolean;
  71609. /**
  71610. * Clones this instance's defines to another instance
  71611. * @param other - material defines to clone values to
  71612. */
  71613. cloneTo(other: MaterialDefines): void;
  71614. /**
  71615. * Resets the material define values
  71616. */
  71617. reset(): void;
  71618. /**
  71619. * Converts the material define values to a string
  71620. * @returns - String of material define information
  71621. */
  71622. toString(): string;
  71623. }
  71624. }
  71625. declare module BABYLON {
  71626. /**
  71627. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  71628. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  71629. * 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;
  71630. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  71631. */
  71632. export class ColorCurves {
  71633. private _dirty;
  71634. private _tempColor;
  71635. private _globalCurve;
  71636. private _highlightsCurve;
  71637. private _midtonesCurve;
  71638. private _shadowsCurve;
  71639. private _positiveCurve;
  71640. private _negativeCurve;
  71641. private _globalHue;
  71642. private _globalDensity;
  71643. private _globalSaturation;
  71644. private _globalExposure;
  71645. /**
  71646. * Gets the global Hue value.
  71647. * 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).
  71648. */
  71649. /**
  71650. * Sets the global Hue value.
  71651. * 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).
  71652. */
  71653. globalHue: number;
  71654. /**
  71655. * Gets the global Density value.
  71656. * 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.
  71657. * Values less than zero provide a filter of opposite hue.
  71658. */
  71659. /**
  71660. * Sets the global Density value.
  71661. * 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.
  71662. * Values less than zero provide a filter of opposite hue.
  71663. */
  71664. globalDensity: number;
  71665. /**
  71666. * Gets the global Saturation value.
  71667. * 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.
  71668. */
  71669. /**
  71670. * Sets the global Saturation value.
  71671. * 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.
  71672. */
  71673. globalSaturation: number;
  71674. /**
  71675. * Gets the global Exposure value.
  71676. * 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.
  71677. */
  71678. /**
  71679. * Sets the global Exposure value.
  71680. * 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.
  71681. */
  71682. globalExposure: number;
  71683. private _highlightsHue;
  71684. private _highlightsDensity;
  71685. private _highlightsSaturation;
  71686. private _highlightsExposure;
  71687. /**
  71688. * Gets the highlights Hue value.
  71689. * 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).
  71690. */
  71691. /**
  71692. * Sets the highlights Hue value.
  71693. * 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).
  71694. */
  71695. highlightsHue: number;
  71696. /**
  71697. * Gets the highlights Density value.
  71698. * 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.
  71699. * Values less than zero provide a filter of opposite hue.
  71700. */
  71701. /**
  71702. * Sets the highlights Density value.
  71703. * 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.
  71704. * Values less than zero provide a filter of opposite hue.
  71705. */
  71706. highlightsDensity: number;
  71707. /**
  71708. * Gets the highlights Saturation value.
  71709. * 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.
  71710. */
  71711. /**
  71712. * Sets the highlights Saturation value.
  71713. * 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.
  71714. */
  71715. highlightsSaturation: number;
  71716. /**
  71717. * Gets the highlights Exposure value.
  71718. * 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.
  71719. */
  71720. /**
  71721. * Sets the highlights Exposure value.
  71722. * 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.
  71723. */
  71724. highlightsExposure: number;
  71725. private _midtonesHue;
  71726. private _midtonesDensity;
  71727. private _midtonesSaturation;
  71728. private _midtonesExposure;
  71729. /**
  71730. * Gets the midtones Hue value.
  71731. * 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).
  71732. */
  71733. /**
  71734. * Sets the midtones Hue value.
  71735. * 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).
  71736. */
  71737. midtonesHue: number;
  71738. /**
  71739. * Gets the midtones Density value.
  71740. * 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.
  71741. * Values less than zero provide a filter of opposite hue.
  71742. */
  71743. /**
  71744. * Sets the midtones Density value.
  71745. * 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.
  71746. * Values less than zero provide a filter of opposite hue.
  71747. */
  71748. midtonesDensity: number;
  71749. /**
  71750. * Gets the midtones Saturation value.
  71751. * 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.
  71752. */
  71753. /**
  71754. * Sets the midtones Saturation value.
  71755. * 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.
  71756. */
  71757. midtonesSaturation: number;
  71758. /**
  71759. * Gets the midtones Exposure value.
  71760. * 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.
  71761. */
  71762. /**
  71763. * Sets the midtones Exposure value.
  71764. * 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.
  71765. */
  71766. midtonesExposure: number;
  71767. private _shadowsHue;
  71768. private _shadowsDensity;
  71769. private _shadowsSaturation;
  71770. private _shadowsExposure;
  71771. /**
  71772. * Gets the shadows Hue value.
  71773. * 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).
  71774. */
  71775. /**
  71776. * Sets the shadows Hue value.
  71777. * 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).
  71778. */
  71779. shadowsHue: number;
  71780. /**
  71781. * Gets the shadows Density value.
  71782. * 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.
  71783. * Values less than zero provide a filter of opposite hue.
  71784. */
  71785. /**
  71786. * Sets the shadows Density value.
  71787. * 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.
  71788. * Values less than zero provide a filter of opposite hue.
  71789. */
  71790. shadowsDensity: number;
  71791. /**
  71792. * Gets the shadows Saturation value.
  71793. * 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.
  71794. */
  71795. /**
  71796. * Sets the shadows Saturation value.
  71797. * 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.
  71798. */
  71799. shadowsSaturation: number;
  71800. /**
  71801. * Gets the shadows Exposure value.
  71802. * 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.
  71803. */
  71804. /**
  71805. * Sets the shadows Exposure value.
  71806. * 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.
  71807. */
  71808. shadowsExposure: number;
  71809. /**
  71810. * Returns the class name
  71811. * @returns The class name
  71812. */
  71813. getClassName(): string;
  71814. /**
  71815. * Binds the color curves to the shader.
  71816. * @param colorCurves The color curve to bind
  71817. * @param effect The effect to bind to
  71818. * @param positiveUniform The positive uniform shader parameter
  71819. * @param neutralUniform The neutral uniform shader parameter
  71820. * @param negativeUniform The negative uniform shader parameter
  71821. */
  71822. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  71823. /**
  71824. * Prepare the list of uniforms associated with the ColorCurves effects.
  71825. * @param uniformsList The list of uniforms used in the effect
  71826. */
  71827. static PrepareUniforms(uniformsList: string[]): void;
  71828. /**
  71829. * Returns color grading data based on a hue, density, saturation and exposure value.
  71830. * @param filterHue The hue of the color filter.
  71831. * @param filterDensity The density of the color filter.
  71832. * @param saturation The saturation.
  71833. * @param exposure The exposure.
  71834. * @param result The result data container.
  71835. */
  71836. private getColorGradingDataToRef;
  71837. /**
  71838. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  71839. * @param value The input slider value in range [-100,100].
  71840. * @returns Adjusted value.
  71841. */
  71842. private static applyColorGradingSliderNonlinear;
  71843. /**
  71844. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  71845. * @param hue The hue (H) input.
  71846. * @param saturation The saturation (S) input.
  71847. * @param brightness The brightness (B) input.
  71848. * @result An RGBA color represented as Vector4.
  71849. */
  71850. private static fromHSBToRef;
  71851. /**
  71852. * Returns a value clamped between min and max
  71853. * @param value The value to clamp
  71854. * @param min The minimum of value
  71855. * @param max The maximum of value
  71856. * @returns The clamped value.
  71857. */
  71858. private static clamp;
  71859. /**
  71860. * Clones the current color curve instance.
  71861. * @return The cloned curves
  71862. */
  71863. clone(): ColorCurves;
  71864. /**
  71865. * Serializes the current color curve instance to a json representation.
  71866. * @return a JSON representation
  71867. */
  71868. serialize(): any;
  71869. /**
  71870. * Parses the color curve from a json representation.
  71871. * @param source the JSON source to parse
  71872. * @return The parsed curves
  71873. */
  71874. static Parse(source: any): ColorCurves;
  71875. }
  71876. }
  71877. declare module BABYLON {
  71878. /**
  71879. * Interface to follow in your material defines to integrate easily the
  71880. * Image proccessing functions.
  71881. * @hidden
  71882. */
  71883. export interface IImageProcessingConfigurationDefines {
  71884. IMAGEPROCESSING: boolean;
  71885. VIGNETTE: boolean;
  71886. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71887. VIGNETTEBLENDMODEOPAQUE: boolean;
  71888. TONEMAPPING: boolean;
  71889. TONEMAPPING_ACES: boolean;
  71890. CONTRAST: boolean;
  71891. EXPOSURE: boolean;
  71892. COLORCURVES: boolean;
  71893. COLORGRADING: boolean;
  71894. COLORGRADING3D: boolean;
  71895. SAMPLER3DGREENDEPTH: boolean;
  71896. SAMPLER3DBGRMAP: boolean;
  71897. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71898. }
  71899. /**
  71900. * @hidden
  71901. */
  71902. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  71903. IMAGEPROCESSING: boolean;
  71904. VIGNETTE: boolean;
  71905. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71906. VIGNETTEBLENDMODEOPAQUE: boolean;
  71907. TONEMAPPING: boolean;
  71908. TONEMAPPING_ACES: boolean;
  71909. CONTRAST: boolean;
  71910. COLORCURVES: boolean;
  71911. COLORGRADING: boolean;
  71912. COLORGRADING3D: boolean;
  71913. SAMPLER3DGREENDEPTH: boolean;
  71914. SAMPLER3DBGRMAP: boolean;
  71915. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71916. EXPOSURE: boolean;
  71917. constructor();
  71918. }
  71919. /**
  71920. * This groups together the common properties used for image processing either in direct forward pass
  71921. * or through post processing effect depending on the use of the image processing pipeline in your scene
  71922. * or not.
  71923. */
  71924. export class ImageProcessingConfiguration {
  71925. /**
  71926. * Default tone mapping applied in BabylonJS.
  71927. */
  71928. static readonly TONEMAPPING_STANDARD: number;
  71929. /**
  71930. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  71931. * to other engines rendering to increase portability.
  71932. */
  71933. static readonly TONEMAPPING_ACES: number;
  71934. /**
  71935. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  71936. */
  71937. colorCurves: Nullable<ColorCurves>;
  71938. private _colorCurvesEnabled;
  71939. /**
  71940. * Gets wether the color curves effect is enabled.
  71941. */
  71942. /**
  71943. * Sets wether the color curves effect is enabled.
  71944. */
  71945. colorCurvesEnabled: boolean;
  71946. private _colorGradingTexture;
  71947. /**
  71948. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71949. */
  71950. /**
  71951. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71952. */
  71953. colorGradingTexture: Nullable<BaseTexture>;
  71954. private _colorGradingEnabled;
  71955. /**
  71956. * Gets wether the color grading effect is enabled.
  71957. */
  71958. /**
  71959. * Sets wether the color grading effect is enabled.
  71960. */
  71961. colorGradingEnabled: boolean;
  71962. private _colorGradingWithGreenDepth;
  71963. /**
  71964. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  71965. */
  71966. /**
  71967. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  71968. */
  71969. colorGradingWithGreenDepth: boolean;
  71970. private _colorGradingBGR;
  71971. /**
  71972. * Gets wether the color grading texture contains BGR values.
  71973. */
  71974. /**
  71975. * Sets wether the color grading texture contains BGR values.
  71976. */
  71977. colorGradingBGR: boolean;
  71978. /** @hidden */
  71979. _exposure: number;
  71980. /**
  71981. * Gets the Exposure used in the effect.
  71982. */
  71983. /**
  71984. * Sets the Exposure used in the effect.
  71985. */
  71986. exposure: number;
  71987. private _toneMappingEnabled;
  71988. /**
  71989. * Gets wether the tone mapping effect is enabled.
  71990. */
  71991. /**
  71992. * Sets wether the tone mapping effect is enabled.
  71993. */
  71994. toneMappingEnabled: boolean;
  71995. private _toneMappingType;
  71996. /**
  71997. * Gets the type of tone mapping effect.
  71998. */
  71999. /**
  72000. * Sets the type of tone mapping effect used in BabylonJS.
  72001. */
  72002. toneMappingType: number;
  72003. protected _contrast: number;
  72004. /**
  72005. * Gets the contrast used in the effect.
  72006. */
  72007. /**
  72008. * Sets the contrast used in the effect.
  72009. */
  72010. contrast: number;
  72011. /**
  72012. * Vignette stretch size.
  72013. */
  72014. vignetteStretch: number;
  72015. /**
  72016. * Vignette centre X Offset.
  72017. */
  72018. vignetteCentreX: number;
  72019. /**
  72020. * Vignette centre Y Offset.
  72021. */
  72022. vignetteCentreY: number;
  72023. /**
  72024. * Vignette weight or intensity of the vignette effect.
  72025. */
  72026. vignetteWeight: number;
  72027. /**
  72028. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  72029. * if vignetteEnabled is set to true.
  72030. */
  72031. vignetteColor: Color4;
  72032. /**
  72033. * Camera field of view used by the Vignette effect.
  72034. */
  72035. vignetteCameraFov: number;
  72036. private _vignetteBlendMode;
  72037. /**
  72038. * Gets the vignette blend mode allowing different kind of effect.
  72039. */
  72040. /**
  72041. * Sets the vignette blend mode allowing different kind of effect.
  72042. */
  72043. vignetteBlendMode: number;
  72044. private _vignetteEnabled;
  72045. /**
  72046. * Gets wether the vignette effect is enabled.
  72047. */
  72048. /**
  72049. * Sets wether the vignette effect is enabled.
  72050. */
  72051. vignetteEnabled: boolean;
  72052. private _applyByPostProcess;
  72053. /**
  72054. * Gets wether the image processing is applied through a post process or not.
  72055. */
  72056. /**
  72057. * Sets wether the image processing is applied through a post process or not.
  72058. */
  72059. applyByPostProcess: boolean;
  72060. private _isEnabled;
  72061. /**
  72062. * Gets wether the image processing is enabled or not.
  72063. */
  72064. /**
  72065. * Sets wether the image processing is enabled or not.
  72066. */
  72067. isEnabled: boolean;
  72068. /**
  72069. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  72070. */
  72071. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  72072. /**
  72073. * Method called each time the image processing information changes requires to recompile the effect.
  72074. */
  72075. protected _updateParameters(): void;
  72076. /**
  72077. * Gets the current class name.
  72078. * @return "ImageProcessingConfiguration"
  72079. */
  72080. getClassName(): string;
  72081. /**
  72082. * Prepare the list of uniforms associated with the Image Processing effects.
  72083. * @param uniforms The list of uniforms used in the effect
  72084. * @param defines the list of defines currently in use
  72085. */
  72086. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  72087. /**
  72088. * Prepare the list of samplers associated with the Image Processing effects.
  72089. * @param samplersList The list of uniforms used in the effect
  72090. * @param defines the list of defines currently in use
  72091. */
  72092. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  72093. /**
  72094. * Prepare the list of defines associated to the shader.
  72095. * @param defines the list of defines to complete
  72096. * @param forPostProcess Define if we are currently in post process mode or not
  72097. */
  72098. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  72099. /**
  72100. * Returns true if all the image processing information are ready.
  72101. * @returns True if ready, otherwise, false
  72102. */
  72103. isReady(): boolean;
  72104. /**
  72105. * Binds the image processing to the shader.
  72106. * @param effect The effect to bind to
  72107. * @param aspectRatio Define the current aspect ratio of the effect
  72108. */
  72109. bind(effect: Effect, aspectRatio?: number): void;
  72110. /**
  72111. * Clones the current image processing instance.
  72112. * @return The cloned image processing
  72113. */
  72114. clone(): ImageProcessingConfiguration;
  72115. /**
  72116. * Serializes the current image processing instance to a json representation.
  72117. * @return a JSON representation
  72118. */
  72119. serialize(): any;
  72120. /**
  72121. * Parses the image processing from a json representation.
  72122. * @param source the JSON source to parse
  72123. * @return The parsed image processing
  72124. */
  72125. static Parse(source: any): ImageProcessingConfiguration;
  72126. private static _VIGNETTEMODE_MULTIPLY;
  72127. private static _VIGNETTEMODE_OPAQUE;
  72128. /**
  72129. * Used to apply the vignette as a mix with the pixel color.
  72130. */
  72131. static readonly VIGNETTEMODE_MULTIPLY: number;
  72132. /**
  72133. * Used to apply the vignette as a replacement of the pixel color.
  72134. */
  72135. static readonly VIGNETTEMODE_OPAQUE: number;
  72136. }
  72137. }
  72138. declare module BABYLON {
  72139. /** @hidden */
  72140. export var postprocessVertexShader: {
  72141. name: string;
  72142. shader: string;
  72143. };
  72144. }
  72145. declare module BABYLON {
  72146. /** Defines supported spaces */
  72147. export enum Space {
  72148. /** Local (object) space */
  72149. LOCAL = 0,
  72150. /** World space */
  72151. WORLD = 1,
  72152. /** Bone space */
  72153. BONE = 2
  72154. }
  72155. /** Defines the 3 main axes */
  72156. export class Axis {
  72157. /** X axis */
  72158. static X: Vector3;
  72159. /** Y axis */
  72160. static Y: Vector3;
  72161. /** Z axis */
  72162. static Z: Vector3;
  72163. }
  72164. }
  72165. declare module BABYLON {
  72166. /**
  72167. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  72168. * This is the base of the follow, arc rotate cameras and Free camera
  72169. * @see http://doc.babylonjs.com/features/cameras
  72170. */
  72171. export class TargetCamera extends Camera {
  72172. private static _RigCamTransformMatrix;
  72173. private static _TargetTransformMatrix;
  72174. private static _TargetFocalPoint;
  72175. /**
  72176. * Define the current direction the camera is moving to
  72177. */
  72178. cameraDirection: Vector3;
  72179. /**
  72180. * Define the current rotation the camera is rotating to
  72181. */
  72182. cameraRotation: Vector2;
  72183. /**
  72184. * When set, the up vector of the camera will be updated by the rotation of the camera
  72185. */
  72186. updateUpVectorFromRotation: boolean;
  72187. private _tmpQuaternion;
  72188. /**
  72189. * Define the current rotation of the camera
  72190. */
  72191. rotation: Vector3;
  72192. /**
  72193. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  72194. */
  72195. rotationQuaternion: Quaternion;
  72196. /**
  72197. * Define the current speed of the camera
  72198. */
  72199. speed: number;
  72200. /**
  72201. * Add cconstraint to the camera to prevent it to move freely in all directions and
  72202. * around all axis.
  72203. */
  72204. noRotationConstraint: boolean;
  72205. /**
  72206. * Define the current target of the camera as an object or a position.
  72207. */
  72208. lockedTarget: any;
  72209. /** @hidden */
  72210. _currentTarget: Vector3;
  72211. /** @hidden */
  72212. _initialFocalDistance: number;
  72213. /** @hidden */
  72214. _viewMatrix: Matrix;
  72215. /** @hidden */
  72216. _camMatrix: Matrix;
  72217. /** @hidden */
  72218. _cameraTransformMatrix: Matrix;
  72219. /** @hidden */
  72220. _cameraRotationMatrix: Matrix;
  72221. /** @hidden */
  72222. _referencePoint: Vector3;
  72223. /** @hidden */
  72224. _transformedReferencePoint: Vector3;
  72225. protected _globalCurrentTarget: Vector3;
  72226. protected _globalCurrentUpVector: Vector3;
  72227. /** @hidden */
  72228. _reset: () => void;
  72229. private _defaultUp;
  72230. /**
  72231. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  72232. * This is the base of the follow, arc rotate cameras and Free camera
  72233. * @see http://doc.babylonjs.com/features/cameras
  72234. * @param name Defines the name of the camera in the scene
  72235. * @param position Defines the start position of the camera in the scene
  72236. * @param scene Defines the scene the camera belongs to
  72237. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72238. */
  72239. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72240. /**
  72241. * Gets the position in front of the camera at a given distance.
  72242. * @param distance The distance from the camera we want the position to be
  72243. * @returns the position
  72244. */
  72245. getFrontPosition(distance: number): Vector3;
  72246. /** @hidden */
  72247. _getLockedTargetPosition(): Nullable<Vector3>;
  72248. private _storedPosition;
  72249. private _storedRotation;
  72250. private _storedRotationQuaternion;
  72251. /**
  72252. * Store current camera state of the camera (fov, position, rotation, etc..)
  72253. * @returns the camera
  72254. */
  72255. storeState(): Camera;
  72256. /**
  72257. * Restored camera state. You must call storeState() first
  72258. * @returns whether it was successful or not
  72259. * @hidden
  72260. */
  72261. _restoreStateValues(): boolean;
  72262. /** @hidden */
  72263. _initCache(): void;
  72264. /** @hidden */
  72265. _updateCache(ignoreParentClass?: boolean): void;
  72266. /** @hidden */
  72267. _isSynchronizedViewMatrix(): boolean;
  72268. /** @hidden */
  72269. _computeLocalCameraSpeed(): number;
  72270. /**
  72271. * Defines the target the camera should look at.
  72272. * @param target Defines the new target as a Vector or a mesh
  72273. */
  72274. setTarget(target: Vector3): void;
  72275. /**
  72276. * Return the current target position of the camera. This value is expressed in local space.
  72277. * @returns the target position
  72278. */
  72279. getTarget(): Vector3;
  72280. /** @hidden */
  72281. _decideIfNeedsToMove(): boolean;
  72282. /** @hidden */
  72283. _updatePosition(): void;
  72284. /** @hidden */
  72285. _checkInputs(): void;
  72286. protected _updateCameraRotationMatrix(): void;
  72287. /**
  72288. * 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)
  72289. * @returns the current camera
  72290. */
  72291. private _rotateUpVectorWithCameraRotationMatrix;
  72292. private _cachedRotationZ;
  72293. private _cachedQuaternionRotationZ;
  72294. /** @hidden */
  72295. _getViewMatrix(): Matrix;
  72296. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  72297. /**
  72298. * @hidden
  72299. */
  72300. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  72301. /**
  72302. * @hidden
  72303. */
  72304. _updateRigCameras(): void;
  72305. private _getRigCamPositionAndTarget;
  72306. /**
  72307. * Gets the current object class name.
  72308. * @return the class name
  72309. */
  72310. getClassName(): string;
  72311. }
  72312. }
  72313. declare module BABYLON {
  72314. /**
  72315. * Gather the list of keyboard event types as constants.
  72316. */
  72317. export class KeyboardEventTypes {
  72318. /**
  72319. * The keydown event is fired when a key becomes active (pressed).
  72320. */
  72321. static readonly KEYDOWN: number;
  72322. /**
  72323. * The keyup event is fired when a key has been released.
  72324. */
  72325. static readonly KEYUP: number;
  72326. }
  72327. /**
  72328. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72329. */
  72330. export class KeyboardInfo {
  72331. /**
  72332. * Defines the type of event (KeyboardEventTypes)
  72333. */
  72334. type: number;
  72335. /**
  72336. * Defines the related dom event
  72337. */
  72338. event: KeyboardEvent;
  72339. /**
  72340. * Instantiates a new keyboard info.
  72341. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72342. * @param type Defines the type of event (KeyboardEventTypes)
  72343. * @param event Defines the related dom event
  72344. */
  72345. constructor(
  72346. /**
  72347. * Defines the type of event (KeyboardEventTypes)
  72348. */
  72349. type: number,
  72350. /**
  72351. * Defines the related dom event
  72352. */
  72353. event: KeyboardEvent);
  72354. }
  72355. /**
  72356. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72357. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  72358. */
  72359. export class KeyboardInfoPre extends KeyboardInfo {
  72360. /**
  72361. * Defines the type of event (KeyboardEventTypes)
  72362. */
  72363. type: number;
  72364. /**
  72365. * Defines the related dom event
  72366. */
  72367. event: KeyboardEvent;
  72368. /**
  72369. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  72370. */
  72371. skipOnPointerObservable: boolean;
  72372. /**
  72373. * Instantiates a new keyboard pre info.
  72374. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72375. * @param type Defines the type of event (KeyboardEventTypes)
  72376. * @param event Defines the related dom event
  72377. */
  72378. constructor(
  72379. /**
  72380. * Defines the type of event (KeyboardEventTypes)
  72381. */
  72382. type: number,
  72383. /**
  72384. * Defines the related dom event
  72385. */
  72386. event: KeyboardEvent);
  72387. }
  72388. }
  72389. declare module BABYLON {
  72390. /**
  72391. * Manage the keyboard inputs to control the movement of a free camera.
  72392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72393. */
  72394. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  72395. /**
  72396. * Defines the camera the input is attached to.
  72397. */
  72398. camera: FreeCamera;
  72399. /**
  72400. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72401. */
  72402. keysUp: number[];
  72403. /**
  72404. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72405. */
  72406. keysDown: number[];
  72407. /**
  72408. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72409. */
  72410. keysLeft: number[];
  72411. /**
  72412. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72413. */
  72414. keysRight: number[];
  72415. private _keys;
  72416. private _onCanvasBlurObserver;
  72417. private _onKeyboardObserver;
  72418. private _engine;
  72419. private _scene;
  72420. /**
  72421. * Attach the input controls to a specific dom element to get the input from.
  72422. * @param element Defines the element the controls should be listened from
  72423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72424. */
  72425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72426. /**
  72427. * Detach the current controls from the specified dom element.
  72428. * @param element Defines the element to stop listening the inputs from
  72429. */
  72430. detachControl(element: Nullable<HTMLElement>): void;
  72431. /**
  72432. * Update the current camera state depending on the inputs that have been used this frame.
  72433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72434. */
  72435. checkInputs(): void;
  72436. /**
  72437. * Gets the class name of the current intput.
  72438. * @returns the class name
  72439. */
  72440. getClassName(): string;
  72441. /** @hidden */
  72442. _onLostFocus(): void;
  72443. /**
  72444. * Get the friendly name associated with the input class.
  72445. * @returns the input friendly name
  72446. */
  72447. getSimpleName(): string;
  72448. }
  72449. }
  72450. declare module BABYLON {
  72451. /**
  72452. * Interface describing all the common properties and methods a shadow light needs to implement.
  72453. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  72454. * as well as binding the different shadow properties to the effects.
  72455. */
  72456. export interface IShadowLight extends Light {
  72457. /**
  72458. * The light id in the scene (used in scene.findLighById for instance)
  72459. */
  72460. id: string;
  72461. /**
  72462. * The position the shdow will be casted from.
  72463. */
  72464. position: Vector3;
  72465. /**
  72466. * In 2d mode (needCube being false), the direction used to cast the shadow.
  72467. */
  72468. direction: Vector3;
  72469. /**
  72470. * The transformed position. Position of the light in world space taking parenting in account.
  72471. */
  72472. transformedPosition: Vector3;
  72473. /**
  72474. * The transformed direction. Direction of the light in world space taking parenting in account.
  72475. */
  72476. transformedDirection: Vector3;
  72477. /**
  72478. * The friendly name of the light in the scene.
  72479. */
  72480. name: string;
  72481. /**
  72482. * Defines the shadow projection clipping minimum z value.
  72483. */
  72484. shadowMinZ: number;
  72485. /**
  72486. * Defines the shadow projection clipping maximum z value.
  72487. */
  72488. shadowMaxZ: number;
  72489. /**
  72490. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72491. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72492. */
  72493. computeTransformedInformation(): boolean;
  72494. /**
  72495. * Gets the scene the light belongs to.
  72496. * @returns The scene
  72497. */
  72498. getScene(): Scene;
  72499. /**
  72500. * Callback defining a custom Projection Matrix Builder.
  72501. * This can be used to override the default projection matrix computation.
  72502. */
  72503. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72504. /**
  72505. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72506. * @param matrix The materix to updated with the projection information
  72507. * @param viewMatrix The transform matrix of the light
  72508. * @param renderList The list of mesh to render in the map
  72509. * @returns The current light
  72510. */
  72511. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72512. /**
  72513. * Gets the current depth scale used in ESM.
  72514. * @returns The scale
  72515. */
  72516. getDepthScale(): number;
  72517. /**
  72518. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72519. * @returns true if a cube texture needs to be use
  72520. */
  72521. needCube(): boolean;
  72522. /**
  72523. * Detects if the projection matrix requires to be recomputed this frame.
  72524. * @returns true if it requires to be recomputed otherwise, false.
  72525. */
  72526. needProjectionMatrixCompute(): boolean;
  72527. /**
  72528. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72529. */
  72530. forceProjectionMatrixCompute(): void;
  72531. /**
  72532. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72533. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72534. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72535. */
  72536. getShadowDirection(faceIndex?: number): Vector3;
  72537. /**
  72538. * Gets the minZ used for shadow according to both the scene and the light.
  72539. * @param activeCamera The camera we are returning the min for
  72540. * @returns the depth min z
  72541. */
  72542. getDepthMinZ(activeCamera: Camera): number;
  72543. /**
  72544. * Gets the maxZ used for shadow according to both the scene and the light.
  72545. * @param activeCamera The camera we are returning the max for
  72546. * @returns the depth max z
  72547. */
  72548. getDepthMaxZ(activeCamera: Camera): number;
  72549. }
  72550. /**
  72551. * Base implementation IShadowLight
  72552. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  72553. */
  72554. export abstract class ShadowLight extends Light implements IShadowLight {
  72555. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  72556. protected _position: Vector3;
  72557. protected _setPosition(value: Vector3): void;
  72558. /**
  72559. * Sets the position the shadow will be casted from. Also use as the light position for both
  72560. * point and spot lights.
  72561. */
  72562. /**
  72563. * Sets the position the shadow will be casted from. Also use as the light position for both
  72564. * point and spot lights.
  72565. */
  72566. position: Vector3;
  72567. protected _direction: Vector3;
  72568. protected _setDirection(value: Vector3): void;
  72569. /**
  72570. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  72571. * Also use as the light direction on spot and directional lights.
  72572. */
  72573. /**
  72574. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  72575. * Also use as the light direction on spot and directional lights.
  72576. */
  72577. direction: Vector3;
  72578. private _shadowMinZ;
  72579. /**
  72580. * Gets the shadow projection clipping minimum z value.
  72581. */
  72582. /**
  72583. * Sets the shadow projection clipping minimum z value.
  72584. */
  72585. shadowMinZ: number;
  72586. private _shadowMaxZ;
  72587. /**
  72588. * Sets the shadow projection clipping maximum z value.
  72589. */
  72590. /**
  72591. * Gets the shadow projection clipping maximum z value.
  72592. */
  72593. shadowMaxZ: number;
  72594. /**
  72595. * Callback defining a custom Projection Matrix Builder.
  72596. * This can be used to override the default projection matrix computation.
  72597. */
  72598. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72599. /**
  72600. * The transformed position. Position of the light in world space taking parenting in account.
  72601. */
  72602. transformedPosition: Vector3;
  72603. /**
  72604. * The transformed direction. Direction of the light in world space taking parenting in account.
  72605. */
  72606. transformedDirection: Vector3;
  72607. private _needProjectionMatrixCompute;
  72608. /**
  72609. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72610. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72611. */
  72612. computeTransformedInformation(): boolean;
  72613. /**
  72614. * Return the depth scale used for the shadow map.
  72615. * @returns the depth scale.
  72616. */
  72617. getDepthScale(): number;
  72618. /**
  72619. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72620. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72621. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72622. */
  72623. getShadowDirection(faceIndex?: number): Vector3;
  72624. /**
  72625. * Returns the ShadowLight absolute position in the World.
  72626. * @returns the position vector in world space
  72627. */
  72628. getAbsolutePosition(): Vector3;
  72629. /**
  72630. * Sets the ShadowLight direction toward the passed target.
  72631. * @param target The point to target in local space
  72632. * @returns the updated ShadowLight direction
  72633. */
  72634. setDirectionToTarget(target: Vector3): Vector3;
  72635. /**
  72636. * Returns the light rotation in euler definition.
  72637. * @returns the x y z rotation in local space.
  72638. */
  72639. getRotation(): Vector3;
  72640. /**
  72641. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72642. * @returns true if a cube texture needs to be use
  72643. */
  72644. needCube(): boolean;
  72645. /**
  72646. * Detects if the projection matrix requires to be recomputed this frame.
  72647. * @returns true if it requires to be recomputed otherwise, false.
  72648. */
  72649. needProjectionMatrixCompute(): boolean;
  72650. /**
  72651. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72652. */
  72653. forceProjectionMatrixCompute(): void;
  72654. /** @hidden */
  72655. _initCache(): void;
  72656. /** @hidden */
  72657. _isSynchronized(): boolean;
  72658. /**
  72659. * Computes the world matrix of the node
  72660. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72661. * @returns the world matrix
  72662. */
  72663. computeWorldMatrix(force?: boolean): Matrix;
  72664. /**
  72665. * Gets the minZ used for shadow according to both the scene and the light.
  72666. * @param activeCamera The camera we are returning the min for
  72667. * @returns the depth min z
  72668. */
  72669. getDepthMinZ(activeCamera: Camera): number;
  72670. /**
  72671. * Gets the maxZ used for shadow according to both the scene and the light.
  72672. * @param activeCamera The camera we are returning the max for
  72673. * @returns the depth max z
  72674. */
  72675. getDepthMaxZ(activeCamera: Camera): number;
  72676. /**
  72677. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72678. * @param matrix The materix to updated with the projection information
  72679. * @param viewMatrix The transform matrix of the light
  72680. * @param renderList The list of mesh to render in the map
  72681. * @returns The current light
  72682. */
  72683. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72684. }
  72685. }
  72686. declare module BABYLON {
  72687. /**
  72688. * "Static Class" containing the most commonly used helper while dealing with material for
  72689. * rendering purpose.
  72690. *
  72691. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  72692. *
  72693. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  72694. */
  72695. export class MaterialHelper {
  72696. /**
  72697. * Bind the current view position to an effect.
  72698. * @param effect The effect to be bound
  72699. * @param scene The scene the eyes position is used from
  72700. */
  72701. static BindEyePosition(effect: Effect, scene: Scene): void;
  72702. /**
  72703. * Helps preparing the defines values about the UVs in used in the effect.
  72704. * UVs are shared as much as we can accross channels in the shaders.
  72705. * @param texture The texture we are preparing the UVs for
  72706. * @param defines The defines to update
  72707. * @param key The channel key "diffuse", "specular"... used in the shader
  72708. */
  72709. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  72710. /**
  72711. * Binds a texture matrix value to its corrsponding uniform
  72712. * @param texture The texture to bind the matrix for
  72713. * @param uniformBuffer The uniform buffer receivin the data
  72714. * @param key The channel key "diffuse", "specular"... used in the shader
  72715. */
  72716. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  72717. /**
  72718. * Gets the current status of the fog (should it be enabled?)
  72719. * @param mesh defines the mesh to evaluate for fog support
  72720. * @param scene defines the hosting scene
  72721. * @returns true if fog must be enabled
  72722. */
  72723. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  72724. /**
  72725. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  72726. * @param mesh defines the current mesh
  72727. * @param scene defines the current scene
  72728. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  72729. * @param pointsCloud defines if point cloud rendering has to be turned on
  72730. * @param fogEnabled defines if fog has to be turned on
  72731. * @param alphaTest defines if alpha testing has to be turned on
  72732. * @param defines defines the current list of defines
  72733. */
  72734. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  72735. /**
  72736. * Helper used to prepare the list of defines associated with frame values for shader compilation
  72737. * @param scene defines the current scene
  72738. * @param engine defines the current engine
  72739. * @param defines specifies the list of active defines
  72740. * @param useInstances defines if instances have to be turned on
  72741. * @param useClipPlane defines if clip plane have to be turned on
  72742. */
  72743. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  72744. /**
  72745. * Prepares the defines for bones
  72746. * @param mesh The mesh containing the geometry data we will draw
  72747. * @param defines The defines to update
  72748. */
  72749. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  72750. /**
  72751. * Prepares the defines for morph targets
  72752. * @param mesh The mesh containing the geometry data we will draw
  72753. * @param defines The defines to update
  72754. */
  72755. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  72756. /**
  72757. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  72758. * @param mesh The mesh containing the geometry data we will draw
  72759. * @param defines The defines to update
  72760. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  72761. * @param useBones Precise whether bones should be used or not (override mesh info)
  72762. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  72763. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  72764. * @returns false if defines are considered not dirty and have not been checked
  72765. */
  72766. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  72767. /**
  72768. * Prepares the defines related to multiview
  72769. * @param scene The scene we are intending to draw
  72770. * @param defines The defines to update
  72771. */
  72772. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  72773. /**
  72774. * Prepares the defines related to the light information passed in parameter
  72775. * @param scene The scene we are intending to draw
  72776. * @param mesh The mesh the effect is compiling for
  72777. * @param light The light the effect is compiling for
  72778. * @param lightIndex The index of the light
  72779. * @param defines The defines to update
  72780. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72781. * @param state Defines the current state regarding what is needed (normals, etc...)
  72782. */
  72783. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  72784. needNormals: boolean;
  72785. needRebuild: boolean;
  72786. shadowEnabled: boolean;
  72787. specularEnabled: boolean;
  72788. lightmapMode: boolean;
  72789. }): void;
  72790. /**
  72791. * Prepares the defines related to the light information passed in parameter
  72792. * @param scene The scene we are intending to draw
  72793. * @param mesh The mesh the effect is compiling for
  72794. * @param defines The defines to update
  72795. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72796. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  72797. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  72798. * @returns true if normals will be required for the rest of the effect
  72799. */
  72800. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  72801. /**
  72802. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  72803. * @param lightIndex defines the light index
  72804. * @param uniformsList The uniform list
  72805. * @param samplersList The sampler list
  72806. * @param projectedLightTexture defines if projected texture must be used
  72807. * @param uniformBuffersList defines an optional list of uniform buffers
  72808. */
  72809. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  72810. /**
  72811. * Prepares the uniforms and samplers list to be used in the effect
  72812. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  72813. * @param samplersList The sampler list
  72814. * @param defines The defines helping in the list generation
  72815. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  72816. */
  72817. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  72818. /**
  72819. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  72820. * @param defines The defines to update while falling back
  72821. * @param fallbacks The authorized effect fallbacks
  72822. * @param maxSimultaneousLights The maximum number of lights allowed
  72823. * @param rank the current rank of the Effect
  72824. * @returns The newly affected rank
  72825. */
  72826. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  72827. private static _TmpMorphInfluencers;
  72828. /**
  72829. * Prepares the list of attributes required for morph targets according to the effect defines.
  72830. * @param attribs The current list of supported attribs
  72831. * @param mesh The mesh to prepare the morph targets attributes for
  72832. * @param influencers The number of influencers
  72833. */
  72834. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  72835. /**
  72836. * Prepares the list of attributes required for morph targets according to the effect defines.
  72837. * @param attribs The current list of supported attribs
  72838. * @param mesh The mesh to prepare the morph targets attributes for
  72839. * @param defines The current Defines of the effect
  72840. */
  72841. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  72842. /**
  72843. * Prepares the list of attributes required for bones according to the effect defines.
  72844. * @param attribs The current list of supported attribs
  72845. * @param mesh The mesh to prepare the bones attributes for
  72846. * @param defines The current Defines of the effect
  72847. * @param fallbacks The current efffect fallback strategy
  72848. */
  72849. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  72850. /**
  72851. * Check and prepare the list of attributes required for instances according to the effect defines.
  72852. * @param attribs The current list of supported attribs
  72853. * @param defines The current MaterialDefines of the effect
  72854. */
  72855. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  72856. /**
  72857. * Add the list of attributes required for instances to the attribs array.
  72858. * @param attribs The current list of supported attribs
  72859. */
  72860. static PushAttributesForInstances(attribs: string[]): void;
  72861. /**
  72862. * Binds the light shadow information to the effect for the given mesh.
  72863. * @param light The light containing the generator
  72864. * @param scene The scene the lights belongs to
  72865. * @param mesh The mesh we are binding the information to render
  72866. * @param lightIndex The light index in the effect used to render the mesh
  72867. * @param effect The effect we are binding the data to
  72868. */
  72869. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  72870. /**
  72871. * Binds the light information to the effect.
  72872. * @param light The light containing the generator
  72873. * @param effect The effect we are binding the data to
  72874. * @param lightIndex The light index in the effect used to render
  72875. */
  72876. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  72877. /**
  72878. * Binds the lights information from the scene to the effect for the given mesh.
  72879. * @param light Light to bind
  72880. * @param lightIndex Light index
  72881. * @param scene The scene where the light belongs to
  72882. * @param mesh The mesh we are binding the information to render
  72883. * @param effect The effect we are binding the data to
  72884. * @param useSpecular Defines if specular is supported
  72885. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72886. */
  72887. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  72888. /**
  72889. * Binds the lights information from the scene to the effect for the given mesh.
  72890. * @param scene The scene the lights belongs to
  72891. * @param mesh The mesh we are binding the information to render
  72892. * @param effect The effect we are binding the data to
  72893. * @param defines The generated defines for the effect
  72894. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  72895. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72896. */
  72897. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  72898. private static _tempFogColor;
  72899. /**
  72900. * Binds the fog information from the scene to the effect for the given mesh.
  72901. * @param scene The scene the lights belongs to
  72902. * @param mesh The mesh we are binding the information to render
  72903. * @param effect The effect we are binding the data to
  72904. * @param linearSpace Defines if the fog effect is applied in linear space
  72905. */
  72906. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  72907. /**
  72908. * Binds the bones information from the mesh to the effect.
  72909. * @param mesh The mesh we are binding the information to render
  72910. * @param effect The effect we are binding the data to
  72911. */
  72912. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  72913. /**
  72914. * Binds the morph targets information from the mesh to the effect.
  72915. * @param abstractMesh The mesh we are binding the information to render
  72916. * @param effect The effect we are binding the data to
  72917. */
  72918. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  72919. /**
  72920. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  72921. * @param defines The generated defines used in the effect
  72922. * @param effect The effect we are binding the data to
  72923. * @param scene The scene we are willing to render with logarithmic scale for
  72924. */
  72925. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  72926. /**
  72927. * Binds the clip plane information from the scene to the effect.
  72928. * @param scene The scene the clip plane information are extracted from
  72929. * @param effect The effect we are binding the data to
  72930. */
  72931. static BindClipPlane(effect: Effect, scene: Scene): void;
  72932. }
  72933. }
  72934. declare module BABYLON {
  72935. /** @hidden */
  72936. export var packingFunctions: {
  72937. name: string;
  72938. shader: string;
  72939. };
  72940. }
  72941. declare module BABYLON {
  72942. /** @hidden */
  72943. export var shadowMapPixelShader: {
  72944. name: string;
  72945. shader: string;
  72946. };
  72947. }
  72948. declare module BABYLON {
  72949. /** @hidden */
  72950. export var bonesDeclaration: {
  72951. name: string;
  72952. shader: string;
  72953. };
  72954. }
  72955. declare module BABYLON {
  72956. /** @hidden */
  72957. export var morphTargetsVertexGlobalDeclaration: {
  72958. name: string;
  72959. shader: string;
  72960. };
  72961. }
  72962. declare module BABYLON {
  72963. /** @hidden */
  72964. export var morphTargetsVertexDeclaration: {
  72965. name: string;
  72966. shader: string;
  72967. };
  72968. }
  72969. declare module BABYLON {
  72970. /** @hidden */
  72971. export var instancesDeclaration: {
  72972. name: string;
  72973. shader: string;
  72974. };
  72975. }
  72976. declare module BABYLON {
  72977. /** @hidden */
  72978. export var helperFunctions: {
  72979. name: string;
  72980. shader: string;
  72981. };
  72982. }
  72983. declare module BABYLON {
  72984. /** @hidden */
  72985. export var morphTargetsVertex: {
  72986. name: string;
  72987. shader: string;
  72988. };
  72989. }
  72990. declare module BABYLON {
  72991. /** @hidden */
  72992. export var instancesVertex: {
  72993. name: string;
  72994. shader: string;
  72995. };
  72996. }
  72997. declare module BABYLON {
  72998. /** @hidden */
  72999. export var bonesVertex: {
  73000. name: string;
  73001. shader: string;
  73002. };
  73003. }
  73004. declare module BABYLON {
  73005. /** @hidden */
  73006. export var shadowMapVertexShader: {
  73007. name: string;
  73008. shader: string;
  73009. };
  73010. }
  73011. declare module BABYLON {
  73012. /** @hidden */
  73013. export var depthBoxBlurPixelShader: {
  73014. name: string;
  73015. shader: string;
  73016. };
  73017. }
  73018. declare module BABYLON {
  73019. /**
  73020. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73021. */
  73022. export interface ICustomShaderOptions {
  73023. /**
  73024. * Gets or sets the custom shader name to use
  73025. */
  73026. shaderName: string;
  73027. /**
  73028. * The list of attribute names used in the shader
  73029. */
  73030. attributes?: string[];
  73031. /**
  73032. * The list of unifrom names used in the shader
  73033. */
  73034. uniforms?: string[];
  73035. /**
  73036. * The list of sampler names used in the shader
  73037. */
  73038. samplers?: string[];
  73039. /**
  73040. * The list of defines used in the shader
  73041. */
  73042. defines?: string[];
  73043. }
  73044. /**
  73045. * Interface to implement to create a shadow generator compatible with BJS.
  73046. */
  73047. export interface IShadowGenerator {
  73048. /**
  73049. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73050. * @returns The render target texture if present otherwise, null
  73051. */
  73052. getShadowMap(): Nullable<RenderTargetTexture>;
  73053. /**
  73054. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73055. * @returns The render target texture if the shadow map is present otherwise, null
  73056. */
  73057. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73058. /**
  73059. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73060. * @param subMesh The submesh we want to render in the shadow map
  73061. * @param useInstances Defines wether will draw in the map using instances
  73062. * @returns true if ready otherwise, false
  73063. */
  73064. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73065. /**
  73066. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73067. * @param defines Defines of the material we want to update
  73068. * @param lightIndex Index of the light in the enabled light list of the material
  73069. */
  73070. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73071. /**
  73072. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73073. * defined in the generator but impacting the effect).
  73074. * It implies the unifroms available on the materials are the standard BJS ones.
  73075. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73076. * @param effect The effect we are binfing the information for
  73077. */
  73078. bindShadowLight(lightIndex: string, effect: Effect): void;
  73079. /**
  73080. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73081. * (eq to shadow prjection matrix * light transform matrix)
  73082. * @returns The transform matrix used to create the shadow map
  73083. */
  73084. getTransformMatrix(): Matrix;
  73085. /**
  73086. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73087. * Cube and 2D textures for instance.
  73088. */
  73089. recreateShadowMap(): void;
  73090. /**
  73091. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73092. * @param onCompiled Callback triggered at the and of the effects compilation
  73093. * @param options Sets of optional options forcing the compilation with different modes
  73094. */
  73095. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73096. useInstances: boolean;
  73097. }>): void;
  73098. /**
  73099. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73100. * @param options Sets of optional options forcing the compilation with different modes
  73101. * @returns A promise that resolves when the compilation completes
  73102. */
  73103. forceCompilationAsync(options?: Partial<{
  73104. useInstances: boolean;
  73105. }>): Promise<void>;
  73106. /**
  73107. * Serializes the shadow generator setup to a json object.
  73108. * @returns The serialized JSON object
  73109. */
  73110. serialize(): any;
  73111. /**
  73112. * Disposes the Shadow map and related Textures and effects.
  73113. */
  73114. dispose(): void;
  73115. }
  73116. /**
  73117. * Default implementation IShadowGenerator.
  73118. * This is the main object responsible of generating shadows in the framework.
  73119. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73120. */
  73121. export class ShadowGenerator implements IShadowGenerator {
  73122. /**
  73123. * Shadow generator mode None: no filtering applied.
  73124. */
  73125. static readonly FILTER_NONE: number;
  73126. /**
  73127. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73128. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73129. */
  73130. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73131. /**
  73132. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73133. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73134. */
  73135. static readonly FILTER_POISSONSAMPLING: number;
  73136. /**
  73137. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73138. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73139. */
  73140. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73141. /**
  73142. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73143. * edge artifacts on steep falloff.
  73144. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73145. */
  73146. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73147. /**
  73148. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73149. * edge artifacts on steep falloff.
  73150. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73151. */
  73152. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73153. /**
  73154. * Shadow generator mode PCF: Percentage Closer Filtering
  73155. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73156. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73157. */
  73158. static readonly FILTER_PCF: number;
  73159. /**
  73160. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73161. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73162. * Contact Hardening
  73163. */
  73164. static readonly FILTER_PCSS: number;
  73165. /**
  73166. * Reserved for PCF and PCSS
  73167. * Highest Quality.
  73168. *
  73169. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73170. *
  73171. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73172. */
  73173. static readonly QUALITY_HIGH: number;
  73174. /**
  73175. * Reserved for PCF and PCSS
  73176. * Good tradeoff for quality/perf cross devices
  73177. *
  73178. * Execute PCF on a 3*3 kernel.
  73179. *
  73180. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73181. */
  73182. static readonly QUALITY_MEDIUM: number;
  73183. /**
  73184. * Reserved for PCF and PCSS
  73185. * The lowest quality but the fastest.
  73186. *
  73187. * Execute PCF on a 1*1 kernel.
  73188. *
  73189. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73190. */
  73191. static readonly QUALITY_LOW: number;
  73192. /** Gets or sets the custom shader name to use */
  73193. customShaderOptions: ICustomShaderOptions;
  73194. /**
  73195. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73196. */
  73197. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73198. /**
  73199. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73200. */
  73201. onAfterShadowMapRenderObservable: Observable<Effect>;
  73202. /**
  73203. * Observable triggered before a mesh is rendered in the shadow map.
  73204. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73205. */
  73206. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73207. /**
  73208. * Observable triggered after a mesh is rendered in the shadow map.
  73209. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73210. */
  73211. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73212. private _bias;
  73213. /**
  73214. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73215. */
  73216. /**
  73217. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73218. */
  73219. bias: number;
  73220. private _normalBias;
  73221. /**
  73222. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73223. */
  73224. /**
  73225. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73226. */
  73227. normalBias: number;
  73228. private _blurBoxOffset;
  73229. /**
  73230. * Gets the blur box offset: offset applied during the blur pass.
  73231. * Only useful if useKernelBlur = false
  73232. */
  73233. /**
  73234. * Sets the blur box offset: offset applied during the blur pass.
  73235. * Only useful if useKernelBlur = false
  73236. */
  73237. blurBoxOffset: number;
  73238. private _blurScale;
  73239. /**
  73240. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73241. * 2 means half of the size.
  73242. */
  73243. /**
  73244. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73245. * 2 means half of the size.
  73246. */
  73247. blurScale: number;
  73248. private _blurKernel;
  73249. /**
  73250. * Gets the blur kernel: kernel size of the blur pass.
  73251. * Only useful if useKernelBlur = true
  73252. */
  73253. /**
  73254. * Sets the blur kernel: kernel size of the blur pass.
  73255. * Only useful if useKernelBlur = true
  73256. */
  73257. blurKernel: number;
  73258. private _useKernelBlur;
  73259. /**
  73260. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73261. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73262. */
  73263. /**
  73264. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73265. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73266. */
  73267. useKernelBlur: boolean;
  73268. private _depthScale;
  73269. /**
  73270. * Gets the depth scale used in ESM mode.
  73271. */
  73272. /**
  73273. * Sets the depth scale used in ESM mode.
  73274. * This can override the scale stored on the light.
  73275. */
  73276. depthScale: number;
  73277. private _filter;
  73278. /**
  73279. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73280. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73281. */
  73282. /**
  73283. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  73284. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73285. */
  73286. filter: number;
  73287. /**
  73288. * Gets if the current filter is set to Poisson Sampling.
  73289. */
  73290. /**
  73291. * Sets the current filter to Poisson Sampling.
  73292. */
  73293. usePoissonSampling: boolean;
  73294. /**
  73295. * Gets if the current filter is set to ESM.
  73296. */
  73297. /**
  73298. * Sets the current filter is to ESM.
  73299. */
  73300. useExponentialShadowMap: boolean;
  73301. /**
  73302. * Gets if the current filter is set to filtered ESM.
  73303. */
  73304. /**
  73305. * Gets if the current filter is set to filtered ESM.
  73306. */
  73307. useBlurExponentialShadowMap: boolean;
  73308. /**
  73309. * Gets if the current filter is set to "close ESM" (using the inverse of the
  73310. * exponential to prevent steep falloff artifacts).
  73311. */
  73312. /**
  73313. * Sets the current filter to "close ESM" (using the inverse of the
  73314. * exponential to prevent steep falloff artifacts).
  73315. */
  73316. useCloseExponentialShadowMap: boolean;
  73317. /**
  73318. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  73319. * exponential to prevent steep falloff artifacts).
  73320. */
  73321. /**
  73322. * Sets the current filter to filtered "close ESM" (using the inverse of the
  73323. * exponential to prevent steep falloff artifacts).
  73324. */
  73325. useBlurCloseExponentialShadowMap: boolean;
  73326. /**
  73327. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  73328. */
  73329. /**
  73330. * Sets the current filter to "PCF" (percentage closer filtering).
  73331. */
  73332. usePercentageCloserFiltering: boolean;
  73333. private _filteringQuality;
  73334. /**
  73335. * Gets the PCF or PCSS Quality.
  73336. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73337. */
  73338. /**
  73339. * Sets the PCF or PCSS Quality.
  73340. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73341. */
  73342. filteringQuality: number;
  73343. /**
  73344. * Gets if the current filter is set to "PCSS" (contact hardening).
  73345. */
  73346. /**
  73347. * Sets the current filter to "PCSS" (contact hardening).
  73348. */
  73349. useContactHardeningShadow: boolean;
  73350. private _contactHardeningLightSizeUVRatio;
  73351. /**
  73352. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73353. * Using a ratio helps keeping shape stability independently of the map size.
  73354. *
  73355. * It does not account for the light projection as it was having too much
  73356. * instability during the light setup or during light position changes.
  73357. *
  73358. * Only valid if useContactHardeningShadow is true.
  73359. */
  73360. /**
  73361. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73362. * Using a ratio helps keeping shape stability independently of the map size.
  73363. *
  73364. * It does not account for the light projection as it was having too much
  73365. * instability during the light setup or during light position changes.
  73366. *
  73367. * Only valid if useContactHardeningShadow is true.
  73368. */
  73369. contactHardeningLightSizeUVRatio: number;
  73370. private _darkness;
  73371. /** Gets or sets the actual darkness of a shadow */
  73372. darkness: number;
  73373. /**
  73374. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  73375. * 0 means strongest and 1 would means no shadow.
  73376. * @returns the darkness.
  73377. */
  73378. getDarkness(): number;
  73379. /**
  73380. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  73381. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  73382. * @returns the shadow generator allowing fluent coding.
  73383. */
  73384. setDarkness(darkness: number): ShadowGenerator;
  73385. private _transparencyShadow;
  73386. /** Gets or sets the ability to have transparent shadow */
  73387. transparencyShadow: boolean;
  73388. /**
  73389. * Sets the ability to have transparent shadow (boolean).
  73390. * @param transparent True if transparent else False
  73391. * @returns the shadow generator allowing fluent coding
  73392. */
  73393. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  73394. private _shadowMap;
  73395. private _shadowMap2;
  73396. /**
  73397. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73398. * @returns The render target texture if present otherwise, null
  73399. */
  73400. getShadowMap(): Nullable<RenderTargetTexture>;
  73401. /**
  73402. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73403. * @returns The render target texture if the shadow map is present otherwise, null
  73404. */
  73405. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73406. /**
  73407. * Gets the class name of that object
  73408. * @returns "ShadowGenerator"
  73409. */
  73410. getClassName(): string;
  73411. /**
  73412. * Helper function to add a mesh and its descendants to the list of shadow casters.
  73413. * @param mesh Mesh to add
  73414. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  73415. * @returns the Shadow Generator itself
  73416. */
  73417. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73418. /**
  73419. * Helper function to remove a mesh and its descendants from the list of shadow casters
  73420. * @param mesh Mesh to remove
  73421. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  73422. * @returns the Shadow Generator itself
  73423. */
  73424. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73425. /**
  73426. * Controls the extent to which the shadows fade out at the edge of the frustum
  73427. * Used only by directionals and spots
  73428. */
  73429. frustumEdgeFalloff: number;
  73430. private _light;
  73431. /**
  73432. * Returns the associated light object.
  73433. * @returns the light generating the shadow
  73434. */
  73435. getLight(): IShadowLight;
  73436. /**
  73437. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  73438. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  73439. * It might on the other hand introduce peter panning.
  73440. */
  73441. forceBackFacesOnly: boolean;
  73442. private _scene;
  73443. private _lightDirection;
  73444. private _effect;
  73445. private _viewMatrix;
  73446. private _projectionMatrix;
  73447. private _transformMatrix;
  73448. private _cachedPosition;
  73449. private _cachedDirection;
  73450. private _cachedDefines;
  73451. private _currentRenderID;
  73452. private _boxBlurPostprocess;
  73453. private _kernelBlurXPostprocess;
  73454. private _kernelBlurYPostprocess;
  73455. private _blurPostProcesses;
  73456. private _mapSize;
  73457. private _currentFaceIndex;
  73458. private _currentFaceIndexCache;
  73459. private _textureType;
  73460. private _defaultTextureMatrix;
  73461. /** @hidden */
  73462. static _SceneComponentInitialization: (scene: Scene) => void;
  73463. /**
  73464. * Creates a ShadowGenerator object.
  73465. * A ShadowGenerator is the required tool to use the shadows.
  73466. * Each light casting shadows needs to use its own ShadowGenerator.
  73467. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  73468. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  73469. * @param light The light object generating the shadows.
  73470. * @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.
  73471. */
  73472. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  73473. private _initializeGenerator;
  73474. private _initializeShadowMap;
  73475. private _initializeBlurRTTAndPostProcesses;
  73476. private _renderForShadowMap;
  73477. private _renderSubMeshForShadowMap;
  73478. private _applyFilterValues;
  73479. /**
  73480. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73481. * @param onCompiled Callback triggered at the and of the effects compilation
  73482. * @param options Sets of optional options forcing the compilation with different modes
  73483. */
  73484. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73485. useInstances: boolean;
  73486. }>): void;
  73487. /**
  73488. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73489. * @param options Sets of optional options forcing the compilation with different modes
  73490. * @returns A promise that resolves when the compilation completes
  73491. */
  73492. forceCompilationAsync(options?: Partial<{
  73493. useInstances: boolean;
  73494. }>): Promise<void>;
  73495. /**
  73496. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73497. * @param subMesh The submesh we want to render in the shadow map
  73498. * @param useInstances Defines wether will draw in the map using instances
  73499. * @returns true if ready otherwise, false
  73500. */
  73501. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73502. /**
  73503. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73504. * @param defines Defines of the material we want to update
  73505. * @param lightIndex Index of the light in the enabled light list of the material
  73506. */
  73507. prepareDefines(defines: any, lightIndex: number): void;
  73508. /**
  73509. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73510. * defined in the generator but impacting the effect).
  73511. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73512. * @param effect The effect we are binfing the information for
  73513. */
  73514. bindShadowLight(lightIndex: string, effect: Effect): void;
  73515. /**
  73516. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73517. * (eq to shadow prjection matrix * light transform matrix)
  73518. * @returns The transform matrix used to create the shadow map
  73519. */
  73520. getTransformMatrix(): Matrix;
  73521. /**
  73522. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73523. * Cube and 2D textures for instance.
  73524. */
  73525. recreateShadowMap(): void;
  73526. private _disposeBlurPostProcesses;
  73527. private _disposeRTTandPostProcesses;
  73528. /**
  73529. * Disposes the ShadowGenerator.
  73530. * Returns nothing.
  73531. */
  73532. dispose(): void;
  73533. /**
  73534. * Serializes the shadow generator setup to a json object.
  73535. * @returns The serialized JSON object
  73536. */
  73537. serialize(): any;
  73538. /**
  73539. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  73540. * @param parsedShadowGenerator The JSON object to parse
  73541. * @param scene The scene to create the shadow map for
  73542. * @returns The parsed shadow generator
  73543. */
  73544. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  73545. }
  73546. }
  73547. declare module BABYLON {
  73548. /**
  73549. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  73550. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  73551. * 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.
  73552. */
  73553. export abstract class Light extends Node {
  73554. /**
  73555. * Falloff Default: light is falling off following the material specification:
  73556. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  73557. */
  73558. static readonly FALLOFF_DEFAULT: number;
  73559. /**
  73560. * Falloff Physical: light is falling off following the inverse squared distance law.
  73561. */
  73562. static readonly FALLOFF_PHYSICAL: number;
  73563. /**
  73564. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  73565. * to enhance interoperability with other engines.
  73566. */
  73567. static readonly FALLOFF_GLTF: number;
  73568. /**
  73569. * Falloff Standard: light is falling off like in the standard material
  73570. * to enhance interoperability with other materials.
  73571. */
  73572. static readonly FALLOFF_STANDARD: number;
  73573. /**
  73574. * If every light affecting the material is in this lightmapMode,
  73575. * material.lightmapTexture adds or multiplies
  73576. * (depends on material.useLightmapAsShadowmap)
  73577. * after every other light calculations.
  73578. */
  73579. static readonly LIGHTMAP_DEFAULT: number;
  73580. /**
  73581. * material.lightmapTexture as only diffuse lighting from this light
  73582. * adds only specular lighting from this light
  73583. * adds dynamic shadows
  73584. */
  73585. static readonly LIGHTMAP_SPECULAR: number;
  73586. /**
  73587. * material.lightmapTexture as only lighting
  73588. * no light calculation from this light
  73589. * only adds dynamic shadows from this light
  73590. */
  73591. static readonly LIGHTMAP_SHADOWSONLY: number;
  73592. /**
  73593. * Each light type uses the default quantity according to its type:
  73594. * point/spot lights use luminous intensity
  73595. * directional lights use illuminance
  73596. */
  73597. static readonly INTENSITYMODE_AUTOMATIC: number;
  73598. /**
  73599. * lumen (lm)
  73600. */
  73601. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  73602. /**
  73603. * candela (lm/sr)
  73604. */
  73605. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  73606. /**
  73607. * lux (lm/m^2)
  73608. */
  73609. static readonly INTENSITYMODE_ILLUMINANCE: number;
  73610. /**
  73611. * nit (cd/m^2)
  73612. */
  73613. static readonly INTENSITYMODE_LUMINANCE: number;
  73614. /**
  73615. * Light type const id of the point light.
  73616. */
  73617. static readonly LIGHTTYPEID_POINTLIGHT: number;
  73618. /**
  73619. * Light type const id of the directional light.
  73620. */
  73621. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  73622. /**
  73623. * Light type const id of the spot light.
  73624. */
  73625. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  73626. /**
  73627. * Light type const id of the hemispheric light.
  73628. */
  73629. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  73630. /**
  73631. * Diffuse gives the basic color to an object.
  73632. */
  73633. diffuse: Color3;
  73634. /**
  73635. * Specular produces a highlight color on an object.
  73636. * Note: This is note affecting PBR materials.
  73637. */
  73638. specular: Color3;
  73639. /**
  73640. * Defines the falloff type for this light. This lets overrriding how punctual light are
  73641. * falling off base on range or angle.
  73642. * This can be set to any values in Light.FALLOFF_x.
  73643. *
  73644. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  73645. * other types of materials.
  73646. */
  73647. falloffType: number;
  73648. /**
  73649. * Strength of the light.
  73650. * Note: By default it is define in the framework own unit.
  73651. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  73652. */
  73653. intensity: number;
  73654. private _range;
  73655. protected _inverseSquaredRange: number;
  73656. /**
  73657. * Defines how far from the source the light is impacting in scene units.
  73658. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73659. */
  73660. /**
  73661. * Defines how far from the source the light is impacting in scene units.
  73662. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73663. */
  73664. range: number;
  73665. /**
  73666. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  73667. * of light.
  73668. */
  73669. private _photometricScale;
  73670. private _intensityMode;
  73671. /**
  73672. * Gets the photometric scale used to interpret the intensity.
  73673. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73674. */
  73675. /**
  73676. * Sets the photometric scale used to interpret the intensity.
  73677. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73678. */
  73679. intensityMode: number;
  73680. private _radius;
  73681. /**
  73682. * Gets the light radius used by PBR Materials to simulate soft area lights.
  73683. */
  73684. /**
  73685. * sets the light radius used by PBR Materials to simulate soft area lights.
  73686. */
  73687. radius: number;
  73688. private _renderPriority;
  73689. /**
  73690. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  73691. * exceeding the number allowed of the materials.
  73692. */
  73693. renderPriority: number;
  73694. private _shadowEnabled;
  73695. /**
  73696. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73697. * the current shadow generator.
  73698. */
  73699. /**
  73700. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73701. * the current shadow generator.
  73702. */
  73703. shadowEnabled: boolean;
  73704. private _includedOnlyMeshes;
  73705. /**
  73706. * Gets the only meshes impacted by this light.
  73707. */
  73708. /**
  73709. * Sets the only meshes impacted by this light.
  73710. */
  73711. includedOnlyMeshes: AbstractMesh[];
  73712. private _excludedMeshes;
  73713. /**
  73714. * Gets the meshes not impacted by this light.
  73715. */
  73716. /**
  73717. * Sets the meshes not impacted by this light.
  73718. */
  73719. excludedMeshes: AbstractMesh[];
  73720. private _excludeWithLayerMask;
  73721. /**
  73722. * Gets the layer id use to find what meshes are not impacted by the light.
  73723. * Inactive if 0
  73724. */
  73725. /**
  73726. * Sets the layer id use to find what meshes are not impacted by the light.
  73727. * Inactive if 0
  73728. */
  73729. excludeWithLayerMask: number;
  73730. private _includeOnlyWithLayerMask;
  73731. /**
  73732. * Gets the layer id use to find what meshes are impacted by the light.
  73733. * Inactive if 0
  73734. */
  73735. /**
  73736. * Sets the layer id use to find what meshes are impacted by the light.
  73737. * Inactive if 0
  73738. */
  73739. includeOnlyWithLayerMask: number;
  73740. private _lightmapMode;
  73741. /**
  73742. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  73743. */
  73744. /**
  73745. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  73746. */
  73747. lightmapMode: number;
  73748. /**
  73749. * Shadow generator associted to the light.
  73750. * @hidden Internal use only.
  73751. */
  73752. _shadowGenerator: Nullable<IShadowGenerator>;
  73753. /**
  73754. * @hidden Internal use only.
  73755. */
  73756. _excludedMeshesIds: string[];
  73757. /**
  73758. * @hidden Internal use only.
  73759. */
  73760. _includedOnlyMeshesIds: string[];
  73761. /**
  73762. * The current light unifom buffer.
  73763. * @hidden Internal use only.
  73764. */
  73765. _uniformBuffer: UniformBuffer;
  73766. /**
  73767. * Creates a Light object in the scene.
  73768. * Documentation : https://doc.babylonjs.com/babylon101/lights
  73769. * @param name The firendly name of the light
  73770. * @param scene The scene the light belongs too
  73771. */
  73772. constructor(name: string, scene: Scene);
  73773. protected abstract _buildUniformLayout(): void;
  73774. /**
  73775. * Sets the passed Effect "effect" with the Light information.
  73776. * @param effect The effect to update
  73777. * @param lightIndex The index of the light in the effect to update
  73778. * @returns The light
  73779. */
  73780. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  73781. /**
  73782. * Returns the string "Light".
  73783. * @returns the class name
  73784. */
  73785. getClassName(): string;
  73786. /** @hidden */
  73787. readonly _isLight: boolean;
  73788. /**
  73789. * Converts the light information to a readable string for debug purpose.
  73790. * @param fullDetails Supports for multiple levels of logging within scene loading
  73791. * @returns the human readable light info
  73792. */
  73793. toString(fullDetails?: boolean): string;
  73794. /** @hidden */
  73795. protected _syncParentEnabledState(): void;
  73796. /**
  73797. * Set the enabled state of this node.
  73798. * @param value - the new enabled state
  73799. */
  73800. setEnabled(value: boolean): void;
  73801. /**
  73802. * Returns the Light associated shadow generator if any.
  73803. * @return the associated shadow generator.
  73804. */
  73805. getShadowGenerator(): Nullable<IShadowGenerator>;
  73806. /**
  73807. * Returns a Vector3, the absolute light position in the World.
  73808. * @returns the world space position of the light
  73809. */
  73810. getAbsolutePosition(): Vector3;
  73811. /**
  73812. * Specifies if the light will affect the passed mesh.
  73813. * @param mesh The mesh to test against the light
  73814. * @return true the mesh is affected otherwise, false.
  73815. */
  73816. canAffectMesh(mesh: AbstractMesh): boolean;
  73817. /**
  73818. * Sort function to order lights for rendering.
  73819. * @param a First Light object to compare to second.
  73820. * @param b Second Light object to compare first.
  73821. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  73822. */
  73823. static CompareLightsPriority(a: Light, b: Light): number;
  73824. /**
  73825. * Releases resources associated with this node.
  73826. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  73827. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  73828. */
  73829. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73830. /**
  73831. * Returns the light type ID (integer).
  73832. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73833. */
  73834. getTypeID(): number;
  73835. /**
  73836. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  73837. * @returns the scaled intensity in intensity mode unit
  73838. */
  73839. getScaledIntensity(): number;
  73840. /**
  73841. * Returns a new Light object, named "name", from the current one.
  73842. * @param name The name of the cloned light
  73843. * @returns the new created light
  73844. */
  73845. clone(name: string): Nullable<Light>;
  73846. /**
  73847. * Serializes the current light into a Serialization object.
  73848. * @returns the serialized object.
  73849. */
  73850. serialize(): any;
  73851. /**
  73852. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  73853. * This new light is named "name" and added to the passed scene.
  73854. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  73855. * @param name The friendly name of the light
  73856. * @param scene The scene the new light will belong to
  73857. * @returns the constructor function
  73858. */
  73859. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  73860. /**
  73861. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  73862. * @param parsedLight The JSON representation of the light
  73863. * @param scene The scene to create the parsed light in
  73864. * @returns the created light after parsing
  73865. */
  73866. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  73867. private _hookArrayForExcluded;
  73868. private _hookArrayForIncludedOnly;
  73869. private _resyncMeshes;
  73870. /**
  73871. * Forces the meshes to update their light related information in their rendering used effects
  73872. * @hidden Internal Use Only
  73873. */
  73874. _markMeshesAsLightDirty(): void;
  73875. /**
  73876. * Recomputes the cached photometric scale if needed.
  73877. */
  73878. private _computePhotometricScale;
  73879. /**
  73880. * Returns the Photometric Scale according to the light type and intensity mode.
  73881. */
  73882. private _getPhotometricScale;
  73883. /**
  73884. * Reorder the light in the scene according to their defined priority.
  73885. * @hidden Internal Use Only
  73886. */
  73887. _reorderLightsInScene(): void;
  73888. /**
  73889. * Prepares the list of defines specific to the light type.
  73890. * @param defines the list of defines
  73891. * @param lightIndex defines the index of the light for the effect
  73892. */
  73893. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73894. }
  73895. }
  73896. declare module BABYLON {
  73897. /**
  73898. * Interface used to define Action
  73899. */
  73900. export interface IAction {
  73901. /**
  73902. * Trigger for the action
  73903. */
  73904. trigger: number;
  73905. /** Options of the trigger */
  73906. triggerOptions: any;
  73907. /**
  73908. * Gets the trigger parameters
  73909. * @returns the trigger parameters
  73910. */
  73911. getTriggerParameter(): any;
  73912. /**
  73913. * Internal only - executes current action event
  73914. * @hidden
  73915. */
  73916. _executeCurrent(evt?: ActionEvent): void;
  73917. /**
  73918. * Serialize placeholder for child classes
  73919. * @param parent of child
  73920. * @returns the serialized object
  73921. */
  73922. serialize(parent: any): any;
  73923. /**
  73924. * Internal only
  73925. * @hidden
  73926. */
  73927. _prepare(): void;
  73928. /**
  73929. * Internal only - manager for action
  73930. * @hidden
  73931. */
  73932. _actionManager: AbstractActionManager;
  73933. /**
  73934. * Adds action to chain of actions, may be a DoNothingAction
  73935. * @param action defines the next action to execute
  73936. * @returns The action passed in
  73937. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73938. */
  73939. then(action: IAction): IAction;
  73940. }
  73941. /**
  73942. * The action to be carried out following a trigger
  73943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  73944. */
  73945. export class Action implements IAction {
  73946. /** the trigger, with or without parameters, for the action */
  73947. triggerOptions: any;
  73948. /**
  73949. * Trigger for the action
  73950. */
  73951. trigger: number;
  73952. /**
  73953. * Internal only - manager for action
  73954. * @hidden
  73955. */
  73956. _actionManager: ActionManager;
  73957. private _nextActiveAction;
  73958. private _child;
  73959. private _condition?;
  73960. private _triggerParameter;
  73961. /**
  73962. * An event triggered prior to action being executed.
  73963. */
  73964. onBeforeExecuteObservable: Observable<Action>;
  73965. /**
  73966. * Creates a new Action
  73967. * @param triggerOptions the trigger, with or without parameters, for the action
  73968. * @param condition an optional determinant of action
  73969. */
  73970. constructor(
  73971. /** the trigger, with or without parameters, for the action */
  73972. triggerOptions: any, condition?: Condition);
  73973. /**
  73974. * Internal only
  73975. * @hidden
  73976. */
  73977. _prepare(): void;
  73978. /**
  73979. * Gets the trigger parameters
  73980. * @returns the trigger parameters
  73981. */
  73982. getTriggerParameter(): any;
  73983. /**
  73984. * Internal only - executes current action event
  73985. * @hidden
  73986. */
  73987. _executeCurrent(evt?: ActionEvent): void;
  73988. /**
  73989. * Execute placeholder for child classes
  73990. * @param evt optional action event
  73991. */
  73992. execute(evt?: ActionEvent): void;
  73993. /**
  73994. * Skips to next active action
  73995. */
  73996. skipToNextActiveAction(): void;
  73997. /**
  73998. * Adds action to chain of actions, may be a DoNothingAction
  73999. * @param action defines the next action to execute
  74000. * @returns The action passed in
  74001. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74002. */
  74003. then(action: Action): Action;
  74004. /**
  74005. * Internal only
  74006. * @hidden
  74007. */
  74008. _getProperty(propertyPath: string): string;
  74009. /**
  74010. * Internal only
  74011. * @hidden
  74012. */
  74013. _getEffectiveTarget(target: any, propertyPath: string): any;
  74014. /**
  74015. * Serialize placeholder for child classes
  74016. * @param parent of child
  74017. * @returns the serialized object
  74018. */
  74019. serialize(parent: any): any;
  74020. /**
  74021. * Internal only called by serialize
  74022. * @hidden
  74023. */
  74024. protected _serialize(serializedAction: any, parent?: any): any;
  74025. /**
  74026. * Internal only
  74027. * @hidden
  74028. */
  74029. static _SerializeValueAsString: (value: any) => string;
  74030. /**
  74031. * Internal only
  74032. * @hidden
  74033. */
  74034. static _GetTargetProperty: (target: Node | Scene) => {
  74035. name: string;
  74036. targetType: string;
  74037. value: string;
  74038. };
  74039. }
  74040. }
  74041. declare module BABYLON {
  74042. /**
  74043. * A Condition applied to an Action
  74044. */
  74045. export class Condition {
  74046. /**
  74047. * Internal only - manager for action
  74048. * @hidden
  74049. */
  74050. _actionManager: ActionManager;
  74051. /**
  74052. * Internal only
  74053. * @hidden
  74054. */
  74055. _evaluationId: number;
  74056. /**
  74057. * Internal only
  74058. * @hidden
  74059. */
  74060. _currentResult: boolean;
  74061. /**
  74062. * Creates a new Condition
  74063. * @param actionManager the manager of the action the condition is applied to
  74064. */
  74065. constructor(actionManager: ActionManager);
  74066. /**
  74067. * Check if the current condition is valid
  74068. * @returns a boolean
  74069. */
  74070. isValid(): boolean;
  74071. /**
  74072. * Internal only
  74073. * @hidden
  74074. */
  74075. _getProperty(propertyPath: string): string;
  74076. /**
  74077. * Internal only
  74078. * @hidden
  74079. */
  74080. _getEffectiveTarget(target: any, propertyPath: string): any;
  74081. /**
  74082. * Serialize placeholder for child classes
  74083. * @returns the serialized object
  74084. */
  74085. serialize(): any;
  74086. /**
  74087. * Internal only
  74088. * @hidden
  74089. */
  74090. protected _serialize(serializedCondition: any): any;
  74091. }
  74092. /**
  74093. * Defines specific conditional operators as extensions of Condition
  74094. */
  74095. export class ValueCondition extends Condition {
  74096. /** path to specify the property of the target the conditional operator uses */
  74097. propertyPath: string;
  74098. /** the value compared by the conditional operator against the current value of the property */
  74099. value: any;
  74100. /** the conditional operator, default ValueCondition.IsEqual */
  74101. operator: number;
  74102. /**
  74103. * Internal only
  74104. * @hidden
  74105. */
  74106. private static _IsEqual;
  74107. /**
  74108. * Internal only
  74109. * @hidden
  74110. */
  74111. private static _IsDifferent;
  74112. /**
  74113. * Internal only
  74114. * @hidden
  74115. */
  74116. private static _IsGreater;
  74117. /**
  74118. * Internal only
  74119. * @hidden
  74120. */
  74121. private static _IsLesser;
  74122. /**
  74123. * returns the number for IsEqual
  74124. */
  74125. static readonly IsEqual: number;
  74126. /**
  74127. * Returns the number for IsDifferent
  74128. */
  74129. static readonly IsDifferent: number;
  74130. /**
  74131. * Returns the number for IsGreater
  74132. */
  74133. static readonly IsGreater: number;
  74134. /**
  74135. * Returns the number for IsLesser
  74136. */
  74137. static readonly IsLesser: number;
  74138. /**
  74139. * Internal only The action manager for the condition
  74140. * @hidden
  74141. */
  74142. _actionManager: ActionManager;
  74143. /**
  74144. * Internal only
  74145. * @hidden
  74146. */
  74147. private _target;
  74148. /**
  74149. * Internal only
  74150. * @hidden
  74151. */
  74152. private _effectiveTarget;
  74153. /**
  74154. * Internal only
  74155. * @hidden
  74156. */
  74157. private _property;
  74158. /**
  74159. * Creates a new ValueCondition
  74160. * @param actionManager manager for the action the condition applies to
  74161. * @param target for the action
  74162. * @param propertyPath path to specify the property of the target the conditional operator uses
  74163. * @param value the value compared by the conditional operator against the current value of the property
  74164. * @param operator the conditional operator, default ValueCondition.IsEqual
  74165. */
  74166. constructor(actionManager: ActionManager, target: any,
  74167. /** path to specify the property of the target the conditional operator uses */
  74168. propertyPath: string,
  74169. /** the value compared by the conditional operator against the current value of the property */
  74170. value: any,
  74171. /** the conditional operator, default ValueCondition.IsEqual */
  74172. operator?: number);
  74173. /**
  74174. * Compares the given value with the property value for the specified conditional operator
  74175. * @returns the result of the comparison
  74176. */
  74177. isValid(): boolean;
  74178. /**
  74179. * Serialize the ValueCondition into a JSON compatible object
  74180. * @returns serialization object
  74181. */
  74182. serialize(): any;
  74183. /**
  74184. * Gets the name of the conditional operator for the ValueCondition
  74185. * @param operator the conditional operator
  74186. * @returns the name
  74187. */
  74188. static GetOperatorName(operator: number): string;
  74189. }
  74190. /**
  74191. * Defines a predicate condition as an extension of Condition
  74192. */
  74193. export class PredicateCondition extends Condition {
  74194. /** defines the predicate function used to validate the condition */
  74195. predicate: () => boolean;
  74196. /**
  74197. * Internal only - manager for action
  74198. * @hidden
  74199. */
  74200. _actionManager: ActionManager;
  74201. /**
  74202. * Creates a new PredicateCondition
  74203. * @param actionManager manager for the action the condition applies to
  74204. * @param predicate defines the predicate function used to validate the condition
  74205. */
  74206. constructor(actionManager: ActionManager,
  74207. /** defines the predicate function used to validate the condition */
  74208. predicate: () => boolean);
  74209. /**
  74210. * @returns the validity of the predicate condition
  74211. */
  74212. isValid(): boolean;
  74213. }
  74214. /**
  74215. * Defines a state condition as an extension of Condition
  74216. */
  74217. export class StateCondition extends Condition {
  74218. /** Value to compare with target state */
  74219. value: string;
  74220. /**
  74221. * Internal only - manager for action
  74222. * @hidden
  74223. */
  74224. _actionManager: ActionManager;
  74225. /**
  74226. * Internal only
  74227. * @hidden
  74228. */
  74229. private _target;
  74230. /**
  74231. * Creates a new StateCondition
  74232. * @param actionManager manager for the action the condition applies to
  74233. * @param target of the condition
  74234. * @param value to compare with target state
  74235. */
  74236. constructor(actionManager: ActionManager, target: any,
  74237. /** Value to compare with target state */
  74238. value: string);
  74239. /**
  74240. * Gets a boolean indicating if the current condition is met
  74241. * @returns the validity of the state
  74242. */
  74243. isValid(): boolean;
  74244. /**
  74245. * Serialize the StateCondition into a JSON compatible object
  74246. * @returns serialization object
  74247. */
  74248. serialize(): any;
  74249. }
  74250. }
  74251. declare module BABYLON {
  74252. /**
  74253. * This defines an action responsible to toggle a boolean once triggered.
  74254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74255. */
  74256. export class SwitchBooleanAction extends Action {
  74257. /**
  74258. * The path to the boolean property in the target object
  74259. */
  74260. propertyPath: string;
  74261. private _target;
  74262. private _effectiveTarget;
  74263. private _property;
  74264. /**
  74265. * Instantiate the action
  74266. * @param triggerOptions defines the trigger options
  74267. * @param target defines the object containing the boolean
  74268. * @param propertyPath defines the path to the boolean property in the target object
  74269. * @param condition defines the trigger related conditions
  74270. */
  74271. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  74272. /** @hidden */
  74273. _prepare(): void;
  74274. /**
  74275. * Execute the action toggle the boolean value.
  74276. */
  74277. execute(): void;
  74278. /**
  74279. * Serializes the actions and its related information.
  74280. * @param parent defines the object to serialize in
  74281. * @returns the serialized object
  74282. */
  74283. serialize(parent: any): any;
  74284. }
  74285. /**
  74286. * This defines an action responsible to set a the state field of the target
  74287. * to a desired value once triggered.
  74288. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74289. */
  74290. export class SetStateAction extends Action {
  74291. /**
  74292. * The value to store in the state field.
  74293. */
  74294. value: string;
  74295. private _target;
  74296. /**
  74297. * Instantiate the action
  74298. * @param triggerOptions defines the trigger options
  74299. * @param target defines the object containing the state property
  74300. * @param value defines the value to store in the state field
  74301. * @param condition defines the trigger related conditions
  74302. */
  74303. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  74304. /**
  74305. * Execute the action and store the value on the target state property.
  74306. */
  74307. execute(): void;
  74308. /**
  74309. * Serializes the actions and its related information.
  74310. * @param parent defines the object to serialize in
  74311. * @returns the serialized object
  74312. */
  74313. serialize(parent: any): any;
  74314. }
  74315. /**
  74316. * This defines an action responsible to set a property of the target
  74317. * to a desired value once triggered.
  74318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74319. */
  74320. export class SetValueAction extends Action {
  74321. /**
  74322. * The path of the property to set in the target.
  74323. */
  74324. propertyPath: string;
  74325. /**
  74326. * The value to set in the property
  74327. */
  74328. value: any;
  74329. private _target;
  74330. private _effectiveTarget;
  74331. private _property;
  74332. /**
  74333. * Instantiate the action
  74334. * @param triggerOptions defines the trigger options
  74335. * @param target defines the object containing the property
  74336. * @param propertyPath defines the path of the property to set in the target
  74337. * @param value defines the value to set in the property
  74338. * @param condition defines the trigger related conditions
  74339. */
  74340. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74341. /** @hidden */
  74342. _prepare(): void;
  74343. /**
  74344. * Execute the action and set the targetted property to the desired value.
  74345. */
  74346. execute(): void;
  74347. /**
  74348. * Serializes the actions and its related information.
  74349. * @param parent defines the object to serialize in
  74350. * @returns the serialized object
  74351. */
  74352. serialize(parent: any): any;
  74353. }
  74354. /**
  74355. * This defines an action responsible to increment the target value
  74356. * to a desired value once triggered.
  74357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74358. */
  74359. export class IncrementValueAction extends Action {
  74360. /**
  74361. * The path of the property to increment in the target.
  74362. */
  74363. propertyPath: string;
  74364. /**
  74365. * The value we should increment the property by.
  74366. */
  74367. value: any;
  74368. private _target;
  74369. private _effectiveTarget;
  74370. private _property;
  74371. /**
  74372. * Instantiate the action
  74373. * @param triggerOptions defines the trigger options
  74374. * @param target defines the object containing the property
  74375. * @param propertyPath defines the path of the property to increment in the target
  74376. * @param value defines the value value we should increment the property by
  74377. * @param condition defines the trigger related conditions
  74378. */
  74379. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74380. /** @hidden */
  74381. _prepare(): void;
  74382. /**
  74383. * Execute the action and increment the target of the value amount.
  74384. */
  74385. execute(): void;
  74386. /**
  74387. * Serializes the actions and its related information.
  74388. * @param parent defines the object to serialize in
  74389. * @returns the serialized object
  74390. */
  74391. serialize(parent: any): any;
  74392. }
  74393. /**
  74394. * This defines an action responsible to start an animation once triggered.
  74395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74396. */
  74397. export class PlayAnimationAction extends Action {
  74398. /**
  74399. * Where the animation should start (animation frame)
  74400. */
  74401. from: number;
  74402. /**
  74403. * Where the animation should stop (animation frame)
  74404. */
  74405. to: number;
  74406. /**
  74407. * Define if the animation should loop or stop after the first play.
  74408. */
  74409. loop?: boolean;
  74410. private _target;
  74411. /**
  74412. * Instantiate the action
  74413. * @param triggerOptions defines the trigger options
  74414. * @param target defines the target animation or animation name
  74415. * @param from defines from where the animation should start (animation frame)
  74416. * @param end defines where the animation should stop (animation frame)
  74417. * @param loop defines if the animation should loop or stop after the first play
  74418. * @param condition defines the trigger related conditions
  74419. */
  74420. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  74421. /** @hidden */
  74422. _prepare(): void;
  74423. /**
  74424. * Execute the action and play the animation.
  74425. */
  74426. execute(): void;
  74427. /**
  74428. * Serializes the actions and its related information.
  74429. * @param parent defines the object to serialize in
  74430. * @returns the serialized object
  74431. */
  74432. serialize(parent: any): any;
  74433. }
  74434. /**
  74435. * This defines an action responsible to stop an animation once triggered.
  74436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74437. */
  74438. export class StopAnimationAction extends Action {
  74439. private _target;
  74440. /**
  74441. * Instantiate the action
  74442. * @param triggerOptions defines the trigger options
  74443. * @param target defines the target animation or animation name
  74444. * @param condition defines the trigger related conditions
  74445. */
  74446. constructor(triggerOptions: any, target: any, condition?: Condition);
  74447. /** @hidden */
  74448. _prepare(): void;
  74449. /**
  74450. * Execute the action and stop the animation.
  74451. */
  74452. execute(): void;
  74453. /**
  74454. * Serializes the actions and its related information.
  74455. * @param parent defines the object to serialize in
  74456. * @returns the serialized object
  74457. */
  74458. serialize(parent: any): any;
  74459. }
  74460. /**
  74461. * This defines an action responsible that does nothing once triggered.
  74462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74463. */
  74464. export class DoNothingAction extends Action {
  74465. /**
  74466. * Instantiate the action
  74467. * @param triggerOptions defines the trigger options
  74468. * @param condition defines the trigger related conditions
  74469. */
  74470. constructor(triggerOptions?: any, condition?: Condition);
  74471. /**
  74472. * Execute the action and do nothing.
  74473. */
  74474. execute(): void;
  74475. /**
  74476. * Serializes the actions and its related information.
  74477. * @param parent defines the object to serialize in
  74478. * @returns the serialized object
  74479. */
  74480. serialize(parent: any): any;
  74481. }
  74482. /**
  74483. * This defines an action responsible to trigger several actions once triggered.
  74484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74485. */
  74486. export class CombineAction extends Action {
  74487. /**
  74488. * The list of aggregated animations to run.
  74489. */
  74490. children: Action[];
  74491. /**
  74492. * Instantiate the action
  74493. * @param triggerOptions defines the trigger options
  74494. * @param children defines the list of aggregated animations to run
  74495. * @param condition defines the trigger related conditions
  74496. */
  74497. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  74498. /** @hidden */
  74499. _prepare(): void;
  74500. /**
  74501. * Execute the action and executes all the aggregated actions.
  74502. */
  74503. execute(evt: ActionEvent): void;
  74504. /**
  74505. * Serializes the actions and its related information.
  74506. * @param parent defines the object to serialize in
  74507. * @returns the serialized object
  74508. */
  74509. serialize(parent: any): any;
  74510. }
  74511. /**
  74512. * This defines an action responsible to run code (external event) once triggered.
  74513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74514. */
  74515. export class ExecuteCodeAction extends Action {
  74516. /**
  74517. * The callback function to run.
  74518. */
  74519. func: (evt: ActionEvent) => void;
  74520. /**
  74521. * Instantiate the action
  74522. * @param triggerOptions defines the trigger options
  74523. * @param func defines the callback function to run
  74524. * @param condition defines the trigger related conditions
  74525. */
  74526. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  74527. /**
  74528. * Execute the action and run the attached code.
  74529. */
  74530. execute(evt: ActionEvent): void;
  74531. }
  74532. /**
  74533. * This defines an action responsible to set the parent property of the target once triggered.
  74534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74535. */
  74536. export class SetParentAction extends Action {
  74537. private _parent;
  74538. private _target;
  74539. /**
  74540. * Instantiate the action
  74541. * @param triggerOptions defines the trigger options
  74542. * @param target defines the target containing the parent property
  74543. * @param parent defines from where the animation should start (animation frame)
  74544. * @param condition defines the trigger related conditions
  74545. */
  74546. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  74547. /** @hidden */
  74548. _prepare(): void;
  74549. /**
  74550. * Execute the action and set the parent property.
  74551. */
  74552. execute(): void;
  74553. /**
  74554. * Serializes the actions and its related information.
  74555. * @param parent defines the object to serialize in
  74556. * @returns the serialized object
  74557. */
  74558. serialize(parent: any): any;
  74559. }
  74560. }
  74561. declare module BABYLON {
  74562. /**
  74563. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  74564. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  74565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74566. */
  74567. export class ActionManager extends AbstractActionManager {
  74568. /**
  74569. * Nothing
  74570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74571. */
  74572. static readonly NothingTrigger: number;
  74573. /**
  74574. * On pick
  74575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74576. */
  74577. static readonly OnPickTrigger: number;
  74578. /**
  74579. * On left pick
  74580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74581. */
  74582. static readonly OnLeftPickTrigger: number;
  74583. /**
  74584. * On right pick
  74585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74586. */
  74587. static readonly OnRightPickTrigger: number;
  74588. /**
  74589. * On center pick
  74590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74591. */
  74592. static readonly OnCenterPickTrigger: number;
  74593. /**
  74594. * On pick down
  74595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74596. */
  74597. static readonly OnPickDownTrigger: number;
  74598. /**
  74599. * On double pick
  74600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74601. */
  74602. static readonly OnDoublePickTrigger: number;
  74603. /**
  74604. * On pick up
  74605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74606. */
  74607. static readonly OnPickUpTrigger: number;
  74608. /**
  74609. * On pick out.
  74610. * This trigger will only be raised if you also declared a OnPickDown
  74611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74612. */
  74613. static readonly OnPickOutTrigger: number;
  74614. /**
  74615. * On long press
  74616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74617. */
  74618. static readonly OnLongPressTrigger: number;
  74619. /**
  74620. * On pointer over
  74621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74622. */
  74623. static readonly OnPointerOverTrigger: number;
  74624. /**
  74625. * On pointer out
  74626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74627. */
  74628. static readonly OnPointerOutTrigger: number;
  74629. /**
  74630. * On every frame
  74631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74632. */
  74633. static readonly OnEveryFrameTrigger: number;
  74634. /**
  74635. * On intersection enter
  74636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74637. */
  74638. static readonly OnIntersectionEnterTrigger: number;
  74639. /**
  74640. * On intersection exit
  74641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74642. */
  74643. static readonly OnIntersectionExitTrigger: number;
  74644. /**
  74645. * On key down
  74646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74647. */
  74648. static readonly OnKeyDownTrigger: number;
  74649. /**
  74650. * On key up
  74651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74652. */
  74653. static readonly OnKeyUpTrigger: number;
  74654. private _scene;
  74655. /**
  74656. * Creates a new action manager
  74657. * @param scene defines the hosting scene
  74658. */
  74659. constructor(scene: Scene);
  74660. /**
  74661. * Releases all associated resources
  74662. */
  74663. dispose(): void;
  74664. /**
  74665. * Gets hosting scene
  74666. * @returns the hosting scene
  74667. */
  74668. getScene(): Scene;
  74669. /**
  74670. * Does this action manager handles actions of any of the given triggers
  74671. * @param triggers defines the triggers to be tested
  74672. * @return a boolean indicating whether one (or more) of the triggers is handled
  74673. */
  74674. hasSpecificTriggers(triggers: number[]): boolean;
  74675. /**
  74676. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  74677. * speed.
  74678. * @param triggerA defines the trigger to be tested
  74679. * @param triggerB defines the trigger to be tested
  74680. * @return a boolean indicating whether one (or more) of the triggers is handled
  74681. */
  74682. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  74683. /**
  74684. * Does this action manager handles actions of a given trigger
  74685. * @param trigger defines the trigger to be tested
  74686. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  74687. * @return whether the trigger is handled
  74688. */
  74689. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  74690. /**
  74691. * Does this action manager has pointer triggers
  74692. */
  74693. readonly hasPointerTriggers: boolean;
  74694. /**
  74695. * Does this action manager has pick triggers
  74696. */
  74697. readonly hasPickTriggers: boolean;
  74698. /**
  74699. * Registers an action to this action manager
  74700. * @param action defines the action to be registered
  74701. * @return the action amended (prepared) after registration
  74702. */
  74703. registerAction(action: IAction): Nullable<IAction>;
  74704. /**
  74705. * Unregisters an action to this action manager
  74706. * @param action defines the action to be unregistered
  74707. * @return a boolean indicating whether the action has been unregistered
  74708. */
  74709. unregisterAction(action: IAction): Boolean;
  74710. /**
  74711. * Process a specific trigger
  74712. * @param trigger defines the trigger to process
  74713. * @param evt defines the event details to be processed
  74714. */
  74715. processTrigger(trigger: number, evt?: IActionEvent): void;
  74716. /** @hidden */
  74717. _getEffectiveTarget(target: any, propertyPath: string): any;
  74718. /** @hidden */
  74719. _getProperty(propertyPath: string): string;
  74720. /**
  74721. * Serialize this manager to a JSON object
  74722. * @param name defines the property name to store this manager
  74723. * @returns a JSON representation of this manager
  74724. */
  74725. serialize(name: string): any;
  74726. /**
  74727. * Creates a new ActionManager from a JSON data
  74728. * @param parsedActions defines the JSON data to read from
  74729. * @param object defines the hosting mesh
  74730. * @param scene defines the hosting scene
  74731. */
  74732. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  74733. /**
  74734. * Get a trigger name by index
  74735. * @param trigger defines the trigger index
  74736. * @returns a trigger name
  74737. */
  74738. static GetTriggerName(trigger: number): string;
  74739. }
  74740. }
  74741. declare module BABYLON {
  74742. /**
  74743. * Class representing a ray with position and direction
  74744. */
  74745. export class Ray {
  74746. /** origin point */
  74747. origin: Vector3;
  74748. /** direction */
  74749. direction: Vector3;
  74750. /** length of the ray */
  74751. length: number;
  74752. private static readonly TmpVector3;
  74753. private _tmpRay;
  74754. /**
  74755. * Creates a new ray
  74756. * @param origin origin point
  74757. * @param direction direction
  74758. * @param length length of the ray
  74759. */
  74760. constructor(
  74761. /** origin point */
  74762. origin: Vector3,
  74763. /** direction */
  74764. direction: Vector3,
  74765. /** length of the ray */
  74766. length?: number);
  74767. /**
  74768. * Checks if the ray intersects a box
  74769. * @param minimum bound of the box
  74770. * @param maximum bound of the box
  74771. * @param intersectionTreshold extra extend to be added to the box in all direction
  74772. * @returns if the box was hit
  74773. */
  74774. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  74775. /**
  74776. * Checks if the ray intersects a box
  74777. * @param box the bounding box to check
  74778. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  74779. * @returns if the box was hit
  74780. */
  74781. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  74782. /**
  74783. * If the ray hits a sphere
  74784. * @param sphere the bounding sphere to check
  74785. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  74786. * @returns true if it hits the sphere
  74787. */
  74788. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  74789. /**
  74790. * If the ray hits a triange
  74791. * @param vertex0 triangle vertex
  74792. * @param vertex1 triangle vertex
  74793. * @param vertex2 triangle vertex
  74794. * @returns intersection information if hit
  74795. */
  74796. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  74797. /**
  74798. * Checks if ray intersects a plane
  74799. * @param plane the plane to check
  74800. * @returns the distance away it was hit
  74801. */
  74802. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  74803. /**
  74804. * Calculate the intercept of a ray on a given axis
  74805. * @param axis to check 'x' | 'y' | 'z'
  74806. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  74807. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  74808. */
  74809. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  74810. /**
  74811. * Checks if ray intersects a mesh
  74812. * @param mesh the mesh to check
  74813. * @param fastCheck if only the bounding box should checked
  74814. * @returns picking info of the intersecton
  74815. */
  74816. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  74817. /**
  74818. * Checks if ray intersects a mesh
  74819. * @param meshes the meshes to check
  74820. * @param fastCheck if only the bounding box should checked
  74821. * @param results array to store result in
  74822. * @returns Array of picking infos
  74823. */
  74824. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  74825. private _comparePickingInfo;
  74826. private static smallnum;
  74827. private static rayl;
  74828. /**
  74829. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  74830. * @param sega the first point of the segment to test the intersection against
  74831. * @param segb the second point of the segment to test the intersection against
  74832. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  74833. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  74834. */
  74835. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  74836. /**
  74837. * Update the ray from viewport position
  74838. * @param x position
  74839. * @param y y position
  74840. * @param viewportWidth viewport width
  74841. * @param viewportHeight viewport height
  74842. * @param world world matrix
  74843. * @param view view matrix
  74844. * @param projection projection matrix
  74845. * @returns this ray updated
  74846. */
  74847. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74848. /**
  74849. * Creates a ray with origin and direction of 0,0,0
  74850. * @returns the new ray
  74851. */
  74852. static Zero(): Ray;
  74853. /**
  74854. * Creates a new ray from screen space and viewport
  74855. * @param x position
  74856. * @param y y position
  74857. * @param viewportWidth viewport width
  74858. * @param viewportHeight viewport height
  74859. * @param world world matrix
  74860. * @param view view matrix
  74861. * @param projection projection matrix
  74862. * @returns new ray
  74863. */
  74864. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74865. /**
  74866. * 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
  74867. * transformed to the given world matrix.
  74868. * @param origin The origin point
  74869. * @param end The end point
  74870. * @param world a matrix to transform the ray to. Default is the identity matrix.
  74871. * @returns the new ray
  74872. */
  74873. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  74874. /**
  74875. * Transforms a ray by a matrix
  74876. * @param ray ray to transform
  74877. * @param matrix matrix to apply
  74878. * @returns the resulting new ray
  74879. */
  74880. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  74881. /**
  74882. * Transforms a ray by a matrix
  74883. * @param ray ray to transform
  74884. * @param matrix matrix to apply
  74885. * @param result ray to store result in
  74886. */
  74887. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  74888. /**
  74889. * Unproject a ray from screen space to object space
  74890. * @param sourceX defines the screen space x coordinate to use
  74891. * @param sourceY defines the screen space y coordinate to use
  74892. * @param viewportWidth defines the current width of the viewport
  74893. * @param viewportHeight defines the current height of the viewport
  74894. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74895. * @param view defines the view matrix to use
  74896. * @param projection defines the projection matrix to use
  74897. */
  74898. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  74899. }
  74900. /**
  74901. * Type used to define predicate used to select faces when a mesh intersection is detected
  74902. */
  74903. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  74904. interface Scene {
  74905. /** @hidden */
  74906. _tempPickingRay: Nullable<Ray>;
  74907. /** @hidden */
  74908. _cachedRayForTransform: Ray;
  74909. /** @hidden */
  74910. _pickWithRayInverseMatrix: Matrix;
  74911. /** @hidden */
  74912. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  74913. /** @hidden */
  74914. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  74915. }
  74916. }
  74917. declare module BABYLON {
  74918. /**
  74919. * Groups all the scene component constants in one place to ease maintenance.
  74920. * @hidden
  74921. */
  74922. export class SceneComponentConstants {
  74923. static readonly NAME_EFFECTLAYER: string;
  74924. static readonly NAME_LAYER: string;
  74925. static readonly NAME_LENSFLARESYSTEM: string;
  74926. static readonly NAME_BOUNDINGBOXRENDERER: string;
  74927. static readonly NAME_PARTICLESYSTEM: string;
  74928. static readonly NAME_GAMEPAD: string;
  74929. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  74930. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  74931. static readonly NAME_DEPTHRENDERER: string;
  74932. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  74933. static readonly NAME_SPRITE: string;
  74934. static readonly NAME_OUTLINERENDERER: string;
  74935. static readonly NAME_PROCEDURALTEXTURE: string;
  74936. static readonly NAME_SHADOWGENERATOR: string;
  74937. static readonly NAME_OCTREE: string;
  74938. static readonly NAME_PHYSICSENGINE: string;
  74939. static readonly NAME_AUDIO: string;
  74940. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  74941. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74942. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  74943. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74944. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  74945. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  74946. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  74947. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  74948. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  74949. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  74950. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  74951. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  74952. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  74953. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  74954. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  74955. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  74956. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  74957. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  74958. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  74959. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  74960. static readonly STEP_AFTERRENDER_AUDIO: number;
  74961. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  74962. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  74963. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  74964. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  74965. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  74966. static readonly STEP_POINTERMOVE_SPRITE: number;
  74967. static readonly STEP_POINTERDOWN_SPRITE: number;
  74968. static readonly STEP_POINTERUP_SPRITE: number;
  74969. }
  74970. /**
  74971. * This represents a scene component.
  74972. *
  74973. * This is used to decouple the dependency the scene is having on the different workloads like
  74974. * layers, post processes...
  74975. */
  74976. export interface ISceneComponent {
  74977. /**
  74978. * The name of the component. Each component must have a unique name.
  74979. */
  74980. name: string;
  74981. /**
  74982. * The scene the component belongs to.
  74983. */
  74984. scene: Scene;
  74985. /**
  74986. * Register the component to one instance of a scene.
  74987. */
  74988. register(): void;
  74989. /**
  74990. * Rebuilds the elements related to this component in case of
  74991. * context lost for instance.
  74992. */
  74993. rebuild(): void;
  74994. /**
  74995. * Disposes the component and the associated ressources.
  74996. */
  74997. dispose(): void;
  74998. }
  74999. /**
  75000. * This represents a SERIALIZABLE scene component.
  75001. *
  75002. * This extends Scene Component to add Serialization methods on top.
  75003. */
  75004. export interface ISceneSerializableComponent extends ISceneComponent {
  75005. /**
  75006. * Adds all the elements from the container to the scene
  75007. * @param container the container holding the elements
  75008. */
  75009. addFromContainer(container: AbstractScene): void;
  75010. /**
  75011. * Removes all the elements in the container from the scene
  75012. * @param container contains the elements to remove
  75013. * @param dispose if the removed element should be disposed (default: false)
  75014. */
  75015. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75016. /**
  75017. * Serializes the component data to the specified json object
  75018. * @param serializationObject The object to serialize to
  75019. */
  75020. serialize(serializationObject: any): void;
  75021. }
  75022. /**
  75023. * Strong typing of a Mesh related stage step action
  75024. */
  75025. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  75026. /**
  75027. * Strong typing of a Evaluate Sub Mesh related stage step action
  75028. */
  75029. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  75030. /**
  75031. * Strong typing of a Active Mesh related stage step action
  75032. */
  75033. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  75034. /**
  75035. * Strong typing of a Camera related stage step action
  75036. */
  75037. export type CameraStageAction = (camera: Camera) => void;
  75038. /**
  75039. * Strong typing of a Camera Frame buffer related stage step action
  75040. */
  75041. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  75042. /**
  75043. * Strong typing of a Render Target related stage step action
  75044. */
  75045. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  75046. /**
  75047. * Strong typing of a RenderingGroup related stage step action
  75048. */
  75049. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  75050. /**
  75051. * Strong typing of a Mesh Render related stage step action
  75052. */
  75053. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  75054. /**
  75055. * Strong typing of a simple stage step action
  75056. */
  75057. export type SimpleStageAction = () => void;
  75058. /**
  75059. * Strong typing of a render target action.
  75060. */
  75061. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  75062. /**
  75063. * Strong typing of a pointer move action.
  75064. */
  75065. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  75066. /**
  75067. * Strong typing of a pointer up/down action.
  75068. */
  75069. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  75070. /**
  75071. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  75072. * @hidden
  75073. */
  75074. export class Stage<T extends Function> extends Array<{
  75075. index: number;
  75076. component: ISceneComponent;
  75077. action: T;
  75078. }> {
  75079. /**
  75080. * Hide ctor from the rest of the world.
  75081. * @param items The items to add.
  75082. */
  75083. private constructor();
  75084. /**
  75085. * Creates a new Stage.
  75086. * @returns A new instance of a Stage
  75087. */
  75088. static Create<T extends Function>(): Stage<T>;
  75089. /**
  75090. * Registers a step in an ordered way in the targeted stage.
  75091. * @param index Defines the position to register the step in
  75092. * @param component Defines the component attached to the step
  75093. * @param action Defines the action to launch during the step
  75094. */
  75095. registerStep(index: number, component: ISceneComponent, action: T): void;
  75096. /**
  75097. * Clears all the steps from the stage.
  75098. */
  75099. clear(): void;
  75100. }
  75101. }
  75102. declare module BABYLON {
  75103. interface Scene {
  75104. /** @hidden */
  75105. _pointerOverSprite: Nullable<Sprite>;
  75106. /** @hidden */
  75107. _pickedDownSprite: Nullable<Sprite>;
  75108. /** @hidden */
  75109. _tempSpritePickingRay: Nullable<Ray>;
  75110. /**
  75111. * All of the sprite managers added to this scene
  75112. * @see http://doc.babylonjs.com/babylon101/sprites
  75113. */
  75114. spriteManagers: Array<ISpriteManager>;
  75115. /**
  75116. * An event triggered when sprites rendering is about to start
  75117. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75118. */
  75119. onBeforeSpritesRenderingObservable: Observable<Scene>;
  75120. /**
  75121. * An event triggered when sprites rendering is done
  75122. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75123. */
  75124. onAfterSpritesRenderingObservable: Observable<Scene>;
  75125. /** @hidden */
  75126. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75127. /** Launch a ray to try to pick a sprite in the scene
  75128. * @param x position on screen
  75129. * @param y position on screen
  75130. * @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
  75131. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75132. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  75133. * @returns a PickingInfo
  75134. */
  75135. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75136. /** Use the given ray to pick a sprite in the scene
  75137. * @param ray The ray (in world space) to use to pick meshes
  75138. * @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
  75139. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75140. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  75141. * @returns a PickingInfo
  75142. */
  75143. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75144. /**
  75145. * Force the sprite under the pointer
  75146. * @param sprite defines the sprite to use
  75147. */
  75148. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  75149. /**
  75150. * Gets the sprite under the pointer
  75151. * @returns a Sprite or null if no sprite is under the pointer
  75152. */
  75153. getPointerOverSprite(): Nullable<Sprite>;
  75154. }
  75155. /**
  75156. * Defines the sprite scene component responsible to manage sprites
  75157. * in a given scene.
  75158. */
  75159. export class SpriteSceneComponent implements ISceneComponent {
  75160. /**
  75161. * The component name helpfull to identify the component in the list of scene components.
  75162. */
  75163. readonly name: string;
  75164. /**
  75165. * The scene the component belongs to.
  75166. */
  75167. scene: Scene;
  75168. /** @hidden */
  75169. private _spritePredicate;
  75170. /**
  75171. * Creates a new instance of the component for the given scene
  75172. * @param scene Defines the scene to register the component in
  75173. */
  75174. constructor(scene: Scene);
  75175. /**
  75176. * Registers the component in a given scene
  75177. */
  75178. register(): void;
  75179. /**
  75180. * Rebuilds the elements related to this component in case of
  75181. * context lost for instance.
  75182. */
  75183. rebuild(): void;
  75184. /**
  75185. * Disposes the component and the associated ressources.
  75186. */
  75187. dispose(): void;
  75188. private _pickSpriteButKeepRay;
  75189. private _pointerMove;
  75190. private _pointerDown;
  75191. private _pointerUp;
  75192. }
  75193. }
  75194. declare module BABYLON {
  75195. /** @hidden */
  75196. export var fogFragmentDeclaration: {
  75197. name: string;
  75198. shader: string;
  75199. };
  75200. }
  75201. declare module BABYLON {
  75202. /** @hidden */
  75203. export var fogFragment: {
  75204. name: string;
  75205. shader: string;
  75206. };
  75207. }
  75208. declare module BABYLON {
  75209. /** @hidden */
  75210. export var spritesPixelShader: {
  75211. name: string;
  75212. shader: string;
  75213. };
  75214. }
  75215. declare module BABYLON {
  75216. /** @hidden */
  75217. export var fogVertexDeclaration: {
  75218. name: string;
  75219. shader: string;
  75220. };
  75221. }
  75222. declare module BABYLON {
  75223. /** @hidden */
  75224. export var spritesVertexShader: {
  75225. name: string;
  75226. shader: string;
  75227. };
  75228. }
  75229. declare module BABYLON {
  75230. /**
  75231. * Defines the minimum interface to fullfil in order to be a sprite manager.
  75232. */
  75233. export interface ISpriteManager extends IDisposable {
  75234. /**
  75235. * Restricts the camera to viewing objects with the same layerMask.
  75236. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  75237. */
  75238. layerMask: number;
  75239. /**
  75240. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  75241. */
  75242. isPickable: boolean;
  75243. /**
  75244. * Specifies the rendering group id for this mesh (0 by default)
  75245. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  75246. */
  75247. renderingGroupId: number;
  75248. /**
  75249. * Defines the list of sprites managed by the manager.
  75250. */
  75251. sprites: Array<Sprite>;
  75252. /**
  75253. * Tests the intersection of a sprite with a specific ray.
  75254. * @param ray The ray we are sending to test the collision
  75255. * @param camera The camera space we are sending rays in
  75256. * @param predicate A predicate allowing excluding sprites from the list of object to test
  75257. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  75258. * @returns picking info or null.
  75259. */
  75260. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75261. /**
  75262. * Renders the list of sprites on screen.
  75263. */
  75264. render(): void;
  75265. }
  75266. /**
  75267. * Class used to manage multiple sprites on the same spritesheet
  75268. * @see http://doc.babylonjs.com/babylon101/sprites
  75269. */
  75270. export class SpriteManager implements ISpriteManager {
  75271. /** defines the manager's name */
  75272. name: string;
  75273. /** Gets the list of sprites */
  75274. sprites: Sprite[];
  75275. /** Gets or sets the rendering group id (0 by default) */
  75276. renderingGroupId: number;
  75277. /** Gets or sets camera layer mask */
  75278. layerMask: number;
  75279. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  75280. fogEnabled: boolean;
  75281. /** Gets or sets a boolean indicating if the sprites are pickable */
  75282. isPickable: boolean;
  75283. /** Defines the default width of a cell in the spritesheet */
  75284. cellWidth: number;
  75285. /** Defines the default height of a cell in the spritesheet */
  75286. cellHeight: number;
  75287. /**
  75288. * An event triggered when the manager is disposed.
  75289. */
  75290. onDisposeObservable: Observable<SpriteManager>;
  75291. private _onDisposeObserver;
  75292. /**
  75293. * Callback called when the manager is disposed
  75294. */
  75295. onDispose: () => void;
  75296. private _capacity;
  75297. private _spriteTexture;
  75298. private _epsilon;
  75299. private _scene;
  75300. private _vertexData;
  75301. private _buffer;
  75302. private _vertexBuffers;
  75303. private _indexBuffer;
  75304. private _effectBase;
  75305. private _effectFog;
  75306. /**
  75307. * Gets or sets the spritesheet texture
  75308. */
  75309. texture: Texture;
  75310. /**
  75311. * Creates a new sprite manager
  75312. * @param name defines the manager's name
  75313. * @param imgUrl defines the sprite sheet url
  75314. * @param capacity defines the maximum allowed number of sprites
  75315. * @param cellSize defines the size of a sprite cell
  75316. * @param scene defines the hosting scene
  75317. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75318. * @param samplingMode defines the smapling mode to use with spritesheet
  75319. */
  75320. constructor(
  75321. /** defines the manager's name */
  75322. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  75323. private _appendSpriteVertex;
  75324. /**
  75325. * Intersects the sprites with a ray
  75326. * @param ray defines the ray to intersect with
  75327. * @param camera defines the current active camera
  75328. * @param predicate defines a predicate used to select candidate sprites
  75329. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  75330. * @returns null if no hit or a PickingInfo
  75331. */
  75332. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75333. /**
  75334. * Render all child sprites
  75335. */
  75336. render(): void;
  75337. /**
  75338. * Release associated resources
  75339. */
  75340. dispose(): void;
  75341. }
  75342. }
  75343. declare module BABYLON {
  75344. /**
  75345. * Class used to represent a sprite
  75346. * @see http://doc.babylonjs.com/babylon101/sprites
  75347. */
  75348. export class Sprite {
  75349. /** defines the name */
  75350. name: string;
  75351. /** Gets or sets the current world position */
  75352. position: Vector3;
  75353. /** Gets or sets the main color */
  75354. color: Color4;
  75355. /** Gets or sets the width */
  75356. width: number;
  75357. /** Gets or sets the height */
  75358. height: number;
  75359. /** Gets or sets rotation angle */
  75360. angle: number;
  75361. /** Gets or sets the cell index in the sprite sheet */
  75362. cellIndex: number;
  75363. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  75364. invertU: number;
  75365. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  75366. invertV: number;
  75367. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  75368. disposeWhenFinishedAnimating: boolean;
  75369. /** Gets the list of attached animations */
  75370. animations: Animation[];
  75371. /** Gets or sets a boolean indicating if the sprite can be picked */
  75372. isPickable: boolean;
  75373. /**
  75374. * Gets or sets the associated action manager
  75375. */
  75376. actionManager: Nullable<ActionManager>;
  75377. private _animationStarted;
  75378. private _loopAnimation;
  75379. private _fromIndex;
  75380. private _toIndex;
  75381. private _delay;
  75382. private _direction;
  75383. private _manager;
  75384. private _time;
  75385. private _onAnimationEnd;
  75386. /**
  75387. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  75388. */
  75389. isVisible: boolean;
  75390. /**
  75391. * Gets or sets the sprite size
  75392. */
  75393. size: number;
  75394. /**
  75395. * Creates a new Sprite
  75396. * @param name defines the name
  75397. * @param manager defines the manager
  75398. */
  75399. constructor(
  75400. /** defines the name */
  75401. name: string, manager: ISpriteManager);
  75402. /**
  75403. * Starts an animation
  75404. * @param from defines the initial key
  75405. * @param to defines the end key
  75406. * @param loop defines if the animation must loop
  75407. * @param delay defines the start delay (in ms)
  75408. * @param onAnimationEnd defines a callback to call when animation ends
  75409. */
  75410. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  75411. /** Stops current animation (if any) */
  75412. stopAnimation(): void;
  75413. /** @hidden */
  75414. _animate(deltaTime: number): void;
  75415. /** Release associated resources */
  75416. dispose(): void;
  75417. }
  75418. }
  75419. declare module BABYLON {
  75420. /**
  75421. * Information about the result of picking within a scene
  75422. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  75423. */
  75424. export class PickingInfo {
  75425. /** @hidden */
  75426. _pickingUnavailable: boolean;
  75427. /**
  75428. * If the pick collided with an object
  75429. */
  75430. hit: boolean;
  75431. /**
  75432. * Distance away where the pick collided
  75433. */
  75434. distance: number;
  75435. /**
  75436. * The location of pick collision
  75437. */
  75438. pickedPoint: Nullable<Vector3>;
  75439. /**
  75440. * The mesh corresponding the the pick collision
  75441. */
  75442. pickedMesh: Nullable<AbstractMesh>;
  75443. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  75444. bu: number;
  75445. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  75446. bv: number;
  75447. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  75448. faceId: number;
  75449. /** Id of the the submesh that was picked */
  75450. subMeshId: number;
  75451. /** If a sprite was picked, this will be the sprite the pick collided with */
  75452. pickedSprite: Nullable<Sprite>;
  75453. /**
  75454. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  75455. */
  75456. originMesh: Nullable<AbstractMesh>;
  75457. /**
  75458. * The ray that was used to perform the picking.
  75459. */
  75460. ray: Nullable<Ray>;
  75461. /**
  75462. * Gets the normal correspodning to the face the pick collided with
  75463. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  75464. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  75465. * @returns The normal correspodning to the face the pick collided with
  75466. */
  75467. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  75468. /**
  75469. * Gets the texture coordinates of where the pick occured
  75470. * @returns the vector containing the coordnates of the texture
  75471. */
  75472. getTextureCoordinates(): Nullable<Vector2>;
  75473. }
  75474. }
  75475. declare module BABYLON {
  75476. /**
  75477. * Gather the list of pointer event types as constants.
  75478. */
  75479. export class PointerEventTypes {
  75480. /**
  75481. * 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.
  75482. */
  75483. static readonly POINTERDOWN: number;
  75484. /**
  75485. * The pointerup event is fired when a pointer is no longer active.
  75486. */
  75487. static readonly POINTERUP: number;
  75488. /**
  75489. * The pointermove event is fired when a pointer changes coordinates.
  75490. */
  75491. static readonly POINTERMOVE: number;
  75492. /**
  75493. * The pointerwheel event is fired when a mouse wheel has been rotated.
  75494. */
  75495. static readonly POINTERWHEEL: number;
  75496. /**
  75497. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  75498. */
  75499. static readonly POINTERPICK: number;
  75500. /**
  75501. * The pointertap event is fired when a the object has been touched and released without drag.
  75502. */
  75503. static readonly POINTERTAP: number;
  75504. /**
  75505. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  75506. */
  75507. static readonly POINTERDOUBLETAP: number;
  75508. }
  75509. /**
  75510. * Base class of pointer info types.
  75511. */
  75512. export class PointerInfoBase {
  75513. /**
  75514. * Defines the type of event (PointerEventTypes)
  75515. */
  75516. type: number;
  75517. /**
  75518. * Defines the related dom event
  75519. */
  75520. event: PointerEvent | MouseWheelEvent;
  75521. /**
  75522. * Instantiates the base class of pointers info.
  75523. * @param type Defines the type of event (PointerEventTypes)
  75524. * @param event Defines the related dom event
  75525. */
  75526. constructor(
  75527. /**
  75528. * Defines the type of event (PointerEventTypes)
  75529. */
  75530. type: number,
  75531. /**
  75532. * Defines the related dom event
  75533. */
  75534. event: PointerEvent | MouseWheelEvent);
  75535. }
  75536. /**
  75537. * This class is used to store pointer related info for the onPrePointerObservable event.
  75538. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  75539. */
  75540. export class PointerInfoPre extends PointerInfoBase {
  75541. /**
  75542. * Ray from a pointer if availible (eg. 6dof controller)
  75543. */
  75544. ray: Nullable<Ray>;
  75545. /**
  75546. * Defines the local position of the pointer on the canvas.
  75547. */
  75548. localPosition: Vector2;
  75549. /**
  75550. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  75551. */
  75552. skipOnPointerObservable: boolean;
  75553. /**
  75554. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  75555. * @param type Defines the type of event (PointerEventTypes)
  75556. * @param event Defines the related dom event
  75557. * @param localX Defines the local x coordinates of the pointer when the event occured
  75558. * @param localY Defines the local y coordinates of the pointer when the event occured
  75559. */
  75560. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  75561. }
  75562. /**
  75563. * This type contains all the data related to a pointer event in Babylon.js.
  75564. * 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.
  75565. */
  75566. export class PointerInfo extends PointerInfoBase {
  75567. /**
  75568. * Defines the picking info associated to the info (if any)\
  75569. */
  75570. pickInfo: Nullable<PickingInfo>;
  75571. /**
  75572. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  75573. * @param type Defines the type of event (PointerEventTypes)
  75574. * @param event Defines the related dom event
  75575. * @param pickInfo Defines the picking info associated to the info (if any)\
  75576. */
  75577. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  75578. /**
  75579. * Defines the picking info associated to the info (if any)\
  75580. */
  75581. pickInfo: Nullable<PickingInfo>);
  75582. }
  75583. /**
  75584. * Data relating to a touch event on the screen.
  75585. */
  75586. export interface PointerTouch {
  75587. /**
  75588. * X coordinate of touch.
  75589. */
  75590. x: number;
  75591. /**
  75592. * Y coordinate of touch.
  75593. */
  75594. y: number;
  75595. /**
  75596. * Id of touch. Unique for each finger.
  75597. */
  75598. pointerId: number;
  75599. /**
  75600. * Event type passed from DOM.
  75601. */
  75602. type: any;
  75603. }
  75604. }
  75605. declare module BABYLON {
  75606. /**
  75607. * Manage the mouse inputs to control the movement of a free camera.
  75608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75609. */
  75610. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  75611. /**
  75612. * Define if touch is enabled in the mouse input
  75613. */
  75614. touchEnabled: boolean;
  75615. /**
  75616. * Defines the camera the input is attached to.
  75617. */
  75618. camera: FreeCamera;
  75619. /**
  75620. * Defines the buttons associated with the input to handle camera move.
  75621. */
  75622. buttons: number[];
  75623. /**
  75624. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  75625. */
  75626. angularSensibility: number;
  75627. private _pointerInput;
  75628. private _onMouseMove;
  75629. private _observer;
  75630. private previousPosition;
  75631. /**
  75632. * Observable for when a pointer move event occurs containing the move offset
  75633. */
  75634. onPointerMovedObservable: Observable<{
  75635. offsetX: number;
  75636. offsetY: number;
  75637. }>;
  75638. /**
  75639. * @hidden
  75640. * If the camera should be rotated automatically based on pointer movement
  75641. */
  75642. _allowCameraRotation: boolean;
  75643. /**
  75644. * Manage the mouse inputs to control the movement of a free camera.
  75645. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75646. * @param touchEnabled Defines if touch is enabled or not
  75647. */
  75648. constructor(
  75649. /**
  75650. * Define if touch is enabled in the mouse input
  75651. */
  75652. touchEnabled?: boolean);
  75653. /**
  75654. * Attach the input controls to a specific dom element to get the input from.
  75655. * @param element Defines the element the controls should be listened from
  75656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75657. */
  75658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75659. /**
  75660. * Called on JS contextmenu event.
  75661. * Override this method to provide functionality.
  75662. */
  75663. protected onContextMenu(evt: PointerEvent): void;
  75664. /**
  75665. * Detach the current controls from the specified dom element.
  75666. * @param element Defines the element to stop listening the inputs from
  75667. */
  75668. detachControl(element: Nullable<HTMLElement>): void;
  75669. /**
  75670. * Gets the class name of the current intput.
  75671. * @returns the class name
  75672. */
  75673. getClassName(): string;
  75674. /**
  75675. * Get the friendly name associated with the input class.
  75676. * @returns the input friendly name
  75677. */
  75678. getSimpleName(): string;
  75679. }
  75680. }
  75681. declare module BABYLON {
  75682. /**
  75683. * Manage the touch inputs to control the movement of a free camera.
  75684. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75685. */
  75686. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  75687. /**
  75688. * Defines the camera the input is attached to.
  75689. */
  75690. camera: FreeCamera;
  75691. /**
  75692. * Defines the touch sensibility for rotation.
  75693. * The higher the faster.
  75694. */
  75695. touchAngularSensibility: number;
  75696. /**
  75697. * Defines the touch sensibility for move.
  75698. * The higher the faster.
  75699. */
  75700. touchMoveSensibility: number;
  75701. private _offsetX;
  75702. private _offsetY;
  75703. private _pointerPressed;
  75704. private _pointerInput;
  75705. private _observer;
  75706. private _onLostFocus;
  75707. /**
  75708. * Attach the input controls to a specific dom element to get the input from.
  75709. * @param element Defines the element the controls should be listened from
  75710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75711. */
  75712. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75713. /**
  75714. * Detach the current controls from the specified dom element.
  75715. * @param element Defines the element to stop listening the inputs from
  75716. */
  75717. detachControl(element: Nullable<HTMLElement>): void;
  75718. /**
  75719. * Update the current camera state depending on the inputs that have been used this frame.
  75720. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75721. */
  75722. checkInputs(): void;
  75723. /**
  75724. * Gets the class name of the current intput.
  75725. * @returns the class name
  75726. */
  75727. getClassName(): string;
  75728. /**
  75729. * Get the friendly name associated with the input class.
  75730. * @returns the input friendly name
  75731. */
  75732. getSimpleName(): string;
  75733. }
  75734. }
  75735. declare module BABYLON {
  75736. /**
  75737. * Default Inputs manager for the FreeCamera.
  75738. * It groups all the default supported inputs for ease of use.
  75739. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75740. */
  75741. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  75742. /**
  75743. * @hidden
  75744. */
  75745. _mouseInput: Nullable<FreeCameraMouseInput>;
  75746. /**
  75747. * Instantiates a new FreeCameraInputsManager.
  75748. * @param camera Defines the camera the inputs belong to
  75749. */
  75750. constructor(camera: FreeCamera);
  75751. /**
  75752. * Add keyboard input support to the input manager.
  75753. * @returns the current input manager
  75754. */
  75755. addKeyboard(): FreeCameraInputsManager;
  75756. /**
  75757. * Add mouse input support to the input manager.
  75758. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  75759. * @returns the current input manager
  75760. */
  75761. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  75762. /**
  75763. * Removes the mouse input support from the manager
  75764. * @returns the current input manager
  75765. */
  75766. removeMouse(): FreeCameraInputsManager;
  75767. /**
  75768. * Add touch input support to the input manager.
  75769. * @returns the current input manager
  75770. */
  75771. addTouch(): FreeCameraInputsManager;
  75772. /**
  75773. * Remove all attached input methods from a camera
  75774. */
  75775. clear(): void;
  75776. }
  75777. }
  75778. declare module BABYLON {
  75779. /**
  75780. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75781. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  75782. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75783. */
  75784. export class FreeCamera extends TargetCamera {
  75785. /**
  75786. * Define the collision ellipsoid of the camera.
  75787. * This is helpful to simulate a camera body like the player body around the camera
  75788. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  75789. */
  75790. ellipsoid: Vector3;
  75791. /**
  75792. * Define an offset for the position of the ellipsoid around the camera.
  75793. * This can be helpful to determine the center of the body near the gravity center of the body
  75794. * instead of its head.
  75795. */
  75796. ellipsoidOffset: Vector3;
  75797. /**
  75798. * Enable or disable collisions of the camera with the rest of the scene objects.
  75799. */
  75800. checkCollisions: boolean;
  75801. /**
  75802. * Enable or disable gravity on the camera.
  75803. */
  75804. applyGravity: boolean;
  75805. /**
  75806. * Define the input manager associated to the camera.
  75807. */
  75808. inputs: FreeCameraInputsManager;
  75809. /**
  75810. * Gets the input sensibility for a mouse input. (default is 2000.0)
  75811. * Higher values reduce sensitivity.
  75812. */
  75813. /**
  75814. * Sets the input sensibility for a mouse input. (default is 2000.0)
  75815. * Higher values reduce sensitivity.
  75816. */
  75817. angularSensibility: number;
  75818. /**
  75819. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75820. */
  75821. keysUp: number[];
  75822. /**
  75823. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75824. */
  75825. keysDown: number[];
  75826. /**
  75827. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75828. */
  75829. keysLeft: number[];
  75830. /**
  75831. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75832. */
  75833. keysRight: number[];
  75834. /**
  75835. * Event raised when the camera collide with a mesh in the scene.
  75836. */
  75837. onCollide: (collidedMesh: AbstractMesh) => void;
  75838. private _collider;
  75839. private _needMoveForGravity;
  75840. private _oldPosition;
  75841. private _diffPosition;
  75842. private _newPosition;
  75843. /** @hidden */
  75844. _localDirection: Vector3;
  75845. /** @hidden */
  75846. _transformedDirection: Vector3;
  75847. /**
  75848. * Instantiates a Free Camera.
  75849. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75850. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  75851. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75852. * @param name Define the name of the camera in the scene
  75853. * @param position Define the start position of the camera in the scene
  75854. * @param scene Define the scene the camera belongs to
  75855. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75856. */
  75857. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75858. /**
  75859. * Attached controls to the current camera.
  75860. * @param element Defines the element the controls should be listened from
  75861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75862. */
  75863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75864. /**
  75865. * Detach the current controls from the camera.
  75866. * The camera will stop reacting to inputs.
  75867. * @param element Defines the element to stop listening the inputs from
  75868. */
  75869. detachControl(element: HTMLElement): void;
  75870. private _collisionMask;
  75871. /**
  75872. * Define a collision mask to limit the list of object the camera can collide with
  75873. */
  75874. collisionMask: number;
  75875. /** @hidden */
  75876. _collideWithWorld(displacement: Vector3): void;
  75877. private _onCollisionPositionChange;
  75878. /** @hidden */
  75879. _checkInputs(): void;
  75880. /** @hidden */
  75881. _decideIfNeedsToMove(): boolean;
  75882. /** @hidden */
  75883. _updatePosition(): void;
  75884. /**
  75885. * Destroy the camera and release the current resources hold by it.
  75886. */
  75887. dispose(): void;
  75888. /**
  75889. * Gets the current object class name.
  75890. * @return the class name
  75891. */
  75892. getClassName(): string;
  75893. }
  75894. }
  75895. declare module BABYLON {
  75896. /**
  75897. * Represents a gamepad control stick position
  75898. */
  75899. export class StickValues {
  75900. /**
  75901. * The x component of the control stick
  75902. */
  75903. x: number;
  75904. /**
  75905. * The y component of the control stick
  75906. */
  75907. y: number;
  75908. /**
  75909. * Initializes the gamepad x and y control stick values
  75910. * @param x The x component of the gamepad control stick value
  75911. * @param y The y component of the gamepad control stick value
  75912. */
  75913. constructor(
  75914. /**
  75915. * The x component of the control stick
  75916. */
  75917. x: number,
  75918. /**
  75919. * The y component of the control stick
  75920. */
  75921. y: number);
  75922. }
  75923. /**
  75924. * An interface which manages callbacks for gamepad button changes
  75925. */
  75926. export interface GamepadButtonChanges {
  75927. /**
  75928. * Called when a gamepad has been changed
  75929. */
  75930. changed: boolean;
  75931. /**
  75932. * Called when a gamepad press event has been triggered
  75933. */
  75934. pressChanged: boolean;
  75935. /**
  75936. * Called when a touch event has been triggered
  75937. */
  75938. touchChanged: boolean;
  75939. /**
  75940. * Called when a value has changed
  75941. */
  75942. valueChanged: boolean;
  75943. }
  75944. /**
  75945. * Represents a gamepad
  75946. */
  75947. export class Gamepad {
  75948. /**
  75949. * The id of the gamepad
  75950. */
  75951. id: string;
  75952. /**
  75953. * The index of the gamepad
  75954. */
  75955. index: number;
  75956. /**
  75957. * The browser gamepad
  75958. */
  75959. browserGamepad: any;
  75960. /**
  75961. * Specifies what type of gamepad this represents
  75962. */
  75963. type: number;
  75964. private _leftStick;
  75965. private _rightStick;
  75966. /** @hidden */
  75967. _isConnected: boolean;
  75968. private _leftStickAxisX;
  75969. private _leftStickAxisY;
  75970. private _rightStickAxisX;
  75971. private _rightStickAxisY;
  75972. /**
  75973. * Triggered when the left control stick has been changed
  75974. */
  75975. private _onleftstickchanged;
  75976. /**
  75977. * Triggered when the right control stick has been changed
  75978. */
  75979. private _onrightstickchanged;
  75980. /**
  75981. * Represents a gamepad controller
  75982. */
  75983. static GAMEPAD: number;
  75984. /**
  75985. * Represents a generic controller
  75986. */
  75987. static GENERIC: number;
  75988. /**
  75989. * Represents an XBox controller
  75990. */
  75991. static XBOX: number;
  75992. /**
  75993. * Represents a pose-enabled controller
  75994. */
  75995. static POSE_ENABLED: number;
  75996. /**
  75997. * Specifies whether the left control stick should be Y-inverted
  75998. */
  75999. protected _invertLeftStickY: boolean;
  76000. /**
  76001. * Specifies if the gamepad has been connected
  76002. */
  76003. readonly isConnected: boolean;
  76004. /**
  76005. * Initializes the gamepad
  76006. * @param id The id of the gamepad
  76007. * @param index The index of the gamepad
  76008. * @param browserGamepad The browser gamepad
  76009. * @param leftStickX The x component of the left joystick
  76010. * @param leftStickY The y component of the left joystick
  76011. * @param rightStickX The x component of the right joystick
  76012. * @param rightStickY The y component of the right joystick
  76013. */
  76014. constructor(
  76015. /**
  76016. * The id of the gamepad
  76017. */
  76018. id: string,
  76019. /**
  76020. * The index of the gamepad
  76021. */
  76022. index: number,
  76023. /**
  76024. * The browser gamepad
  76025. */
  76026. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  76027. /**
  76028. * Callback triggered when the left joystick has changed
  76029. * @param callback
  76030. */
  76031. onleftstickchanged(callback: (values: StickValues) => void): void;
  76032. /**
  76033. * Callback triggered when the right joystick has changed
  76034. * @param callback
  76035. */
  76036. onrightstickchanged(callback: (values: StickValues) => void): void;
  76037. /**
  76038. * Gets the left joystick
  76039. */
  76040. /**
  76041. * Sets the left joystick values
  76042. */
  76043. leftStick: StickValues;
  76044. /**
  76045. * Gets the right joystick
  76046. */
  76047. /**
  76048. * Sets the right joystick value
  76049. */
  76050. rightStick: StickValues;
  76051. /**
  76052. * Updates the gamepad joystick positions
  76053. */
  76054. update(): void;
  76055. /**
  76056. * Disposes the gamepad
  76057. */
  76058. dispose(): void;
  76059. }
  76060. /**
  76061. * Represents a generic gamepad
  76062. */
  76063. export class GenericPad extends Gamepad {
  76064. private _buttons;
  76065. private _onbuttondown;
  76066. private _onbuttonup;
  76067. /**
  76068. * Observable triggered when a button has been pressed
  76069. */
  76070. onButtonDownObservable: Observable<number>;
  76071. /**
  76072. * Observable triggered when a button has been released
  76073. */
  76074. onButtonUpObservable: Observable<number>;
  76075. /**
  76076. * Callback triggered when a button has been pressed
  76077. * @param callback Called when a button has been pressed
  76078. */
  76079. onbuttondown(callback: (buttonPressed: number) => void): void;
  76080. /**
  76081. * Callback triggered when a button has been released
  76082. * @param callback Called when a button has been released
  76083. */
  76084. onbuttonup(callback: (buttonReleased: number) => void): void;
  76085. /**
  76086. * Initializes the generic gamepad
  76087. * @param id The id of the generic gamepad
  76088. * @param index The index of the generic gamepad
  76089. * @param browserGamepad The browser gamepad
  76090. */
  76091. constructor(id: string, index: number, browserGamepad: any);
  76092. private _setButtonValue;
  76093. /**
  76094. * Updates the generic gamepad
  76095. */
  76096. update(): void;
  76097. /**
  76098. * Disposes the generic gamepad
  76099. */
  76100. dispose(): void;
  76101. }
  76102. }
  76103. declare module BABYLON {
  76104. interface Engine {
  76105. /**
  76106. * Creates a raw texture
  76107. * @param data defines the data to store in the texture
  76108. * @param width defines the width of the texture
  76109. * @param height defines the height of the texture
  76110. * @param format defines the format of the data
  76111. * @param generateMipMaps defines if the engine should generate the mip levels
  76112. * @param invertY defines if data must be stored with Y axis inverted
  76113. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76114. * @param compression defines the compression used (null by default)
  76115. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76116. * @returns the raw texture inside an InternalTexture
  76117. */
  76118. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  76119. /**
  76120. * Update a raw texture
  76121. * @param texture defines the texture to update
  76122. * @param data defines the data to store in the texture
  76123. * @param format defines the format of the data
  76124. * @param invertY defines if data must be stored with Y axis inverted
  76125. */
  76126. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76127. /**
  76128. * Update a raw texture
  76129. * @param texture defines the texture to update
  76130. * @param data defines the data to store in the texture
  76131. * @param format defines the format of the data
  76132. * @param invertY defines if data must be stored with Y axis inverted
  76133. * @param compression defines the compression used (null by default)
  76134. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76135. */
  76136. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  76137. /**
  76138. * Creates a new raw cube texture
  76139. * @param data defines the array of data to use to create each face
  76140. * @param size defines the size of the textures
  76141. * @param format defines the format of the data
  76142. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76143. * @param generateMipMaps defines if the engine should generate the mip levels
  76144. * @param invertY defines if data must be stored with Y axis inverted
  76145. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76146. * @param compression defines the compression used (null by default)
  76147. * @returns the cube texture as an InternalTexture
  76148. */
  76149. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  76150. /**
  76151. * Update a raw cube texture
  76152. * @param texture defines the texture to udpdate
  76153. * @param data defines the data to store
  76154. * @param format defines the data format
  76155. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76156. * @param invertY defines if data must be stored with Y axis inverted
  76157. */
  76158. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  76159. /**
  76160. * Update a raw cube texture
  76161. * @param texture defines the texture to udpdate
  76162. * @param data defines the data to store
  76163. * @param format defines the data format
  76164. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76165. * @param invertY defines if data must be stored with Y axis inverted
  76166. * @param compression defines the compression used (null by default)
  76167. */
  76168. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  76169. /**
  76170. * Update a raw cube texture
  76171. * @param texture defines the texture to udpdate
  76172. * @param data defines the data to store
  76173. * @param format defines the data format
  76174. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76175. * @param invertY defines if data must be stored with Y axis inverted
  76176. * @param compression defines the compression used (null by default)
  76177. * @param level defines which level of the texture to update
  76178. */
  76179. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  76180. /**
  76181. * Creates a new raw cube texture from a specified url
  76182. * @param url defines the url where the data is located
  76183. * @param scene defines the current scene
  76184. * @param size defines the size of the textures
  76185. * @param format defines the format of the data
  76186. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76187. * @param noMipmap defines if the engine should avoid generating the mip levels
  76188. * @param callback defines a callback used to extract texture data from loaded data
  76189. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76190. * @param onLoad defines a callback called when texture is loaded
  76191. * @param onError defines a callback called if there is an error
  76192. * @returns the cube texture as an InternalTexture
  76193. */
  76194. 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;
  76195. /**
  76196. * Creates a new raw cube texture from a specified url
  76197. * @param url defines the url where the data is located
  76198. * @param scene defines the current scene
  76199. * @param size defines the size of the textures
  76200. * @param format defines the format of the data
  76201. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76202. * @param noMipmap defines if the engine should avoid generating the mip levels
  76203. * @param callback defines a callback used to extract texture data from loaded data
  76204. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76205. * @param onLoad defines a callback called when texture is loaded
  76206. * @param onError defines a callback called if there is an error
  76207. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76208. * @param invertY defines if data must be stored with Y axis inverted
  76209. * @returns the cube texture as an InternalTexture
  76210. */
  76211. 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;
  76212. /**
  76213. * Creates a new raw 3D texture
  76214. * @param data defines the data used to create the texture
  76215. * @param width defines the width of the texture
  76216. * @param height defines the height of the texture
  76217. * @param depth defines the depth of the texture
  76218. * @param format defines the format of the texture
  76219. * @param generateMipMaps defines if the engine must generate mip levels
  76220. * @param invertY defines if data must be stored with Y axis inverted
  76221. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76222. * @param compression defines the compressed used (can be null)
  76223. * @param textureType defines the compressed used (can be null)
  76224. * @returns a new raw 3D texture (stored in an InternalTexture)
  76225. */
  76226. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  76227. /**
  76228. * Update a raw 3D texture
  76229. * @param texture defines the texture to update
  76230. * @param data defines the data to store
  76231. * @param format defines the data format
  76232. * @param invertY defines if data must be stored with Y axis inverted
  76233. */
  76234. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76235. /**
  76236. * Update a raw 3D texture
  76237. * @param texture defines the texture to update
  76238. * @param data defines the data to store
  76239. * @param format defines the data format
  76240. * @param invertY defines if data must be stored with Y axis inverted
  76241. * @param compression defines the used compression (can be null)
  76242. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  76243. */
  76244. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  76245. }
  76246. }
  76247. declare module BABYLON {
  76248. /**
  76249. * Raw texture can help creating a texture directly from an array of data.
  76250. * This can be super useful if you either get the data from an uncompressed source or
  76251. * if you wish to create your texture pixel by pixel.
  76252. */
  76253. export class RawTexture extends Texture {
  76254. /**
  76255. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76256. */
  76257. format: number;
  76258. private _engine;
  76259. /**
  76260. * Instantiates a new RawTexture.
  76261. * Raw texture can help creating a texture directly from an array of data.
  76262. * This can be super useful if you either get the data from an uncompressed source or
  76263. * if you wish to create your texture pixel by pixel.
  76264. * @param data define the array of data to use to create the texture
  76265. * @param width define the width of the texture
  76266. * @param height define the height of the texture
  76267. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76268. * @param scene define the scene the texture belongs to
  76269. * @param generateMipMaps define whether mip maps should be generated or not
  76270. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76271. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76272. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76273. */
  76274. constructor(data: ArrayBufferView, width: number, height: number,
  76275. /**
  76276. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76277. */
  76278. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76279. /**
  76280. * Updates the texture underlying data.
  76281. * @param data Define the new data of the texture
  76282. */
  76283. update(data: ArrayBufferView): void;
  76284. /**
  76285. * Creates a luminance texture from some data.
  76286. * @param data Define the texture data
  76287. * @param width Define the width of the texture
  76288. * @param height Define the height of the texture
  76289. * @param scene Define the scene the texture belongs to
  76290. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76291. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76292. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76293. * @returns the luminance texture
  76294. */
  76295. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76296. /**
  76297. * Creates a luminance alpha texture from some data.
  76298. * @param data Define the texture data
  76299. * @param width Define the width of the texture
  76300. * @param height Define the height of the texture
  76301. * @param scene Define the scene the texture belongs to
  76302. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76303. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76304. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76305. * @returns the luminance alpha texture
  76306. */
  76307. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76308. /**
  76309. * Creates an alpha texture from some data.
  76310. * @param data Define the texture data
  76311. * @param width Define the width of the texture
  76312. * @param height Define the height of the texture
  76313. * @param scene Define the scene the texture belongs to
  76314. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76315. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76316. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76317. * @returns the alpha texture
  76318. */
  76319. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76320. /**
  76321. * Creates a RGB texture from some data.
  76322. * @param data Define the texture data
  76323. * @param width Define the width of the texture
  76324. * @param height Define the height of the texture
  76325. * @param scene Define the scene the texture belongs to
  76326. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76327. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76328. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76329. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76330. * @returns the RGB alpha texture
  76331. */
  76332. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76333. /**
  76334. * Creates a RGBA texture from some data.
  76335. * @param data Define the texture data
  76336. * @param width Define the width of the texture
  76337. * @param height Define the height of the texture
  76338. * @param scene Define the scene the texture belongs to
  76339. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76340. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76341. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76342. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76343. * @returns the RGBA texture
  76344. */
  76345. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76346. /**
  76347. * Creates a R texture from some data.
  76348. * @param data Define the texture data
  76349. * @param width Define the width of the texture
  76350. * @param height Define the height of the texture
  76351. * @param scene Define the scene the texture belongs to
  76352. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76353. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76354. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76355. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76356. * @returns the R texture
  76357. */
  76358. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76359. }
  76360. }
  76361. declare module BABYLON {
  76362. /**
  76363. * Interface for the size containing width and height
  76364. */
  76365. export interface ISize {
  76366. /**
  76367. * Width
  76368. */
  76369. width: number;
  76370. /**
  76371. * Heighht
  76372. */
  76373. height: number;
  76374. }
  76375. /**
  76376. * Size containing widht and height
  76377. */
  76378. export class Size implements ISize {
  76379. /**
  76380. * Width
  76381. */
  76382. width: number;
  76383. /**
  76384. * Height
  76385. */
  76386. height: number;
  76387. /**
  76388. * Creates a Size object from the given width and height (floats).
  76389. * @param width width of the new size
  76390. * @param height height of the new size
  76391. */
  76392. constructor(width: number, height: number);
  76393. /**
  76394. * Returns a string with the Size width and height
  76395. * @returns a string with the Size width and height
  76396. */
  76397. toString(): string;
  76398. /**
  76399. * "Size"
  76400. * @returns the string "Size"
  76401. */
  76402. getClassName(): string;
  76403. /**
  76404. * Returns the Size hash code.
  76405. * @returns a hash code for a unique width and height
  76406. */
  76407. getHashCode(): number;
  76408. /**
  76409. * Updates the current size from the given one.
  76410. * @param src the given size
  76411. */
  76412. copyFrom(src: Size): void;
  76413. /**
  76414. * Updates in place the current Size from the given floats.
  76415. * @param width width of the new size
  76416. * @param height height of the new size
  76417. * @returns the updated Size.
  76418. */
  76419. copyFromFloats(width: number, height: number): Size;
  76420. /**
  76421. * Updates in place the current Size from the given floats.
  76422. * @param width width to set
  76423. * @param height height to set
  76424. * @returns the updated Size.
  76425. */
  76426. set(width: number, height: number): Size;
  76427. /**
  76428. * Multiplies the width and height by numbers
  76429. * @param w factor to multiple the width by
  76430. * @param h factor to multiple the height by
  76431. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  76432. */
  76433. multiplyByFloats(w: number, h: number): Size;
  76434. /**
  76435. * Clones the size
  76436. * @returns a new Size copied from the given one.
  76437. */
  76438. clone(): Size;
  76439. /**
  76440. * True if the current Size and the given one width and height are strictly equal.
  76441. * @param other the other size to compare against
  76442. * @returns True if the current Size and the given one width and height are strictly equal.
  76443. */
  76444. equals(other: Size): boolean;
  76445. /**
  76446. * The surface of the Size : width * height (float).
  76447. */
  76448. readonly surface: number;
  76449. /**
  76450. * Create a new size of zero
  76451. * @returns a new Size set to (0.0, 0.0)
  76452. */
  76453. static Zero(): Size;
  76454. /**
  76455. * Sums the width and height of two sizes
  76456. * @param otherSize size to add to this size
  76457. * @returns a new Size set as the addition result of the current Size and the given one.
  76458. */
  76459. add(otherSize: Size): Size;
  76460. /**
  76461. * Subtracts the width and height of two
  76462. * @param otherSize size to subtract to this size
  76463. * @returns a new Size set as the subtraction result of the given one from the current Size.
  76464. */
  76465. subtract(otherSize: Size): Size;
  76466. /**
  76467. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  76468. * @param start starting size to lerp between
  76469. * @param end end size to lerp between
  76470. * @param amount amount to lerp between the start and end values
  76471. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  76472. */
  76473. static Lerp(start: Size, end: Size, amount: number): Size;
  76474. }
  76475. }
  76476. declare module BABYLON {
  76477. /**
  76478. * Defines a runtime animation
  76479. */
  76480. export class RuntimeAnimation {
  76481. private _events;
  76482. /**
  76483. * The current frame of the runtime animation
  76484. */
  76485. private _currentFrame;
  76486. /**
  76487. * The animation used by the runtime animation
  76488. */
  76489. private _animation;
  76490. /**
  76491. * The target of the runtime animation
  76492. */
  76493. private _target;
  76494. /**
  76495. * The initiating animatable
  76496. */
  76497. private _host;
  76498. /**
  76499. * The original value of the runtime animation
  76500. */
  76501. private _originalValue;
  76502. /**
  76503. * The original blend value of the runtime animation
  76504. */
  76505. private _originalBlendValue;
  76506. /**
  76507. * The offsets cache of the runtime animation
  76508. */
  76509. private _offsetsCache;
  76510. /**
  76511. * The high limits cache of the runtime animation
  76512. */
  76513. private _highLimitsCache;
  76514. /**
  76515. * Specifies if the runtime animation has been stopped
  76516. */
  76517. private _stopped;
  76518. /**
  76519. * The blending factor of the runtime animation
  76520. */
  76521. private _blendingFactor;
  76522. /**
  76523. * The BabylonJS scene
  76524. */
  76525. private _scene;
  76526. /**
  76527. * The current value of the runtime animation
  76528. */
  76529. private _currentValue;
  76530. /** @hidden */
  76531. _animationState: _IAnimationState;
  76532. /**
  76533. * The active target of the runtime animation
  76534. */
  76535. private _activeTargets;
  76536. private _currentActiveTarget;
  76537. private _directTarget;
  76538. /**
  76539. * The target path of the runtime animation
  76540. */
  76541. private _targetPath;
  76542. /**
  76543. * The weight of the runtime animation
  76544. */
  76545. private _weight;
  76546. /**
  76547. * The ratio offset of the runtime animation
  76548. */
  76549. private _ratioOffset;
  76550. /**
  76551. * The previous delay of the runtime animation
  76552. */
  76553. private _previousDelay;
  76554. /**
  76555. * The previous ratio of the runtime animation
  76556. */
  76557. private _previousRatio;
  76558. private _enableBlending;
  76559. private _keys;
  76560. private _minFrame;
  76561. private _maxFrame;
  76562. private _minValue;
  76563. private _maxValue;
  76564. private _targetIsArray;
  76565. /**
  76566. * Gets the current frame of the runtime animation
  76567. */
  76568. readonly currentFrame: number;
  76569. /**
  76570. * Gets the weight of the runtime animation
  76571. */
  76572. readonly weight: number;
  76573. /**
  76574. * Gets the current value of the runtime animation
  76575. */
  76576. readonly currentValue: any;
  76577. /**
  76578. * Gets the target path of the runtime animation
  76579. */
  76580. readonly targetPath: string;
  76581. /**
  76582. * Gets the actual target of the runtime animation
  76583. */
  76584. readonly target: any;
  76585. /** @hidden */
  76586. _onLoop: () => void;
  76587. /**
  76588. * Create a new RuntimeAnimation object
  76589. * @param target defines the target of the animation
  76590. * @param animation defines the source animation object
  76591. * @param scene defines the hosting scene
  76592. * @param host defines the initiating Animatable
  76593. */
  76594. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76595. private _preparePath;
  76596. /**
  76597. * Gets the animation from the runtime animation
  76598. */
  76599. readonly animation: Animation;
  76600. /**
  76601. * Resets the runtime animation to the beginning
  76602. * @param restoreOriginal defines whether to restore the target property to the original value
  76603. */
  76604. reset(restoreOriginal?: boolean): void;
  76605. /**
  76606. * Specifies if the runtime animation is stopped
  76607. * @returns Boolean specifying if the runtime animation is stopped
  76608. */
  76609. isStopped(): boolean;
  76610. /**
  76611. * Disposes of the runtime animation
  76612. */
  76613. dispose(): void;
  76614. /**
  76615. * Apply the interpolated value to the target
  76616. * @param currentValue defines the value computed by the animation
  76617. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76618. */
  76619. setValue(currentValue: any, weight: number): void;
  76620. private _getOriginalValues;
  76621. private _setValue;
  76622. /**
  76623. * Gets the loop pmode of the runtime animation
  76624. * @returns Loop Mode
  76625. */
  76626. private _getCorrectLoopMode;
  76627. /**
  76628. * Move the current animation to a given frame
  76629. * @param frame defines the frame to move to
  76630. */
  76631. goToFrame(frame: number): void;
  76632. /**
  76633. * @hidden Internal use only
  76634. */
  76635. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76636. /**
  76637. * Execute the current animation
  76638. * @param delay defines the delay to add to the current frame
  76639. * @param from defines the lower bound of the animation range
  76640. * @param to defines the upper bound of the animation range
  76641. * @param loop defines if the current animation must loop
  76642. * @param speedRatio defines the current speed ratio
  76643. * @param weight defines the weight of the animation (default is -1 so no weight)
  76644. * @param onLoop optional callback called when animation loops
  76645. * @returns a boolean indicating if the animation is running
  76646. */
  76647. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  76648. }
  76649. }
  76650. declare module BABYLON {
  76651. /**
  76652. * Class used to store an actual running animation
  76653. */
  76654. export class Animatable {
  76655. /** defines the target object */
  76656. target: any;
  76657. /** defines the starting frame number (default is 0) */
  76658. fromFrame: number;
  76659. /** defines the ending frame number (default is 100) */
  76660. toFrame: number;
  76661. /** defines if the animation must loop (default is false) */
  76662. loopAnimation: boolean;
  76663. /** defines a callback to call when animation ends if it is not looping */
  76664. onAnimationEnd?: (() => void) | null | undefined;
  76665. /** defines a callback to call when animation loops */
  76666. onAnimationLoop?: (() => void) | null | undefined;
  76667. private _localDelayOffset;
  76668. private _pausedDelay;
  76669. private _runtimeAnimations;
  76670. private _paused;
  76671. private _scene;
  76672. private _speedRatio;
  76673. private _weight;
  76674. private _syncRoot;
  76675. /**
  76676. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76677. * This will only apply for non looping animation (default is true)
  76678. */
  76679. disposeOnEnd: boolean;
  76680. /**
  76681. * Gets a boolean indicating if the animation has started
  76682. */
  76683. animationStarted: boolean;
  76684. /**
  76685. * Observer raised when the animation ends
  76686. */
  76687. onAnimationEndObservable: Observable<Animatable>;
  76688. /**
  76689. * Observer raised when the animation loops
  76690. */
  76691. onAnimationLoopObservable: Observable<Animatable>;
  76692. /**
  76693. * Gets the root Animatable used to synchronize and normalize animations
  76694. */
  76695. readonly syncRoot: Nullable<Animatable>;
  76696. /**
  76697. * Gets the current frame of the first RuntimeAnimation
  76698. * Used to synchronize Animatables
  76699. */
  76700. readonly masterFrame: number;
  76701. /**
  76702. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76703. */
  76704. weight: number;
  76705. /**
  76706. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76707. */
  76708. speedRatio: number;
  76709. /**
  76710. * Creates a new Animatable
  76711. * @param scene defines the hosting scene
  76712. * @param target defines the target object
  76713. * @param fromFrame defines the starting frame number (default is 0)
  76714. * @param toFrame defines the ending frame number (default is 100)
  76715. * @param loopAnimation defines if the animation must loop (default is false)
  76716. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76717. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76718. * @param animations defines a group of animation to add to the new Animatable
  76719. * @param onAnimationLoop defines a callback to call when animation loops
  76720. */
  76721. constructor(scene: Scene,
  76722. /** defines the target object */
  76723. target: any,
  76724. /** defines the starting frame number (default is 0) */
  76725. fromFrame?: number,
  76726. /** defines the ending frame number (default is 100) */
  76727. toFrame?: number,
  76728. /** defines if the animation must loop (default is false) */
  76729. loopAnimation?: boolean, speedRatio?: number,
  76730. /** defines a callback to call when animation ends if it is not looping */
  76731. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76732. /** defines a callback to call when animation loops */
  76733. onAnimationLoop?: (() => void) | null | undefined);
  76734. /**
  76735. * Synchronize and normalize current Animatable with a source Animatable
  76736. * This is useful when using animation weights and when animations are not of the same length
  76737. * @param root defines the root Animatable to synchronize with
  76738. * @returns the current Animatable
  76739. */
  76740. syncWith(root: Animatable): Animatable;
  76741. /**
  76742. * Gets the list of runtime animations
  76743. * @returns an array of RuntimeAnimation
  76744. */
  76745. getAnimations(): RuntimeAnimation[];
  76746. /**
  76747. * Adds more animations to the current animatable
  76748. * @param target defines the target of the animations
  76749. * @param animations defines the new animations to add
  76750. */
  76751. appendAnimations(target: any, animations: Animation[]): void;
  76752. /**
  76753. * Gets the source animation for a specific property
  76754. * @param property defines the propertyu to look for
  76755. * @returns null or the source animation for the given property
  76756. */
  76757. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76758. /**
  76759. * Gets the runtime animation for a specific property
  76760. * @param property defines the propertyu to look for
  76761. * @returns null or the runtime animation for the given property
  76762. */
  76763. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76764. /**
  76765. * Resets the animatable to its original state
  76766. */
  76767. reset(): void;
  76768. /**
  76769. * Allows the animatable to blend with current running animations
  76770. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76771. * @param blendingSpeed defines the blending speed to use
  76772. */
  76773. enableBlending(blendingSpeed: number): void;
  76774. /**
  76775. * Disable animation blending
  76776. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76777. */
  76778. disableBlending(): void;
  76779. /**
  76780. * Jump directly to a given frame
  76781. * @param frame defines the frame to jump to
  76782. */
  76783. goToFrame(frame: number): void;
  76784. /**
  76785. * Pause the animation
  76786. */
  76787. pause(): void;
  76788. /**
  76789. * Restart the animation
  76790. */
  76791. restart(): void;
  76792. private _raiseOnAnimationEnd;
  76793. /**
  76794. * Stop and delete the current animation
  76795. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76796. * @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)
  76797. */
  76798. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76799. /**
  76800. * Wait asynchronously for the animation to end
  76801. * @returns a promise which will be fullfilled when the animation ends
  76802. */
  76803. waitAsync(): Promise<Animatable>;
  76804. /** @hidden */
  76805. _animate(delay: number): boolean;
  76806. }
  76807. interface Scene {
  76808. /** @hidden */
  76809. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76810. /** @hidden */
  76811. _processLateAnimationBindingsForMatrices(holder: {
  76812. totalWeight: number;
  76813. animations: RuntimeAnimation[];
  76814. originalValue: Matrix;
  76815. }): any;
  76816. /** @hidden */
  76817. _processLateAnimationBindingsForQuaternions(holder: {
  76818. totalWeight: number;
  76819. animations: RuntimeAnimation[];
  76820. originalValue: Quaternion;
  76821. }, refQuaternion: Quaternion): Quaternion;
  76822. /** @hidden */
  76823. _processLateAnimationBindings(): void;
  76824. /**
  76825. * Will start the animation sequence of a given target
  76826. * @param target defines the target
  76827. * @param from defines from which frame should animation start
  76828. * @param to defines until which frame should animation run.
  76829. * @param weight defines the weight to apply to the animation (1.0 by default)
  76830. * @param loop defines if the animation loops
  76831. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76832. * @param onAnimationEnd defines the function to be executed when the animation ends
  76833. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76834. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76835. * @param onAnimationLoop defines the callback to call when an animation loops
  76836. * @returns the animatable object created for this animation
  76837. */
  76838. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76839. /**
  76840. * Will start the animation sequence of a given target
  76841. * @param target defines the target
  76842. * @param from defines from which frame should animation start
  76843. * @param to defines until which frame should animation run.
  76844. * @param loop defines if the animation loops
  76845. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76846. * @param onAnimationEnd defines the function to be executed when the animation ends
  76847. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76848. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76849. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76850. * @param onAnimationLoop defines the callback to call when an animation loops
  76851. * @returns the animatable object created for this animation
  76852. */
  76853. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76854. /**
  76855. * Will start the animation sequence of a given target and its hierarchy
  76856. * @param target defines the target
  76857. * @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.
  76858. * @param from defines from which frame should animation start
  76859. * @param to defines until which frame should animation run.
  76860. * @param loop defines if the animation loops
  76861. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76862. * @param onAnimationEnd defines the function to be executed when the animation ends
  76863. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76864. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76865. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76866. * @param onAnimationLoop defines the callback to call when an animation loops
  76867. * @returns the list of created animatables
  76868. */
  76869. 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[];
  76870. /**
  76871. * Begin a new animation on a given node
  76872. * @param target defines the target where the animation will take place
  76873. * @param animations defines the list of animations to start
  76874. * @param from defines the initial value
  76875. * @param to defines the final value
  76876. * @param loop defines if you want animation to loop (off by default)
  76877. * @param speedRatio defines the speed ratio to apply to all animations
  76878. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76879. * @param onAnimationLoop defines the callback to call when an animation loops
  76880. * @returns the list of created animatables
  76881. */
  76882. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76883. /**
  76884. * Begin a new animation on a given node and its hierarchy
  76885. * @param target defines the root node where the animation will take place
  76886. * @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.
  76887. * @param animations defines the list of animations to start
  76888. * @param from defines the initial value
  76889. * @param to defines the final value
  76890. * @param loop defines if you want animation to loop (off by default)
  76891. * @param speedRatio defines the speed ratio to apply to all animations
  76892. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76893. * @param onAnimationLoop defines the callback to call when an animation loops
  76894. * @returns the list of animatables created for all nodes
  76895. */
  76896. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76897. /**
  76898. * Gets the animatable associated with a specific target
  76899. * @param target defines the target of the animatable
  76900. * @returns the required animatable if found
  76901. */
  76902. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76903. /**
  76904. * Gets all animatables associated with a given target
  76905. * @param target defines the target to look animatables for
  76906. * @returns an array of Animatables
  76907. */
  76908. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76909. /**
  76910. * Stops and removes all animations that have been applied to the scene
  76911. */
  76912. stopAllAnimations(): void;
  76913. }
  76914. interface Bone {
  76915. /**
  76916. * Copy an animation range from another bone
  76917. * @param source defines the source bone
  76918. * @param rangeName defines the range name to copy
  76919. * @param frameOffset defines the frame offset
  76920. * @param rescaleAsRequired defines if rescaling must be applied if required
  76921. * @param skelDimensionsRatio defines the scaling ratio
  76922. * @returns true if operation was successful
  76923. */
  76924. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76925. }
  76926. }
  76927. declare module BABYLON {
  76928. /**
  76929. * Class used to override all child animations of a given target
  76930. */
  76931. export class AnimationPropertiesOverride {
  76932. /**
  76933. * Gets or sets a value indicating if animation blending must be used
  76934. */
  76935. enableBlending: boolean;
  76936. /**
  76937. * Gets or sets the blending speed to use when enableBlending is true
  76938. */
  76939. blendingSpeed: number;
  76940. /**
  76941. * Gets or sets the default loop mode to use
  76942. */
  76943. loopMode: number;
  76944. }
  76945. }
  76946. declare module BABYLON {
  76947. /**
  76948. * Class used to handle skinning animations
  76949. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76950. */
  76951. export class Skeleton implements IAnimatable {
  76952. /** defines the skeleton name */
  76953. name: string;
  76954. /** defines the skeleton Id */
  76955. id: string;
  76956. /**
  76957. * Defines the list of child bones
  76958. */
  76959. bones: Bone[];
  76960. /**
  76961. * Defines an estimate of the dimension of the skeleton at rest
  76962. */
  76963. dimensionsAtRest: Vector3;
  76964. /**
  76965. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76966. */
  76967. needInitialSkinMatrix: boolean;
  76968. /**
  76969. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76970. */
  76971. overrideMesh: Nullable<AbstractMesh>;
  76972. /**
  76973. * Gets the list of animations attached to this skeleton
  76974. */
  76975. animations: Array<Animation>;
  76976. private _scene;
  76977. private _isDirty;
  76978. private _transformMatrices;
  76979. private _transformMatrixTexture;
  76980. private _meshesWithPoseMatrix;
  76981. private _animatables;
  76982. private _identity;
  76983. private _synchronizedWithMesh;
  76984. private _ranges;
  76985. private _lastAbsoluteTransformsUpdateId;
  76986. private _canUseTextureForBones;
  76987. private _uniqueId;
  76988. /** @hidden */
  76989. _numBonesWithLinkedTransformNode: number;
  76990. /** @hidden */
  76991. _hasWaitingData: Nullable<boolean>;
  76992. /**
  76993. * Specifies if the skeleton should be serialized
  76994. */
  76995. doNotSerialize: boolean;
  76996. private _useTextureToStoreBoneMatrices;
  76997. /**
  76998. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76999. * Please note that this option is not available if the hardware does not support it
  77000. */
  77001. useTextureToStoreBoneMatrices: boolean;
  77002. private _animationPropertiesOverride;
  77003. /**
  77004. * Gets or sets the animation properties override
  77005. */
  77006. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77007. /**
  77008. * List of inspectable custom properties (used by the Inspector)
  77009. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77010. */
  77011. inspectableCustomProperties: IInspectable[];
  77012. /**
  77013. * An observable triggered before computing the skeleton's matrices
  77014. */
  77015. onBeforeComputeObservable: Observable<Skeleton>;
  77016. /**
  77017. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77018. */
  77019. readonly isUsingTextureForMatrices: boolean;
  77020. /**
  77021. * Gets the unique ID of this skeleton
  77022. */
  77023. readonly uniqueId: number;
  77024. /**
  77025. * Creates a new skeleton
  77026. * @param name defines the skeleton name
  77027. * @param id defines the skeleton Id
  77028. * @param scene defines the hosting scene
  77029. */
  77030. constructor(
  77031. /** defines the skeleton name */
  77032. name: string,
  77033. /** defines the skeleton Id */
  77034. id: string, scene: Scene);
  77035. /**
  77036. * Gets the current object class name.
  77037. * @return the class name
  77038. */
  77039. getClassName(): string;
  77040. /**
  77041. * Returns an array containing the root bones
  77042. * @returns an array containing the root bones
  77043. */
  77044. getChildren(): Array<Bone>;
  77045. /**
  77046. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77047. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77048. * @returns a Float32Array containing matrices data
  77049. */
  77050. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77051. /**
  77052. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77053. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77054. * @returns a raw texture containing the data
  77055. */
  77056. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  77057. /**
  77058. * Gets the current hosting scene
  77059. * @returns a scene object
  77060. */
  77061. getScene(): Scene;
  77062. /**
  77063. * Gets a string representing the current skeleton data
  77064. * @param fullDetails defines a boolean indicating if we want a verbose version
  77065. * @returns a string representing the current skeleton data
  77066. */
  77067. toString(fullDetails?: boolean): string;
  77068. /**
  77069. * Get bone's index searching by name
  77070. * @param name defines bone's name to search for
  77071. * @return the indice of the bone. Returns -1 if not found
  77072. */
  77073. getBoneIndexByName(name: string): number;
  77074. /**
  77075. * Creater a new animation range
  77076. * @param name defines the name of the range
  77077. * @param from defines the start key
  77078. * @param to defines the end key
  77079. */
  77080. createAnimationRange(name: string, from: number, to: number): void;
  77081. /**
  77082. * Delete a specific animation range
  77083. * @param name defines the name of the range
  77084. * @param deleteFrames defines if frames must be removed as well
  77085. */
  77086. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77087. /**
  77088. * Gets a specific animation range
  77089. * @param name defines the name of the range to look for
  77090. * @returns the requested animation range or null if not found
  77091. */
  77092. getAnimationRange(name: string): Nullable<AnimationRange>;
  77093. /**
  77094. * Gets the list of all animation ranges defined on this skeleton
  77095. * @returns an array
  77096. */
  77097. getAnimationRanges(): Nullable<AnimationRange>[];
  77098. /**
  77099. * Copy animation range from a source skeleton.
  77100. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77101. * @param source defines the source skeleton
  77102. * @param name defines the name of the range to copy
  77103. * @param rescaleAsRequired defines if rescaling must be applied if required
  77104. * @returns true if operation was successful
  77105. */
  77106. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77107. /**
  77108. * Forces the skeleton to go to rest pose
  77109. */
  77110. returnToRest(): void;
  77111. private _getHighestAnimationFrame;
  77112. /**
  77113. * Begin a specific animation range
  77114. * @param name defines the name of the range to start
  77115. * @param loop defines if looping must be turned on (false by default)
  77116. * @param speedRatio defines the speed ratio to apply (1 by default)
  77117. * @param onAnimationEnd defines a callback which will be called when animation will end
  77118. * @returns a new animatable
  77119. */
  77120. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77121. /** @hidden */
  77122. _markAsDirty(): void;
  77123. /** @hidden */
  77124. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77125. /** @hidden */
  77126. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77127. private _computeTransformMatrices;
  77128. /**
  77129. * Build all resources required to render a skeleton
  77130. */
  77131. prepare(): void;
  77132. /**
  77133. * Gets the list of animatables currently running for this skeleton
  77134. * @returns an array of animatables
  77135. */
  77136. getAnimatables(): IAnimatable[];
  77137. /**
  77138. * Clone the current skeleton
  77139. * @param name defines the name of the new skeleton
  77140. * @param id defines the id of the new skeleton
  77141. * @returns the new skeleton
  77142. */
  77143. clone(name: string, id: string): Skeleton;
  77144. /**
  77145. * Enable animation blending for this skeleton
  77146. * @param blendingSpeed defines the blending speed to apply
  77147. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77148. */
  77149. enableBlending(blendingSpeed?: number): void;
  77150. /**
  77151. * Releases all resources associated with the current skeleton
  77152. */
  77153. dispose(): void;
  77154. /**
  77155. * Serialize the skeleton in a JSON object
  77156. * @returns a JSON object
  77157. */
  77158. serialize(): any;
  77159. /**
  77160. * Creates a new skeleton from serialized data
  77161. * @param parsedSkeleton defines the serialized data
  77162. * @param scene defines the hosting scene
  77163. * @returns a new skeleton
  77164. */
  77165. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77166. /**
  77167. * Compute all node absolute transforms
  77168. * @param forceUpdate defines if computation must be done even if cache is up to date
  77169. */
  77170. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77171. /**
  77172. * Gets the root pose matrix
  77173. * @returns a matrix
  77174. */
  77175. getPoseMatrix(): Nullable<Matrix>;
  77176. /**
  77177. * Sorts bones per internal index
  77178. */
  77179. sortBones(): void;
  77180. private _sortBones;
  77181. }
  77182. }
  77183. declare module BABYLON {
  77184. /**
  77185. * Class used to store bone information
  77186. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77187. */
  77188. export class Bone extends Node {
  77189. /**
  77190. * defines the bone name
  77191. */
  77192. name: string;
  77193. private static _tmpVecs;
  77194. private static _tmpQuat;
  77195. private static _tmpMats;
  77196. /**
  77197. * Gets the list of child bones
  77198. */
  77199. children: Bone[];
  77200. /** Gets the animations associated with this bone */
  77201. animations: Animation[];
  77202. /**
  77203. * Gets or sets bone length
  77204. */
  77205. length: number;
  77206. /**
  77207. * @hidden Internal only
  77208. * Set this value to map this bone to a different index in the transform matrices
  77209. * Set this value to -1 to exclude the bone from the transform matrices
  77210. */
  77211. _index: Nullable<number>;
  77212. private _skeleton;
  77213. private _localMatrix;
  77214. private _restPose;
  77215. private _baseMatrix;
  77216. private _absoluteTransform;
  77217. private _invertedAbsoluteTransform;
  77218. private _parent;
  77219. private _scalingDeterminant;
  77220. private _worldTransform;
  77221. private _localScaling;
  77222. private _localRotation;
  77223. private _localPosition;
  77224. private _needToDecompose;
  77225. private _needToCompose;
  77226. /** @hidden */
  77227. _linkedTransformNode: Nullable<TransformNode>;
  77228. /** @hidden */
  77229. _waitingTransformNodeId: Nullable<string>;
  77230. /** @hidden */
  77231. /** @hidden */
  77232. _matrix: Matrix;
  77233. /**
  77234. * Create a new bone
  77235. * @param name defines the bone name
  77236. * @param skeleton defines the parent skeleton
  77237. * @param parentBone defines the parent (can be null if the bone is the root)
  77238. * @param localMatrix defines the local matrix
  77239. * @param restPose defines the rest pose matrix
  77240. * @param baseMatrix defines the base matrix
  77241. * @param index defines index of the bone in the hiearchy
  77242. */
  77243. constructor(
  77244. /**
  77245. * defines the bone name
  77246. */
  77247. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  77248. /**
  77249. * Gets the current object class name.
  77250. * @return the class name
  77251. */
  77252. getClassName(): string;
  77253. /**
  77254. * Gets the parent skeleton
  77255. * @returns a skeleton
  77256. */
  77257. getSkeleton(): Skeleton;
  77258. /**
  77259. * Gets parent bone
  77260. * @returns a bone or null if the bone is the root of the bone hierarchy
  77261. */
  77262. getParent(): Nullable<Bone>;
  77263. /**
  77264. * Returns an array containing the root bones
  77265. * @returns an array containing the root bones
  77266. */
  77267. getChildren(): Array<Bone>;
  77268. /**
  77269. * Sets the parent bone
  77270. * @param parent defines the parent (can be null if the bone is the root)
  77271. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77272. */
  77273. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  77274. /**
  77275. * Gets the local matrix
  77276. * @returns a matrix
  77277. */
  77278. getLocalMatrix(): Matrix;
  77279. /**
  77280. * Gets the base matrix (initial matrix which remains unchanged)
  77281. * @returns a matrix
  77282. */
  77283. getBaseMatrix(): Matrix;
  77284. /**
  77285. * Gets the rest pose matrix
  77286. * @returns a matrix
  77287. */
  77288. getRestPose(): Matrix;
  77289. /**
  77290. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  77291. */
  77292. getWorldMatrix(): Matrix;
  77293. /**
  77294. * Sets the local matrix to rest pose matrix
  77295. */
  77296. returnToRest(): void;
  77297. /**
  77298. * Gets the inverse of the absolute transform matrix.
  77299. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  77300. * @returns a matrix
  77301. */
  77302. getInvertedAbsoluteTransform(): Matrix;
  77303. /**
  77304. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  77305. * @returns a matrix
  77306. */
  77307. getAbsoluteTransform(): Matrix;
  77308. /**
  77309. * Links with the given transform node.
  77310. * The local matrix of this bone is copied from the transform node every frame.
  77311. * @param transformNode defines the transform node to link to
  77312. */
  77313. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  77314. /**
  77315. * Gets the node used to drive the bone's transformation
  77316. * @returns a transform node or null
  77317. */
  77318. getTransformNode(): Nullable<TransformNode>;
  77319. /** Gets or sets current position (in local space) */
  77320. position: Vector3;
  77321. /** Gets or sets current rotation (in local space) */
  77322. rotation: Vector3;
  77323. /** Gets or sets current rotation quaternion (in local space) */
  77324. rotationQuaternion: Quaternion;
  77325. /** Gets or sets current scaling (in local space) */
  77326. scaling: Vector3;
  77327. /**
  77328. * Gets the animation properties override
  77329. */
  77330. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77331. private _decompose;
  77332. private _compose;
  77333. /**
  77334. * Update the base and local matrices
  77335. * @param matrix defines the new base or local matrix
  77336. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77337. * @param updateLocalMatrix defines if the local matrix should be updated
  77338. */
  77339. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  77340. /** @hidden */
  77341. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  77342. /**
  77343. * Flag the bone as dirty (Forcing it to update everything)
  77344. */
  77345. markAsDirty(): void;
  77346. /** @hidden */
  77347. _markAsDirtyAndCompose(): void;
  77348. private _markAsDirtyAndDecompose;
  77349. /**
  77350. * Translate the bone in local or world space
  77351. * @param vec The amount to translate the bone
  77352. * @param space The space that the translation is in
  77353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77354. */
  77355. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77356. /**
  77357. * Set the postion of the bone in local or world space
  77358. * @param position The position to set the bone
  77359. * @param space The space that the position is in
  77360. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77361. */
  77362. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77363. /**
  77364. * Set the absolute position of the bone (world space)
  77365. * @param position The position to set the bone
  77366. * @param mesh The mesh that this bone is attached to
  77367. */
  77368. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  77369. /**
  77370. * Scale the bone on the x, y and z axes (in local space)
  77371. * @param x The amount to scale the bone on the x axis
  77372. * @param y The amount to scale the bone on the y axis
  77373. * @param z The amount to scale the bone on the z axis
  77374. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  77375. */
  77376. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  77377. /**
  77378. * Set the bone scaling in local space
  77379. * @param scale defines the scaling vector
  77380. */
  77381. setScale(scale: Vector3): void;
  77382. /**
  77383. * Gets the current scaling in local space
  77384. * @returns the current scaling vector
  77385. */
  77386. getScale(): Vector3;
  77387. /**
  77388. * Gets the current scaling in local space and stores it in a target vector
  77389. * @param result defines the target vector
  77390. */
  77391. getScaleToRef(result: Vector3): void;
  77392. /**
  77393. * Set the yaw, pitch, and roll of the bone in local or world space
  77394. * @param yaw The rotation of the bone on the y axis
  77395. * @param pitch The rotation of the bone on the x axis
  77396. * @param roll The rotation of the bone on the z axis
  77397. * @param space The space that the axes of rotation are in
  77398. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77399. */
  77400. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  77401. /**
  77402. * Add a rotation to the bone on an axis in local or world space
  77403. * @param axis The axis to rotate the bone on
  77404. * @param amount The amount to rotate the bone
  77405. * @param space The space that the axis is in
  77406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77407. */
  77408. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  77409. /**
  77410. * Set the rotation of the bone to a particular axis angle in local or world space
  77411. * @param axis The axis to rotate the bone on
  77412. * @param angle The angle that the bone should be rotated to
  77413. * @param space The space that the axis is in
  77414. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77415. */
  77416. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  77417. /**
  77418. * Set the euler rotation of the bone in local of world space
  77419. * @param rotation The euler rotation that the bone should be set to
  77420. * @param space The space that the rotation is in
  77421. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77422. */
  77423. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77424. /**
  77425. * Set the quaternion rotation of the bone in local of world space
  77426. * @param quat The quaternion rotation that the bone should be set to
  77427. * @param space The space that the rotation is in
  77428. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77429. */
  77430. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  77431. /**
  77432. * Set the rotation matrix of the bone in local of world space
  77433. * @param rotMat The rotation matrix that the bone should be set to
  77434. * @param space The space that the rotation is in
  77435. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77436. */
  77437. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  77438. private _rotateWithMatrix;
  77439. private _getNegativeRotationToRef;
  77440. /**
  77441. * Get the position of the bone in local or world space
  77442. * @param space The space that the returned position is in
  77443. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77444. * @returns The position of the bone
  77445. */
  77446. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77447. /**
  77448. * Copy the position of the bone to a vector3 in local or world space
  77449. * @param space The space that the returned position is in
  77450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77451. * @param result The vector3 to copy the position to
  77452. */
  77453. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  77454. /**
  77455. * Get the absolute position of the bone (world space)
  77456. * @param mesh The mesh that this bone is attached to
  77457. * @returns The absolute position of the bone
  77458. */
  77459. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  77460. /**
  77461. * Copy the absolute position of the bone (world space) to the result param
  77462. * @param mesh The mesh that this bone is attached to
  77463. * @param result The vector3 to copy the absolute position to
  77464. */
  77465. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  77466. /**
  77467. * Compute the absolute transforms of this bone and its children
  77468. */
  77469. computeAbsoluteTransforms(): void;
  77470. /**
  77471. * Get the world direction from an axis that is in the local space of the bone
  77472. * @param localAxis The local direction that is used to compute the world direction
  77473. * @param mesh The mesh that this bone is attached to
  77474. * @returns The world direction
  77475. */
  77476. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77477. /**
  77478. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  77479. * @param localAxis The local direction that is used to compute the world direction
  77480. * @param mesh The mesh that this bone is attached to
  77481. * @param result The vector3 that the world direction will be copied to
  77482. */
  77483. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77484. /**
  77485. * Get the euler rotation of the bone in local or world space
  77486. * @param space The space that the rotation should be in
  77487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77488. * @returns The euler rotation
  77489. */
  77490. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77491. /**
  77492. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  77493. * @param space The space that the rotation should be in
  77494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77495. * @param result The vector3 that the rotation should be copied to
  77496. */
  77497. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77498. /**
  77499. * Get the quaternion rotation of the bone in either local or world space
  77500. * @param space The space that the rotation should be in
  77501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77502. * @returns The quaternion rotation
  77503. */
  77504. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  77505. /**
  77506. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  77507. * @param space The space that the rotation should be in
  77508. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77509. * @param result The quaternion that the rotation should be copied to
  77510. */
  77511. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  77512. /**
  77513. * Get the rotation matrix of the bone in local or world space
  77514. * @param space The space that the rotation should be in
  77515. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77516. * @returns The rotation matrix
  77517. */
  77518. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  77519. /**
  77520. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  77521. * @param space The space that the rotation should be in
  77522. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77523. * @param result The quaternion that the rotation should be copied to
  77524. */
  77525. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  77526. /**
  77527. * Get the world position of a point that is in the local space of the bone
  77528. * @param position The local position
  77529. * @param mesh The mesh that this bone is attached to
  77530. * @returns The world position
  77531. */
  77532. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77533. /**
  77534. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  77535. * @param position The local position
  77536. * @param mesh The mesh that this bone is attached to
  77537. * @param result The vector3 that the world position should be copied to
  77538. */
  77539. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77540. /**
  77541. * Get the local position of a point that is in world space
  77542. * @param position The world position
  77543. * @param mesh The mesh that this bone is attached to
  77544. * @returns The local position
  77545. */
  77546. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77547. /**
  77548. * Get the local position of a point that is in world space and copy it to the result param
  77549. * @param position The world position
  77550. * @param mesh The mesh that this bone is attached to
  77551. * @param result The vector3 that the local position should be copied to
  77552. */
  77553. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77554. }
  77555. }
  77556. declare module BABYLON {
  77557. /**
  77558. * 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.
  77559. * @see https://doc.babylonjs.com/how_to/transformnode
  77560. */
  77561. export class TransformNode extends Node {
  77562. /**
  77563. * Object will not rotate to face the camera
  77564. */
  77565. static BILLBOARDMODE_NONE: number;
  77566. /**
  77567. * Object will rotate to face the camera but only on the x axis
  77568. */
  77569. static BILLBOARDMODE_X: number;
  77570. /**
  77571. * Object will rotate to face the camera but only on the y axis
  77572. */
  77573. static BILLBOARDMODE_Y: number;
  77574. /**
  77575. * Object will rotate to face the camera but only on the z axis
  77576. */
  77577. static BILLBOARDMODE_Z: number;
  77578. /**
  77579. * Object will rotate to face the camera
  77580. */
  77581. static BILLBOARDMODE_ALL: number;
  77582. private _forward;
  77583. private _forwardInverted;
  77584. private _up;
  77585. private _right;
  77586. private _rightInverted;
  77587. private _position;
  77588. private _rotation;
  77589. private _rotationQuaternion;
  77590. protected _scaling: Vector3;
  77591. protected _isDirty: boolean;
  77592. private _transformToBoneReferal;
  77593. private _isAbsoluteSynced;
  77594. private _billboardMode;
  77595. /**
  77596. * Gets or sets the billboard mode. Default is 0.
  77597. *
  77598. * | Value | Type | Description |
  77599. * | --- | --- | --- |
  77600. * | 0 | BILLBOARDMODE_NONE | |
  77601. * | 1 | BILLBOARDMODE_X | |
  77602. * | 2 | BILLBOARDMODE_Y | |
  77603. * | 4 | BILLBOARDMODE_Z | |
  77604. * | 7 | BILLBOARDMODE_ALL | |
  77605. *
  77606. */
  77607. billboardMode: number;
  77608. private _preserveParentRotationForBillboard;
  77609. /**
  77610. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  77611. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  77612. */
  77613. preserveParentRotationForBillboard: boolean;
  77614. /**
  77615. * 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
  77616. */
  77617. scalingDeterminant: number;
  77618. private _infiniteDistance;
  77619. /**
  77620. * Gets or sets the distance of the object to max, often used by skybox
  77621. */
  77622. infiniteDistance: boolean;
  77623. /**
  77624. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  77625. * By default the system will update normals to compensate
  77626. */
  77627. ignoreNonUniformScaling: boolean;
  77628. /**
  77629. * 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
  77630. */
  77631. reIntegrateRotationIntoRotationQuaternion: boolean;
  77632. /** @hidden */
  77633. _poseMatrix: Nullable<Matrix>;
  77634. /** @hidden */
  77635. _localMatrix: Matrix;
  77636. private _usePivotMatrix;
  77637. private _absolutePosition;
  77638. private _absoluteScaling;
  77639. private _absoluteRotationQuaternion;
  77640. private _pivotMatrix;
  77641. private _pivotMatrixInverse;
  77642. protected _postMultiplyPivotMatrix: boolean;
  77643. protected _isWorldMatrixFrozen: boolean;
  77644. /** @hidden */
  77645. _indexInSceneTransformNodesArray: number;
  77646. /**
  77647. * An event triggered after the world matrix is updated
  77648. */
  77649. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  77650. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  77651. /**
  77652. * Gets a string identifying the name of the class
  77653. * @returns "TransformNode" string
  77654. */
  77655. getClassName(): string;
  77656. /**
  77657. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  77658. */
  77659. position: Vector3;
  77660. /**
  77661. * 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)).
  77662. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  77663. */
  77664. rotation: Vector3;
  77665. /**
  77666. * 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)).
  77667. */
  77668. scaling: Vector3;
  77669. /**
  77670. * 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).
  77671. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  77672. */
  77673. rotationQuaternion: Nullable<Quaternion>;
  77674. /**
  77675. * The forward direction of that transform in world space.
  77676. */
  77677. readonly forward: Vector3;
  77678. /**
  77679. * The up direction of that transform in world space.
  77680. */
  77681. readonly up: Vector3;
  77682. /**
  77683. * The right direction of that transform in world space.
  77684. */
  77685. readonly right: Vector3;
  77686. /**
  77687. * Copies the parameter passed Matrix into the mesh Pose matrix.
  77688. * @param matrix the matrix to copy the pose from
  77689. * @returns this TransformNode.
  77690. */
  77691. updatePoseMatrix(matrix: Matrix): TransformNode;
  77692. /**
  77693. * Returns the mesh Pose matrix.
  77694. * @returns the pose matrix
  77695. */
  77696. getPoseMatrix(): Matrix;
  77697. /** @hidden */
  77698. _isSynchronized(): boolean;
  77699. /** @hidden */
  77700. _initCache(): void;
  77701. /**
  77702. * Flag the transform node as dirty (Forcing it to update everything)
  77703. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  77704. * @returns this transform node
  77705. */
  77706. markAsDirty(property: string): TransformNode;
  77707. /**
  77708. * Returns the current mesh absolute position.
  77709. * Returns a Vector3.
  77710. */
  77711. readonly absolutePosition: Vector3;
  77712. /**
  77713. * Returns the current mesh absolute scaling.
  77714. * Returns a Vector3.
  77715. */
  77716. readonly absoluteScaling: Vector3;
  77717. /**
  77718. * Returns the current mesh absolute rotation.
  77719. * Returns a Quaternion.
  77720. */
  77721. readonly absoluteRotationQuaternion: Quaternion;
  77722. /**
  77723. * Sets a new matrix to apply before all other transformation
  77724. * @param matrix defines the transform matrix
  77725. * @returns the current TransformNode
  77726. */
  77727. setPreTransformMatrix(matrix: Matrix): TransformNode;
  77728. /**
  77729. * Sets a new pivot matrix to the current node
  77730. * @param matrix defines the new pivot matrix to use
  77731. * @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
  77732. * @returns the current TransformNode
  77733. */
  77734. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  77735. /**
  77736. * Returns the mesh pivot matrix.
  77737. * Default : Identity.
  77738. * @returns the matrix
  77739. */
  77740. getPivotMatrix(): Matrix;
  77741. /**
  77742. * Prevents the World matrix to be computed any longer.
  77743. * @returns the TransformNode.
  77744. */
  77745. freezeWorldMatrix(): TransformNode;
  77746. /**
  77747. * Allows back the World matrix computation.
  77748. * @returns the TransformNode.
  77749. */
  77750. unfreezeWorldMatrix(): this;
  77751. /**
  77752. * True if the World matrix has been frozen.
  77753. */
  77754. readonly isWorldMatrixFrozen: boolean;
  77755. /**
  77756. * Retuns the mesh absolute position in the World.
  77757. * @returns a Vector3.
  77758. */
  77759. getAbsolutePosition(): Vector3;
  77760. /**
  77761. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  77762. * @param absolutePosition the absolute position to set
  77763. * @returns the TransformNode.
  77764. */
  77765. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77766. /**
  77767. * Sets the mesh position in its local space.
  77768. * @param vector3 the position to set in localspace
  77769. * @returns the TransformNode.
  77770. */
  77771. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  77772. /**
  77773. * Returns the mesh position in the local space from the current World matrix values.
  77774. * @returns a new Vector3.
  77775. */
  77776. getPositionExpressedInLocalSpace(): Vector3;
  77777. /**
  77778. * Translates the mesh along the passed Vector3 in its local space.
  77779. * @param vector3 the distance to translate in localspace
  77780. * @returns the TransformNode.
  77781. */
  77782. locallyTranslate(vector3: Vector3): TransformNode;
  77783. private static _lookAtVectorCache;
  77784. /**
  77785. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  77786. * @param targetPoint the position (must be in same space as current mesh) to look at
  77787. * @param yawCor optional yaw (y-axis) correction in radians
  77788. * @param pitchCor optional pitch (x-axis) correction in radians
  77789. * @param rollCor optional roll (z-axis) correction in radians
  77790. * @param space the choosen space of the target
  77791. * @returns the TransformNode.
  77792. */
  77793. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  77794. /**
  77795. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77796. * This Vector3 is expressed in the World space.
  77797. * @param localAxis axis to rotate
  77798. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77799. */
  77800. getDirection(localAxis: Vector3): Vector3;
  77801. /**
  77802. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  77803. * localAxis is expressed in the mesh local space.
  77804. * result is computed in the Wordl space from the mesh World matrix.
  77805. * @param localAxis axis to rotate
  77806. * @param result the resulting transformnode
  77807. * @returns this TransformNode.
  77808. */
  77809. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  77810. /**
  77811. * Sets this transform node rotation to the given local axis.
  77812. * @param localAxis the axis in local space
  77813. * @param yawCor optional yaw (y-axis) correction in radians
  77814. * @param pitchCor optional pitch (x-axis) correction in radians
  77815. * @param rollCor optional roll (z-axis) correction in radians
  77816. * @returns this TransformNode
  77817. */
  77818. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  77819. /**
  77820. * Sets a new pivot point to the current node
  77821. * @param point defines the new pivot point to use
  77822. * @param space defines if the point is in world or local space (local by default)
  77823. * @returns the current TransformNode
  77824. */
  77825. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  77826. /**
  77827. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  77828. * @returns the pivot point
  77829. */
  77830. getPivotPoint(): Vector3;
  77831. /**
  77832. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  77833. * @param result the vector3 to store the result
  77834. * @returns this TransformNode.
  77835. */
  77836. getPivotPointToRef(result: Vector3): TransformNode;
  77837. /**
  77838. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  77839. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  77840. */
  77841. getAbsolutePivotPoint(): Vector3;
  77842. /**
  77843. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  77844. * @param result vector3 to store the result
  77845. * @returns this TransformNode.
  77846. */
  77847. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  77848. /**
  77849. * Defines the passed node as the parent of the current node.
  77850. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  77851. * @see https://doc.babylonjs.com/how_to/parenting
  77852. * @param node the node ot set as the parent
  77853. * @returns this TransformNode.
  77854. */
  77855. setParent(node: Nullable<Node>): TransformNode;
  77856. private _nonUniformScaling;
  77857. /**
  77858. * True if the scaling property of this object is non uniform eg. (1,2,1)
  77859. */
  77860. readonly nonUniformScaling: boolean;
  77861. /** @hidden */
  77862. _updateNonUniformScalingState(value: boolean): boolean;
  77863. /**
  77864. * Attach the current TransformNode to another TransformNode associated with a bone
  77865. * @param bone Bone affecting the TransformNode
  77866. * @param affectedTransformNode TransformNode associated with the bone
  77867. * @returns this object
  77868. */
  77869. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  77870. /**
  77871. * Detach the transform node if its associated with a bone
  77872. * @returns this object
  77873. */
  77874. detachFromBone(): TransformNode;
  77875. private static _rotationAxisCache;
  77876. /**
  77877. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  77878. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77879. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77880. * The passed axis is also normalized.
  77881. * @param axis the axis to rotate around
  77882. * @param amount the amount to rotate in radians
  77883. * @param space Space to rotate in (Default: local)
  77884. * @returns the TransformNode.
  77885. */
  77886. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77887. /**
  77888. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  77889. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77890. * The passed axis is also normalized. .
  77891. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  77892. * @param point the point to rotate around
  77893. * @param axis the axis to rotate around
  77894. * @param amount the amount to rotate in radians
  77895. * @returns the TransformNode
  77896. */
  77897. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  77898. /**
  77899. * Translates the mesh along the axis vector for the passed distance in the given space.
  77900. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77901. * @param axis the axis to translate in
  77902. * @param distance the distance to translate
  77903. * @param space Space to rotate in (Default: local)
  77904. * @returns the TransformNode.
  77905. */
  77906. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77907. /**
  77908. * Adds a rotation step to the mesh current rotation.
  77909. * x, y, z are Euler angles expressed in radians.
  77910. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  77911. * This means this rotation is made in the mesh local space only.
  77912. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  77913. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  77914. * ```javascript
  77915. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  77916. * ```
  77917. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  77918. * 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.
  77919. * @param x Rotation to add
  77920. * @param y Rotation to add
  77921. * @param z Rotation to add
  77922. * @returns the TransformNode.
  77923. */
  77924. addRotation(x: number, y: number, z: number): TransformNode;
  77925. /**
  77926. * @hidden
  77927. */
  77928. protected _getEffectiveParent(): Nullable<Node>;
  77929. /**
  77930. * Computes the world matrix of the node
  77931. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77932. * @returns the world matrix
  77933. */
  77934. computeWorldMatrix(force?: boolean): Matrix;
  77935. protected _afterComputeWorldMatrix(): void;
  77936. /**
  77937. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  77938. * @param func callback function to add
  77939. *
  77940. * @returns the TransformNode.
  77941. */
  77942. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77943. /**
  77944. * Removes a registered callback function.
  77945. * @param func callback function to remove
  77946. * @returns the TransformNode.
  77947. */
  77948. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77949. /**
  77950. * Gets the position of the current mesh in camera space
  77951. * @param camera defines the camera to use
  77952. * @returns a position
  77953. */
  77954. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  77955. /**
  77956. * Returns the distance from the mesh to the active camera
  77957. * @param camera defines the camera to use
  77958. * @returns the distance
  77959. */
  77960. getDistanceToCamera(camera?: Nullable<Camera>): number;
  77961. /**
  77962. * Clone the current transform node
  77963. * @param name Name of the new clone
  77964. * @param newParent New parent for the clone
  77965. * @param doNotCloneChildren Do not clone children hierarchy
  77966. * @returns the new transform node
  77967. */
  77968. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  77969. /**
  77970. * Serializes the objects information.
  77971. * @param currentSerializationObject defines the object to serialize in
  77972. * @returns the serialized object
  77973. */
  77974. serialize(currentSerializationObject?: any): any;
  77975. /**
  77976. * Returns a new TransformNode object parsed from the source provided.
  77977. * @param parsedTransformNode is the source.
  77978. * @param scene the scne the object belongs to
  77979. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  77980. * @returns a new TransformNode object parsed from the source provided.
  77981. */
  77982. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  77983. /**
  77984. * Get all child-transformNodes of this node
  77985. * @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
  77986. * @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
  77987. * @returns an array of TransformNode
  77988. */
  77989. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  77990. /**
  77991. * Releases resources associated with this transform node.
  77992. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77993. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77994. */
  77995. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77996. /**
  77997. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  77998. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  77999. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  78000. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  78001. * @returns the current mesh
  78002. */
  78003. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  78004. private _syncAbsoluteScalingAndRotation;
  78005. }
  78006. }
  78007. declare module BABYLON {
  78008. /**
  78009. * Defines the types of pose enabled controllers that are supported
  78010. */
  78011. export enum PoseEnabledControllerType {
  78012. /**
  78013. * HTC Vive
  78014. */
  78015. VIVE = 0,
  78016. /**
  78017. * Oculus Rift
  78018. */
  78019. OCULUS = 1,
  78020. /**
  78021. * Windows mixed reality
  78022. */
  78023. WINDOWS = 2,
  78024. /**
  78025. * Samsung gear VR
  78026. */
  78027. GEAR_VR = 3,
  78028. /**
  78029. * Google Daydream
  78030. */
  78031. DAYDREAM = 4,
  78032. /**
  78033. * Generic
  78034. */
  78035. GENERIC = 5
  78036. }
  78037. /**
  78038. * Defines the MutableGamepadButton interface for the state of a gamepad button
  78039. */
  78040. export interface MutableGamepadButton {
  78041. /**
  78042. * Value of the button/trigger
  78043. */
  78044. value: number;
  78045. /**
  78046. * If the button/trigger is currently touched
  78047. */
  78048. touched: boolean;
  78049. /**
  78050. * If the button/trigger is currently pressed
  78051. */
  78052. pressed: boolean;
  78053. }
  78054. /**
  78055. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  78056. * @hidden
  78057. */
  78058. export interface ExtendedGamepadButton extends GamepadButton {
  78059. /**
  78060. * If the button/trigger is currently pressed
  78061. */
  78062. readonly pressed: boolean;
  78063. /**
  78064. * If the button/trigger is currently touched
  78065. */
  78066. readonly touched: boolean;
  78067. /**
  78068. * Value of the button/trigger
  78069. */
  78070. readonly value: number;
  78071. }
  78072. /** @hidden */
  78073. export interface _GamePadFactory {
  78074. /**
  78075. * Returns wether or not the current gamepad can be created for this type of controller.
  78076. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78077. * @returns true if it can be created, otherwise false
  78078. */
  78079. canCreate(gamepadInfo: any): boolean;
  78080. /**
  78081. * Creates a new instance of the Gamepad.
  78082. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78083. * @returns the new gamepad instance
  78084. */
  78085. create(gamepadInfo: any): Gamepad;
  78086. }
  78087. /**
  78088. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78089. */
  78090. export class PoseEnabledControllerHelper {
  78091. /** @hidden */
  78092. static _ControllerFactories: _GamePadFactory[];
  78093. /** @hidden */
  78094. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  78095. /**
  78096. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78097. * @param vrGamepad the gamepad to initialized
  78098. * @returns a vr controller of the type the gamepad identified as
  78099. */
  78100. static InitiateController(vrGamepad: any): Gamepad;
  78101. }
  78102. /**
  78103. * Defines the PoseEnabledController object that contains state of a vr capable controller
  78104. */
  78105. export class PoseEnabledController extends Gamepad implements PoseControlled {
  78106. /**
  78107. * If the controller is used in a webXR session
  78108. */
  78109. isXR: boolean;
  78110. private _deviceRoomPosition;
  78111. private _deviceRoomRotationQuaternion;
  78112. /**
  78113. * The device position in babylon space
  78114. */
  78115. devicePosition: Vector3;
  78116. /**
  78117. * The device rotation in babylon space
  78118. */
  78119. deviceRotationQuaternion: Quaternion;
  78120. /**
  78121. * The scale factor of the device in babylon space
  78122. */
  78123. deviceScaleFactor: number;
  78124. /**
  78125. * (Likely devicePosition should be used instead) The device position in its room space
  78126. */
  78127. position: Vector3;
  78128. /**
  78129. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  78130. */
  78131. rotationQuaternion: Quaternion;
  78132. /**
  78133. * The type of controller (Eg. Windows mixed reality)
  78134. */
  78135. controllerType: PoseEnabledControllerType;
  78136. protected _calculatedPosition: Vector3;
  78137. private _calculatedRotation;
  78138. /**
  78139. * The raw pose from the device
  78140. */
  78141. rawPose: DevicePose;
  78142. private _trackPosition;
  78143. private _maxRotationDistFromHeadset;
  78144. private _draggedRoomRotation;
  78145. /**
  78146. * @hidden
  78147. */
  78148. _disableTrackPosition(fixedPosition: Vector3): void;
  78149. /**
  78150. * Internal, the mesh attached to the controller
  78151. * @hidden
  78152. */
  78153. _mesh: Nullable<AbstractMesh>;
  78154. private _poseControlledCamera;
  78155. private _leftHandSystemQuaternion;
  78156. /**
  78157. * Internal, matrix used to convert room space to babylon space
  78158. * @hidden
  78159. */
  78160. _deviceToWorld: Matrix;
  78161. /**
  78162. * Node to be used when casting a ray from the controller
  78163. * @hidden
  78164. */
  78165. _pointingPoseNode: Nullable<TransformNode>;
  78166. /**
  78167. * Name of the child mesh that can be used to cast a ray from the controller
  78168. */
  78169. static readonly POINTING_POSE: string;
  78170. /**
  78171. * Creates a new PoseEnabledController from a gamepad
  78172. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  78173. */
  78174. constructor(browserGamepad: any);
  78175. private _workingMatrix;
  78176. /**
  78177. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  78178. */
  78179. update(): void;
  78180. /**
  78181. * Updates only the pose device and mesh without doing any button event checking
  78182. */
  78183. protected _updatePoseAndMesh(): void;
  78184. /**
  78185. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  78186. * @param poseData raw pose fromthe device
  78187. */
  78188. updateFromDevice(poseData: DevicePose): void;
  78189. /**
  78190. * @hidden
  78191. */
  78192. _meshAttachedObservable: Observable<AbstractMesh>;
  78193. /**
  78194. * Attaches a mesh to the controller
  78195. * @param mesh the mesh to be attached
  78196. */
  78197. attachToMesh(mesh: AbstractMesh): void;
  78198. /**
  78199. * Attaches the controllers mesh to a camera
  78200. * @param camera the camera the mesh should be attached to
  78201. */
  78202. attachToPoseControlledCamera(camera: TargetCamera): void;
  78203. /**
  78204. * Disposes of the controller
  78205. */
  78206. dispose(): void;
  78207. /**
  78208. * The mesh that is attached to the controller
  78209. */
  78210. readonly mesh: Nullable<AbstractMesh>;
  78211. /**
  78212. * Gets the ray of the controller in the direction the controller is pointing
  78213. * @param length the length the resulting ray should be
  78214. * @returns a ray in the direction the controller is pointing
  78215. */
  78216. getForwardRay(length?: number): Ray;
  78217. }
  78218. }
  78219. declare module BABYLON {
  78220. /**
  78221. * Defines the WebVRController object that represents controllers tracked in 3D space
  78222. */
  78223. export abstract class WebVRController extends PoseEnabledController {
  78224. /**
  78225. * Internal, the default controller model for the controller
  78226. */
  78227. protected _defaultModel: AbstractMesh;
  78228. /**
  78229. * Fired when the trigger state has changed
  78230. */
  78231. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  78232. /**
  78233. * Fired when the main button state has changed
  78234. */
  78235. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78236. /**
  78237. * Fired when the secondary button state has changed
  78238. */
  78239. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78240. /**
  78241. * Fired when the pad state has changed
  78242. */
  78243. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  78244. /**
  78245. * Fired when controllers stick values have changed
  78246. */
  78247. onPadValuesChangedObservable: Observable<StickValues>;
  78248. /**
  78249. * Array of button availible on the controller
  78250. */
  78251. protected _buttons: Array<MutableGamepadButton>;
  78252. private _onButtonStateChange;
  78253. /**
  78254. * Fired when a controller button's state has changed
  78255. * @param callback the callback containing the button that was modified
  78256. */
  78257. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  78258. /**
  78259. * X and Y axis corresponding to the controllers joystick
  78260. */
  78261. pad: StickValues;
  78262. /**
  78263. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  78264. */
  78265. hand: string;
  78266. /**
  78267. * The default controller model for the controller
  78268. */
  78269. readonly defaultModel: AbstractMesh;
  78270. /**
  78271. * Creates a new WebVRController from a gamepad
  78272. * @param vrGamepad the gamepad that the WebVRController should be created from
  78273. */
  78274. constructor(vrGamepad: any);
  78275. /**
  78276. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  78277. */
  78278. update(): void;
  78279. /**
  78280. * Function to be called when a button is modified
  78281. */
  78282. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  78283. /**
  78284. * Loads a mesh and attaches it to the controller
  78285. * @param scene the scene the mesh should be added to
  78286. * @param meshLoaded callback for when the mesh has been loaded
  78287. */
  78288. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  78289. private _setButtonValue;
  78290. private _changes;
  78291. private _checkChanges;
  78292. /**
  78293. * Disposes of th webVRCOntroller
  78294. */
  78295. dispose(): void;
  78296. }
  78297. }
  78298. declare module BABYLON {
  78299. /**
  78300. * The HemisphericLight simulates the ambient environment light,
  78301. * so the passed direction is the light reflection direction, not the incoming direction.
  78302. */
  78303. export class HemisphericLight extends Light {
  78304. /**
  78305. * The groundColor is the light in the opposite direction to the one specified during creation.
  78306. * 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.
  78307. */
  78308. groundColor: Color3;
  78309. /**
  78310. * The light reflection direction, not the incoming direction.
  78311. */
  78312. direction: Vector3;
  78313. /**
  78314. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  78315. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  78316. * The HemisphericLight can't cast shadows.
  78317. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78318. * @param name The friendly name of the light
  78319. * @param direction The direction of the light reflection
  78320. * @param scene The scene the light belongs to
  78321. */
  78322. constructor(name: string, direction: Vector3, scene: Scene);
  78323. protected _buildUniformLayout(): void;
  78324. /**
  78325. * Returns the string "HemisphericLight".
  78326. * @return The class name
  78327. */
  78328. getClassName(): string;
  78329. /**
  78330. * Sets the HemisphericLight direction towards the passed target (Vector3).
  78331. * Returns the updated direction.
  78332. * @param target The target the direction should point to
  78333. * @return The computed direction
  78334. */
  78335. setDirectionToTarget(target: Vector3): Vector3;
  78336. /**
  78337. * Returns the shadow generator associated to the light.
  78338. * @returns Always null for hemispheric lights because it does not support shadows.
  78339. */
  78340. getShadowGenerator(): Nullable<IShadowGenerator>;
  78341. /**
  78342. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  78343. * @param effect The effect to update
  78344. * @param lightIndex The index of the light in the effect to update
  78345. * @returns The hemispheric light
  78346. */
  78347. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  78348. /**
  78349. * Computes the world matrix of the node
  78350. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78351. * @param useWasUpdatedFlag defines a reserved property
  78352. * @returns the world matrix
  78353. */
  78354. computeWorldMatrix(): Matrix;
  78355. /**
  78356. * Returns the integer 3.
  78357. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78358. */
  78359. getTypeID(): number;
  78360. /**
  78361. * Prepares the list of defines specific to the light type.
  78362. * @param defines the list of defines
  78363. * @param lightIndex defines the index of the light for the effect
  78364. */
  78365. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78366. }
  78367. }
  78368. declare module BABYLON {
  78369. /** @hidden */
  78370. export var vrMultiviewToSingleviewPixelShader: {
  78371. name: string;
  78372. shader: string;
  78373. };
  78374. }
  78375. declare module BABYLON {
  78376. /**
  78377. * Renders to multiple views with a single draw call
  78378. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  78379. */
  78380. export class MultiviewRenderTarget extends RenderTargetTexture {
  78381. /**
  78382. * Creates a multiview render target
  78383. * @param scene scene used with the render target
  78384. * @param size the size of the render target (used for each view)
  78385. */
  78386. constructor(scene: Scene, size?: number | {
  78387. width: number;
  78388. height: number;
  78389. } | {
  78390. ratio: number;
  78391. });
  78392. /**
  78393. * @hidden
  78394. * @param faceIndex the face index, if its a cube texture
  78395. */
  78396. _bindFrameBuffer(faceIndex?: number): void;
  78397. /**
  78398. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  78399. * @returns the view count
  78400. */
  78401. getViewCount(): number;
  78402. }
  78403. }
  78404. declare module BABYLON {
  78405. /**
  78406. * Reprasents a camera frustum
  78407. */
  78408. export class Frustum {
  78409. /**
  78410. * Gets the planes representing the frustum
  78411. * @param transform matrix to be applied to the returned planes
  78412. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  78413. */
  78414. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  78415. /**
  78416. * Gets the near frustum plane transformed by the transform matrix
  78417. * @param transform transformation matrix to be applied to the resulting frustum plane
  78418. * @param frustumPlane the resuling frustum plane
  78419. */
  78420. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78421. /**
  78422. * Gets the far frustum plane transformed by the transform matrix
  78423. * @param transform transformation matrix to be applied to the resulting frustum plane
  78424. * @param frustumPlane the resuling frustum plane
  78425. */
  78426. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78427. /**
  78428. * Gets the left frustum plane transformed by the transform matrix
  78429. * @param transform transformation matrix to be applied to the resulting frustum plane
  78430. * @param frustumPlane the resuling frustum plane
  78431. */
  78432. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78433. /**
  78434. * Gets the right frustum plane transformed by the transform matrix
  78435. * @param transform transformation matrix to be applied to the resulting frustum plane
  78436. * @param frustumPlane the resuling frustum plane
  78437. */
  78438. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78439. /**
  78440. * Gets the top frustum plane transformed by the transform matrix
  78441. * @param transform transformation matrix to be applied to the resulting frustum plane
  78442. * @param frustumPlane the resuling frustum plane
  78443. */
  78444. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78445. /**
  78446. * Gets the bottom frustum plane transformed by the transform matrix
  78447. * @param transform transformation matrix to be applied to the resulting frustum plane
  78448. * @param frustumPlane the resuling frustum plane
  78449. */
  78450. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78451. /**
  78452. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  78453. * @param transform transformation matrix to be applied to the resulting frustum planes
  78454. * @param frustumPlanes the resuling frustum planes
  78455. */
  78456. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  78457. }
  78458. }
  78459. declare module BABYLON {
  78460. interface Engine {
  78461. /**
  78462. * Creates a new multiview render target
  78463. * @param width defines the width of the texture
  78464. * @param height defines the height of the texture
  78465. * @returns the created multiview texture
  78466. */
  78467. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  78468. /**
  78469. * Binds a multiview framebuffer to be drawn to
  78470. * @param multiviewTexture texture to bind
  78471. */
  78472. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  78473. }
  78474. interface Camera {
  78475. /**
  78476. * @hidden
  78477. * 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)
  78478. */
  78479. _useMultiviewToSingleView: boolean;
  78480. /**
  78481. * @hidden
  78482. * 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)
  78483. */
  78484. _multiviewTexture: Nullable<RenderTargetTexture>;
  78485. /**
  78486. * @hidden
  78487. * ensures the multiview texture of the camera exists and has the specified width/height
  78488. * @param width height to set on the multiview texture
  78489. * @param height width to set on the multiview texture
  78490. */
  78491. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  78492. }
  78493. interface Scene {
  78494. /** @hidden */
  78495. _transformMatrixR: Matrix;
  78496. /** @hidden */
  78497. _multiviewSceneUbo: Nullable<UniformBuffer>;
  78498. /** @hidden */
  78499. _createMultiviewUbo(): void;
  78500. /** @hidden */
  78501. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  78502. /** @hidden */
  78503. _renderMultiviewToSingleView(camera: Camera): void;
  78504. }
  78505. }
  78506. declare module BABYLON {
  78507. /**
  78508. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  78509. * This will not be used for webXR as it supports displaying texture arrays directly
  78510. */
  78511. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  78512. /**
  78513. * Initializes a VRMultiviewToSingleview
  78514. * @param name name of the post process
  78515. * @param camera camera to be applied to
  78516. * @param scaleFactor scaling factor to the size of the output texture
  78517. */
  78518. constructor(name: string, camera: Camera, scaleFactor: number);
  78519. }
  78520. }
  78521. declare module BABYLON {
  78522. interface Engine {
  78523. /** @hidden */
  78524. _vrDisplay: any;
  78525. /** @hidden */
  78526. _vrSupported: boolean;
  78527. /** @hidden */
  78528. _oldSize: Size;
  78529. /** @hidden */
  78530. _oldHardwareScaleFactor: number;
  78531. /** @hidden */
  78532. _vrExclusivePointerMode: boolean;
  78533. /** @hidden */
  78534. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  78535. /** @hidden */
  78536. _onVRDisplayPointerRestricted: () => void;
  78537. /** @hidden */
  78538. _onVRDisplayPointerUnrestricted: () => void;
  78539. /** @hidden */
  78540. _onVrDisplayConnect: Nullable<(display: any) => void>;
  78541. /** @hidden */
  78542. _onVrDisplayDisconnect: Nullable<() => void>;
  78543. /** @hidden */
  78544. _onVrDisplayPresentChange: Nullable<() => void>;
  78545. /**
  78546. * Observable signaled when VR display mode changes
  78547. */
  78548. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  78549. /**
  78550. * Observable signaled when VR request present is complete
  78551. */
  78552. onVRRequestPresentComplete: Observable<boolean>;
  78553. /**
  78554. * Observable signaled when VR request present starts
  78555. */
  78556. onVRRequestPresentStart: Observable<Engine>;
  78557. /**
  78558. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  78559. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  78560. */
  78561. isInVRExclusivePointerMode: boolean;
  78562. /**
  78563. * Gets a boolean indicating if a webVR device was detected
  78564. * @returns true if a webVR device was detected
  78565. */
  78566. isVRDevicePresent(): boolean;
  78567. /**
  78568. * Gets the current webVR device
  78569. * @returns the current webVR device (or null)
  78570. */
  78571. getVRDevice(): any;
  78572. /**
  78573. * Initializes a webVR display and starts listening to display change events
  78574. * The onVRDisplayChangedObservable will be notified upon these changes
  78575. * @returns A promise containing a VRDisplay and if vr is supported
  78576. */
  78577. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  78578. /** @hidden */
  78579. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  78580. /**
  78581. * Call this function to switch to webVR mode
  78582. * Will do nothing if webVR is not supported or if there is no webVR device
  78583. * @see http://doc.babylonjs.com/how_to/webvr_camera
  78584. */
  78585. enableVR(): void;
  78586. /** @hidden */
  78587. _onVRFullScreenTriggered(): void;
  78588. }
  78589. }
  78590. declare module BABYLON {
  78591. /**
  78592. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  78593. * IMPORTANT!! The data is right-hand data.
  78594. * @export
  78595. * @interface DevicePose
  78596. */
  78597. export interface DevicePose {
  78598. /**
  78599. * The position of the device, values in array are [x,y,z].
  78600. */
  78601. readonly position: Nullable<Float32Array>;
  78602. /**
  78603. * The linearVelocity of the device, values in array are [x,y,z].
  78604. */
  78605. readonly linearVelocity: Nullable<Float32Array>;
  78606. /**
  78607. * The linearAcceleration of the device, values in array are [x,y,z].
  78608. */
  78609. readonly linearAcceleration: Nullable<Float32Array>;
  78610. /**
  78611. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  78612. */
  78613. readonly orientation: Nullable<Float32Array>;
  78614. /**
  78615. * The angularVelocity of the device, values in array are [x,y,z].
  78616. */
  78617. readonly angularVelocity: Nullable<Float32Array>;
  78618. /**
  78619. * The angularAcceleration of the device, values in array are [x,y,z].
  78620. */
  78621. readonly angularAcceleration: Nullable<Float32Array>;
  78622. }
  78623. /**
  78624. * Interface representing a pose controlled object in Babylon.
  78625. * A pose controlled object has both regular pose values as well as pose values
  78626. * from an external device such as a VR head mounted display
  78627. */
  78628. export interface PoseControlled {
  78629. /**
  78630. * The position of the object in babylon space.
  78631. */
  78632. position: Vector3;
  78633. /**
  78634. * The rotation quaternion of the object in babylon space.
  78635. */
  78636. rotationQuaternion: Quaternion;
  78637. /**
  78638. * The position of the device in babylon space.
  78639. */
  78640. devicePosition?: Vector3;
  78641. /**
  78642. * The rotation quaternion of the device in babylon space.
  78643. */
  78644. deviceRotationQuaternion: Quaternion;
  78645. /**
  78646. * The raw pose coming from the device.
  78647. */
  78648. rawPose: Nullable<DevicePose>;
  78649. /**
  78650. * The scale of the device to be used when translating from device space to babylon space.
  78651. */
  78652. deviceScaleFactor: number;
  78653. /**
  78654. * Updates the poseControlled values based on the input device pose.
  78655. * @param poseData the pose data to update the object with
  78656. */
  78657. updateFromDevice(poseData: DevicePose): void;
  78658. }
  78659. /**
  78660. * Set of options to customize the webVRCamera
  78661. */
  78662. export interface WebVROptions {
  78663. /**
  78664. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  78665. */
  78666. trackPosition?: boolean;
  78667. /**
  78668. * Sets the scale of the vrDevice in babylon space. (default: 1)
  78669. */
  78670. positionScale?: number;
  78671. /**
  78672. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  78673. */
  78674. displayName?: string;
  78675. /**
  78676. * Should the native controller meshes be initialized. (default: true)
  78677. */
  78678. controllerMeshes?: boolean;
  78679. /**
  78680. * Creating a default HemiLight only on controllers. (default: true)
  78681. */
  78682. defaultLightingOnControllers?: boolean;
  78683. /**
  78684. * If you don't want to use the default VR button of the helper. (default: false)
  78685. */
  78686. useCustomVRButton?: boolean;
  78687. /**
  78688. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  78689. */
  78690. customVRButton?: HTMLButtonElement;
  78691. /**
  78692. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  78693. */
  78694. rayLength?: number;
  78695. /**
  78696. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  78697. */
  78698. defaultHeight?: number;
  78699. /**
  78700. * If multiview should be used if availible (default: false)
  78701. */
  78702. useMultiview?: boolean;
  78703. }
  78704. /**
  78705. * This represents a WebVR camera.
  78706. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  78707. * @example http://doc.babylonjs.com/how_to/webvr_camera
  78708. */
  78709. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  78710. private webVROptions;
  78711. /**
  78712. * @hidden
  78713. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  78714. */
  78715. _vrDevice: any;
  78716. /**
  78717. * The rawPose of the vrDevice.
  78718. */
  78719. rawPose: Nullable<DevicePose>;
  78720. private _onVREnabled;
  78721. private _specsVersion;
  78722. private _attached;
  78723. private _frameData;
  78724. protected _descendants: Array<Node>;
  78725. private _deviceRoomPosition;
  78726. /** @hidden */
  78727. _deviceRoomRotationQuaternion: Quaternion;
  78728. private _standingMatrix;
  78729. /**
  78730. * Represents device position in babylon space.
  78731. */
  78732. devicePosition: Vector3;
  78733. /**
  78734. * Represents device rotation in babylon space.
  78735. */
  78736. deviceRotationQuaternion: Quaternion;
  78737. /**
  78738. * The scale of the device to be used when translating from device space to babylon space.
  78739. */
  78740. deviceScaleFactor: number;
  78741. private _deviceToWorld;
  78742. private _worldToDevice;
  78743. /**
  78744. * References to the webVR controllers for the vrDevice.
  78745. */
  78746. controllers: Array<WebVRController>;
  78747. /**
  78748. * Emits an event when a controller is attached.
  78749. */
  78750. onControllersAttachedObservable: Observable<WebVRController[]>;
  78751. /**
  78752. * Emits an event when a controller's mesh has been loaded;
  78753. */
  78754. onControllerMeshLoadedObservable: Observable<WebVRController>;
  78755. /**
  78756. * Emits an event when the HMD's pose has been updated.
  78757. */
  78758. onPoseUpdatedFromDeviceObservable: Observable<any>;
  78759. private _poseSet;
  78760. /**
  78761. * If the rig cameras be used as parent instead of this camera.
  78762. */
  78763. rigParenting: boolean;
  78764. private _lightOnControllers;
  78765. private _defaultHeight?;
  78766. /**
  78767. * Instantiates a WebVRFreeCamera.
  78768. * @param name The name of the WebVRFreeCamera
  78769. * @param position The starting anchor position for the camera
  78770. * @param scene The scene the camera belongs to
  78771. * @param webVROptions a set of customizable options for the webVRCamera
  78772. */
  78773. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  78774. /**
  78775. * Gets the device distance from the ground in meters.
  78776. * @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.
  78777. */
  78778. deviceDistanceToRoomGround(): number;
  78779. /**
  78780. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78781. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  78782. */
  78783. useStandingMatrix(callback?: (bool: boolean) => void): void;
  78784. /**
  78785. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78786. * @returns A promise with a boolean set to if the standing matrix is supported.
  78787. */
  78788. useStandingMatrixAsync(): Promise<boolean>;
  78789. /**
  78790. * Disposes the camera
  78791. */
  78792. dispose(): void;
  78793. /**
  78794. * Gets a vrController by name.
  78795. * @param name The name of the controller to retreive
  78796. * @returns the controller matching the name specified or null if not found
  78797. */
  78798. getControllerByName(name: string): Nullable<WebVRController>;
  78799. private _leftController;
  78800. /**
  78801. * The controller corresponding to the users left hand.
  78802. */
  78803. readonly leftController: Nullable<WebVRController>;
  78804. private _rightController;
  78805. /**
  78806. * The controller corresponding to the users right hand.
  78807. */
  78808. readonly rightController: Nullable<WebVRController>;
  78809. /**
  78810. * Casts a ray forward from the vrCamera's gaze.
  78811. * @param length Length of the ray (default: 100)
  78812. * @returns the ray corresponding to the gaze
  78813. */
  78814. getForwardRay(length?: number): Ray;
  78815. /**
  78816. * @hidden
  78817. * Updates the camera based on device's frame data
  78818. */
  78819. _checkInputs(): void;
  78820. /**
  78821. * Updates the poseControlled values based on the input device pose.
  78822. * @param poseData Pose coming from the device
  78823. */
  78824. updateFromDevice(poseData: DevicePose): void;
  78825. private _htmlElementAttached;
  78826. private _detachIfAttached;
  78827. /**
  78828. * WebVR's attach control will start broadcasting frames to the device.
  78829. * Note that in certain browsers (chrome for example) this function must be called
  78830. * within a user-interaction callback. Example:
  78831. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  78832. *
  78833. * @param element html element to attach the vrDevice to
  78834. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  78835. */
  78836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78837. /**
  78838. * Detaches the camera from the html element and disables VR
  78839. *
  78840. * @param element html element to detach from
  78841. */
  78842. detachControl(element: HTMLElement): void;
  78843. /**
  78844. * @returns the name of this class
  78845. */
  78846. getClassName(): string;
  78847. /**
  78848. * Calls resetPose on the vrDisplay
  78849. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  78850. */
  78851. resetToCurrentRotation(): void;
  78852. /**
  78853. * @hidden
  78854. * Updates the rig cameras (left and right eye)
  78855. */
  78856. _updateRigCameras(): void;
  78857. private _workingVector;
  78858. private _oneVector;
  78859. private _workingMatrix;
  78860. private updateCacheCalled;
  78861. private _correctPositionIfNotTrackPosition;
  78862. /**
  78863. * @hidden
  78864. * Updates the cached values of the camera
  78865. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  78866. */
  78867. _updateCache(ignoreParentClass?: boolean): void;
  78868. /**
  78869. * @hidden
  78870. * Get current device position in babylon world
  78871. */
  78872. _computeDevicePosition(): void;
  78873. /**
  78874. * Updates the current device position and rotation in the babylon world
  78875. */
  78876. update(): void;
  78877. /**
  78878. * @hidden
  78879. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  78880. * @returns an identity matrix
  78881. */
  78882. _getViewMatrix(): Matrix;
  78883. private _tmpMatrix;
  78884. /**
  78885. * This function is called by the two RIG cameras.
  78886. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  78887. * @hidden
  78888. */
  78889. _getWebVRViewMatrix(): Matrix;
  78890. /** @hidden */
  78891. _getWebVRProjectionMatrix(): Matrix;
  78892. private _onGamepadConnectedObserver;
  78893. private _onGamepadDisconnectedObserver;
  78894. private _updateCacheWhenTrackingDisabledObserver;
  78895. /**
  78896. * Initializes the controllers and their meshes
  78897. */
  78898. initControllers(): void;
  78899. }
  78900. }
  78901. declare module BABYLON {
  78902. /**
  78903. * Size options for a post process
  78904. */
  78905. export type PostProcessOptions = {
  78906. width: number;
  78907. height: number;
  78908. };
  78909. /**
  78910. * PostProcess can be used to apply a shader to a texture after it has been rendered
  78911. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78912. */
  78913. export class PostProcess {
  78914. /** Name of the PostProcess. */
  78915. name: string;
  78916. /**
  78917. * Gets or sets the unique id of the post process
  78918. */
  78919. uniqueId: number;
  78920. /**
  78921. * Width of the texture to apply the post process on
  78922. */
  78923. width: number;
  78924. /**
  78925. * Height of the texture to apply the post process on
  78926. */
  78927. height: number;
  78928. /**
  78929. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  78930. * @hidden
  78931. */
  78932. _outputTexture: Nullable<InternalTexture>;
  78933. /**
  78934. * Sampling mode used by the shader
  78935. * See https://doc.babylonjs.com/classes/3.1/texture
  78936. */
  78937. renderTargetSamplingMode: number;
  78938. /**
  78939. * Clear color to use when screen clearing
  78940. */
  78941. clearColor: Color4;
  78942. /**
  78943. * If the buffer needs to be cleared before applying the post process. (default: true)
  78944. * Should be set to false if shader will overwrite all previous pixels.
  78945. */
  78946. autoClear: boolean;
  78947. /**
  78948. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  78949. */
  78950. alphaMode: number;
  78951. /**
  78952. * Sets the setAlphaBlendConstants of the babylon engine
  78953. */
  78954. alphaConstants: Color4;
  78955. /**
  78956. * Animations to be used for the post processing
  78957. */
  78958. animations: Animation[];
  78959. /**
  78960. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  78961. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  78962. */
  78963. enablePixelPerfectMode: boolean;
  78964. /**
  78965. * Force the postprocess to be applied without taking in account viewport
  78966. */
  78967. forceFullscreenViewport: boolean;
  78968. /**
  78969. * List of inspectable custom properties (used by the Inspector)
  78970. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78971. */
  78972. inspectableCustomProperties: IInspectable[];
  78973. /**
  78974. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  78975. *
  78976. * | Value | Type | Description |
  78977. * | ----- | ----------------------------------- | ----------- |
  78978. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  78979. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  78980. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  78981. *
  78982. */
  78983. scaleMode: number;
  78984. /**
  78985. * Force textures to be a power of two (default: false)
  78986. */
  78987. alwaysForcePOT: boolean;
  78988. private _samples;
  78989. /**
  78990. * Number of sample textures (default: 1)
  78991. */
  78992. samples: number;
  78993. /**
  78994. * Modify the scale of the post process to be the same as the viewport (default: false)
  78995. */
  78996. adaptScaleToCurrentViewport: boolean;
  78997. private _camera;
  78998. private _scene;
  78999. private _engine;
  79000. private _options;
  79001. private _reusable;
  79002. private _textureType;
  79003. /**
  79004. * Smart array of input and output textures for the post process.
  79005. * @hidden
  79006. */
  79007. _textures: SmartArray<InternalTexture>;
  79008. /**
  79009. * The index in _textures that corresponds to the output texture.
  79010. * @hidden
  79011. */
  79012. _currentRenderTextureInd: number;
  79013. private _effect;
  79014. private _samplers;
  79015. private _fragmentUrl;
  79016. private _vertexUrl;
  79017. private _parameters;
  79018. private _scaleRatio;
  79019. protected _indexParameters: any;
  79020. private _shareOutputWithPostProcess;
  79021. private _texelSize;
  79022. private _forcedOutputTexture;
  79023. /**
  79024. * Returns the fragment url or shader name used in the post process.
  79025. * @returns the fragment url or name in the shader store.
  79026. */
  79027. getEffectName(): string;
  79028. /**
  79029. * An event triggered when the postprocess is activated.
  79030. */
  79031. onActivateObservable: Observable<Camera>;
  79032. private _onActivateObserver;
  79033. /**
  79034. * A function that is added to the onActivateObservable
  79035. */
  79036. onActivate: Nullable<(camera: Camera) => void>;
  79037. /**
  79038. * An event triggered when the postprocess changes its size.
  79039. */
  79040. onSizeChangedObservable: Observable<PostProcess>;
  79041. private _onSizeChangedObserver;
  79042. /**
  79043. * A function that is added to the onSizeChangedObservable
  79044. */
  79045. onSizeChanged: (postProcess: PostProcess) => void;
  79046. /**
  79047. * An event triggered when the postprocess applies its effect.
  79048. */
  79049. onApplyObservable: Observable<Effect>;
  79050. private _onApplyObserver;
  79051. /**
  79052. * A function that is added to the onApplyObservable
  79053. */
  79054. onApply: (effect: Effect) => void;
  79055. /**
  79056. * An event triggered before rendering the postprocess
  79057. */
  79058. onBeforeRenderObservable: Observable<Effect>;
  79059. private _onBeforeRenderObserver;
  79060. /**
  79061. * A function that is added to the onBeforeRenderObservable
  79062. */
  79063. onBeforeRender: (effect: Effect) => void;
  79064. /**
  79065. * An event triggered after rendering the postprocess
  79066. */
  79067. onAfterRenderObservable: Observable<Effect>;
  79068. private _onAfterRenderObserver;
  79069. /**
  79070. * A function that is added to the onAfterRenderObservable
  79071. */
  79072. onAfterRender: (efect: Effect) => void;
  79073. /**
  79074. * 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
  79075. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  79076. */
  79077. inputTexture: InternalTexture;
  79078. /**
  79079. * Gets the camera which post process is applied to.
  79080. * @returns The camera the post process is applied to.
  79081. */
  79082. getCamera(): Camera;
  79083. /**
  79084. * Gets the texel size of the postprocess.
  79085. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  79086. */
  79087. readonly texelSize: Vector2;
  79088. /**
  79089. * Creates a new instance PostProcess
  79090. * @param name The name of the PostProcess.
  79091. * @param fragmentUrl The url of the fragment shader to be used.
  79092. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  79093. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  79094. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79095. * @param camera The camera to apply the render pass to.
  79096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79097. * @param engine The engine which the post process will be applied. (default: current engine)
  79098. * @param reusable If the post process can be reused on the same frame. (default: false)
  79099. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  79100. * @param textureType Type of textures used when performing the post process. (default: 0)
  79101. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  79102. * @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
  79103. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  79104. */
  79105. constructor(
  79106. /** Name of the PostProcess. */
  79107. 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);
  79108. /**
  79109. * Gets a string idenfifying the name of the class
  79110. * @returns "PostProcess" string
  79111. */
  79112. getClassName(): string;
  79113. /**
  79114. * Gets the engine which this post process belongs to.
  79115. * @returns The engine the post process was enabled with.
  79116. */
  79117. getEngine(): Engine;
  79118. /**
  79119. * The effect that is created when initializing the post process.
  79120. * @returns The created effect corresponding the the postprocess.
  79121. */
  79122. getEffect(): Effect;
  79123. /**
  79124. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  79125. * @param postProcess The post process to share the output with.
  79126. * @returns This post process.
  79127. */
  79128. shareOutputWith(postProcess: PostProcess): PostProcess;
  79129. /**
  79130. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  79131. * This should be called if the post process that shares output with this post process is disabled/disposed.
  79132. */
  79133. useOwnOutput(): void;
  79134. /**
  79135. * Updates the effect with the current post process compile time values and recompiles the shader.
  79136. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79137. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79138. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79139. * @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
  79140. * @param onCompiled Called when the shader has been compiled.
  79141. * @param onError Called if there is an error when compiling a shader.
  79142. */
  79143. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79144. /**
  79145. * The post process is reusable if it can be used multiple times within one frame.
  79146. * @returns If the post process is reusable
  79147. */
  79148. isReusable(): boolean;
  79149. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  79150. markTextureDirty(): void;
  79151. /**
  79152. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  79153. * 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.
  79154. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  79155. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  79156. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  79157. * @returns The target texture that was bound to be written to.
  79158. */
  79159. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  79160. /**
  79161. * If the post process is supported.
  79162. */
  79163. readonly isSupported: boolean;
  79164. /**
  79165. * The aspect ratio of the output texture.
  79166. */
  79167. readonly aspectRatio: number;
  79168. /**
  79169. * Get a value indicating if the post-process is ready to be used
  79170. * @returns true if the post-process is ready (shader is compiled)
  79171. */
  79172. isReady(): boolean;
  79173. /**
  79174. * Binds all textures and uniforms to the shader, this will be run on every pass.
  79175. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  79176. */
  79177. apply(): Nullable<Effect>;
  79178. private _disposeTextures;
  79179. /**
  79180. * Disposes the post process.
  79181. * @param camera The camera to dispose the post process on.
  79182. */
  79183. dispose(camera?: Camera): void;
  79184. }
  79185. }
  79186. declare module BABYLON {
  79187. /** @hidden */
  79188. export var kernelBlurVaryingDeclaration: {
  79189. name: string;
  79190. shader: string;
  79191. };
  79192. }
  79193. declare module BABYLON {
  79194. /** @hidden */
  79195. export var kernelBlurFragment: {
  79196. name: string;
  79197. shader: string;
  79198. };
  79199. }
  79200. declare module BABYLON {
  79201. /** @hidden */
  79202. export var kernelBlurFragment2: {
  79203. name: string;
  79204. shader: string;
  79205. };
  79206. }
  79207. declare module BABYLON {
  79208. /** @hidden */
  79209. export var kernelBlurPixelShader: {
  79210. name: string;
  79211. shader: string;
  79212. };
  79213. }
  79214. declare module BABYLON {
  79215. /** @hidden */
  79216. export var kernelBlurVertex: {
  79217. name: string;
  79218. shader: string;
  79219. };
  79220. }
  79221. declare module BABYLON {
  79222. /** @hidden */
  79223. export var kernelBlurVertexShader: {
  79224. name: string;
  79225. shader: string;
  79226. };
  79227. }
  79228. declare module BABYLON {
  79229. /**
  79230. * The Blur Post Process which blurs an image based on a kernel and direction.
  79231. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  79232. */
  79233. export class BlurPostProcess extends PostProcess {
  79234. /** The direction in which to blur the image. */
  79235. direction: Vector2;
  79236. private blockCompilation;
  79237. protected _kernel: number;
  79238. protected _idealKernel: number;
  79239. protected _packedFloat: boolean;
  79240. private _staticDefines;
  79241. /**
  79242. * Sets the length in pixels of the blur sample region
  79243. */
  79244. /**
  79245. * Gets the length in pixels of the blur sample region
  79246. */
  79247. kernel: number;
  79248. /**
  79249. * Sets wether or not the blur needs to unpack/repack floats
  79250. */
  79251. /**
  79252. * Gets wether or not the blur is unpacking/repacking floats
  79253. */
  79254. packedFloat: boolean;
  79255. /**
  79256. * Creates a new instance BlurPostProcess
  79257. * @param name The name of the effect.
  79258. * @param direction The direction in which to blur the image.
  79259. * @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.
  79260. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79261. * @param camera The camera to apply the render pass to.
  79262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79263. * @param engine The engine which the post process will be applied. (default: current engine)
  79264. * @param reusable If the post process can be reused on the same frame. (default: false)
  79265. * @param textureType Type of textures used when performing the post process. (default: 0)
  79266. * @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)
  79267. */
  79268. constructor(name: string,
  79269. /** The direction in which to blur the image. */
  79270. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  79271. /**
  79272. * Updates the effect with the current post process compile time values and recompiles the shader.
  79273. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79274. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79275. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79276. * @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
  79277. * @param onCompiled Called when the shader has been compiled.
  79278. * @param onError Called if there is an error when compiling a shader.
  79279. */
  79280. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79281. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79282. /**
  79283. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  79284. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  79285. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  79286. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  79287. * The gaps between physical kernels are compensated for in the weighting of the samples
  79288. * @param idealKernel Ideal blur kernel.
  79289. * @return Nearest best kernel.
  79290. */
  79291. protected _nearestBestKernel(idealKernel: number): number;
  79292. /**
  79293. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  79294. * @param x The point on the Gaussian distribution to sample.
  79295. * @return the value of the Gaussian function at x.
  79296. */
  79297. protected _gaussianWeight(x: number): number;
  79298. /**
  79299. * Generates a string that can be used as a floating point number in GLSL.
  79300. * @param x Value to print.
  79301. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  79302. * @return GLSL float string.
  79303. */
  79304. protected _glslFloat(x: number, decimalFigures?: number): string;
  79305. }
  79306. }
  79307. declare module BABYLON {
  79308. /**
  79309. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79310. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79311. * You can then easily use it as a reflectionTexture on a flat surface.
  79312. * In case the surface is not a plane, please consider relying on reflection probes.
  79313. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79314. */
  79315. export class MirrorTexture extends RenderTargetTexture {
  79316. private scene;
  79317. /**
  79318. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  79319. * 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.
  79320. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79321. */
  79322. mirrorPlane: Plane;
  79323. /**
  79324. * Define the blur ratio used to blur the reflection if needed.
  79325. */
  79326. blurRatio: number;
  79327. /**
  79328. * Define the adaptive blur kernel used to blur the reflection if needed.
  79329. * This will autocompute the closest best match for the `blurKernel`
  79330. */
  79331. adaptiveBlurKernel: number;
  79332. /**
  79333. * Define the blur kernel used to blur the reflection if needed.
  79334. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79335. */
  79336. blurKernel: number;
  79337. /**
  79338. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  79339. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79340. */
  79341. blurKernelX: number;
  79342. /**
  79343. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  79344. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79345. */
  79346. blurKernelY: number;
  79347. private _autoComputeBlurKernel;
  79348. protected _onRatioRescale(): void;
  79349. private _updateGammaSpace;
  79350. private _imageProcessingConfigChangeObserver;
  79351. private _transformMatrix;
  79352. private _mirrorMatrix;
  79353. private _savedViewMatrix;
  79354. private _blurX;
  79355. private _blurY;
  79356. private _adaptiveBlurKernel;
  79357. private _blurKernelX;
  79358. private _blurKernelY;
  79359. private _blurRatio;
  79360. /**
  79361. * Instantiates a Mirror Texture.
  79362. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79363. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79364. * You can then easily use it as a reflectionTexture on a flat surface.
  79365. * In case the surface is not a plane, please consider relying on reflection probes.
  79366. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79367. * @param name
  79368. * @param size
  79369. * @param scene
  79370. * @param generateMipMaps
  79371. * @param type
  79372. * @param samplingMode
  79373. * @param generateDepthBuffer
  79374. */
  79375. constructor(name: string, size: number | {
  79376. width: number;
  79377. height: number;
  79378. } | {
  79379. ratio: number;
  79380. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  79381. private _preparePostProcesses;
  79382. /**
  79383. * Clone the mirror texture.
  79384. * @returns the cloned texture
  79385. */
  79386. clone(): MirrorTexture;
  79387. /**
  79388. * Serialize the texture to a JSON representation you could use in Parse later on
  79389. * @returns the serialized JSON representation
  79390. */
  79391. serialize(): any;
  79392. /**
  79393. * Dispose the texture and release its associated resources.
  79394. */
  79395. dispose(): void;
  79396. }
  79397. }
  79398. declare module BABYLON {
  79399. /**
  79400. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79401. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79402. */
  79403. export class Texture extends BaseTexture {
  79404. /** @hidden */
  79405. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  79406. /** @hidden */
  79407. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  79408. /** @hidden */
  79409. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  79410. /** nearest is mag = nearest and min = nearest and mip = linear */
  79411. static readonly NEAREST_SAMPLINGMODE: number;
  79412. /** nearest is mag = nearest and min = nearest and mip = linear */
  79413. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  79414. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79415. static readonly BILINEAR_SAMPLINGMODE: number;
  79416. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79417. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  79418. /** Trilinear is mag = linear and min = linear and mip = linear */
  79419. static readonly TRILINEAR_SAMPLINGMODE: number;
  79420. /** Trilinear is mag = linear and min = linear and mip = linear */
  79421. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  79422. /** mag = nearest and min = nearest and mip = nearest */
  79423. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  79424. /** mag = nearest and min = linear and mip = nearest */
  79425. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  79426. /** mag = nearest and min = linear and mip = linear */
  79427. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  79428. /** mag = nearest and min = linear and mip = none */
  79429. static readonly NEAREST_LINEAR: number;
  79430. /** mag = nearest and min = nearest and mip = none */
  79431. static readonly NEAREST_NEAREST: number;
  79432. /** mag = linear and min = nearest and mip = nearest */
  79433. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  79434. /** mag = linear and min = nearest and mip = linear */
  79435. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  79436. /** mag = linear and min = linear and mip = none */
  79437. static readonly LINEAR_LINEAR: number;
  79438. /** mag = linear and min = nearest and mip = none */
  79439. static readonly LINEAR_NEAREST: number;
  79440. /** Explicit coordinates mode */
  79441. static readonly EXPLICIT_MODE: number;
  79442. /** Spherical coordinates mode */
  79443. static readonly SPHERICAL_MODE: number;
  79444. /** Planar coordinates mode */
  79445. static readonly PLANAR_MODE: number;
  79446. /** Cubic coordinates mode */
  79447. static readonly CUBIC_MODE: number;
  79448. /** Projection coordinates mode */
  79449. static readonly PROJECTION_MODE: number;
  79450. /** Inverse Cubic coordinates mode */
  79451. static readonly SKYBOX_MODE: number;
  79452. /** Inverse Cubic coordinates mode */
  79453. static readonly INVCUBIC_MODE: number;
  79454. /** Equirectangular coordinates mode */
  79455. static readonly EQUIRECTANGULAR_MODE: number;
  79456. /** Equirectangular Fixed coordinates mode */
  79457. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  79458. /** Equirectangular Fixed Mirrored coordinates mode */
  79459. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79460. /** Texture is not repeating outside of 0..1 UVs */
  79461. static readonly CLAMP_ADDRESSMODE: number;
  79462. /** Texture is repeating outside of 0..1 UVs */
  79463. static readonly WRAP_ADDRESSMODE: number;
  79464. /** Texture is repeating and mirrored */
  79465. static readonly MIRROR_ADDRESSMODE: number;
  79466. /**
  79467. * 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
  79468. */
  79469. static UseSerializedUrlIfAny: boolean;
  79470. /**
  79471. * Define the url of the texture.
  79472. */
  79473. url: Nullable<string>;
  79474. /**
  79475. * Define an offset on the texture to offset the u coordinates of the UVs
  79476. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79477. */
  79478. uOffset: number;
  79479. /**
  79480. * Define an offset on the texture to offset the v coordinates of the UVs
  79481. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79482. */
  79483. vOffset: number;
  79484. /**
  79485. * Define an offset on the texture to scale the u coordinates of the UVs
  79486. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79487. */
  79488. uScale: number;
  79489. /**
  79490. * Define an offset on the texture to scale the v coordinates of the UVs
  79491. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79492. */
  79493. vScale: number;
  79494. /**
  79495. * Define an offset on the texture to rotate around the u coordinates of the UVs
  79496. * @see http://doc.babylonjs.com/how_to/more_materials
  79497. */
  79498. uAng: number;
  79499. /**
  79500. * Define an offset on the texture to rotate around the v coordinates of the UVs
  79501. * @see http://doc.babylonjs.com/how_to/more_materials
  79502. */
  79503. vAng: number;
  79504. /**
  79505. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  79506. * @see http://doc.babylonjs.com/how_to/more_materials
  79507. */
  79508. wAng: number;
  79509. /**
  79510. * Defines the center of rotation (U)
  79511. */
  79512. uRotationCenter: number;
  79513. /**
  79514. * Defines the center of rotation (V)
  79515. */
  79516. vRotationCenter: number;
  79517. /**
  79518. * Defines the center of rotation (W)
  79519. */
  79520. wRotationCenter: number;
  79521. /**
  79522. * Are mip maps generated for this texture or not.
  79523. */
  79524. readonly noMipmap: boolean;
  79525. /**
  79526. * List of inspectable custom properties (used by the Inspector)
  79527. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79528. */
  79529. inspectableCustomProperties: Nullable<IInspectable[]>;
  79530. private _noMipmap;
  79531. /** @hidden */
  79532. _invertY: boolean;
  79533. private _rowGenerationMatrix;
  79534. private _cachedTextureMatrix;
  79535. private _projectionModeMatrix;
  79536. private _t0;
  79537. private _t1;
  79538. private _t2;
  79539. private _cachedUOffset;
  79540. private _cachedVOffset;
  79541. private _cachedUScale;
  79542. private _cachedVScale;
  79543. private _cachedUAng;
  79544. private _cachedVAng;
  79545. private _cachedWAng;
  79546. private _cachedProjectionMatrixId;
  79547. private _cachedCoordinatesMode;
  79548. /** @hidden */
  79549. protected _initialSamplingMode: number;
  79550. /** @hidden */
  79551. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  79552. private _deleteBuffer;
  79553. protected _format: Nullable<number>;
  79554. private _delayedOnLoad;
  79555. private _delayedOnError;
  79556. /**
  79557. * Observable triggered once the texture has been loaded.
  79558. */
  79559. onLoadObservable: Observable<Texture>;
  79560. protected _isBlocking: boolean;
  79561. /**
  79562. * Is the texture preventing material to render while loading.
  79563. * If false, a default texture will be used instead of the loading one during the preparation step.
  79564. */
  79565. isBlocking: boolean;
  79566. /**
  79567. * Get the current sampling mode associated with the texture.
  79568. */
  79569. readonly samplingMode: number;
  79570. /**
  79571. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  79572. */
  79573. readonly invertY: boolean;
  79574. /**
  79575. * Instantiates a new texture.
  79576. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79577. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79578. * @param url define the url of the picture to load as a texture
  79579. * @param scene define the scene or engine the texture will belong to
  79580. * @param noMipmap define if the texture will require mip maps or not
  79581. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79582. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79583. * @param onLoad define a callback triggered when the texture has been loaded
  79584. * @param onError define a callback triggered when an error occurred during the loading session
  79585. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79586. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79587. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79588. */
  79589. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  79590. /**
  79591. * Update the url (and optional buffer) of this texture if url was null during construction.
  79592. * @param url the url of the texture
  79593. * @param buffer the buffer of the texture (defaults to null)
  79594. * @param onLoad callback called when the texture is loaded (defaults to null)
  79595. */
  79596. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  79597. /**
  79598. * Finish the loading sequence of a texture flagged as delayed load.
  79599. * @hidden
  79600. */
  79601. delayLoad(): void;
  79602. private _prepareRowForTextureGeneration;
  79603. /**
  79604. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  79605. * @returns the transform matrix of the texture.
  79606. */
  79607. getTextureMatrix(): Matrix;
  79608. /**
  79609. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  79610. * @returns The reflection texture transform
  79611. */
  79612. getReflectionTextureMatrix(): Matrix;
  79613. /**
  79614. * Clones the texture.
  79615. * @returns the cloned texture
  79616. */
  79617. clone(): Texture;
  79618. /**
  79619. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  79620. * @returns The JSON representation of the texture
  79621. */
  79622. serialize(): any;
  79623. /**
  79624. * Get the current class name of the texture useful for serialization or dynamic coding.
  79625. * @returns "Texture"
  79626. */
  79627. getClassName(): string;
  79628. /**
  79629. * Dispose the texture and release its associated resources.
  79630. */
  79631. dispose(): void;
  79632. /**
  79633. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  79634. * @param parsedTexture Define the JSON representation of the texture
  79635. * @param scene Define the scene the parsed texture should be instantiated in
  79636. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  79637. * @returns The parsed texture if successful
  79638. */
  79639. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  79640. /**
  79641. * Creates a texture from its base 64 representation.
  79642. * @param data Define the base64 payload without the data: prefix
  79643. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79644. * @param scene Define the scene the texture should belong to
  79645. * @param noMipmap Forces the texture to not create mip map information if true
  79646. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79647. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79648. * @param onLoad define a callback triggered when the texture has been loaded
  79649. * @param onError define a callback triggered when an error occurred during the loading session
  79650. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79651. * @returns the created texture
  79652. */
  79653. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  79654. /**
  79655. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  79656. * @param data Define the base64 payload without the data: prefix
  79657. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79658. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79659. * @param scene Define the scene the texture should belong to
  79660. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79661. * @param noMipmap Forces the texture to not create mip map information if true
  79662. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79663. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79664. * @param onLoad define a callback triggered when the texture has been loaded
  79665. * @param onError define a callback triggered when an error occurred during the loading session
  79666. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79667. * @returns the created texture
  79668. */
  79669. 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;
  79670. }
  79671. }
  79672. declare module BABYLON {
  79673. /**
  79674. * PostProcessManager is used to manage one or more post processes or post process pipelines
  79675. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79676. */
  79677. export class PostProcessManager {
  79678. private _scene;
  79679. private _indexBuffer;
  79680. private _vertexBuffers;
  79681. /**
  79682. * Creates a new instance PostProcess
  79683. * @param scene The scene that the post process is associated with.
  79684. */
  79685. constructor(scene: Scene);
  79686. private _prepareBuffers;
  79687. private _buildIndexBuffer;
  79688. /**
  79689. * Rebuilds the vertex buffers of the manager.
  79690. * @hidden
  79691. */
  79692. _rebuild(): void;
  79693. /**
  79694. * Prepares a frame to be run through a post process.
  79695. * @param sourceTexture The input texture to the post procesess. (default: null)
  79696. * @param postProcesses An array of post processes to be run. (default: null)
  79697. * @returns True if the post processes were able to be run.
  79698. * @hidden
  79699. */
  79700. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  79701. /**
  79702. * Manually render a set of post processes to a texture.
  79703. * @param postProcesses An array of post processes to be run.
  79704. * @param targetTexture The target texture to render to.
  79705. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  79706. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  79707. * @param lodLevel defines which lod of the texture to render to
  79708. */
  79709. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  79710. /**
  79711. * Finalize the result of the output of the postprocesses.
  79712. * @param doNotPresent If true the result will not be displayed to the screen.
  79713. * @param targetTexture The target texture to render to.
  79714. * @param faceIndex The index of the face to bind the target texture to.
  79715. * @param postProcesses The array of post processes to render.
  79716. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  79717. * @hidden
  79718. */
  79719. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  79720. /**
  79721. * Disposes of the post process manager.
  79722. */
  79723. dispose(): void;
  79724. }
  79725. }
  79726. declare module BABYLON {
  79727. /** Interface used by value gradients (color, factor, ...) */
  79728. export interface IValueGradient {
  79729. /**
  79730. * Gets or sets the gradient value (between 0 and 1)
  79731. */
  79732. gradient: number;
  79733. }
  79734. /** Class used to store color4 gradient */
  79735. export class ColorGradient implements IValueGradient {
  79736. /**
  79737. * Gets or sets the gradient value (between 0 and 1)
  79738. */
  79739. gradient: number;
  79740. /**
  79741. * Gets or sets first associated color
  79742. */
  79743. color1: Color4;
  79744. /**
  79745. * Gets or sets second associated color
  79746. */
  79747. color2?: Color4;
  79748. /**
  79749. * Will get a color picked randomly between color1 and color2.
  79750. * If color2 is undefined then color1 will be used
  79751. * @param result defines the target Color4 to store the result in
  79752. */
  79753. getColorToRef(result: Color4): void;
  79754. }
  79755. /** Class used to store color 3 gradient */
  79756. export class Color3Gradient implements IValueGradient {
  79757. /**
  79758. * Gets or sets the gradient value (between 0 and 1)
  79759. */
  79760. gradient: number;
  79761. /**
  79762. * Gets or sets the associated color
  79763. */
  79764. color: Color3;
  79765. }
  79766. /** Class used to store factor gradient */
  79767. export class FactorGradient implements IValueGradient {
  79768. /**
  79769. * Gets or sets the gradient value (between 0 and 1)
  79770. */
  79771. gradient: number;
  79772. /**
  79773. * Gets or sets first associated factor
  79774. */
  79775. factor1: number;
  79776. /**
  79777. * Gets or sets second associated factor
  79778. */
  79779. factor2?: number;
  79780. /**
  79781. * Will get a number picked randomly between factor1 and factor2.
  79782. * If factor2 is undefined then factor1 will be used
  79783. * @returns the picked number
  79784. */
  79785. getFactor(): number;
  79786. }
  79787. /**
  79788. * Helper used to simplify some generic gradient tasks
  79789. */
  79790. export class GradientHelper {
  79791. /**
  79792. * Gets the current gradient from an array of IValueGradient
  79793. * @param ratio defines the current ratio to get
  79794. * @param gradients defines the array of IValueGradient
  79795. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  79796. */
  79797. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  79798. }
  79799. }
  79800. declare module BABYLON {
  79801. interface AbstractScene {
  79802. /**
  79803. * The list of procedural textures added to the scene
  79804. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79805. */
  79806. proceduralTextures: Array<ProceduralTexture>;
  79807. }
  79808. /**
  79809. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  79810. * in a given scene.
  79811. */
  79812. export class ProceduralTextureSceneComponent implements ISceneComponent {
  79813. /**
  79814. * The component name helpfull to identify the component in the list of scene components.
  79815. */
  79816. readonly name: string;
  79817. /**
  79818. * The scene the component belongs to.
  79819. */
  79820. scene: Scene;
  79821. /**
  79822. * Creates a new instance of the component for the given scene
  79823. * @param scene Defines the scene to register the component in
  79824. */
  79825. constructor(scene: Scene);
  79826. /**
  79827. * Registers the component in a given scene
  79828. */
  79829. register(): void;
  79830. /**
  79831. * Rebuilds the elements related to this component in case of
  79832. * context lost for instance.
  79833. */
  79834. rebuild(): void;
  79835. /**
  79836. * Disposes the component and the associated ressources.
  79837. */
  79838. dispose(): void;
  79839. private _beforeClear;
  79840. }
  79841. }
  79842. declare module BABYLON {
  79843. interface Engine {
  79844. /**
  79845. * Creates a new render target cube texture
  79846. * @param size defines the size of the texture
  79847. * @param options defines the options used to create the texture
  79848. * @returns a new render target cube texture stored in an InternalTexture
  79849. */
  79850. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  79851. }
  79852. }
  79853. declare module BABYLON {
  79854. /** @hidden */
  79855. export var proceduralVertexShader: {
  79856. name: string;
  79857. shader: string;
  79858. };
  79859. }
  79860. declare module BABYLON {
  79861. /**
  79862. * 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.
  79863. * This is the base class of any Procedural texture and contains most of the shareable code.
  79864. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79865. */
  79866. export class ProceduralTexture extends Texture {
  79867. isCube: boolean;
  79868. /**
  79869. * Define if the texture is enabled or not (disabled texture will not render)
  79870. */
  79871. isEnabled: boolean;
  79872. /**
  79873. * Define if the texture must be cleared before rendering (default is true)
  79874. */
  79875. autoClear: boolean;
  79876. /**
  79877. * Callback called when the texture is generated
  79878. */
  79879. onGenerated: () => void;
  79880. /**
  79881. * Event raised when the texture is generated
  79882. */
  79883. onGeneratedObservable: Observable<ProceduralTexture>;
  79884. /** @hidden */
  79885. _generateMipMaps: boolean;
  79886. /** @hidden **/
  79887. _effect: Effect;
  79888. /** @hidden */
  79889. _textures: {
  79890. [key: string]: Texture;
  79891. };
  79892. private _size;
  79893. private _currentRefreshId;
  79894. private _refreshRate;
  79895. private _vertexBuffers;
  79896. private _indexBuffer;
  79897. private _uniforms;
  79898. private _samplers;
  79899. private _fragment;
  79900. private _floats;
  79901. private _ints;
  79902. private _floatsArrays;
  79903. private _colors3;
  79904. private _colors4;
  79905. private _vectors2;
  79906. private _vectors3;
  79907. private _matrices;
  79908. private _fallbackTexture;
  79909. private _fallbackTextureUsed;
  79910. private _engine;
  79911. private _cachedDefines;
  79912. private _contentUpdateId;
  79913. private _contentData;
  79914. /**
  79915. * Instantiates a new procedural texture.
  79916. * 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.
  79917. * This is the base class of any Procedural texture and contains most of the shareable code.
  79918. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79919. * @param name Define the name of the texture
  79920. * @param size Define the size of the texture to create
  79921. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  79922. * @param scene Define the scene the texture belongs to
  79923. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  79924. * @param generateMipMaps Define if the texture should creates mip maps or not
  79925. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  79926. */
  79927. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  79928. /**
  79929. * The effect that is created when initializing the post process.
  79930. * @returns The created effect corresponding the the postprocess.
  79931. */
  79932. getEffect(): Effect;
  79933. /**
  79934. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  79935. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  79936. */
  79937. getContent(): Nullable<ArrayBufferView>;
  79938. private _createIndexBuffer;
  79939. /** @hidden */
  79940. _rebuild(): void;
  79941. /**
  79942. * Resets the texture in order to recreate its associated resources.
  79943. * This can be called in case of context loss
  79944. */
  79945. reset(): void;
  79946. protected _getDefines(): string;
  79947. /**
  79948. * Is the texture ready to be used ? (rendered at least once)
  79949. * @returns true if ready, otherwise, false.
  79950. */
  79951. isReady(): boolean;
  79952. /**
  79953. * Resets the refresh counter of the texture and start bak from scratch.
  79954. * Could be useful to regenerate the texture if it is setup to render only once.
  79955. */
  79956. resetRefreshCounter(): void;
  79957. /**
  79958. * Set the fragment shader to use in order to render the texture.
  79959. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  79960. */
  79961. setFragment(fragment: any): void;
  79962. /**
  79963. * Define the refresh rate of the texture or the rendering frequency.
  79964. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  79965. */
  79966. refreshRate: number;
  79967. /** @hidden */
  79968. _shouldRender(): boolean;
  79969. /**
  79970. * Get the size the texture is rendering at.
  79971. * @returns the size (texture is always squared)
  79972. */
  79973. getRenderSize(): number;
  79974. /**
  79975. * Resize the texture to new value.
  79976. * @param size Define the new size the texture should have
  79977. * @param generateMipMaps Define whether the new texture should create mip maps
  79978. */
  79979. resize(size: number, generateMipMaps: boolean): void;
  79980. private _checkUniform;
  79981. /**
  79982. * Set a texture in the shader program used to render.
  79983. * @param name Define the name of the uniform samplers as defined in the shader
  79984. * @param texture Define the texture to bind to this sampler
  79985. * @return the texture itself allowing "fluent" like uniform updates
  79986. */
  79987. setTexture(name: string, texture: Texture): ProceduralTexture;
  79988. /**
  79989. * Set a float in the shader.
  79990. * @param name Define the name of the uniform as defined in the shader
  79991. * @param value Define the value to give to the uniform
  79992. * @return the texture itself allowing "fluent" like uniform updates
  79993. */
  79994. setFloat(name: string, value: number): ProceduralTexture;
  79995. /**
  79996. * Set a int in the shader.
  79997. * @param name Define the name of the uniform as defined in the shader
  79998. * @param value Define the value to give to the uniform
  79999. * @return the texture itself allowing "fluent" like uniform updates
  80000. */
  80001. setInt(name: string, value: number): ProceduralTexture;
  80002. /**
  80003. * Set an array of floats in the shader.
  80004. * @param name Define the name of the uniform as defined in the shader
  80005. * @param value Define the value to give to the uniform
  80006. * @return the texture itself allowing "fluent" like uniform updates
  80007. */
  80008. setFloats(name: string, value: number[]): ProceduralTexture;
  80009. /**
  80010. * Set a vec3 in the shader from a Color3.
  80011. * @param name Define the name of the uniform as defined in the shader
  80012. * @param value Define the value to give to the uniform
  80013. * @return the texture itself allowing "fluent" like uniform updates
  80014. */
  80015. setColor3(name: string, value: Color3): ProceduralTexture;
  80016. /**
  80017. * Set a vec4 in the shader from a Color4.
  80018. * @param name Define the name of the uniform as defined in the shader
  80019. * @param value Define the value to give to the uniform
  80020. * @return the texture itself allowing "fluent" like uniform updates
  80021. */
  80022. setColor4(name: string, value: Color4): ProceduralTexture;
  80023. /**
  80024. * Set a vec2 in the shader from a Vector2.
  80025. * @param name Define the name of the uniform as defined in the shader
  80026. * @param value Define the value to give to the uniform
  80027. * @return the texture itself allowing "fluent" like uniform updates
  80028. */
  80029. setVector2(name: string, value: Vector2): ProceduralTexture;
  80030. /**
  80031. * Set a vec3 in the shader from a Vector3.
  80032. * @param name Define the name of the uniform as defined in the shader
  80033. * @param value Define the value to give to the uniform
  80034. * @return the texture itself allowing "fluent" like uniform updates
  80035. */
  80036. setVector3(name: string, value: Vector3): ProceduralTexture;
  80037. /**
  80038. * Set a mat4 in the shader from a MAtrix.
  80039. * @param name Define the name of the uniform as defined in the shader
  80040. * @param value Define the value to give to the uniform
  80041. * @return the texture itself allowing "fluent" like uniform updates
  80042. */
  80043. setMatrix(name: string, value: Matrix): ProceduralTexture;
  80044. /**
  80045. * Render the texture to its associated render target.
  80046. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  80047. */
  80048. render(useCameraPostProcess?: boolean): void;
  80049. /**
  80050. * Clone the texture.
  80051. * @returns the cloned texture
  80052. */
  80053. clone(): ProceduralTexture;
  80054. /**
  80055. * Dispose the texture and release its asoociated resources.
  80056. */
  80057. dispose(): void;
  80058. }
  80059. }
  80060. declare module BABYLON {
  80061. /**
  80062. * This represents the base class for particle system in Babylon.
  80063. * 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.
  80064. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80065. * @example https://doc.babylonjs.com/babylon101/particles
  80066. */
  80067. export class BaseParticleSystem {
  80068. /**
  80069. * Source color is added to the destination color without alpha affecting the result
  80070. */
  80071. static BLENDMODE_ONEONE: number;
  80072. /**
  80073. * Blend current color and particle color using particle’s alpha
  80074. */
  80075. static BLENDMODE_STANDARD: number;
  80076. /**
  80077. * Add current color and particle color multiplied by particle’s alpha
  80078. */
  80079. static BLENDMODE_ADD: number;
  80080. /**
  80081. * Multiply current color with particle color
  80082. */
  80083. static BLENDMODE_MULTIPLY: number;
  80084. /**
  80085. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  80086. */
  80087. static BLENDMODE_MULTIPLYADD: number;
  80088. /**
  80089. * List of animations used by the particle system.
  80090. */
  80091. animations: Animation[];
  80092. /**
  80093. * The id of the Particle system.
  80094. */
  80095. id: string;
  80096. /**
  80097. * The friendly name of the Particle system.
  80098. */
  80099. name: string;
  80100. /**
  80101. * The rendering group used by the Particle system to chose when to render.
  80102. */
  80103. renderingGroupId: number;
  80104. /**
  80105. * The emitter represents the Mesh or position we are attaching the particle system to.
  80106. */
  80107. emitter: Nullable<AbstractMesh | Vector3>;
  80108. /**
  80109. * The maximum number of particles to emit per frame
  80110. */
  80111. emitRate: number;
  80112. /**
  80113. * If you want to launch only a few particles at once, that can be done, as well.
  80114. */
  80115. manualEmitCount: number;
  80116. /**
  80117. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  80118. */
  80119. updateSpeed: number;
  80120. /**
  80121. * The amount of time the particle system is running (depends of the overall update speed).
  80122. */
  80123. targetStopDuration: number;
  80124. /**
  80125. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  80126. */
  80127. disposeOnStop: boolean;
  80128. /**
  80129. * Minimum power of emitting particles.
  80130. */
  80131. minEmitPower: number;
  80132. /**
  80133. * Maximum power of emitting particles.
  80134. */
  80135. maxEmitPower: number;
  80136. /**
  80137. * Minimum life time of emitting particles.
  80138. */
  80139. minLifeTime: number;
  80140. /**
  80141. * Maximum life time of emitting particles.
  80142. */
  80143. maxLifeTime: number;
  80144. /**
  80145. * Minimum Size of emitting particles.
  80146. */
  80147. minSize: number;
  80148. /**
  80149. * Maximum Size of emitting particles.
  80150. */
  80151. maxSize: number;
  80152. /**
  80153. * Minimum scale of emitting particles on X axis.
  80154. */
  80155. minScaleX: number;
  80156. /**
  80157. * Maximum scale of emitting particles on X axis.
  80158. */
  80159. maxScaleX: number;
  80160. /**
  80161. * Minimum scale of emitting particles on Y axis.
  80162. */
  80163. minScaleY: number;
  80164. /**
  80165. * Maximum scale of emitting particles on Y axis.
  80166. */
  80167. maxScaleY: number;
  80168. /**
  80169. * Gets or sets the minimal initial rotation in radians.
  80170. */
  80171. minInitialRotation: number;
  80172. /**
  80173. * Gets or sets the maximal initial rotation in radians.
  80174. */
  80175. maxInitialRotation: number;
  80176. /**
  80177. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  80178. */
  80179. minAngularSpeed: number;
  80180. /**
  80181. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  80182. */
  80183. maxAngularSpeed: number;
  80184. /**
  80185. * The texture used to render each particle. (this can be a spritesheet)
  80186. */
  80187. particleTexture: Nullable<Texture>;
  80188. /**
  80189. * The layer mask we are rendering the particles through.
  80190. */
  80191. layerMask: number;
  80192. /**
  80193. * This can help using your own shader to render the particle system.
  80194. * The according effect will be created
  80195. */
  80196. customShader: any;
  80197. /**
  80198. * By default particle system starts as soon as they are created. This prevents the
  80199. * automatic start to happen and let you decide when to start emitting particles.
  80200. */
  80201. preventAutoStart: boolean;
  80202. private _noiseTexture;
  80203. /**
  80204. * Gets or sets a texture used to add random noise to particle positions
  80205. */
  80206. noiseTexture: Nullable<ProceduralTexture>;
  80207. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  80208. noiseStrength: Vector3;
  80209. /**
  80210. * Callback triggered when the particle animation is ending.
  80211. */
  80212. onAnimationEnd: Nullable<() => void>;
  80213. /**
  80214. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  80215. */
  80216. blendMode: number;
  80217. /**
  80218. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  80219. * to override the particles.
  80220. */
  80221. forceDepthWrite: boolean;
  80222. /** 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 */
  80223. preWarmCycles: number;
  80224. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  80225. preWarmStepOffset: number;
  80226. /**
  80227. * 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)
  80228. */
  80229. spriteCellChangeSpeed: number;
  80230. /**
  80231. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  80232. */
  80233. startSpriteCellID: number;
  80234. /**
  80235. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  80236. */
  80237. endSpriteCellID: number;
  80238. /**
  80239. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  80240. */
  80241. spriteCellWidth: number;
  80242. /**
  80243. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  80244. */
  80245. spriteCellHeight: number;
  80246. /**
  80247. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  80248. */
  80249. spriteRandomStartCell: boolean;
  80250. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  80251. translationPivot: Vector2;
  80252. /** @hidden */
  80253. protected _isAnimationSheetEnabled: boolean;
  80254. /**
  80255. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  80256. */
  80257. beginAnimationOnStart: boolean;
  80258. /**
  80259. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  80260. */
  80261. beginAnimationFrom: number;
  80262. /**
  80263. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  80264. */
  80265. beginAnimationTo: number;
  80266. /**
  80267. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  80268. */
  80269. beginAnimationLoop: boolean;
  80270. /**
  80271. * Gets or sets a world offset applied to all particles
  80272. */
  80273. worldOffset: Vector3;
  80274. /**
  80275. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  80276. */
  80277. isAnimationSheetEnabled: boolean;
  80278. /**
  80279. * Get hosting scene
  80280. * @returns the scene
  80281. */
  80282. getScene(): Scene;
  80283. /**
  80284. * You can use gravity if you want to give an orientation to your particles.
  80285. */
  80286. gravity: Vector3;
  80287. protected _colorGradients: Nullable<Array<ColorGradient>>;
  80288. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  80289. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  80290. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  80291. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  80292. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  80293. protected _dragGradients: Nullable<Array<FactorGradient>>;
  80294. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  80295. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  80296. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  80297. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  80298. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  80299. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  80300. /**
  80301. * Defines the delay in milliseconds before starting the system (0 by default)
  80302. */
  80303. startDelay: number;
  80304. /**
  80305. * Gets the current list of drag gradients.
  80306. * You must use addDragGradient and removeDragGradient to udpate this list
  80307. * @returns the list of drag gradients
  80308. */
  80309. getDragGradients(): Nullable<Array<FactorGradient>>;
  80310. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  80311. limitVelocityDamping: number;
  80312. /**
  80313. * Gets the current list of limit velocity gradients.
  80314. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  80315. * @returns the list of limit velocity gradients
  80316. */
  80317. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  80318. /**
  80319. * Gets the current list of color gradients.
  80320. * You must use addColorGradient and removeColorGradient to udpate this list
  80321. * @returns the list of color gradients
  80322. */
  80323. getColorGradients(): Nullable<Array<ColorGradient>>;
  80324. /**
  80325. * Gets the current list of size gradients.
  80326. * You must use addSizeGradient and removeSizeGradient to udpate this list
  80327. * @returns the list of size gradients
  80328. */
  80329. getSizeGradients(): Nullable<Array<FactorGradient>>;
  80330. /**
  80331. * Gets the current list of color remap gradients.
  80332. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  80333. * @returns the list of color remap gradients
  80334. */
  80335. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  80336. /**
  80337. * Gets the current list of alpha remap gradients.
  80338. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  80339. * @returns the list of alpha remap gradients
  80340. */
  80341. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  80342. /**
  80343. * Gets the current list of life time gradients.
  80344. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  80345. * @returns the list of life time gradients
  80346. */
  80347. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  80348. /**
  80349. * Gets the current list of angular speed gradients.
  80350. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  80351. * @returns the list of angular speed gradients
  80352. */
  80353. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  80354. /**
  80355. * Gets the current list of velocity gradients.
  80356. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  80357. * @returns the list of velocity gradients
  80358. */
  80359. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  80360. /**
  80361. * Gets the current list of start size gradients.
  80362. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  80363. * @returns the list of start size gradients
  80364. */
  80365. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  80366. /**
  80367. * Gets the current list of emit rate gradients.
  80368. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  80369. * @returns the list of emit rate gradients
  80370. */
  80371. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  80372. /**
  80373. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80374. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80375. */
  80376. direction1: Vector3;
  80377. /**
  80378. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80379. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80380. */
  80381. direction2: Vector3;
  80382. /**
  80383. * 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.
  80384. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80385. */
  80386. minEmitBox: Vector3;
  80387. /**
  80388. * 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.
  80389. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80390. */
  80391. maxEmitBox: Vector3;
  80392. /**
  80393. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80394. */
  80395. color1: Color4;
  80396. /**
  80397. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80398. */
  80399. color2: Color4;
  80400. /**
  80401. * Color the particle will have at the end of its lifetime
  80402. */
  80403. colorDead: Color4;
  80404. /**
  80405. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  80406. */
  80407. textureMask: Color4;
  80408. /**
  80409. * The particle emitter type defines the emitter used by the particle system.
  80410. * It can be for example box, sphere, or cone...
  80411. */
  80412. particleEmitterType: IParticleEmitterType;
  80413. /** @hidden */
  80414. _isSubEmitter: boolean;
  80415. /**
  80416. * Gets or sets the billboard mode to use when isBillboardBased = true.
  80417. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  80418. */
  80419. billboardMode: number;
  80420. protected _isBillboardBased: boolean;
  80421. /**
  80422. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  80423. */
  80424. isBillboardBased: boolean;
  80425. /**
  80426. * The scene the particle system belongs to.
  80427. */
  80428. protected _scene: Scene;
  80429. /**
  80430. * Local cache of defines for image processing.
  80431. */
  80432. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  80433. /**
  80434. * Default configuration related to image processing available in the standard Material.
  80435. */
  80436. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  80437. /**
  80438. * Gets the image processing configuration used either in this material.
  80439. */
  80440. /**
  80441. * Sets the Default image processing configuration used either in the this material.
  80442. *
  80443. * If sets to null, the scene one is in use.
  80444. */
  80445. imageProcessingConfiguration: ImageProcessingConfiguration;
  80446. /**
  80447. * Attaches a new image processing configuration to the Standard Material.
  80448. * @param configuration
  80449. */
  80450. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  80451. /** @hidden */
  80452. protected _reset(): void;
  80453. /** @hidden */
  80454. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  80455. /**
  80456. * Instantiates a particle system.
  80457. * 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.
  80458. * @param name The name of the particle system
  80459. */
  80460. constructor(name: string);
  80461. /**
  80462. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  80463. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80464. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80465. * @returns the emitter
  80466. */
  80467. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  80468. /**
  80469. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  80470. * @param radius The radius of the hemisphere to emit from
  80471. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80472. * @returns the emitter
  80473. */
  80474. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  80475. /**
  80476. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  80477. * @param radius The radius of the sphere to emit from
  80478. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80479. * @returns the emitter
  80480. */
  80481. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  80482. /**
  80483. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  80484. * @param radius The radius of the sphere to emit from
  80485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  80486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  80487. * @returns the emitter
  80488. */
  80489. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  80490. /**
  80491. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  80492. * @param radius The radius of the emission cylinder
  80493. * @param height The height of the emission cylinder
  80494. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  80495. * @param directionRandomizer How much to randomize the particle direction [0-1]
  80496. * @returns the emitter
  80497. */
  80498. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  80499. /**
  80500. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  80501. * @param radius The radius of the cylinder to emit from
  80502. * @param height The height of the emission cylinder
  80503. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  80504. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  80505. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  80506. * @returns the emitter
  80507. */
  80508. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  80509. /**
  80510. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  80511. * @param radius The radius of the cone to emit from
  80512. * @param angle The base angle of the cone
  80513. * @returns the emitter
  80514. */
  80515. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  80516. /**
  80517. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  80518. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80519. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80520. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80521. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80522. * @returns the emitter
  80523. */
  80524. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  80525. }
  80526. }
  80527. declare module BABYLON {
  80528. /**
  80529. * Type of sub emitter
  80530. */
  80531. export enum SubEmitterType {
  80532. /**
  80533. * Attached to the particle over it's lifetime
  80534. */
  80535. ATTACHED = 0,
  80536. /**
  80537. * Created when the particle dies
  80538. */
  80539. END = 1
  80540. }
  80541. /**
  80542. * Sub emitter class used to emit particles from an existing particle
  80543. */
  80544. export class SubEmitter {
  80545. /**
  80546. * the particle system to be used by the sub emitter
  80547. */
  80548. particleSystem: ParticleSystem;
  80549. /**
  80550. * Type of the submitter (Default: END)
  80551. */
  80552. type: SubEmitterType;
  80553. /**
  80554. * 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)
  80555. * Note: This only is supported when using an emitter of type Mesh
  80556. */
  80557. inheritDirection: boolean;
  80558. /**
  80559. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  80560. */
  80561. inheritedVelocityAmount: number;
  80562. /**
  80563. * Creates a sub emitter
  80564. * @param particleSystem the particle system to be used by the sub emitter
  80565. */
  80566. constructor(
  80567. /**
  80568. * the particle system to be used by the sub emitter
  80569. */
  80570. particleSystem: ParticleSystem);
  80571. /**
  80572. * Clones the sub emitter
  80573. * @returns the cloned sub emitter
  80574. */
  80575. clone(): SubEmitter;
  80576. /**
  80577. * Serialize current object to a JSON object
  80578. * @returns the serialized object
  80579. */
  80580. serialize(): any;
  80581. /** @hidden */
  80582. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  80583. /**
  80584. * Creates a new SubEmitter from a serialized JSON version
  80585. * @param serializationObject defines the JSON object to read from
  80586. * @param scene defines the hosting scene
  80587. * @param rootUrl defines the rootUrl for data loading
  80588. * @returns a new SubEmitter
  80589. */
  80590. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  80591. /** Release associated resources */
  80592. dispose(): void;
  80593. }
  80594. }
  80595. declare module BABYLON {
  80596. /** @hidden */
  80597. export var clipPlaneFragmentDeclaration: {
  80598. name: string;
  80599. shader: string;
  80600. };
  80601. }
  80602. declare module BABYLON {
  80603. /** @hidden */
  80604. export var imageProcessingDeclaration: {
  80605. name: string;
  80606. shader: string;
  80607. };
  80608. }
  80609. declare module BABYLON {
  80610. /** @hidden */
  80611. export var imageProcessingFunctions: {
  80612. name: string;
  80613. shader: string;
  80614. };
  80615. }
  80616. declare module BABYLON {
  80617. /** @hidden */
  80618. export var clipPlaneFragment: {
  80619. name: string;
  80620. shader: string;
  80621. };
  80622. }
  80623. declare module BABYLON {
  80624. /** @hidden */
  80625. export var particlesPixelShader: {
  80626. name: string;
  80627. shader: string;
  80628. };
  80629. }
  80630. declare module BABYLON {
  80631. /** @hidden */
  80632. export var clipPlaneVertexDeclaration: {
  80633. name: string;
  80634. shader: string;
  80635. };
  80636. }
  80637. declare module BABYLON {
  80638. /** @hidden */
  80639. export var clipPlaneVertex: {
  80640. name: string;
  80641. shader: string;
  80642. };
  80643. }
  80644. declare module BABYLON {
  80645. /** @hidden */
  80646. export var particlesVertexShader: {
  80647. name: string;
  80648. shader: string;
  80649. };
  80650. }
  80651. declare module BABYLON {
  80652. /**
  80653. * This represents a particle system in Babylon.
  80654. * 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.
  80655. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80656. * @example https://doc.babylonjs.com/babylon101/particles
  80657. */
  80658. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  80659. /**
  80660. * Billboard mode will only apply to Y axis
  80661. */
  80662. static readonly BILLBOARDMODE_Y: number;
  80663. /**
  80664. * Billboard mode will apply to all axes
  80665. */
  80666. static readonly BILLBOARDMODE_ALL: number;
  80667. /**
  80668. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80669. */
  80670. static readonly BILLBOARDMODE_STRETCHED: number;
  80671. /**
  80672. * This function can be defined to provide custom update for active particles.
  80673. * This function will be called instead of regular update (age, position, color, etc.).
  80674. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  80675. */
  80676. updateFunction: (particles: Particle[]) => void;
  80677. private _emitterWorldMatrix;
  80678. /**
  80679. * This function can be defined to specify initial direction for every new particle.
  80680. * It by default use the emitterType defined function
  80681. */
  80682. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  80683. /**
  80684. * This function can be defined to specify initial position for every new particle.
  80685. * It by default use the emitterType defined function
  80686. */
  80687. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  80688. /**
  80689. * @hidden
  80690. */
  80691. _inheritedVelocityOffset: Vector3;
  80692. /**
  80693. * An event triggered when the system is disposed
  80694. */
  80695. onDisposeObservable: Observable<ParticleSystem>;
  80696. private _onDisposeObserver;
  80697. /**
  80698. * Sets a callback that will be triggered when the system is disposed
  80699. */
  80700. onDispose: () => void;
  80701. private _particles;
  80702. private _epsilon;
  80703. private _capacity;
  80704. private _stockParticles;
  80705. private _newPartsExcess;
  80706. private _vertexData;
  80707. private _vertexBuffer;
  80708. private _vertexBuffers;
  80709. private _spriteBuffer;
  80710. private _indexBuffer;
  80711. private _effect;
  80712. private _customEffect;
  80713. private _cachedDefines;
  80714. private _scaledColorStep;
  80715. private _colorDiff;
  80716. private _scaledDirection;
  80717. private _scaledGravity;
  80718. private _currentRenderId;
  80719. private _alive;
  80720. private _useInstancing;
  80721. private _started;
  80722. private _stopped;
  80723. private _actualFrame;
  80724. private _scaledUpdateSpeed;
  80725. private _vertexBufferSize;
  80726. /** @hidden */
  80727. _currentEmitRateGradient: Nullable<FactorGradient>;
  80728. /** @hidden */
  80729. _currentEmitRate1: number;
  80730. /** @hidden */
  80731. _currentEmitRate2: number;
  80732. /** @hidden */
  80733. _currentStartSizeGradient: Nullable<FactorGradient>;
  80734. /** @hidden */
  80735. _currentStartSize1: number;
  80736. /** @hidden */
  80737. _currentStartSize2: number;
  80738. private readonly _rawTextureWidth;
  80739. private _rampGradientsTexture;
  80740. private _useRampGradients;
  80741. /** Gets or sets a boolean indicating that ramp gradients must be used
  80742. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  80743. */
  80744. useRampGradients: boolean;
  80745. /**
  80746. * 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.
  80747. * 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: [])
  80748. */
  80749. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  80750. private _subEmitters;
  80751. /**
  80752. * @hidden
  80753. * If the particle systems emitter should be disposed when the particle system is disposed
  80754. */
  80755. _disposeEmitterOnDispose: boolean;
  80756. /**
  80757. * The current active Sub-systems, this property is used by the root particle system only.
  80758. */
  80759. activeSubSystems: Array<ParticleSystem>;
  80760. private _rootParticleSystem;
  80761. /**
  80762. * Gets the current list of active particles
  80763. */
  80764. readonly particles: Particle[];
  80765. /**
  80766. * Returns the string "ParticleSystem"
  80767. * @returns a string containing the class name
  80768. */
  80769. getClassName(): string;
  80770. /**
  80771. * Instantiates a particle system.
  80772. * 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.
  80773. * @param name The name of the particle system
  80774. * @param capacity The max number of particles alive at the same time
  80775. * @param scene The scene the particle system belongs to
  80776. * @param customEffect a custom effect used to change the way particles are rendered by default
  80777. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  80778. * @param epsilon Offset used to render the particles
  80779. */
  80780. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  80781. private _addFactorGradient;
  80782. private _removeFactorGradient;
  80783. /**
  80784. * Adds a new life time gradient
  80785. * @param gradient defines the gradient to use (between 0 and 1)
  80786. * @param factor defines the life time factor to affect to the specified gradient
  80787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80788. * @returns the current particle system
  80789. */
  80790. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80791. /**
  80792. * Remove a specific life time gradient
  80793. * @param gradient defines the gradient to remove
  80794. * @returns the current particle system
  80795. */
  80796. removeLifeTimeGradient(gradient: number): IParticleSystem;
  80797. /**
  80798. * Adds a new size gradient
  80799. * @param gradient defines the gradient to use (between 0 and 1)
  80800. * @param factor defines the size factor to affect to the specified gradient
  80801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80802. * @returns the current particle system
  80803. */
  80804. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80805. /**
  80806. * Remove a specific size gradient
  80807. * @param gradient defines the gradient to remove
  80808. * @returns the current particle system
  80809. */
  80810. removeSizeGradient(gradient: number): IParticleSystem;
  80811. /**
  80812. * Adds a new color remap gradient
  80813. * @param gradient defines the gradient to use (between 0 and 1)
  80814. * @param min defines the color remap minimal range
  80815. * @param max defines the color remap maximal range
  80816. * @returns the current particle system
  80817. */
  80818. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80819. /**
  80820. * Remove a specific color remap gradient
  80821. * @param gradient defines the gradient to remove
  80822. * @returns the current particle system
  80823. */
  80824. removeColorRemapGradient(gradient: number): IParticleSystem;
  80825. /**
  80826. * Adds a new alpha remap gradient
  80827. * @param gradient defines the gradient to use (between 0 and 1)
  80828. * @param min defines the alpha remap minimal range
  80829. * @param max defines the alpha remap maximal range
  80830. * @returns the current particle system
  80831. */
  80832. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80833. /**
  80834. * Remove a specific alpha remap gradient
  80835. * @param gradient defines the gradient to remove
  80836. * @returns the current particle system
  80837. */
  80838. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  80839. /**
  80840. * Adds a new angular speed gradient
  80841. * @param gradient defines the gradient to use (between 0 and 1)
  80842. * @param factor defines the angular speed to affect to the specified gradient
  80843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80844. * @returns the current particle system
  80845. */
  80846. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80847. /**
  80848. * Remove a specific angular speed gradient
  80849. * @param gradient defines the gradient to remove
  80850. * @returns the current particle system
  80851. */
  80852. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  80853. /**
  80854. * Adds a new velocity gradient
  80855. * @param gradient defines the gradient to use (between 0 and 1)
  80856. * @param factor defines the velocity to affect to the specified gradient
  80857. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80858. * @returns the current particle system
  80859. */
  80860. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80861. /**
  80862. * Remove a specific velocity gradient
  80863. * @param gradient defines the gradient to remove
  80864. * @returns the current particle system
  80865. */
  80866. removeVelocityGradient(gradient: number): IParticleSystem;
  80867. /**
  80868. * Adds a new limit velocity gradient
  80869. * @param gradient defines the gradient to use (between 0 and 1)
  80870. * @param factor defines the limit velocity value to affect to the specified gradient
  80871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80872. * @returns the current particle system
  80873. */
  80874. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80875. /**
  80876. * Remove a specific limit velocity gradient
  80877. * @param gradient defines the gradient to remove
  80878. * @returns the current particle system
  80879. */
  80880. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  80881. /**
  80882. * Adds a new drag gradient
  80883. * @param gradient defines the gradient to use (between 0 and 1)
  80884. * @param factor defines the drag value to affect to the specified gradient
  80885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80886. * @returns the current particle system
  80887. */
  80888. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80889. /**
  80890. * Remove a specific drag gradient
  80891. * @param gradient defines the gradient to remove
  80892. * @returns the current particle system
  80893. */
  80894. removeDragGradient(gradient: number): IParticleSystem;
  80895. /**
  80896. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  80897. * @param gradient defines the gradient to use (between 0 and 1)
  80898. * @param factor defines the emit rate value to affect to the specified gradient
  80899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80900. * @returns the current particle system
  80901. */
  80902. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80903. /**
  80904. * Remove a specific emit rate gradient
  80905. * @param gradient defines the gradient to remove
  80906. * @returns the current particle system
  80907. */
  80908. removeEmitRateGradient(gradient: number): IParticleSystem;
  80909. /**
  80910. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  80911. * @param gradient defines the gradient to use (between 0 and 1)
  80912. * @param factor defines the start size value to affect to the specified gradient
  80913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80914. * @returns the current particle system
  80915. */
  80916. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80917. /**
  80918. * Remove a specific start size gradient
  80919. * @param gradient defines the gradient to remove
  80920. * @returns the current particle system
  80921. */
  80922. removeStartSizeGradient(gradient: number): IParticleSystem;
  80923. private _createRampGradientTexture;
  80924. /**
  80925. * Gets the current list of ramp gradients.
  80926. * You must use addRampGradient and removeRampGradient to udpate this list
  80927. * @returns the list of ramp gradients
  80928. */
  80929. getRampGradients(): Nullable<Array<Color3Gradient>>;
  80930. /**
  80931. * Adds a new ramp gradient used to remap particle colors
  80932. * @param gradient defines the gradient to use (between 0 and 1)
  80933. * @param color defines the color to affect to the specified gradient
  80934. * @returns the current particle system
  80935. */
  80936. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  80937. /**
  80938. * Remove a specific ramp gradient
  80939. * @param gradient defines the gradient to remove
  80940. * @returns the current particle system
  80941. */
  80942. removeRampGradient(gradient: number): ParticleSystem;
  80943. /**
  80944. * Adds a new color gradient
  80945. * @param gradient defines the gradient to use (between 0 and 1)
  80946. * @param color1 defines the color to affect to the specified gradient
  80947. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  80948. * @returns this particle system
  80949. */
  80950. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  80951. /**
  80952. * Remove a specific color gradient
  80953. * @param gradient defines the gradient to remove
  80954. * @returns this particle system
  80955. */
  80956. removeColorGradient(gradient: number): IParticleSystem;
  80957. private _fetchR;
  80958. protected _reset(): void;
  80959. private _resetEffect;
  80960. private _createVertexBuffers;
  80961. private _createIndexBuffer;
  80962. /**
  80963. * Gets the maximum number of particles active at the same time.
  80964. * @returns The max number of active particles.
  80965. */
  80966. getCapacity(): number;
  80967. /**
  80968. * Gets whether there are still active particles in the system.
  80969. * @returns True if it is alive, otherwise false.
  80970. */
  80971. isAlive(): boolean;
  80972. /**
  80973. * Gets if the system has been started. (Note: this will still be true after stop is called)
  80974. * @returns True if it has been started, otherwise false.
  80975. */
  80976. isStarted(): boolean;
  80977. private _prepareSubEmitterInternalArray;
  80978. /**
  80979. * Starts the particle system and begins to emit
  80980. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  80981. */
  80982. start(delay?: number): void;
  80983. /**
  80984. * Stops the particle system.
  80985. * @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.
  80986. */
  80987. stop(stopSubEmitters?: boolean): void;
  80988. /**
  80989. * Remove all active particles
  80990. */
  80991. reset(): void;
  80992. /**
  80993. * @hidden (for internal use only)
  80994. */
  80995. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  80996. /**
  80997. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  80998. * Its lifetime will start back at 0.
  80999. */
  81000. recycleParticle: (particle: Particle) => void;
  81001. private _stopSubEmitters;
  81002. private _createParticle;
  81003. private _removeFromRoot;
  81004. private _emitFromParticle;
  81005. private _update;
  81006. /** @hidden */
  81007. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  81008. /** @hidden */
  81009. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  81010. /** @hidden */
  81011. private _getEffect;
  81012. /**
  81013. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  81014. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  81015. */
  81016. animate(preWarmOnly?: boolean): void;
  81017. private _appendParticleVertices;
  81018. /**
  81019. * Rebuilds the particle system.
  81020. */
  81021. rebuild(): void;
  81022. /**
  81023. * Is this system ready to be used/rendered
  81024. * @return true if the system is ready
  81025. */
  81026. isReady(): boolean;
  81027. private _render;
  81028. /**
  81029. * Renders the particle system in its current state.
  81030. * @returns the current number of particles
  81031. */
  81032. render(): number;
  81033. /**
  81034. * Disposes the particle system and free the associated resources
  81035. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  81036. */
  81037. dispose(disposeTexture?: boolean): void;
  81038. /**
  81039. * Clones the particle system.
  81040. * @param name The name of the cloned object
  81041. * @param newEmitter The new emitter to use
  81042. * @returns the cloned particle system
  81043. */
  81044. clone(name: string, newEmitter: any): ParticleSystem;
  81045. /**
  81046. * Serializes the particle system to a JSON object.
  81047. * @returns the JSON object
  81048. */
  81049. serialize(): any;
  81050. /** @hidden */
  81051. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  81052. /** @hidden */
  81053. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  81054. /**
  81055. * Parses a JSON object to create a particle system.
  81056. * @param parsedParticleSystem The JSON object to parse
  81057. * @param scene The scene to create the particle system in
  81058. * @param rootUrl The root url to use to load external dependencies like texture
  81059. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  81060. * @returns the Parsed particle system
  81061. */
  81062. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  81063. }
  81064. }
  81065. declare module BABYLON {
  81066. /**
  81067. * A particle represents one of the element emitted by a particle system.
  81068. * This is mainly define by its coordinates, direction, velocity and age.
  81069. */
  81070. export class Particle {
  81071. /**
  81072. * The particle system the particle belongs to.
  81073. */
  81074. particleSystem: ParticleSystem;
  81075. private static _Count;
  81076. /**
  81077. * Unique ID of the particle
  81078. */
  81079. id: number;
  81080. /**
  81081. * The world position of the particle in the scene.
  81082. */
  81083. position: Vector3;
  81084. /**
  81085. * The world direction of the particle in the scene.
  81086. */
  81087. direction: Vector3;
  81088. /**
  81089. * The color of the particle.
  81090. */
  81091. color: Color4;
  81092. /**
  81093. * The color change of the particle per step.
  81094. */
  81095. colorStep: Color4;
  81096. /**
  81097. * Defines how long will the life of the particle be.
  81098. */
  81099. lifeTime: number;
  81100. /**
  81101. * The current age of the particle.
  81102. */
  81103. age: number;
  81104. /**
  81105. * The current size of the particle.
  81106. */
  81107. size: number;
  81108. /**
  81109. * The current scale of the particle.
  81110. */
  81111. scale: Vector2;
  81112. /**
  81113. * The current angle of the particle.
  81114. */
  81115. angle: number;
  81116. /**
  81117. * Defines how fast is the angle changing.
  81118. */
  81119. angularSpeed: number;
  81120. /**
  81121. * Defines the cell index used by the particle to be rendered from a sprite.
  81122. */
  81123. cellIndex: number;
  81124. /**
  81125. * The information required to support color remapping
  81126. */
  81127. remapData: Vector4;
  81128. /** @hidden */
  81129. _randomCellOffset?: number;
  81130. /** @hidden */
  81131. _initialDirection: Nullable<Vector3>;
  81132. /** @hidden */
  81133. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  81134. /** @hidden */
  81135. _initialStartSpriteCellID: number;
  81136. /** @hidden */
  81137. _initialEndSpriteCellID: number;
  81138. /** @hidden */
  81139. _currentColorGradient: Nullable<ColorGradient>;
  81140. /** @hidden */
  81141. _currentColor1: Color4;
  81142. /** @hidden */
  81143. _currentColor2: Color4;
  81144. /** @hidden */
  81145. _currentSizeGradient: Nullable<FactorGradient>;
  81146. /** @hidden */
  81147. _currentSize1: number;
  81148. /** @hidden */
  81149. _currentSize2: number;
  81150. /** @hidden */
  81151. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  81152. /** @hidden */
  81153. _currentAngularSpeed1: number;
  81154. /** @hidden */
  81155. _currentAngularSpeed2: number;
  81156. /** @hidden */
  81157. _currentVelocityGradient: Nullable<FactorGradient>;
  81158. /** @hidden */
  81159. _currentVelocity1: number;
  81160. /** @hidden */
  81161. _currentVelocity2: number;
  81162. /** @hidden */
  81163. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  81164. /** @hidden */
  81165. _currentLimitVelocity1: number;
  81166. /** @hidden */
  81167. _currentLimitVelocity2: number;
  81168. /** @hidden */
  81169. _currentDragGradient: Nullable<FactorGradient>;
  81170. /** @hidden */
  81171. _currentDrag1: number;
  81172. /** @hidden */
  81173. _currentDrag2: number;
  81174. /** @hidden */
  81175. _randomNoiseCoordinates1: Vector3;
  81176. /** @hidden */
  81177. _randomNoiseCoordinates2: Vector3;
  81178. /**
  81179. * Creates a new instance Particle
  81180. * @param particleSystem the particle system the particle belongs to
  81181. */
  81182. constructor(
  81183. /**
  81184. * The particle system the particle belongs to.
  81185. */
  81186. particleSystem: ParticleSystem);
  81187. private updateCellInfoFromSystem;
  81188. /**
  81189. * Defines how the sprite cell index is updated for the particle
  81190. */
  81191. updateCellIndex(): void;
  81192. /** @hidden */
  81193. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  81194. /** @hidden */
  81195. _inheritParticleInfoToSubEmitters(): void;
  81196. /** @hidden */
  81197. _reset(): void;
  81198. /**
  81199. * Copy the properties of particle to another one.
  81200. * @param other the particle to copy the information to.
  81201. */
  81202. copyTo(other: Particle): void;
  81203. }
  81204. }
  81205. declare module BABYLON {
  81206. /**
  81207. * Particle emitter represents a volume emitting particles.
  81208. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  81209. */
  81210. export interface IParticleEmitterType {
  81211. /**
  81212. * Called by the particle System when the direction is computed for the created particle.
  81213. * @param worldMatrix is the world matrix of the particle system
  81214. * @param directionToUpdate is the direction vector to update with the result
  81215. * @param particle is the particle we are computed the direction for
  81216. */
  81217. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81218. /**
  81219. * Called by the particle System when the position is computed for the created particle.
  81220. * @param worldMatrix is the world matrix of the particle system
  81221. * @param positionToUpdate is the position vector to update with the result
  81222. * @param particle is the particle we are computed the position for
  81223. */
  81224. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81225. /**
  81226. * Clones the current emitter and returns a copy of it
  81227. * @returns the new emitter
  81228. */
  81229. clone(): IParticleEmitterType;
  81230. /**
  81231. * Called by the GPUParticleSystem to setup the update shader
  81232. * @param effect defines the update shader
  81233. */
  81234. applyToShader(effect: Effect): void;
  81235. /**
  81236. * Returns a string to use to update the GPU particles update shader
  81237. * @returns the effect defines string
  81238. */
  81239. getEffectDefines(): string;
  81240. /**
  81241. * Returns a string representing the class name
  81242. * @returns a string containing the class name
  81243. */
  81244. getClassName(): string;
  81245. /**
  81246. * Serializes the particle system to a JSON object.
  81247. * @returns the JSON object
  81248. */
  81249. serialize(): any;
  81250. /**
  81251. * Parse properties from a JSON object
  81252. * @param serializationObject defines the JSON object
  81253. */
  81254. parse(serializationObject: any): void;
  81255. }
  81256. }
  81257. declare module BABYLON {
  81258. /**
  81259. * Particle emitter emitting particles from the inside of a box.
  81260. * It emits the particles randomly between 2 given directions.
  81261. */
  81262. export class BoxParticleEmitter implements IParticleEmitterType {
  81263. /**
  81264. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81265. */
  81266. direction1: Vector3;
  81267. /**
  81268. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81269. */
  81270. direction2: Vector3;
  81271. /**
  81272. * 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.
  81273. */
  81274. minEmitBox: Vector3;
  81275. /**
  81276. * 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.
  81277. */
  81278. maxEmitBox: Vector3;
  81279. /**
  81280. * Creates a new instance BoxParticleEmitter
  81281. */
  81282. constructor();
  81283. /**
  81284. * Called by the particle System when the direction is computed for the created particle.
  81285. * @param worldMatrix is the world matrix of the particle system
  81286. * @param directionToUpdate is the direction vector to update with the result
  81287. * @param particle is the particle we are computed the direction for
  81288. */
  81289. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81290. /**
  81291. * Called by the particle System when the position is computed for the created particle.
  81292. * @param worldMatrix is the world matrix of the particle system
  81293. * @param positionToUpdate is the position vector to update with the result
  81294. * @param particle is the particle we are computed the position for
  81295. */
  81296. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81297. /**
  81298. * Clones the current emitter and returns a copy of it
  81299. * @returns the new emitter
  81300. */
  81301. clone(): BoxParticleEmitter;
  81302. /**
  81303. * Called by the GPUParticleSystem to setup the update shader
  81304. * @param effect defines the update shader
  81305. */
  81306. applyToShader(effect: Effect): void;
  81307. /**
  81308. * Returns a string to use to update the GPU particles update shader
  81309. * @returns a string containng the defines string
  81310. */
  81311. getEffectDefines(): string;
  81312. /**
  81313. * Returns the string "BoxParticleEmitter"
  81314. * @returns a string containing the class name
  81315. */
  81316. getClassName(): string;
  81317. /**
  81318. * Serializes the particle system to a JSON object.
  81319. * @returns the JSON object
  81320. */
  81321. serialize(): any;
  81322. /**
  81323. * Parse properties from a JSON object
  81324. * @param serializationObject defines the JSON object
  81325. */
  81326. parse(serializationObject: any): void;
  81327. }
  81328. }
  81329. declare module BABYLON {
  81330. /**
  81331. * Particle emitter emitting particles from the inside of a cone.
  81332. * It emits the particles alongside the cone volume from the base to the particle.
  81333. * The emission direction might be randomized.
  81334. */
  81335. export class ConeParticleEmitter implements IParticleEmitterType {
  81336. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81337. directionRandomizer: number;
  81338. private _radius;
  81339. private _angle;
  81340. private _height;
  81341. /**
  81342. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  81343. */
  81344. radiusRange: number;
  81345. /**
  81346. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  81347. */
  81348. heightRange: number;
  81349. /**
  81350. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  81351. */
  81352. emitFromSpawnPointOnly: boolean;
  81353. /**
  81354. * Gets or sets the radius of the emission cone
  81355. */
  81356. radius: number;
  81357. /**
  81358. * Gets or sets the angle of the emission cone
  81359. */
  81360. angle: number;
  81361. private _buildHeight;
  81362. /**
  81363. * Creates a new instance ConeParticleEmitter
  81364. * @param radius the radius of the emission cone (1 by default)
  81365. * @param angle the cone base angle (PI by default)
  81366. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  81367. */
  81368. constructor(radius?: number, angle?: number,
  81369. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81370. directionRandomizer?: number);
  81371. /**
  81372. * Called by the particle System when the direction is computed for the created particle.
  81373. * @param worldMatrix is the world matrix of the particle system
  81374. * @param directionToUpdate is the direction vector to update with the result
  81375. * @param particle is the particle we are computed the direction for
  81376. */
  81377. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81378. /**
  81379. * Called by the particle System when the position is computed for the created particle.
  81380. * @param worldMatrix is the world matrix of the particle system
  81381. * @param positionToUpdate is the position vector to update with the result
  81382. * @param particle is the particle we are computed the position for
  81383. */
  81384. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81385. /**
  81386. * Clones the current emitter and returns a copy of it
  81387. * @returns the new emitter
  81388. */
  81389. clone(): ConeParticleEmitter;
  81390. /**
  81391. * Called by the GPUParticleSystem to setup the update shader
  81392. * @param effect defines the update shader
  81393. */
  81394. applyToShader(effect: Effect): void;
  81395. /**
  81396. * Returns a string to use to update the GPU particles update shader
  81397. * @returns a string containng the defines string
  81398. */
  81399. getEffectDefines(): string;
  81400. /**
  81401. * Returns the string "ConeParticleEmitter"
  81402. * @returns a string containing the class name
  81403. */
  81404. getClassName(): string;
  81405. /**
  81406. * Serializes the particle system to a JSON object.
  81407. * @returns the JSON object
  81408. */
  81409. serialize(): any;
  81410. /**
  81411. * Parse properties from a JSON object
  81412. * @param serializationObject defines the JSON object
  81413. */
  81414. parse(serializationObject: any): void;
  81415. }
  81416. }
  81417. declare module BABYLON {
  81418. /**
  81419. * Particle emitter emitting particles from the inside of a cylinder.
  81420. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  81421. */
  81422. export class CylinderParticleEmitter implements IParticleEmitterType {
  81423. /**
  81424. * The radius of the emission cylinder.
  81425. */
  81426. radius: number;
  81427. /**
  81428. * The height of the emission cylinder.
  81429. */
  81430. height: number;
  81431. /**
  81432. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81433. */
  81434. radiusRange: number;
  81435. /**
  81436. * How much to randomize the particle direction [0-1].
  81437. */
  81438. directionRandomizer: number;
  81439. /**
  81440. * Creates a new instance CylinderParticleEmitter
  81441. * @param radius the radius of the emission cylinder (1 by default)
  81442. * @param height the height of the emission cylinder (1 by default)
  81443. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81444. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81445. */
  81446. constructor(
  81447. /**
  81448. * The radius of the emission cylinder.
  81449. */
  81450. radius?: number,
  81451. /**
  81452. * The height of the emission cylinder.
  81453. */
  81454. height?: number,
  81455. /**
  81456. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81457. */
  81458. radiusRange?: number,
  81459. /**
  81460. * How much to randomize the particle direction [0-1].
  81461. */
  81462. directionRandomizer?: number);
  81463. /**
  81464. * Called by the particle System when the direction is computed for the created particle.
  81465. * @param worldMatrix is the world matrix of the particle system
  81466. * @param directionToUpdate is the direction vector to update with the result
  81467. * @param particle is the particle we are computed the direction for
  81468. */
  81469. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81470. /**
  81471. * Called by the particle System when the position is computed for the created particle.
  81472. * @param worldMatrix is the world matrix of the particle system
  81473. * @param positionToUpdate is the position vector to update with the result
  81474. * @param particle is the particle we are computed the position for
  81475. */
  81476. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81477. /**
  81478. * Clones the current emitter and returns a copy of it
  81479. * @returns the new emitter
  81480. */
  81481. clone(): CylinderParticleEmitter;
  81482. /**
  81483. * Called by the GPUParticleSystem to setup the update shader
  81484. * @param effect defines the update shader
  81485. */
  81486. applyToShader(effect: Effect): void;
  81487. /**
  81488. * Returns a string to use to update the GPU particles update shader
  81489. * @returns a string containng the defines string
  81490. */
  81491. getEffectDefines(): string;
  81492. /**
  81493. * Returns the string "CylinderParticleEmitter"
  81494. * @returns a string containing the class name
  81495. */
  81496. getClassName(): string;
  81497. /**
  81498. * Serializes the particle system to a JSON object.
  81499. * @returns the JSON object
  81500. */
  81501. serialize(): any;
  81502. /**
  81503. * Parse properties from a JSON object
  81504. * @param serializationObject defines the JSON object
  81505. */
  81506. parse(serializationObject: any): void;
  81507. }
  81508. /**
  81509. * Particle emitter emitting particles from the inside of a cylinder.
  81510. * It emits the particles randomly between two vectors.
  81511. */
  81512. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  81513. /**
  81514. * The min limit of the emission direction.
  81515. */
  81516. direction1: Vector3;
  81517. /**
  81518. * The max limit of the emission direction.
  81519. */
  81520. direction2: Vector3;
  81521. /**
  81522. * Creates a new instance CylinderDirectedParticleEmitter
  81523. * @param radius the radius of the emission cylinder (1 by default)
  81524. * @param height the height of the emission cylinder (1 by default)
  81525. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81526. * @param direction1 the min limit of the emission direction (up vector by default)
  81527. * @param direction2 the max limit of the emission direction (up vector by default)
  81528. */
  81529. constructor(radius?: number, height?: number, radiusRange?: number,
  81530. /**
  81531. * The min limit of the emission direction.
  81532. */
  81533. direction1?: Vector3,
  81534. /**
  81535. * The max limit of the emission direction.
  81536. */
  81537. direction2?: Vector3);
  81538. /**
  81539. * Called by the particle System when the direction is computed for the created particle.
  81540. * @param worldMatrix is the world matrix of the particle system
  81541. * @param directionToUpdate is the direction vector to update with the result
  81542. * @param particle is the particle we are computed the direction for
  81543. */
  81544. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81545. /**
  81546. * Clones the current emitter and returns a copy of it
  81547. * @returns the new emitter
  81548. */
  81549. clone(): CylinderDirectedParticleEmitter;
  81550. /**
  81551. * Called by the GPUParticleSystem to setup the update shader
  81552. * @param effect defines the update shader
  81553. */
  81554. applyToShader(effect: Effect): void;
  81555. /**
  81556. * Returns a string to use to update the GPU particles update shader
  81557. * @returns a string containng the defines string
  81558. */
  81559. getEffectDefines(): string;
  81560. /**
  81561. * Returns the string "CylinderDirectedParticleEmitter"
  81562. * @returns a string containing the class name
  81563. */
  81564. getClassName(): string;
  81565. /**
  81566. * Serializes the particle system to a JSON object.
  81567. * @returns the JSON object
  81568. */
  81569. serialize(): any;
  81570. /**
  81571. * Parse properties from a JSON object
  81572. * @param serializationObject defines the JSON object
  81573. */
  81574. parse(serializationObject: any): void;
  81575. }
  81576. }
  81577. declare module BABYLON {
  81578. /**
  81579. * Particle emitter emitting particles from the inside of a hemisphere.
  81580. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  81581. */
  81582. export class HemisphericParticleEmitter implements IParticleEmitterType {
  81583. /**
  81584. * The radius of the emission hemisphere.
  81585. */
  81586. radius: number;
  81587. /**
  81588. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81589. */
  81590. radiusRange: number;
  81591. /**
  81592. * How much to randomize the particle direction [0-1].
  81593. */
  81594. directionRandomizer: number;
  81595. /**
  81596. * Creates a new instance HemisphericParticleEmitter
  81597. * @param radius the radius of the emission hemisphere (1 by default)
  81598. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81599. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81600. */
  81601. constructor(
  81602. /**
  81603. * The radius of the emission hemisphere.
  81604. */
  81605. radius?: number,
  81606. /**
  81607. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81608. */
  81609. radiusRange?: number,
  81610. /**
  81611. * How much to randomize the particle direction [0-1].
  81612. */
  81613. directionRandomizer?: number);
  81614. /**
  81615. * Called by the particle System when the direction is computed for the created particle.
  81616. * @param worldMatrix is the world matrix of the particle system
  81617. * @param directionToUpdate is the direction vector to update with the result
  81618. * @param particle is the particle we are computed the direction for
  81619. */
  81620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81621. /**
  81622. * Called by the particle System when the position is computed for the created particle.
  81623. * @param worldMatrix is the world matrix of the particle system
  81624. * @param positionToUpdate is the position vector to update with the result
  81625. * @param particle is the particle we are computed the position for
  81626. */
  81627. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81628. /**
  81629. * Clones the current emitter and returns a copy of it
  81630. * @returns the new emitter
  81631. */
  81632. clone(): HemisphericParticleEmitter;
  81633. /**
  81634. * Called by the GPUParticleSystem to setup the update shader
  81635. * @param effect defines the update shader
  81636. */
  81637. applyToShader(effect: Effect): void;
  81638. /**
  81639. * Returns a string to use to update the GPU particles update shader
  81640. * @returns a string containng the defines string
  81641. */
  81642. getEffectDefines(): string;
  81643. /**
  81644. * Returns the string "HemisphericParticleEmitter"
  81645. * @returns a string containing the class name
  81646. */
  81647. getClassName(): string;
  81648. /**
  81649. * Serializes the particle system to a JSON object.
  81650. * @returns the JSON object
  81651. */
  81652. serialize(): any;
  81653. /**
  81654. * Parse properties from a JSON object
  81655. * @param serializationObject defines the JSON object
  81656. */
  81657. parse(serializationObject: any): void;
  81658. }
  81659. }
  81660. declare module BABYLON {
  81661. /**
  81662. * Particle emitter emitting particles from a point.
  81663. * It emits the particles randomly between 2 given directions.
  81664. */
  81665. export class PointParticleEmitter implements IParticleEmitterType {
  81666. /**
  81667. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81668. */
  81669. direction1: Vector3;
  81670. /**
  81671. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81672. */
  81673. direction2: Vector3;
  81674. /**
  81675. * Creates a new instance PointParticleEmitter
  81676. */
  81677. constructor();
  81678. /**
  81679. * Called by the particle System when the direction is computed for the created particle.
  81680. * @param worldMatrix is the world matrix of the particle system
  81681. * @param directionToUpdate is the direction vector to update with the result
  81682. * @param particle is the particle we are computed the direction for
  81683. */
  81684. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81685. /**
  81686. * Called by the particle System when the position is computed for the created particle.
  81687. * @param worldMatrix is the world matrix of the particle system
  81688. * @param positionToUpdate is the position vector to update with the result
  81689. * @param particle is the particle we are computed the position for
  81690. */
  81691. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81692. /**
  81693. * Clones the current emitter and returns a copy of it
  81694. * @returns the new emitter
  81695. */
  81696. clone(): PointParticleEmitter;
  81697. /**
  81698. * Called by the GPUParticleSystem to setup the update shader
  81699. * @param effect defines the update shader
  81700. */
  81701. applyToShader(effect: Effect): void;
  81702. /**
  81703. * Returns a string to use to update the GPU particles update shader
  81704. * @returns a string containng the defines string
  81705. */
  81706. getEffectDefines(): string;
  81707. /**
  81708. * Returns the string "PointParticleEmitter"
  81709. * @returns a string containing the class name
  81710. */
  81711. getClassName(): string;
  81712. /**
  81713. * Serializes the particle system to a JSON object.
  81714. * @returns the JSON object
  81715. */
  81716. serialize(): any;
  81717. /**
  81718. * Parse properties from a JSON object
  81719. * @param serializationObject defines the JSON object
  81720. */
  81721. parse(serializationObject: any): void;
  81722. }
  81723. }
  81724. declare module BABYLON {
  81725. /**
  81726. * Particle emitter emitting particles from the inside of a sphere.
  81727. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  81728. */
  81729. export class SphereParticleEmitter implements IParticleEmitterType {
  81730. /**
  81731. * The radius of the emission sphere.
  81732. */
  81733. radius: number;
  81734. /**
  81735. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81736. */
  81737. radiusRange: number;
  81738. /**
  81739. * How much to randomize the particle direction [0-1].
  81740. */
  81741. directionRandomizer: number;
  81742. /**
  81743. * Creates a new instance SphereParticleEmitter
  81744. * @param radius the radius of the emission sphere (1 by default)
  81745. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81746. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81747. */
  81748. constructor(
  81749. /**
  81750. * The radius of the emission sphere.
  81751. */
  81752. radius?: number,
  81753. /**
  81754. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81755. */
  81756. radiusRange?: number,
  81757. /**
  81758. * How much to randomize the particle direction [0-1].
  81759. */
  81760. directionRandomizer?: number);
  81761. /**
  81762. * Called by the particle System when the direction is computed for the created particle.
  81763. * @param worldMatrix is the world matrix of the particle system
  81764. * @param directionToUpdate is the direction vector to update with the result
  81765. * @param particle is the particle we are computed the direction for
  81766. */
  81767. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81768. /**
  81769. * Called by the particle System when the position is computed for the created particle.
  81770. * @param worldMatrix is the world matrix of the particle system
  81771. * @param positionToUpdate is the position vector to update with the result
  81772. * @param particle is the particle we are computed the position for
  81773. */
  81774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81775. /**
  81776. * Clones the current emitter and returns a copy of it
  81777. * @returns the new emitter
  81778. */
  81779. clone(): SphereParticleEmitter;
  81780. /**
  81781. * Called by the GPUParticleSystem to setup the update shader
  81782. * @param effect defines the update shader
  81783. */
  81784. applyToShader(effect: Effect): void;
  81785. /**
  81786. * Returns a string to use to update the GPU particles update shader
  81787. * @returns a string containng the defines string
  81788. */
  81789. getEffectDefines(): string;
  81790. /**
  81791. * Returns the string "SphereParticleEmitter"
  81792. * @returns a string containing the class name
  81793. */
  81794. getClassName(): string;
  81795. /**
  81796. * Serializes the particle system to a JSON object.
  81797. * @returns the JSON object
  81798. */
  81799. serialize(): any;
  81800. /**
  81801. * Parse properties from a JSON object
  81802. * @param serializationObject defines the JSON object
  81803. */
  81804. parse(serializationObject: any): void;
  81805. }
  81806. /**
  81807. * Particle emitter emitting particles from the inside of a sphere.
  81808. * It emits the particles randomly between two vectors.
  81809. */
  81810. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  81811. /**
  81812. * The min limit of the emission direction.
  81813. */
  81814. direction1: Vector3;
  81815. /**
  81816. * The max limit of the emission direction.
  81817. */
  81818. direction2: Vector3;
  81819. /**
  81820. * Creates a new instance SphereDirectedParticleEmitter
  81821. * @param radius the radius of the emission sphere (1 by default)
  81822. * @param direction1 the min limit of the emission direction (up vector by default)
  81823. * @param direction2 the max limit of the emission direction (up vector by default)
  81824. */
  81825. constructor(radius?: number,
  81826. /**
  81827. * The min limit of the emission direction.
  81828. */
  81829. direction1?: Vector3,
  81830. /**
  81831. * The max limit of the emission direction.
  81832. */
  81833. direction2?: Vector3);
  81834. /**
  81835. * Called by the particle System when the direction is computed for the created particle.
  81836. * @param worldMatrix is the world matrix of the particle system
  81837. * @param directionToUpdate is the direction vector to update with the result
  81838. * @param particle is the particle we are computed the direction for
  81839. */
  81840. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81841. /**
  81842. * Clones the current emitter and returns a copy of it
  81843. * @returns the new emitter
  81844. */
  81845. clone(): SphereDirectedParticleEmitter;
  81846. /**
  81847. * Called by the GPUParticleSystem to setup the update shader
  81848. * @param effect defines the update shader
  81849. */
  81850. applyToShader(effect: Effect): void;
  81851. /**
  81852. * Returns a string to use to update the GPU particles update shader
  81853. * @returns a string containng the defines string
  81854. */
  81855. getEffectDefines(): string;
  81856. /**
  81857. * Returns the string "SphereDirectedParticleEmitter"
  81858. * @returns a string containing the class name
  81859. */
  81860. getClassName(): string;
  81861. /**
  81862. * Serializes the particle system to a JSON object.
  81863. * @returns the JSON object
  81864. */
  81865. serialize(): any;
  81866. /**
  81867. * Parse properties from a JSON object
  81868. * @param serializationObject defines the JSON object
  81869. */
  81870. parse(serializationObject: any): void;
  81871. }
  81872. }
  81873. declare module BABYLON {
  81874. /**
  81875. * Interface representing a particle system in Babylon.js.
  81876. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  81877. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  81878. */
  81879. export interface IParticleSystem {
  81880. /**
  81881. * List of animations used by the particle system.
  81882. */
  81883. animations: Animation[];
  81884. /**
  81885. * The id of the Particle system.
  81886. */
  81887. id: string;
  81888. /**
  81889. * The name of the Particle system.
  81890. */
  81891. name: string;
  81892. /**
  81893. * The emitter represents the Mesh or position we are attaching the particle system to.
  81894. */
  81895. emitter: Nullable<AbstractMesh | Vector3>;
  81896. /**
  81897. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81898. */
  81899. isBillboardBased: boolean;
  81900. /**
  81901. * The rendering group used by the Particle system to chose when to render.
  81902. */
  81903. renderingGroupId: number;
  81904. /**
  81905. * The layer mask we are rendering the particles through.
  81906. */
  81907. layerMask: number;
  81908. /**
  81909. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81910. */
  81911. updateSpeed: number;
  81912. /**
  81913. * The amount of time the particle system is running (depends of the overall update speed).
  81914. */
  81915. targetStopDuration: number;
  81916. /**
  81917. * The texture used to render each particle. (this can be a spritesheet)
  81918. */
  81919. particleTexture: Nullable<Texture>;
  81920. /**
  81921. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  81922. */
  81923. blendMode: number;
  81924. /**
  81925. * Minimum life time of emitting particles.
  81926. */
  81927. minLifeTime: number;
  81928. /**
  81929. * Maximum life time of emitting particles.
  81930. */
  81931. maxLifeTime: number;
  81932. /**
  81933. * Minimum Size of emitting particles.
  81934. */
  81935. minSize: number;
  81936. /**
  81937. * Maximum Size of emitting particles.
  81938. */
  81939. maxSize: number;
  81940. /**
  81941. * Minimum scale of emitting particles on X axis.
  81942. */
  81943. minScaleX: number;
  81944. /**
  81945. * Maximum scale of emitting particles on X axis.
  81946. */
  81947. maxScaleX: number;
  81948. /**
  81949. * Minimum scale of emitting particles on Y axis.
  81950. */
  81951. minScaleY: number;
  81952. /**
  81953. * Maximum scale of emitting particles on Y axis.
  81954. */
  81955. maxScaleY: number;
  81956. /**
  81957. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  81958. */
  81959. color1: Color4;
  81960. /**
  81961. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  81962. */
  81963. color2: Color4;
  81964. /**
  81965. * Color the particle will have at the end of its lifetime.
  81966. */
  81967. colorDead: Color4;
  81968. /**
  81969. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  81970. */
  81971. emitRate: number;
  81972. /**
  81973. * You can use gravity if you want to give an orientation to your particles.
  81974. */
  81975. gravity: Vector3;
  81976. /**
  81977. * Minimum power of emitting particles.
  81978. */
  81979. minEmitPower: number;
  81980. /**
  81981. * Maximum power of emitting particles.
  81982. */
  81983. maxEmitPower: number;
  81984. /**
  81985. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81986. */
  81987. minAngularSpeed: number;
  81988. /**
  81989. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81990. */
  81991. maxAngularSpeed: number;
  81992. /**
  81993. * Gets or sets the minimal initial rotation in radians.
  81994. */
  81995. minInitialRotation: number;
  81996. /**
  81997. * Gets or sets the maximal initial rotation in radians.
  81998. */
  81999. maxInitialRotation: number;
  82000. /**
  82001. * The particle emitter type defines the emitter used by the particle system.
  82002. * It can be for example box, sphere, or cone...
  82003. */
  82004. particleEmitterType: Nullable<IParticleEmitterType>;
  82005. /**
  82006. * Defines the delay in milliseconds before starting the system (0 by default)
  82007. */
  82008. startDelay: number;
  82009. /**
  82010. * 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
  82011. */
  82012. preWarmCycles: number;
  82013. /**
  82014. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  82015. */
  82016. preWarmStepOffset: number;
  82017. /**
  82018. * 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)
  82019. */
  82020. spriteCellChangeSpeed: number;
  82021. /**
  82022. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82023. */
  82024. startSpriteCellID: number;
  82025. /**
  82026. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82027. */
  82028. endSpriteCellID: number;
  82029. /**
  82030. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82031. */
  82032. spriteCellWidth: number;
  82033. /**
  82034. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82035. */
  82036. spriteCellHeight: number;
  82037. /**
  82038. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82039. */
  82040. spriteRandomStartCell: boolean;
  82041. /**
  82042. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  82043. */
  82044. isAnimationSheetEnabled: boolean;
  82045. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82046. translationPivot: Vector2;
  82047. /**
  82048. * Gets or sets a texture used to add random noise to particle positions
  82049. */
  82050. noiseTexture: Nullable<BaseTexture>;
  82051. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82052. noiseStrength: Vector3;
  82053. /**
  82054. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82055. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82056. */
  82057. billboardMode: number;
  82058. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82059. limitVelocityDamping: number;
  82060. /**
  82061. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82062. */
  82063. beginAnimationOnStart: boolean;
  82064. /**
  82065. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82066. */
  82067. beginAnimationFrom: number;
  82068. /**
  82069. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82070. */
  82071. beginAnimationTo: number;
  82072. /**
  82073. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82074. */
  82075. beginAnimationLoop: boolean;
  82076. /**
  82077. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82078. */
  82079. disposeOnStop: boolean;
  82080. /**
  82081. * Gets the maximum number of particles active at the same time.
  82082. * @returns The max number of active particles.
  82083. */
  82084. getCapacity(): number;
  82085. /**
  82086. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82087. * @returns True if it has been started, otherwise false.
  82088. */
  82089. isStarted(): boolean;
  82090. /**
  82091. * Animates the particle system for this frame.
  82092. */
  82093. animate(): void;
  82094. /**
  82095. * Renders the particle system in its current state.
  82096. * @returns the current number of particles
  82097. */
  82098. render(): number;
  82099. /**
  82100. * Dispose the particle system and frees its associated resources.
  82101. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82102. */
  82103. dispose(disposeTexture?: boolean): void;
  82104. /**
  82105. * Clones the particle system.
  82106. * @param name The name of the cloned object
  82107. * @param newEmitter The new emitter to use
  82108. * @returns the cloned particle system
  82109. */
  82110. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  82111. /**
  82112. * Serializes the particle system to a JSON object.
  82113. * @returns the JSON object
  82114. */
  82115. serialize(): any;
  82116. /**
  82117. * Rebuild the particle system
  82118. */
  82119. rebuild(): void;
  82120. /**
  82121. * Starts the particle system and begins to emit
  82122. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  82123. */
  82124. start(delay?: number): void;
  82125. /**
  82126. * Stops the particle system.
  82127. */
  82128. stop(): void;
  82129. /**
  82130. * Remove all active particles
  82131. */
  82132. reset(): void;
  82133. /**
  82134. * Is this system ready to be used/rendered
  82135. * @return true if the system is ready
  82136. */
  82137. isReady(): boolean;
  82138. /**
  82139. * Adds a new color gradient
  82140. * @param gradient defines the gradient to use (between 0 and 1)
  82141. * @param color1 defines the color to affect to the specified gradient
  82142. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82143. * @returns the current particle system
  82144. */
  82145. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82146. /**
  82147. * Remove a specific color gradient
  82148. * @param gradient defines the gradient to remove
  82149. * @returns the current particle system
  82150. */
  82151. removeColorGradient(gradient: number): IParticleSystem;
  82152. /**
  82153. * Adds a new size gradient
  82154. * @param gradient defines the gradient to use (between 0 and 1)
  82155. * @param factor defines the size factor to affect to the specified gradient
  82156. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82157. * @returns the current particle system
  82158. */
  82159. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82160. /**
  82161. * Remove a specific size gradient
  82162. * @param gradient defines the gradient to remove
  82163. * @returns the current particle system
  82164. */
  82165. removeSizeGradient(gradient: number): IParticleSystem;
  82166. /**
  82167. * Gets the current list of color gradients.
  82168. * You must use addColorGradient and removeColorGradient to udpate this list
  82169. * @returns the list of color gradients
  82170. */
  82171. getColorGradients(): Nullable<Array<ColorGradient>>;
  82172. /**
  82173. * Gets the current list of size gradients.
  82174. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82175. * @returns the list of size gradients
  82176. */
  82177. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82178. /**
  82179. * Gets the current list of angular speed gradients.
  82180. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82181. * @returns the list of angular speed gradients
  82182. */
  82183. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82184. /**
  82185. * Adds a new angular speed gradient
  82186. * @param gradient defines the gradient to use (between 0 and 1)
  82187. * @param factor defines the angular speed to affect to the specified gradient
  82188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82189. * @returns the current particle system
  82190. */
  82191. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82192. /**
  82193. * Remove a specific angular speed gradient
  82194. * @param gradient defines the gradient to remove
  82195. * @returns the current particle system
  82196. */
  82197. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82198. /**
  82199. * Gets the current list of velocity gradients.
  82200. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82201. * @returns the list of velocity gradients
  82202. */
  82203. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82204. /**
  82205. * Adds a new velocity gradient
  82206. * @param gradient defines the gradient to use (between 0 and 1)
  82207. * @param factor defines the velocity to affect to the specified gradient
  82208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82209. * @returns the current particle system
  82210. */
  82211. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82212. /**
  82213. * Remove a specific velocity gradient
  82214. * @param gradient defines the gradient to remove
  82215. * @returns the current particle system
  82216. */
  82217. removeVelocityGradient(gradient: number): IParticleSystem;
  82218. /**
  82219. * Gets the current list of limit velocity gradients.
  82220. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82221. * @returns the list of limit velocity gradients
  82222. */
  82223. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82224. /**
  82225. * Adds a new limit velocity gradient
  82226. * @param gradient defines the gradient to use (between 0 and 1)
  82227. * @param factor defines the limit velocity to affect to the specified gradient
  82228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82229. * @returns the current particle system
  82230. */
  82231. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82232. /**
  82233. * Remove a specific limit velocity gradient
  82234. * @param gradient defines the gradient to remove
  82235. * @returns the current particle system
  82236. */
  82237. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82238. /**
  82239. * Adds a new drag gradient
  82240. * @param gradient defines the gradient to use (between 0 and 1)
  82241. * @param factor defines the drag to affect to the specified gradient
  82242. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82243. * @returns the current particle system
  82244. */
  82245. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82246. /**
  82247. * Remove a specific drag gradient
  82248. * @param gradient defines the gradient to remove
  82249. * @returns the current particle system
  82250. */
  82251. removeDragGradient(gradient: number): IParticleSystem;
  82252. /**
  82253. * Gets the current list of drag gradients.
  82254. * You must use addDragGradient and removeDragGradient to udpate this list
  82255. * @returns the list of drag gradients
  82256. */
  82257. getDragGradients(): Nullable<Array<FactorGradient>>;
  82258. /**
  82259. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82260. * @param gradient defines the gradient to use (between 0 and 1)
  82261. * @param factor defines the emit rate to affect to the specified gradient
  82262. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82263. * @returns the current particle system
  82264. */
  82265. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82266. /**
  82267. * Remove a specific emit rate gradient
  82268. * @param gradient defines the gradient to remove
  82269. * @returns the current particle system
  82270. */
  82271. removeEmitRateGradient(gradient: number): IParticleSystem;
  82272. /**
  82273. * Gets the current list of emit rate gradients.
  82274. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82275. * @returns the list of emit rate gradients
  82276. */
  82277. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82278. /**
  82279. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82280. * @param gradient defines the gradient to use (between 0 and 1)
  82281. * @param factor defines the start size to affect to the specified gradient
  82282. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82283. * @returns the current particle system
  82284. */
  82285. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82286. /**
  82287. * Remove a specific start size gradient
  82288. * @param gradient defines the gradient to remove
  82289. * @returns the current particle system
  82290. */
  82291. removeStartSizeGradient(gradient: number): IParticleSystem;
  82292. /**
  82293. * Gets the current list of start size gradients.
  82294. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82295. * @returns the list of start size gradients
  82296. */
  82297. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82298. /**
  82299. * Adds a new life time gradient
  82300. * @param gradient defines the gradient to use (between 0 and 1)
  82301. * @param factor defines the life time factor to affect to the specified gradient
  82302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82303. * @returns the current particle system
  82304. */
  82305. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82306. /**
  82307. * Remove a specific life time gradient
  82308. * @param gradient defines the gradient to remove
  82309. * @returns the current particle system
  82310. */
  82311. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82312. /**
  82313. * Gets the current list of life time gradients.
  82314. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82315. * @returns the list of life time gradients
  82316. */
  82317. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82318. /**
  82319. * Gets the current list of color gradients.
  82320. * You must use addColorGradient and removeColorGradient to udpate this list
  82321. * @returns the list of color gradients
  82322. */
  82323. getColorGradients(): Nullable<Array<ColorGradient>>;
  82324. /**
  82325. * Adds a new ramp gradient used to remap particle colors
  82326. * @param gradient defines the gradient to use (between 0 and 1)
  82327. * @param color defines the color to affect to the specified gradient
  82328. * @returns the current particle system
  82329. */
  82330. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  82331. /**
  82332. * Gets the current list of ramp gradients.
  82333. * You must use addRampGradient and removeRampGradient to udpate this list
  82334. * @returns the list of ramp gradients
  82335. */
  82336. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82337. /** Gets or sets a boolean indicating that ramp gradients must be used
  82338. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82339. */
  82340. useRampGradients: boolean;
  82341. /**
  82342. * Adds a new color remap gradient
  82343. * @param gradient defines the gradient to use (between 0 and 1)
  82344. * @param min defines the color remap minimal range
  82345. * @param max defines the color remap maximal range
  82346. * @returns the current particle system
  82347. */
  82348. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82349. /**
  82350. * Gets the current list of color remap gradients.
  82351. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82352. * @returns the list of color remap gradients
  82353. */
  82354. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82355. /**
  82356. * Adds a new alpha remap gradient
  82357. * @param gradient defines the gradient to use (between 0 and 1)
  82358. * @param min defines the alpha remap minimal range
  82359. * @param max defines the alpha remap maximal range
  82360. * @returns the current particle system
  82361. */
  82362. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82363. /**
  82364. * Gets the current list of alpha remap gradients.
  82365. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82366. * @returns the list of alpha remap gradients
  82367. */
  82368. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82369. /**
  82370. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82371. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82372. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82373. * @returns the emitter
  82374. */
  82375. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82376. /**
  82377. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82378. * @param radius The radius of the hemisphere to emit from
  82379. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82380. * @returns the emitter
  82381. */
  82382. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  82383. /**
  82384. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82385. * @param radius The radius of the sphere to emit from
  82386. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82387. * @returns the emitter
  82388. */
  82389. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  82390. /**
  82391. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82392. * @param radius The radius of the sphere to emit from
  82393. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82394. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82395. * @returns the emitter
  82396. */
  82397. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82398. /**
  82399. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82400. * @param radius The radius of the emission cylinder
  82401. * @param height The height of the emission cylinder
  82402. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82403. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82404. * @returns the emitter
  82405. */
  82406. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  82407. /**
  82408. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82409. * @param radius The radius of the cylinder to emit from
  82410. * @param height The height of the emission cylinder
  82411. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82412. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82413. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82414. * @returns the emitter
  82415. */
  82416. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82417. /**
  82418. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82419. * @param radius The radius of the cone to emit from
  82420. * @param angle The base angle of the cone
  82421. * @returns the emitter
  82422. */
  82423. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  82424. /**
  82425. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82426. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82427. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82428. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82429. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82430. * @returns the emitter
  82431. */
  82432. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82433. /**
  82434. * Get hosting scene
  82435. * @returns the scene
  82436. */
  82437. getScene(): Scene;
  82438. }
  82439. }
  82440. declare module BABYLON {
  82441. /**
  82442. * Creates an instance based on a source mesh.
  82443. */
  82444. export class InstancedMesh extends AbstractMesh {
  82445. private _sourceMesh;
  82446. private _currentLOD;
  82447. /** @hidden */
  82448. _indexInSourceMeshInstanceArray: number;
  82449. constructor(name: string, source: Mesh);
  82450. /**
  82451. * Returns the string "InstancedMesh".
  82452. */
  82453. getClassName(): string;
  82454. /** Gets the list of lights affecting that mesh */
  82455. readonly lightSources: Light[];
  82456. _resyncLightSources(): void;
  82457. _resyncLighSource(light: Light): void;
  82458. _removeLightSource(light: Light): void;
  82459. /**
  82460. * If the source mesh receives shadows
  82461. */
  82462. readonly receiveShadows: boolean;
  82463. /**
  82464. * The material of the source mesh
  82465. */
  82466. readonly material: Nullable<Material>;
  82467. /**
  82468. * Visibility of the source mesh
  82469. */
  82470. readonly visibility: number;
  82471. /**
  82472. * Skeleton of the source mesh
  82473. */
  82474. readonly skeleton: Nullable<Skeleton>;
  82475. /**
  82476. * Rendering ground id of the source mesh
  82477. */
  82478. renderingGroupId: number;
  82479. /**
  82480. * Returns the total number of vertices (integer).
  82481. */
  82482. getTotalVertices(): number;
  82483. /**
  82484. * Returns a positive integer : the total number of indices in this mesh geometry.
  82485. * @returns the numner of indices or zero if the mesh has no geometry.
  82486. */
  82487. getTotalIndices(): number;
  82488. /**
  82489. * The source mesh of the instance
  82490. */
  82491. readonly sourceMesh: Mesh;
  82492. /**
  82493. * Is this node ready to be used/rendered
  82494. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82495. * @return {boolean} is it ready
  82496. */
  82497. isReady(completeCheck?: boolean): boolean;
  82498. /**
  82499. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82500. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  82501. * @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.
  82502. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  82503. */
  82504. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  82505. /**
  82506. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82507. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82508. * The `data` are either a numeric array either a Float32Array.
  82509. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  82510. * 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).
  82511. * Note that a new underlying VertexBuffer object is created each call.
  82512. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82513. *
  82514. * Possible `kind` values :
  82515. * - VertexBuffer.PositionKind
  82516. * - VertexBuffer.UVKind
  82517. * - VertexBuffer.UV2Kind
  82518. * - VertexBuffer.UV3Kind
  82519. * - VertexBuffer.UV4Kind
  82520. * - VertexBuffer.UV5Kind
  82521. * - VertexBuffer.UV6Kind
  82522. * - VertexBuffer.ColorKind
  82523. * - VertexBuffer.MatricesIndicesKind
  82524. * - VertexBuffer.MatricesIndicesExtraKind
  82525. * - VertexBuffer.MatricesWeightsKind
  82526. * - VertexBuffer.MatricesWeightsExtraKind
  82527. *
  82528. * Returns the Mesh.
  82529. */
  82530. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  82531. /**
  82532. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82533. * If the mesh has no geometry, it is simply returned as it is.
  82534. * The `data` are either a numeric array either a Float32Array.
  82535. * No new underlying VertexBuffer object is created.
  82536. * 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.
  82537. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  82538. *
  82539. * Possible `kind` values :
  82540. * - VertexBuffer.PositionKind
  82541. * - VertexBuffer.UVKind
  82542. * - VertexBuffer.UV2Kind
  82543. * - VertexBuffer.UV3Kind
  82544. * - VertexBuffer.UV4Kind
  82545. * - VertexBuffer.UV5Kind
  82546. * - VertexBuffer.UV6Kind
  82547. * - VertexBuffer.ColorKind
  82548. * - VertexBuffer.MatricesIndicesKind
  82549. * - VertexBuffer.MatricesIndicesExtraKind
  82550. * - VertexBuffer.MatricesWeightsKind
  82551. * - VertexBuffer.MatricesWeightsExtraKind
  82552. *
  82553. * Returns the Mesh.
  82554. */
  82555. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  82556. /**
  82557. * Sets the mesh indices.
  82558. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  82559. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82560. * This method creates a new index buffer each call.
  82561. * Returns the Mesh.
  82562. */
  82563. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  82564. /**
  82565. * Boolean : True if the mesh owns the requested kind of data.
  82566. */
  82567. isVerticesDataPresent(kind: string): boolean;
  82568. /**
  82569. * Returns an array of indices (IndicesArray).
  82570. */
  82571. getIndices(): Nullable<IndicesArray>;
  82572. readonly _positions: Nullable<Vector3[]>;
  82573. /**
  82574. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82575. * This means the mesh underlying bounding box and sphere are recomputed.
  82576. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82577. * @returns the current mesh
  82578. */
  82579. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  82580. /** @hidden */
  82581. _preActivate(): InstancedMesh;
  82582. /** @hidden */
  82583. _activate(renderId: number, intermediateRendering: boolean): boolean;
  82584. /** @hidden */
  82585. _postActivate(): void;
  82586. getWorldMatrix(): Matrix;
  82587. readonly isAnInstance: boolean;
  82588. /**
  82589. * Returns the current associated LOD AbstractMesh.
  82590. */
  82591. getLOD(camera: Camera): AbstractMesh;
  82592. /** @hidden */
  82593. _syncSubMeshes(): InstancedMesh;
  82594. /** @hidden */
  82595. _generatePointsArray(): boolean;
  82596. /**
  82597. * Creates a new InstancedMesh from the current mesh.
  82598. * - name (string) : the cloned mesh name
  82599. * - newParent (optional Node) : the optional Node to parent the clone to.
  82600. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  82601. *
  82602. * Returns the clone.
  82603. */
  82604. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  82605. /**
  82606. * Disposes the InstancedMesh.
  82607. * Returns nothing.
  82608. */
  82609. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82610. }
  82611. }
  82612. declare module BABYLON {
  82613. /**
  82614. * Defines the options associated with the creation of a shader material.
  82615. */
  82616. export interface IShaderMaterialOptions {
  82617. /**
  82618. * Does the material work in alpha blend mode
  82619. */
  82620. needAlphaBlending: boolean;
  82621. /**
  82622. * Does the material work in alpha test mode
  82623. */
  82624. needAlphaTesting: boolean;
  82625. /**
  82626. * The list of attribute names used in the shader
  82627. */
  82628. attributes: string[];
  82629. /**
  82630. * The list of unifrom names used in the shader
  82631. */
  82632. uniforms: string[];
  82633. /**
  82634. * The list of UBO names used in the shader
  82635. */
  82636. uniformBuffers: string[];
  82637. /**
  82638. * The list of sampler names used in the shader
  82639. */
  82640. samplers: string[];
  82641. /**
  82642. * The list of defines used in the shader
  82643. */
  82644. defines: string[];
  82645. }
  82646. /**
  82647. * 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.
  82648. *
  82649. * This returned material effects how the mesh will look based on the code in the shaders.
  82650. *
  82651. * @see http://doc.babylonjs.com/how_to/shader_material
  82652. */
  82653. export class ShaderMaterial extends Material {
  82654. private _shaderPath;
  82655. private _options;
  82656. private _textures;
  82657. private _textureArrays;
  82658. private _floats;
  82659. private _ints;
  82660. private _floatsArrays;
  82661. private _colors3;
  82662. private _colors3Arrays;
  82663. private _colors4;
  82664. private _colors4Arrays;
  82665. private _vectors2;
  82666. private _vectors3;
  82667. private _vectors4;
  82668. private _matrices;
  82669. private _matrices3x3;
  82670. private _matrices2x2;
  82671. private _vectors2Arrays;
  82672. private _vectors3Arrays;
  82673. private _vectors4Arrays;
  82674. private _cachedWorldViewMatrix;
  82675. private _cachedWorldViewProjectionMatrix;
  82676. private _renderId;
  82677. /**
  82678. * Instantiate a new shader material.
  82679. * 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.
  82680. * This returned material effects how the mesh will look based on the code in the shaders.
  82681. * @see http://doc.babylonjs.com/how_to/shader_material
  82682. * @param name Define the name of the material in the scene
  82683. * @param scene Define the scene the material belongs to
  82684. * @param shaderPath Defines the route to the shader code in one of three ways:
  82685. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  82686. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  82687. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  82688. * @param options Define the options used to create the shader
  82689. */
  82690. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  82691. /**
  82692. * Gets the options used to compile the shader.
  82693. * They can be modified to trigger a new compilation
  82694. */
  82695. readonly options: IShaderMaterialOptions;
  82696. /**
  82697. * Gets the current class name of the material e.g. "ShaderMaterial"
  82698. * Mainly use in serialization.
  82699. * @returns the class name
  82700. */
  82701. getClassName(): string;
  82702. /**
  82703. * Specifies if the material will require alpha blending
  82704. * @returns a boolean specifying if alpha blending is needed
  82705. */
  82706. needAlphaBlending(): boolean;
  82707. /**
  82708. * Specifies if this material should be rendered in alpha test mode
  82709. * @returns a boolean specifying if an alpha test is needed.
  82710. */
  82711. needAlphaTesting(): boolean;
  82712. private _checkUniform;
  82713. /**
  82714. * Set a texture in the shader.
  82715. * @param name Define the name of the uniform samplers as defined in the shader
  82716. * @param texture Define the texture to bind to this sampler
  82717. * @return the material itself allowing "fluent" like uniform updates
  82718. */
  82719. setTexture(name: string, texture: Texture): ShaderMaterial;
  82720. /**
  82721. * Set a texture array in the shader.
  82722. * @param name Define the name of the uniform sampler array as defined in the shader
  82723. * @param textures Define the list of textures to bind to this sampler
  82724. * @return the material itself allowing "fluent" like uniform updates
  82725. */
  82726. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  82727. /**
  82728. * Set a float in the shader.
  82729. * @param name Define the name of the uniform as defined in the shader
  82730. * @param value Define the value to give to the uniform
  82731. * @return the material itself allowing "fluent" like uniform updates
  82732. */
  82733. setFloat(name: string, value: number): ShaderMaterial;
  82734. /**
  82735. * Set a int in the shader.
  82736. * @param name Define the name of the uniform as defined in the shader
  82737. * @param value Define the value to give to the uniform
  82738. * @return the material itself allowing "fluent" like uniform updates
  82739. */
  82740. setInt(name: string, value: number): ShaderMaterial;
  82741. /**
  82742. * Set an array of floats in the shader.
  82743. * @param name Define the name of the uniform as defined in the shader
  82744. * @param value Define the value to give to the uniform
  82745. * @return the material itself allowing "fluent" like uniform updates
  82746. */
  82747. setFloats(name: string, value: number[]): ShaderMaterial;
  82748. /**
  82749. * Set a vec3 in the shader from a Color3.
  82750. * @param name Define the name of the uniform as defined in the shader
  82751. * @param value Define the value to give to the uniform
  82752. * @return the material itself allowing "fluent" like uniform updates
  82753. */
  82754. setColor3(name: string, value: Color3): ShaderMaterial;
  82755. /**
  82756. * Set a vec3 array in the shader from a Color3 array.
  82757. * @param name Define the name of the uniform as defined in the shader
  82758. * @param value Define the value to give to the uniform
  82759. * @return the material itself allowing "fluent" like uniform updates
  82760. */
  82761. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  82762. /**
  82763. * Set a vec4 in the shader from a Color4.
  82764. * @param name Define the name of the uniform as defined in the shader
  82765. * @param value Define the value to give to the uniform
  82766. * @return the material itself allowing "fluent" like uniform updates
  82767. */
  82768. setColor4(name: string, value: Color4): ShaderMaterial;
  82769. /**
  82770. * Set a vec4 array in the shader from a Color4 array.
  82771. * @param name Define the name of the uniform as defined in the shader
  82772. * @param value Define the value to give to the uniform
  82773. * @return the material itself allowing "fluent" like uniform updates
  82774. */
  82775. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  82776. /**
  82777. * Set a vec2 in the shader from a Vector2.
  82778. * @param name Define the name of the uniform as defined in the shader
  82779. * @param value Define the value to give to the uniform
  82780. * @return the material itself allowing "fluent" like uniform updates
  82781. */
  82782. setVector2(name: string, value: Vector2): ShaderMaterial;
  82783. /**
  82784. * Set a vec3 in the shader from a Vector3.
  82785. * @param name Define the name of the uniform as defined in the shader
  82786. * @param value Define the value to give to the uniform
  82787. * @return the material itself allowing "fluent" like uniform updates
  82788. */
  82789. setVector3(name: string, value: Vector3): ShaderMaterial;
  82790. /**
  82791. * Set a vec4 in the shader from a Vector4.
  82792. * @param name Define the name of the uniform as defined in the shader
  82793. * @param value Define the value to give to the uniform
  82794. * @return the material itself allowing "fluent" like uniform updates
  82795. */
  82796. setVector4(name: string, value: Vector4): ShaderMaterial;
  82797. /**
  82798. * Set a mat4 in the shader from a Matrix.
  82799. * @param name Define the name of the uniform as defined in the shader
  82800. * @param value Define the value to give to the uniform
  82801. * @return the material itself allowing "fluent" like uniform updates
  82802. */
  82803. setMatrix(name: string, value: Matrix): ShaderMaterial;
  82804. /**
  82805. * Set a mat3 in the shader from a Float32Array.
  82806. * @param name Define the name of the uniform as defined in the shader
  82807. * @param value Define the value to give to the uniform
  82808. * @return the material itself allowing "fluent" like uniform updates
  82809. */
  82810. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  82811. /**
  82812. * Set a mat2 in the shader from a Float32Array.
  82813. * @param name Define the name of the uniform as defined in the shader
  82814. * @param value Define the value to give to the uniform
  82815. * @return the material itself allowing "fluent" like uniform updates
  82816. */
  82817. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  82818. /**
  82819. * Set a vec2 array in the shader from a number array.
  82820. * @param name Define the name of the uniform as defined in the shader
  82821. * @param value Define the value to give to the uniform
  82822. * @return the material itself allowing "fluent" like uniform updates
  82823. */
  82824. setArray2(name: string, value: number[]): ShaderMaterial;
  82825. /**
  82826. * Set a vec3 array in the shader from a number array.
  82827. * @param name Define the name of the uniform as defined in the shader
  82828. * @param value Define the value to give to the uniform
  82829. * @return the material itself allowing "fluent" like uniform updates
  82830. */
  82831. setArray3(name: string, value: number[]): ShaderMaterial;
  82832. /**
  82833. * Set a vec4 array in the shader from a number array.
  82834. * @param name Define the name of the uniform as defined in the shader
  82835. * @param value Define the value to give to the uniform
  82836. * @return the material itself allowing "fluent" like uniform updates
  82837. */
  82838. setArray4(name: string, value: number[]): ShaderMaterial;
  82839. private _checkCache;
  82840. /**
  82841. * Specifies that the submesh is ready to be used
  82842. * @param mesh defines the mesh to check
  82843. * @param subMesh defines which submesh to check
  82844. * @param useInstances specifies that instances should be used
  82845. * @returns a boolean indicating that the submesh is ready or not
  82846. */
  82847. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82848. /**
  82849. * Checks if the material is ready to render the requested mesh
  82850. * @param mesh Define the mesh to render
  82851. * @param useInstances Define whether or not the material is used with instances
  82852. * @returns true if ready, otherwise false
  82853. */
  82854. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82855. /**
  82856. * Binds the world matrix to the material
  82857. * @param world defines the world transformation matrix
  82858. */
  82859. bindOnlyWorldMatrix(world: Matrix): void;
  82860. /**
  82861. * Binds the material to the mesh
  82862. * @param world defines the world transformation matrix
  82863. * @param mesh defines the mesh to bind the material to
  82864. */
  82865. bind(world: Matrix, mesh?: Mesh): void;
  82866. /**
  82867. * Gets the active textures from the material
  82868. * @returns an array of textures
  82869. */
  82870. getActiveTextures(): BaseTexture[];
  82871. /**
  82872. * Specifies if the material uses a texture
  82873. * @param texture defines the texture to check against the material
  82874. * @returns a boolean specifying if the material uses the texture
  82875. */
  82876. hasTexture(texture: BaseTexture): boolean;
  82877. /**
  82878. * Makes a duplicate of the material, and gives it a new name
  82879. * @param name defines the new name for the duplicated material
  82880. * @returns the cloned material
  82881. */
  82882. clone(name: string): ShaderMaterial;
  82883. /**
  82884. * Disposes the material
  82885. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82886. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82887. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82888. */
  82889. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82890. /**
  82891. * Serializes this material in a JSON representation
  82892. * @returns the serialized material object
  82893. */
  82894. serialize(): any;
  82895. /**
  82896. * Creates a shader material from parsed shader material data
  82897. * @param source defines the JSON represnetation of the material
  82898. * @param scene defines the hosting scene
  82899. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  82900. * @returns a new material
  82901. */
  82902. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  82903. }
  82904. }
  82905. declare module BABYLON {
  82906. /** @hidden */
  82907. export var colorPixelShader: {
  82908. name: string;
  82909. shader: string;
  82910. };
  82911. }
  82912. declare module BABYLON {
  82913. /** @hidden */
  82914. export var colorVertexShader: {
  82915. name: string;
  82916. shader: string;
  82917. };
  82918. }
  82919. declare module BABYLON {
  82920. /**
  82921. * Line mesh
  82922. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  82923. */
  82924. export class LinesMesh extends Mesh {
  82925. /**
  82926. * If vertex color should be applied to the mesh
  82927. */
  82928. readonly useVertexColor?: boolean | undefined;
  82929. /**
  82930. * If vertex alpha should be applied to the mesh
  82931. */
  82932. readonly useVertexAlpha?: boolean | undefined;
  82933. /**
  82934. * Color of the line (Default: White)
  82935. */
  82936. color: Color3;
  82937. /**
  82938. * Alpha of the line (Default: 1)
  82939. */
  82940. alpha: number;
  82941. /**
  82942. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  82943. * This margin is expressed in world space coordinates, so its value may vary.
  82944. * Default value is 0.1
  82945. */
  82946. intersectionThreshold: number;
  82947. private _colorShader;
  82948. private color4;
  82949. /**
  82950. * Creates a new LinesMesh
  82951. * @param name defines the name
  82952. * @param scene defines the hosting scene
  82953. * @param parent defines the parent mesh if any
  82954. * @param source defines the optional source LinesMesh used to clone data from
  82955. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  82956. * When false, achieved by calling a clone(), also passing False.
  82957. * This will make creation of children, recursive.
  82958. * @param useVertexColor defines if this LinesMesh supports vertex color
  82959. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  82960. */
  82961. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  82962. /**
  82963. * If vertex color should be applied to the mesh
  82964. */
  82965. useVertexColor?: boolean | undefined,
  82966. /**
  82967. * If vertex alpha should be applied to the mesh
  82968. */
  82969. useVertexAlpha?: boolean | undefined);
  82970. private _addClipPlaneDefine;
  82971. private _removeClipPlaneDefine;
  82972. isReady(): boolean;
  82973. /**
  82974. * Returns the string "LineMesh"
  82975. */
  82976. getClassName(): string;
  82977. /**
  82978. * @hidden
  82979. */
  82980. /**
  82981. * @hidden
  82982. */
  82983. material: Material;
  82984. /**
  82985. * @hidden
  82986. */
  82987. readonly checkCollisions: boolean;
  82988. /** @hidden */
  82989. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  82990. /** @hidden */
  82991. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  82992. /**
  82993. * Disposes of the line mesh
  82994. * @param doNotRecurse If children should be disposed
  82995. */
  82996. dispose(doNotRecurse?: boolean): void;
  82997. /**
  82998. * Returns a new LineMesh object cloned from the current one.
  82999. */
  83000. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  83001. /**
  83002. * Creates a new InstancedLinesMesh object from the mesh model.
  83003. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83004. * @param name defines the name of the new instance
  83005. * @returns a new InstancedLinesMesh
  83006. */
  83007. createInstance(name: string): InstancedLinesMesh;
  83008. }
  83009. /**
  83010. * Creates an instance based on a source LinesMesh
  83011. */
  83012. export class InstancedLinesMesh extends InstancedMesh {
  83013. /**
  83014. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83015. * This margin is expressed in world space coordinates, so its value may vary.
  83016. * Initilized with the intersectionThreshold value of the source LinesMesh
  83017. */
  83018. intersectionThreshold: number;
  83019. constructor(name: string, source: LinesMesh);
  83020. /**
  83021. * Returns the string "InstancedLinesMesh".
  83022. */
  83023. getClassName(): string;
  83024. }
  83025. }
  83026. declare module BABYLON {
  83027. /** @hidden */
  83028. export var linePixelShader: {
  83029. name: string;
  83030. shader: string;
  83031. };
  83032. }
  83033. declare module BABYLON {
  83034. /** @hidden */
  83035. export var lineVertexShader: {
  83036. name: string;
  83037. shader: string;
  83038. };
  83039. }
  83040. declare module BABYLON {
  83041. interface AbstractMesh {
  83042. /**
  83043. * Gets the edgesRenderer associated with the mesh
  83044. */
  83045. edgesRenderer: Nullable<EdgesRenderer>;
  83046. }
  83047. interface LinesMesh {
  83048. /**
  83049. * Enables the edge rendering mode on the mesh.
  83050. * This mode makes the mesh edges visible
  83051. * @param epsilon defines the maximal distance between two angles to detect a face
  83052. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83053. * @returns the currentAbstractMesh
  83054. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83055. */
  83056. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83057. }
  83058. interface InstancedLinesMesh {
  83059. /**
  83060. * Enables the edge rendering mode on the mesh.
  83061. * This mode makes the mesh edges visible
  83062. * @param epsilon defines the maximal distance between two angles to detect a face
  83063. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83064. * @returns the current InstancedLinesMesh
  83065. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83066. */
  83067. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83068. }
  83069. /**
  83070. * Defines the minimum contract an Edges renderer should follow.
  83071. */
  83072. export interface IEdgesRenderer extends IDisposable {
  83073. /**
  83074. * Gets or sets a boolean indicating if the edgesRenderer is active
  83075. */
  83076. isEnabled: boolean;
  83077. /**
  83078. * Renders the edges of the attached mesh,
  83079. */
  83080. render(): void;
  83081. /**
  83082. * Checks wether or not the edges renderer is ready to render.
  83083. * @return true if ready, otherwise false.
  83084. */
  83085. isReady(): boolean;
  83086. }
  83087. /**
  83088. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83089. */
  83090. export class EdgesRenderer implements IEdgesRenderer {
  83091. /**
  83092. * Define the size of the edges with an orthographic camera
  83093. */
  83094. edgesWidthScalerForOrthographic: number;
  83095. /**
  83096. * Define the size of the edges with a perspective camera
  83097. */
  83098. edgesWidthScalerForPerspective: number;
  83099. protected _source: AbstractMesh;
  83100. protected _linesPositions: number[];
  83101. protected _linesNormals: number[];
  83102. protected _linesIndices: number[];
  83103. protected _epsilon: number;
  83104. protected _indicesCount: number;
  83105. protected _lineShader: ShaderMaterial;
  83106. protected _ib: DataBuffer;
  83107. protected _buffers: {
  83108. [key: string]: Nullable<VertexBuffer>;
  83109. };
  83110. protected _checkVerticesInsteadOfIndices: boolean;
  83111. private _meshRebuildObserver;
  83112. private _meshDisposeObserver;
  83113. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  83114. isEnabled: boolean;
  83115. /**
  83116. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  83117. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  83118. * @param source Mesh used to create edges
  83119. * @param epsilon sum of angles in adjacency to check for edge
  83120. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  83121. * @param generateEdgesLines - should generate Lines or only prepare resources.
  83122. */
  83123. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  83124. protected _prepareRessources(): void;
  83125. /** @hidden */
  83126. _rebuild(): void;
  83127. /**
  83128. * Releases the required resources for the edges renderer
  83129. */
  83130. dispose(): void;
  83131. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  83132. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  83133. /**
  83134. * Checks if the pair of p0 and p1 is en edge
  83135. * @param faceIndex
  83136. * @param edge
  83137. * @param faceNormals
  83138. * @param p0
  83139. * @param p1
  83140. * @private
  83141. */
  83142. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  83143. /**
  83144. * push line into the position, normal and index buffer
  83145. * @protected
  83146. */
  83147. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  83148. /**
  83149. * Generates lines edges from adjacencjes
  83150. * @private
  83151. */
  83152. _generateEdgesLines(): void;
  83153. /**
  83154. * Checks wether or not the edges renderer is ready to render.
  83155. * @return true if ready, otherwise false.
  83156. */
  83157. isReady(): boolean;
  83158. /**
  83159. * Renders the edges of the attached mesh,
  83160. */
  83161. render(): void;
  83162. }
  83163. /**
  83164. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  83165. */
  83166. export class LineEdgesRenderer extends EdgesRenderer {
  83167. /**
  83168. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  83169. * @param source LineMesh used to generate edges
  83170. * @param epsilon not important (specified angle for edge detection)
  83171. * @param checkVerticesInsteadOfIndices not important for LineMesh
  83172. */
  83173. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  83174. /**
  83175. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  83176. */
  83177. _generateEdgesLines(): void;
  83178. }
  83179. }
  83180. declare module BABYLON {
  83181. /**
  83182. * This represents the object necessary to create a rendering group.
  83183. * This is exclusively used and created by the rendering manager.
  83184. * To modify the behavior, you use the available helpers in your scene or meshes.
  83185. * @hidden
  83186. */
  83187. export class RenderingGroup {
  83188. index: number;
  83189. private static _zeroVector;
  83190. private _scene;
  83191. private _opaqueSubMeshes;
  83192. private _transparentSubMeshes;
  83193. private _alphaTestSubMeshes;
  83194. private _depthOnlySubMeshes;
  83195. private _particleSystems;
  83196. private _spriteManagers;
  83197. private _opaqueSortCompareFn;
  83198. private _alphaTestSortCompareFn;
  83199. private _transparentSortCompareFn;
  83200. private _renderOpaque;
  83201. private _renderAlphaTest;
  83202. private _renderTransparent;
  83203. /** @hidden */
  83204. _edgesRenderers: SmartArray<IEdgesRenderer>;
  83205. onBeforeTransparentRendering: () => void;
  83206. /**
  83207. * Set the opaque sort comparison function.
  83208. * If null the sub meshes will be render in the order they were created
  83209. */
  83210. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83211. /**
  83212. * Set the alpha test sort comparison function.
  83213. * If null the sub meshes will be render in the order they were created
  83214. */
  83215. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83216. /**
  83217. * Set the transparent sort comparison function.
  83218. * If null the sub meshes will be render in the order they were created
  83219. */
  83220. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83221. /**
  83222. * Creates a new rendering group.
  83223. * @param index The rendering group index
  83224. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  83225. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  83226. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  83227. */
  83228. 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>);
  83229. /**
  83230. * Render all the sub meshes contained in the group.
  83231. * @param customRenderFunction Used to override the default render behaviour of the group.
  83232. * @returns true if rendered some submeshes.
  83233. */
  83234. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  83235. /**
  83236. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  83237. * @param subMeshes The submeshes to render
  83238. */
  83239. private renderOpaqueSorted;
  83240. /**
  83241. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  83242. * @param subMeshes The submeshes to render
  83243. */
  83244. private renderAlphaTestSorted;
  83245. /**
  83246. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  83247. * @param subMeshes The submeshes to render
  83248. */
  83249. private renderTransparentSorted;
  83250. /**
  83251. * Renders the submeshes in a specified order.
  83252. * @param subMeshes The submeshes to sort before render
  83253. * @param sortCompareFn The comparison function use to sort
  83254. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  83255. * @param transparent Specifies to activate blending if true
  83256. */
  83257. private static renderSorted;
  83258. /**
  83259. * Renders the submeshes in the order they were dispatched (no sort applied).
  83260. * @param subMeshes The submeshes to render
  83261. */
  83262. private static renderUnsorted;
  83263. /**
  83264. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83265. * are rendered back to front if in the same alpha index.
  83266. *
  83267. * @param a The first submesh
  83268. * @param b The second submesh
  83269. * @returns The result of the comparison
  83270. */
  83271. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  83272. /**
  83273. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83274. * are rendered back to front.
  83275. *
  83276. * @param a The first submesh
  83277. * @param b The second submesh
  83278. * @returns The result of the comparison
  83279. */
  83280. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  83281. /**
  83282. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83283. * are rendered front to back (prevent overdraw).
  83284. *
  83285. * @param a The first submesh
  83286. * @param b The second submesh
  83287. * @returns The result of the comparison
  83288. */
  83289. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  83290. /**
  83291. * Resets the different lists of submeshes to prepare a new frame.
  83292. */
  83293. prepare(): void;
  83294. dispose(): void;
  83295. /**
  83296. * Inserts the submesh in its correct queue depending on its material.
  83297. * @param subMesh The submesh to dispatch
  83298. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83299. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83300. */
  83301. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83302. dispatchSprites(spriteManager: ISpriteManager): void;
  83303. dispatchParticles(particleSystem: IParticleSystem): void;
  83304. private _renderParticles;
  83305. private _renderSprites;
  83306. }
  83307. }
  83308. declare module BABYLON {
  83309. /**
  83310. * Interface describing the different options available in the rendering manager
  83311. * regarding Auto Clear between groups.
  83312. */
  83313. export interface IRenderingManagerAutoClearSetup {
  83314. /**
  83315. * Defines whether or not autoclear is enable.
  83316. */
  83317. autoClear: boolean;
  83318. /**
  83319. * Defines whether or not to autoclear the depth buffer.
  83320. */
  83321. depth: boolean;
  83322. /**
  83323. * Defines whether or not to autoclear the stencil buffer.
  83324. */
  83325. stencil: boolean;
  83326. }
  83327. /**
  83328. * This class is used by the onRenderingGroupObservable
  83329. */
  83330. export class RenderingGroupInfo {
  83331. /**
  83332. * The Scene that being rendered
  83333. */
  83334. scene: Scene;
  83335. /**
  83336. * The camera currently used for the rendering pass
  83337. */
  83338. camera: Nullable<Camera>;
  83339. /**
  83340. * The ID of the renderingGroup being processed
  83341. */
  83342. renderingGroupId: number;
  83343. }
  83344. /**
  83345. * This is the manager responsible of all the rendering for meshes sprites and particles.
  83346. * It is enable to manage the different groups as well as the different necessary sort functions.
  83347. * This should not be used directly aside of the few static configurations
  83348. */
  83349. export class RenderingManager {
  83350. /**
  83351. * The max id used for rendering groups (not included)
  83352. */
  83353. static MAX_RENDERINGGROUPS: number;
  83354. /**
  83355. * The min id used for rendering groups (included)
  83356. */
  83357. static MIN_RENDERINGGROUPS: number;
  83358. /**
  83359. * Used to globally prevent autoclearing scenes.
  83360. */
  83361. static AUTOCLEAR: boolean;
  83362. /**
  83363. * @hidden
  83364. */
  83365. _useSceneAutoClearSetup: boolean;
  83366. private _scene;
  83367. private _renderingGroups;
  83368. private _depthStencilBufferAlreadyCleaned;
  83369. private _autoClearDepthStencil;
  83370. private _customOpaqueSortCompareFn;
  83371. private _customAlphaTestSortCompareFn;
  83372. private _customTransparentSortCompareFn;
  83373. private _renderingGroupInfo;
  83374. /**
  83375. * Instantiates a new rendering group for a particular scene
  83376. * @param scene Defines the scene the groups belongs to
  83377. */
  83378. constructor(scene: Scene);
  83379. private _clearDepthStencilBuffer;
  83380. /**
  83381. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  83382. * @hidden
  83383. */
  83384. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  83385. /**
  83386. * Resets the different information of the group to prepare a new frame
  83387. * @hidden
  83388. */
  83389. reset(): void;
  83390. /**
  83391. * Dispose and release the group and its associated resources.
  83392. * @hidden
  83393. */
  83394. dispose(): void;
  83395. /**
  83396. * Clear the info related to rendering groups preventing retention points during dispose.
  83397. */
  83398. freeRenderingGroups(): void;
  83399. private _prepareRenderingGroup;
  83400. /**
  83401. * Add a sprite manager to the rendering manager in order to render it this frame.
  83402. * @param spriteManager Define the sprite manager to render
  83403. */
  83404. dispatchSprites(spriteManager: ISpriteManager): void;
  83405. /**
  83406. * Add a particle system to the rendering manager in order to render it this frame.
  83407. * @param particleSystem Define the particle system to render
  83408. */
  83409. dispatchParticles(particleSystem: IParticleSystem): void;
  83410. /**
  83411. * Add a submesh to the manager in order to render it this frame
  83412. * @param subMesh The submesh to dispatch
  83413. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83414. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83415. */
  83416. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83417. /**
  83418. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83419. * This allowed control for front to back rendering or reversly depending of the special needs.
  83420. *
  83421. * @param renderingGroupId The rendering group id corresponding to its index
  83422. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83423. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83424. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83425. */
  83426. 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;
  83427. /**
  83428. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83429. *
  83430. * @param renderingGroupId The rendering group id corresponding to its index
  83431. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83432. * @param depth Automatically clears depth between groups if true and autoClear is true.
  83433. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  83434. */
  83435. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  83436. /**
  83437. * Gets the current auto clear configuration for one rendering group of the rendering
  83438. * manager.
  83439. * @param index the rendering group index to get the information for
  83440. * @returns The auto clear setup for the requested rendering group
  83441. */
  83442. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  83443. }
  83444. }
  83445. declare module BABYLON {
  83446. /**
  83447. * This Helps creating a texture that will be created from a camera in your scene.
  83448. * It is basically a dynamic texture that could be used to create special effects for instance.
  83449. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  83450. */
  83451. export class RenderTargetTexture extends Texture {
  83452. isCube: boolean;
  83453. /**
  83454. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  83455. */
  83456. static readonly REFRESHRATE_RENDER_ONCE: number;
  83457. /**
  83458. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  83459. */
  83460. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  83461. /**
  83462. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  83463. * the central point of your effect and can save a lot of performances.
  83464. */
  83465. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  83466. /**
  83467. * Use this predicate to dynamically define the list of mesh you want to render.
  83468. * If set, the renderList property will be overwritten.
  83469. */
  83470. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  83471. private _renderList;
  83472. /**
  83473. * Use this list to define the list of mesh you want to render.
  83474. */
  83475. renderList: Nullable<Array<AbstractMesh>>;
  83476. private _hookArray;
  83477. /**
  83478. * Define if particles should be rendered in your texture.
  83479. */
  83480. renderParticles: boolean;
  83481. /**
  83482. * Define if sprites should be rendered in your texture.
  83483. */
  83484. renderSprites: boolean;
  83485. /**
  83486. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  83487. */
  83488. coordinatesMode: number;
  83489. /**
  83490. * Define the camera used to render the texture.
  83491. */
  83492. activeCamera: Nullable<Camera>;
  83493. /**
  83494. * Override the render function of the texture with your own one.
  83495. */
  83496. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  83497. /**
  83498. * Define if camera post processes should be use while rendering the texture.
  83499. */
  83500. useCameraPostProcesses: boolean;
  83501. /**
  83502. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  83503. */
  83504. ignoreCameraViewport: boolean;
  83505. private _postProcessManager;
  83506. private _postProcesses;
  83507. private _resizeObserver;
  83508. /**
  83509. * An event triggered when the texture is unbind.
  83510. */
  83511. onBeforeBindObservable: Observable<RenderTargetTexture>;
  83512. /**
  83513. * An event triggered when the texture is unbind.
  83514. */
  83515. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  83516. private _onAfterUnbindObserver;
  83517. /**
  83518. * Set a after unbind callback in the texture.
  83519. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  83520. */
  83521. onAfterUnbind: () => void;
  83522. /**
  83523. * An event triggered before rendering the texture
  83524. */
  83525. onBeforeRenderObservable: Observable<number>;
  83526. private _onBeforeRenderObserver;
  83527. /**
  83528. * Set a before render callback in the texture.
  83529. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  83530. */
  83531. onBeforeRender: (faceIndex: number) => void;
  83532. /**
  83533. * An event triggered after rendering the texture
  83534. */
  83535. onAfterRenderObservable: Observable<number>;
  83536. private _onAfterRenderObserver;
  83537. /**
  83538. * Set a after render callback in the texture.
  83539. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  83540. */
  83541. onAfterRender: (faceIndex: number) => void;
  83542. /**
  83543. * An event triggered after the texture clear
  83544. */
  83545. onClearObservable: Observable<Engine>;
  83546. private _onClearObserver;
  83547. /**
  83548. * Set a clear callback in the texture.
  83549. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  83550. */
  83551. onClear: (Engine: Engine) => void;
  83552. /**
  83553. * An event triggered when the texture is resized.
  83554. */
  83555. onResizeObservable: Observable<RenderTargetTexture>;
  83556. /**
  83557. * Define the clear color of the Render Target if it should be different from the scene.
  83558. */
  83559. clearColor: Color4;
  83560. protected _size: number | {
  83561. width: number;
  83562. height: number;
  83563. };
  83564. protected _initialSizeParameter: number | {
  83565. width: number;
  83566. height: number;
  83567. } | {
  83568. ratio: number;
  83569. };
  83570. protected _sizeRatio: Nullable<number>;
  83571. /** @hidden */
  83572. _generateMipMaps: boolean;
  83573. protected _renderingManager: RenderingManager;
  83574. /** @hidden */
  83575. _waitingRenderList: string[];
  83576. protected _doNotChangeAspectRatio: boolean;
  83577. protected _currentRefreshId: number;
  83578. protected _refreshRate: number;
  83579. protected _textureMatrix: Matrix;
  83580. protected _samples: number;
  83581. protected _renderTargetOptions: RenderTargetCreationOptions;
  83582. /**
  83583. * Gets render target creation options that were used.
  83584. */
  83585. readonly renderTargetOptions: RenderTargetCreationOptions;
  83586. protected _engine: Engine;
  83587. protected _onRatioRescale(): void;
  83588. /**
  83589. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  83590. * It must define where the camera used to render the texture is set
  83591. */
  83592. boundingBoxPosition: Vector3;
  83593. private _boundingBoxSize;
  83594. /**
  83595. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  83596. * When defined, the cubemap will switch to local mode
  83597. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83598. * @example https://www.babylonjs-playground.com/#RNASML
  83599. */
  83600. boundingBoxSize: Vector3;
  83601. /**
  83602. * In case the RTT has been created with a depth texture, get the associated
  83603. * depth texture.
  83604. * Otherwise, return null.
  83605. */
  83606. depthStencilTexture: Nullable<InternalTexture>;
  83607. /**
  83608. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  83609. * or used a shadow, depth texture...
  83610. * @param name The friendly name of the texture
  83611. * @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)
  83612. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  83613. * @param generateMipMaps True if mip maps need to be generated after render.
  83614. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  83615. * @param type The type of the buffer in the RTT (int, half float, float...)
  83616. * @param isCube True if a cube texture needs to be created
  83617. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  83618. * @param generateDepthBuffer True to generate a depth buffer
  83619. * @param generateStencilBuffer True to generate a stencil buffer
  83620. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  83621. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  83622. * @param delayAllocation if the texture allocation should be delayed (default: false)
  83623. */
  83624. constructor(name: string, size: number | {
  83625. width: number;
  83626. height: number;
  83627. } | {
  83628. ratio: number;
  83629. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  83630. /**
  83631. * Creates a depth stencil texture.
  83632. * This is only available in WebGL 2 or with the depth texture extension available.
  83633. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  83634. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  83635. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  83636. */
  83637. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  83638. private _processSizeParameter;
  83639. /**
  83640. * Define the number of samples to use in case of MSAA.
  83641. * It defaults to one meaning no MSAA has been enabled.
  83642. */
  83643. samples: number;
  83644. /**
  83645. * Resets the refresh counter of the texture and start bak from scratch.
  83646. * Could be useful to regenerate the texture if it is setup to render only once.
  83647. */
  83648. resetRefreshCounter(): void;
  83649. /**
  83650. * Define the refresh rate of the texture or the rendering frequency.
  83651. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83652. */
  83653. refreshRate: number;
  83654. /**
  83655. * Adds a post process to the render target rendering passes.
  83656. * @param postProcess define the post process to add
  83657. */
  83658. addPostProcess(postProcess: PostProcess): void;
  83659. /**
  83660. * Clear all the post processes attached to the render target
  83661. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  83662. */
  83663. clearPostProcesses(dispose?: boolean): void;
  83664. /**
  83665. * Remove one of the post process from the list of attached post processes to the texture
  83666. * @param postProcess define the post process to remove from the list
  83667. */
  83668. removePostProcess(postProcess: PostProcess): void;
  83669. /** @hidden */
  83670. _shouldRender(): boolean;
  83671. /**
  83672. * Gets the actual render size of the texture.
  83673. * @returns the width of the render size
  83674. */
  83675. getRenderSize(): number;
  83676. /**
  83677. * Gets the actual render width of the texture.
  83678. * @returns the width of the render size
  83679. */
  83680. getRenderWidth(): number;
  83681. /**
  83682. * Gets the actual render height of the texture.
  83683. * @returns the height of the render size
  83684. */
  83685. getRenderHeight(): number;
  83686. /**
  83687. * Get if the texture can be rescaled or not.
  83688. */
  83689. readonly canRescale: boolean;
  83690. /**
  83691. * Resize the texture using a ratio.
  83692. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  83693. */
  83694. scale(ratio: number): void;
  83695. /**
  83696. * Get the texture reflection matrix used to rotate/transform the reflection.
  83697. * @returns the reflection matrix
  83698. */
  83699. getReflectionTextureMatrix(): Matrix;
  83700. /**
  83701. * Resize the texture to a new desired size.
  83702. * Be carrefull as it will recreate all the data in the new texture.
  83703. * @param size Define the new size. It can be:
  83704. * - a number for squared texture,
  83705. * - an object containing { width: number, height: number }
  83706. * - or an object containing a ratio { ratio: number }
  83707. */
  83708. resize(size: number | {
  83709. width: number;
  83710. height: number;
  83711. } | {
  83712. ratio: number;
  83713. }): void;
  83714. /**
  83715. * Renders all the objects from the render list into the texture.
  83716. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  83717. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  83718. */
  83719. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  83720. private _bestReflectionRenderTargetDimension;
  83721. /**
  83722. * @hidden
  83723. * @param faceIndex face index to bind to if this is a cubetexture
  83724. */
  83725. _bindFrameBuffer(faceIndex?: number): void;
  83726. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83727. private renderToTarget;
  83728. /**
  83729. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83730. * This allowed control for front to back rendering or reversly depending of the special needs.
  83731. *
  83732. * @param renderingGroupId The rendering group id corresponding to its index
  83733. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83734. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83735. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83736. */
  83737. 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;
  83738. /**
  83739. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83740. *
  83741. * @param renderingGroupId The rendering group id corresponding to its index
  83742. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83743. */
  83744. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  83745. /**
  83746. * Clones the texture.
  83747. * @returns the cloned texture
  83748. */
  83749. clone(): RenderTargetTexture;
  83750. /**
  83751. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83752. * @returns The JSON representation of the texture
  83753. */
  83754. serialize(): any;
  83755. /**
  83756. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  83757. */
  83758. disposeFramebufferObjects(): void;
  83759. /**
  83760. * Dispose the texture and release its associated resources.
  83761. */
  83762. dispose(): void;
  83763. /** @hidden */
  83764. _rebuild(): void;
  83765. /**
  83766. * Clear the info related to rendering groups preventing retention point in material dispose.
  83767. */
  83768. freeRenderingGroups(): void;
  83769. /**
  83770. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83771. * @returns the view count
  83772. */
  83773. getViewCount(): number;
  83774. }
  83775. }
  83776. declare module BABYLON {
  83777. /**
  83778. * Base class for the main features of a material in Babylon.js
  83779. */
  83780. export class Material implements IAnimatable {
  83781. /**
  83782. * Returns the triangle fill mode
  83783. */
  83784. static readonly TriangleFillMode: number;
  83785. /**
  83786. * Returns the wireframe mode
  83787. */
  83788. static readonly WireFrameFillMode: number;
  83789. /**
  83790. * Returns the point fill mode
  83791. */
  83792. static readonly PointFillMode: number;
  83793. /**
  83794. * Returns the point list draw mode
  83795. */
  83796. static readonly PointListDrawMode: number;
  83797. /**
  83798. * Returns the line list draw mode
  83799. */
  83800. static readonly LineListDrawMode: number;
  83801. /**
  83802. * Returns the line loop draw mode
  83803. */
  83804. static readonly LineLoopDrawMode: number;
  83805. /**
  83806. * Returns the line strip draw mode
  83807. */
  83808. static readonly LineStripDrawMode: number;
  83809. /**
  83810. * Returns the triangle strip draw mode
  83811. */
  83812. static readonly TriangleStripDrawMode: number;
  83813. /**
  83814. * Returns the triangle fan draw mode
  83815. */
  83816. static readonly TriangleFanDrawMode: number;
  83817. /**
  83818. * Stores the clock-wise side orientation
  83819. */
  83820. static readonly ClockWiseSideOrientation: number;
  83821. /**
  83822. * Stores the counter clock-wise side orientation
  83823. */
  83824. static readonly CounterClockWiseSideOrientation: number;
  83825. /**
  83826. * The dirty texture flag value
  83827. */
  83828. static readonly TextureDirtyFlag: number;
  83829. /**
  83830. * The dirty light flag value
  83831. */
  83832. static readonly LightDirtyFlag: number;
  83833. /**
  83834. * The dirty fresnel flag value
  83835. */
  83836. static readonly FresnelDirtyFlag: number;
  83837. /**
  83838. * The dirty attribute flag value
  83839. */
  83840. static readonly AttributesDirtyFlag: number;
  83841. /**
  83842. * The dirty misc flag value
  83843. */
  83844. static readonly MiscDirtyFlag: number;
  83845. /**
  83846. * The all dirty flag value
  83847. */
  83848. static readonly AllDirtyFlag: number;
  83849. /**
  83850. * The ID of the material
  83851. */
  83852. id: string;
  83853. /**
  83854. * Gets or sets the unique id of the material
  83855. */
  83856. uniqueId: number;
  83857. /**
  83858. * The name of the material
  83859. */
  83860. name: string;
  83861. /**
  83862. * Gets or sets user defined metadata
  83863. */
  83864. metadata: any;
  83865. /**
  83866. * For internal use only. Please do not use.
  83867. */
  83868. reservedDataStore: any;
  83869. /**
  83870. * Specifies if the ready state should be checked on each call
  83871. */
  83872. checkReadyOnEveryCall: boolean;
  83873. /**
  83874. * Specifies if the ready state should be checked once
  83875. */
  83876. checkReadyOnlyOnce: boolean;
  83877. /**
  83878. * The state of the material
  83879. */
  83880. state: string;
  83881. /**
  83882. * The alpha value of the material
  83883. */
  83884. protected _alpha: number;
  83885. /**
  83886. * List of inspectable custom properties (used by the Inspector)
  83887. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83888. */
  83889. inspectableCustomProperties: IInspectable[];
  83890. /**
  83891. * Sets the alpha value of the material
  83892. */
  83893. /**
  83894. * Gets the alpha value of the material
  83895. */
  83896. alpha: number;
  83897. /**
  83898. * Specifies if back face culling is enabled
  83899. */
  83900. protected _backFaceCulling: boolean;
  83901. /**
  83902. * Sets the back-face culling state
  83903. */
  83904. /**
  83905. * Gets the back-face culling state
  83906. */
  83907. backFaceCulling: boolean;
  83908. /**
  83909. * Stores the value for side orientation
  83910. */
  83911. sideOrientation: number;
  83912. /**
  83913. * Callback triggered when the material is compiled
  83914. */
  83915. onCompiled: Nullable<(effect: Effect) => void>;
  83916. /**
  83917. * Callback triggered when an error occurs
  83918. */
  83919. onError: Nullable<(effect: Effect, errors: string) => void>;
  83920. /**
  83921. * Callback triggered to get the render target textures
  83922. */
  83923. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  83924. /**
  83925. * Gets a boolean indicating that current material needs to register RTT
  83926. */
  83927. readonly hasRenderTargetTextures: boolean;
  83928. /**
  83929. * Specifies if the material should be serialized
  83930. */
  83931. doNotSerialize: boolean;
  83932. /**
  83933. * @hidden
  83934. */
  83935. _storeEffectOnSubMeshes: boolean;
  83936. /**
  83937. * Stores the animations for the material
  83938. */
  83939. animations: Nullable<Array<Animation>>;
  83940. /**
  83941. * An event triggered when the material is disposed
  83942. */
  83943. onDisposeObservable: Observable<Material>;
  83944. /**
  83945. * An observer which watches for dispose events
  83946. */
  83947. private _onDisposeObserver;
  83948. private _onUnBindObservable;
  83949. /**
  83950. * Called during a dispose event
  83951. */
  83952. onDispose: () => void;
  83953. private _onBindObservable;
  83954. /**
  83955. * An event triggered when the material is bound
  83956. */
  83957. readonly onBindObservable: Observable<AbstractMesh>;
  83958. /**
  83959. * An observer which watches for bind events
  83960. */
  83961. private _onBindObserver;
  83962. /**
  83963. * Called during a bind event
  83964. */
  83965. onBind: (Mesh: AbstractMesh) => void;
  83966. /**
  83967. * An event triggered when the material is unbound
  83968. */
  83969. readonly onUnBindObservable: Observable<Material>;
  83970. /**
  83971. * Stores the value of the alpha mode
  83972. */
  83973. private _alphaMode;
  83974. /**
  83975. * Sets the value of the alpha mode.
  83976. *
  83977. * | Value | Type | Description |
  83978. * | --- | --- | --- |
  83979. * | 0 | ALPHA_DISABLE | |
  83980. * | 1 | ALPHA_ADD | |
  83981. * | 2 | ALPHA_COMBINE | |
  83982. * | 3 | ALPHA_SUBTRACT | |
  83983. * | 4 | ALPHA_MULTIPLY | |
  83984. * | 5 | ALPHA_MAXIMIZED | |
  83985. * | 6 | ALPHA_ONEONE | |
  83986. * | 7 | ALPHA_PREMULTIPLIED | |
  83987. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  83988. * | 9 | ALPHA_INTERPOLATE | |
  83989. * | 10 | ALPHA_SCREENMODE | |
  83990. *
  83991. */
  83992. /**
  83993. * Gets the value of the alpha mode
  83994. */
  83995. alphaMode: number;
  83996. /**
  83997. * Stores the state of the need depth pre-pass value
  83998. */
  83999. private _needDepthPrePass;
  84000. /**
  84001. * Sets the need depth pre-pass value
  84002. */
  84003. /**
  84004. * Gets the depth pre-pass value
  84005. */
  84006. needDepthPrePass: boolean;
  84007. /**
  84008. * Specifies if depth writing should be disabled
  84009. */
  84010. disableDepthWrite: boolean;
  84011. /**
  84012. * Specifies if depth writing should be forced
  84013. */
  84014. forceDepthWrite: boolean;
  84015. /**
  84016. * Specifies if there should be a separate pass for culling
  84017. */
  84018. separateCullingPass: boolean;
  84019. /**
  84020. * Stores the state specifing if fog should be enabled
  84021. */
  84022. private _fogEnabled;
  84023. /**
  84024. * Sets the state for enabling fog
  84025. */
  84026. /**
  84027. * Gets the value of the fog enabled state
  84028. */
  84029. fogEnabled: boolean;
  84030. /**
  84031. * Stores the size of points
  84032. */
  84033. pointSize: number;
  84034. /**
  84035. * Stores the z offset value
  84036. */
  84037. zOffset: number;
  84038. /**
  84039. * Gets a value specifying if wireframe mode is enabled
  84040. */
  84041. /**
  84042. * Sets the state of wireframe mode
  84043. */
  84044. wireframe: boolean;
  84045. /**
  84046. * Gets the value specifying if point clouds are enabled
  84047. */
  84048. /**
  84049. * Sets the state of point cloud mode
  84050. */
  84051. pointsCloud: boolean;
  84052. /**
  84053. * Gets the material fill mode
  84054. */
  84055. /**
  84056. * Sets the material fill mode
  84057. */
  84058. fillMode: number;
  84059. /**
  84060. * @hidden
  84061. * Stores the effects for the material
  84062. */
  84063. _effect: Nullable<Effect>;
  84064. /**
  84065. * @hidden
  84066. * Specifies if the material was previously ready
  84067. */
  84068. _wasPreviouslyReady: boolean;
  84069. /**
  84070. * Specifies if uniform buffers should be used
  84071. */
  84072. private _useUBO;
  84073. /**
  84074. * Stores a reference to the scene
  84075. */
  84076. private _scene;
  84077. /**
  84078. * Stores the fill mode state
  84079. */
  84080. private _fillMode;
  84081. /**
  84082. * Specifies if the depth write state should be cached
  84083. */
  84084. private _cachedDepthWriteState;
  84085. /**
  84086. * Stores the uniform buffer
  84087. */
  84088. protected _uniformBuffer: UniformBuffer;
  84089. /** @hidden */
  84090. _indexInSceneMaterialArray: number;
  84091. /** @hidden */
  84092. meshMap: Nullable<{
  84093. [id: string]: AbstractMesh | undefined;
  84094. }>;
  84095. /**
  84096. * Creates a material instance
  84097. * @param name defines the name of the material
  84098. * @param scene defines the scene to reference
  84099. * @param doNotAdd specifies if the material should be added to the scene
  84100. */
  84101. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84102. /**
  84103. * Returns a string representation of the current material
  84104. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84105. * @returns a string with material information
  84106. */
  84107. toString(fullDetails?: boolean): string;
  84108. /**
  84109. * Gets the class name of the material
  84110. * @returns a string with the class name of the material
  84111. */
  84112. getClassName(): string;
  84113. /**
  84114. * Specifies if updates for the material been locked
  84115. */
  84116. readonly isFrozen: boolean;
  84117. /**
  84118. * Locks updates for the material
  84119. */
  84120. freeze(): void;
  84121. /**
  84122. * Unlocks updates for the material
  84123. */
  84124. unfreeze(): void;
  84125. /**
  84126. * Specifies if the material is ready to be used
  84127. * @param mesh defines the mesh to check
  84128. * @param useInstances specifies if instances should be used
  84129. * @returns a boolean indicating if the material is ready to be used
  84130. */
  84131. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84132. /**
  84133. * Specifies that the submesh is ready to be used
  84134. * @param mesh defines the mesh to check
  84135. * @param subMesh defines which submesh to check
  84136. * @param useInstances specifies that instances should be used
  84137. * @returns a boolean indicating that the submesh is ready or not
  84138. */
  84139. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84140. /**
  84141. * Returns the material effect
  84142. * @returns the effect associated with the material
  84143. */
  84144. getEffect(): Nullable<Effect>;
  84145. /**
  84146. * Returns the current scene
  84147. * @returns a Scene
  84148. */
  84149. getScene(): Scene;
  84150. /**
  84151. * Specifies if the material will require alpha blending
  84152. * @returns a boolean specifying if alpha blending is needed
  84153. */
  84154. needAlphaBlending(): boolean;
  84155. /**
  84156. * Specifies if the mesh will require alpha blending
  84157. * @param mesh defines the mesh to check
  84158. * @returns a boolean specifying if alpha blending is needed for the mesh
  84159. */
  84160. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84161. /**
  84162. * Specifies if this material should be rendered in alpha test mode
  84163. * @returns a boolean specifying if an alpha test is needed.
  84164. */
  84165. needAlphaTesting(): boolean;
  84166. /**
  84167. * Gets the texture used for the alpha test
  84168. * @returns the texture to use for alpha testing
  84169. */
  84170. getAlphaTestTexture(): Nullable<BaseTexture>;
  84171. /**
  84172. * Marks the material to indicate that it needs to be re-calculated
  84173. */
  84174. markDirty(): void;
  84175. /** @hidden */
  84176. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84177. /**
  84178. * Binds the material to the mesh
  84179. * @param world defines the world transformation matrix
  84180. * @param mesh defines the mesh to bind the material to
  84181. */
  84182. bind(world: Matrix, mesh?: Mesh): void;
  84183. /**
  84184. * Binds the submesh to the material
  84185. * @param world defines the world transformation matrix
  84186. * @param mesh defines the mesh containing the submesh
  84187. * @param subMesh defines the submesh to bind the material to
  84188. */
  84189. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84190. /**
  84191. * Binds the world matrix to the material
  84192. * @param world defines the world transformation matrix
  84193. */
  84194. bindOnlyWorldMatrix(world: Matrix): void;
  84195. /**
  84196. * Binds the scene's uniform buffer to the effect.
  84197. * @param effect defines the effect to bind to the scene uniform buffer
  84198. * @param sceneUbo defines the uniform buffer storing scene data
  84199. */
  84200. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84201. /**
  84202. * Binds the view matrix to the effect
  84203. * @param effect defines the effect to bind the view matrix to
  84204. */
  84205. bindView(effect: Effect): void;
  84206. /**
  84207. * Binds the view projection matrix to the effect
  84208. * @param effect defines the effect to bind the view projection matrix to
  84209. */
  84210. bindViewProjection(effect: Effect): void;
  84211. /**
  84212. * Specifies if material alpha testing should be turned on for the mesh
  84213. * @param mesh defines the mesh to check
  84214. */
  84215. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84216. /**
  84217. * Processes to execute after binding the material to a mesh
  84218. * @param mesh defines the rendered mesh
  84219. */
  84220. protected _afterBind(mesh?: Mesh): void;
  84221. /**
  84222. * Unbinds the material from the mesh
  84223. */
  84224. unbind(): void;
  84225. /**
  84226. * Gets the active textures from the material
  84227. * @returns an array of textures
  84228. */
  84229. getActiveTextures(): BaseTexture[];
  84230. /**
  84231. * Specifies if the material uses a texture
  84232. * @param texture defines the texture to check against the material
  84233. * @returns a boolean specifying if the material uses the texture
  84234. */
  84235. hasTexture(texture: BaseTexture): boolean;
  84236. /**
  84237. * Makes a duplicate of the material, and gives it a new name
  84238. * @param name defines the new name for the duplicated material
  84239. * @returns the cloned material
  84240. */
  84241. clone(name: string): Nullable<Material>;
  84242. /**
  84243. * Gets the meshes bound to the material
  84244. * @returns an array of meshes bound to the material
  84245. */
  84246. getBindedMeshes(): AbstractMesh[];
  84247. /**
  84248. * Force shader compilation
  84249. * @param mesh defines the mesh associated with this material
  84250. * @param onCompiled defines a function to execute once the material is compiled
  84251. * @param options defines the options to configure the compilation
  84252. */
  84253. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84254. clipPlane: boolean;
  84255. }>): void;
  84256. /**
  84257. * Force shader compilation
  84258. * @param mesh defines the mesh that will use this material
  84259. * @param options defines additional options for compiling the shaders
  84260. * @returns a promise that resolves when the compilation completes
  84261. */
  84262. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84263. clipPlane: boolean;
  84264. }>): Promise<void>;
  84265. private static readonly _AllDirtyCallBack;
  84266. private static readonly _ImageProcessingDirtyCallBack;
  84267. private static readonly _TextureDirtyCallBack;
  84268. private static readonly _FresnelDirtyCallBack;
  84269. private static readonly _MiscDirtyCallBack;
  84270. private static readonly _LightsDirtyCallBack;
  84271. private static readonly _AttributeDirtyCallBack;
  84272. private static _FresnelAndMiscDirtyCallBack;
  84273. private static _TextureAndMiscDirtyCallBack;
  84274. private static readonly _DirtyCallbackArray;
  84275. private static readonly _RunDirtyCallBacks;
  84276. /**
  84277. * Marks a define in the material to indicate that it needs to be re-computed
  84278. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84279. */
  84280. markAsDirty(flag: number): void;
  84281. /**
  84282. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84283. * @param func defines a function which checks material defines against the submeshes
  84284. */
  84285. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84286. /**
  84287. * Indicates that we need to re-calculated for all submeshes
  84288. */
  84289. protected _markAllSubMeshesAsAllDirty(): void;
  84290. /**
  84291. * Indicates that image processing needs to be re-calculated for all submeshes
  84292. */
  84293. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84294. /**
  84295. * Indicates that textures need to be re-calculated for all submeshes
  84296. */
  84297. protected _markAllSubMeshesAsTexturesDirty(): void;
  84298. /**
  84299. * Indicates that fresnel needs to be re-calculated for all submeshes
  84300. */
  84301. protected _markAllSubMeshesAsFresnelDirty(): void;
  84302. /**
  84303. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84304. */
  84305. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84306. /**
  84307. * Indicates that lights need to be re-calculated for all submeshes
  84308. */
  84309. protected _markAllSubMeshesAsLightsDirty(): void;
  84310. /**
  84311. * Indicates that attributes need to be re-calculated for all submeshes
  84312. */
  84313. protected _markAllSubMeshesAsAttributesDirty(): void;
  84314. /**
  84315. * Indicates that misc needs to be re-calculated for all submeshes
  84316. */
  84317. protected _markAllSubMeshesAsMiscDirty(): void;
  84318. /**
  84319. * Indicates that textures and misc need to be re-calculated for all submeshes
  84320. */
  84321. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84322. /**
  84323. * Disposes the material
  84324. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84325. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84326. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84327. */
  84328. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84329. /** @hidden */
  84330. private releaseVertexArrayObject;
  84331. /**
  84332. * Serializes this material
  84333. * @returns the serialized material object
  84334. */
  84335. serialize(): any;
  84336. /**
  84337. * Creates a material from parsed material data
  84338. * @param parsedMaterial defines parsed material data
  84339. * @param scene defines the hosting scene
  84340. * @param rootUrl defines the root URL to use to load textures
  84341. * @returns a new material
  84342. */
  84343. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84344. }
  84345. }
  84346. declare module BABYLON {
  84347. /**
  84348. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84349. * separate meshes. This can be use to improve performances.
  84350. * @see http://doc.babylonjs.com/how_to/multi_materials
  84351. */
  84352. export class MultiMaterial extends Material {
  84353. private _subMaterials;
  84354. /**
  84355. * Gets or Sets the list of Materials used within the multi material.
  84356. * They need to be ordered according to the submeshes order in the associated mesh
  84357. */
  84358. subMaterials: Nullable<Material>[];
  84359. /**
  84360. * Function used to align with Node.getChildren()
  84361. * @returns the list of Materials used within the multi material
  84362. */
  84363. getChildren(): Nullable<Material>[];
  84364. /**
  84365. * Instantiates a new Multi Material
  84366. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84367. * separate meshes. This can be use to improve performances.
  84368. * @see http://doc.babylonjs.com/how_to/multi_materials
  84369. * @param name Define the name in the scene
  84370. * @param scene Define the scene the material belongs to
  84371. */
  84372. constructor(name: string, scene: Scene);
  84373. private _hookArray;
  84374. /**
  84375. * Get one of the submaterial by its index in the submaterials array
  84376. * @param index The index to look the sub material at
  84377. * @returns The Material if the index has been defined
  84378. */
  84379. getSubMaterial(index: number): Nullable<Material>;
  84380. /**
  84381. * Get the list of active textures for the whole sub materials list.
  84382. * @returns All the textures that will be used during the rendering
  84383. */
  84384. getActiveTextures(): BaseTexture[];
  84385. /**
  84386. * Gets the current class name of the material e.g. "MultiMaterial"
  84387. * Mainly use in serialization.
  84388. * @returns the class name
  84389. */
  84390. getClassName(): string;
  84391. /**
  84392. * Checks if the material is ready to render the requested sub mesh
  84393. * @param mesh Define the mesh the submesh belongs to
  84394. * @param subMesh Define the sub mesh to look readyness for
  84395. * @param useInstances Define whether or not the material is used with instances
  84396. * @returns true if ready, otherwise false
  84397. */
  84398. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84399. /**
  84400. * Clones the current material and its related sub materials
  84401. * @param name Define the name of the newly cloned material
  84402. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  84403. * @returns the cloned material
  84404. */
  84405. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  84406. /**
  84407. * Serializes the materials into a JSON representation.
  84408. * @returns the JSON representation
  84409. */
  84410. serialize(): any;
  84411. /**
  84412. * Dispose the material and release its associated resources
  84413. * @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)
  84414. * @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)
  84415. * @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)
  84416. */
  84417. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  84418. /**
  84419. * Creates a MultiMaterial from parsed MultiMaterial data.
  84420. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  84421. * @param scene defines the hosting scene
  84422. * @returns a new MultiMaterial
  84423. */
  84424. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  84425. }
  84426. }
  84427. declare module BABYLON {
  84428. /**
  84429. * Base class for submeshes
  84430. */
  84431. export class BaseSubMesh {
  84432. /** @hidden */
  84433. _materialDefines: Nullable<MaterialDefines>;
  84434. /** @hidden */
  84435. _materialEffect: Nullable<Effect>;
  84436. /**
  84437. * Gets associated effect
  84438. */
  84439. readonly effect: Nullable<Effect>;
  84440. /**
  84441. * Sets associated effect (effect used to render this submesh)
  84442. * @param effect defines the effect to associate with
  84443. * @param defines defines the set of defines used to compile this effect
  84444. */
  84445. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84446. }
  84447. /**
  84448. * Defines a subdivision inside a mesh
  84449. */
  84450. export class SubMesh extends BaseSubMesh implements ICullable {
  84451. /** the material index to use */
  84452. materialIndex: number;
  84453. /** vertex index start */
  84454. verticesStart: number;
  84455. /** vertices count */
  84456. verticesCount: number;
  84457. /** index start */
  84458. indexStart: number;
  84459. /** indices count */
  84460. indexCount: number;
  84461. /** @hidden */
  84462. _linesIndexCount: number;
  84463. private _mesh;
  84464. private _renderingMesh;
  84465. private _boundingInfo;
  84466. private _linesIndexBuffer;
  84467. /** @hidden */
  84468. _lastColliderWorldVertices: Nullable<Vector3[]>;
  84469. /** @hidden */
  84470. _trianglePlanes: Plane[];
  84471. /** @hidden */
  84472. _lastColliderTransformMatrix: Nullable<Matrix>;
  84473. /** @hidden */
  84474. _renderId: number;
  84475. /** @hidden */
  84476. _alphaIndex: number;
  84477. /** @hidden */
  84478. _distanceToCamera: number;
  84479. /** @hidden */
  84480. _id: number;
  84481. private _currentMaterial;
  84482. /**
  84483. * Add a new submesh to a mesh
  84484. * @param materialIndex defines the material index to use
  84485. * @param verticesStart defines vertex index start
  84486. * @param verticesCount defines vertices count
  84487. * @param indexStart defines index start
  84488. * @param indexCount defines indices count
  84489. * @param mesh defines the parent mesh
  84490. * @param renderingMesh defines an optional rendering mesh
  84491. * @param createBoundingBox defines if bounding box should be created for this submesh
  84492. * @returns the new submesh
  84493. */
  84494. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  84495. /**
  84496. * Creates a new submesh
  84497. * @param materialIndex defines the material index to use
  84498. * @param verticesStart defines vertex index start
  84499. * @param verticesCount defines vertices count
  84500. * @param indexStart defines index start
  84501. * @param indexCount defines indices count
  84502. * @param mesh defines the parent mesh
  84503. * @param renderingMesh defines an optional rendering mesh
  84504. * @param createBoundingBox defines if bounding box should be created for this submesh
  84505. */
  84506. constructor(
  84507. /** the material index to use */
  84508. materialIndex: number,
  84509. /** vertex index start */
  84510. verticesStart: number,
  84511. /** vertices count */
  84512. verticesCount: number,
  84513. /** index start */
  84514. indexStart: number,
  84515. /** indices count */
  84516. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  84517. /**
  84518. * Returns true if this submesh covers the entire parent mesh
  84519. * @ignorenaming
  84520. */
  84521. readonly IsGlobal: boolean;
  84522. /**
  84523. * Returns the submesh BoudingInfo object
  84524. * @returns current bounding info (or mesh's one if the submesh is global)
  84525. */
  84526. getBoundingInfo(): BoundingInfo;
  84527. /**
  84528. * Sets the submesh BoundingInfo
  84529. * @param boundingInfo defines the new bounding info to use
  84530. * @returns the SubMesh
  84531. */
  84532. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  84533. /**
  84534. * Returns the mesh of the current submesh
  84535. * @return the parent mesh
  84536. */
  84537. getMesh(): AbstractMesh;
  84538. /**
  84539. * Returns the rendering mesh of the submesh
  84540. * @returns the rendering mesh (could be different from parent mesh)
  84541. */
  84542. getRenderingMesh(): Mesh;
  84543. /**
  84544. * Returns the submesh material
  84545. * @returns null or the current material
  84546. */
  84547. getMaterial(): Nullable<Material>;
  84548. /**
  84549. * Sets a new updated BoundingInfo object to the submesh
  84550. * @param data defines an optional position array to use to determine the bounding info
  84551. * @returns the SubMesh
  84552. */
  84553. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  84554. /** @hidden */
  84555. _checkCollision(collider: Collider): boolean;
  84556. /**
  84557. * Updates the submesh BoundingInfo
  84558. * @param world defines the world matrix to use to update the bounding info
  84559. * @returns the submesh
  84560. */
  84561. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  84562. /**
  84563. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  84564. * @param frustumPlanes defines the frustum planes
  84565. * @returns true if the submesh is intersecting with the frustum
  84566. */
  84567. isInFrustum(frustumPlanes: Plane[]): boolean;
  84568. /**
  84569. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  84570. * @param frustumPlanes defines the frustum planes
  84571. * @returns true if the submesh is inside the frustum
  84572. */
  84573. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84574. /**
  84575. * Renders the submesh
  84576. * @param enableAlphaMode defines if alpha needs to be used
  84577. * @returns the submesh
  84578. */
  84579. render(enableAlphaMode: boolean): SubMesh;
  84580. /**
  84581. * @hidden
  84582. */
  84583. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  84584. /**
  84585. * Checks if the submesh intersects with a ray
  84586. * @param ray defines the ray to test
  84587. * @returns true is the passed ray intersects the submesh bounding box
  84588. */
  84589. canIntersects(ray: Ray): boolean;
  84590. /**
  84591. * Intersects current submesh with a ray
  84592. * @param ray defines the ray to test
  84593. * @param positions defines mesh's positions array
  84594. * @param indices defines mesh's indices array
  84595. * @param fastCheck defines if only bounding info should be used
  84596. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84597. * @returns intersection info or null if no intersection
  84598. */
  84599. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  84600. /** @hidden */
  84601. private _intersectLines;
  84602. /** @hidden */
  84603. private _intersectUnIndexedLines;
  84604. /** @hidden */
  84605. private _intersectTriangles;
  84606. /** @hidden */
  84607. private _intersectUnIndexedTriangles;
  84608. /** @hidden */
  84609. _rebuild(): void;
  84610. /**
  84611. * Creates a new submesh from the passed mesh
  84612. * @param newMesh defines the new hosting mesh
  84613. * @param newRenderingMesh defines an optional rendering mesh
  84614. * @returns the new submesh
  84615. */
  84616. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  84617. /**
  84618. * Release associated resources
  84619. */
  84620. dispose(): void;
  84621. /**
  84622. * Gets the class name
  84623. * @returns the string "SubMesh".
  84624. */
  84625. getClassName(): string;
  84626. /**
  84627. * Creates a new submesh from indices data
  84628. * @param materialIndex the index of the main mesh material
  84629. * @param startIndex the index where to start the copy in the mesh indices array
  84630. * @param indexCount the number of indices to copy then from the startIndex
  84631. * @param mesh the main mesh to create the submesh from
  84632. * @param renderingMesh the optional rendering mesh
  84633. * @returns a new submesh
  84634. */
  84635. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  84636. }
  84637. }
  84638. declare module BABYLON {
  84639. /**
  84640. * Class used to represent data loading progression
  84641. */
  84642. export class SceneLoaderFlags {
  84643. private static _ForceFullSceneLoadingForIncremental;
  84644. private static _ShowLoadingScreen;
  84645. private static _CleanBoneMatrixWeights;
  84646. private static _loggingLevel;
  84647. /**
  84648. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  84649. */
  84650. static ForceFullSceneLoadingForIncremental: boolean;
  84651. /**
  84652. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  84653. */
  84654. static ShowLoadingScreen: boolean;
  84655. /**
  84656. * Defines the current logging level (while loading the scene)
  84657. * @ignorenaming
  84658. */
  84659. static loggingLevel: number;
  84660. /**
  84661. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  84662. */
  84663. static CleanBoneMatrixWeights: boolean;
  84664. }
  84665. }
  84666. declare module BABYLON {
  84667. /**
  84668. * Class used to store geometry data (vertex buffers + index buffer)
  84669. */
  84670. export class Geometry implements IGetSetVerticesData {
  84671. /**
  84672. * Gets or sets the ID of the geometry
  84673. */
  84674. id: string;
  84675. /**
  84676. * Gets or sets the unique ID of the geometry
  84677. */
  84678. uniqueId: number;
  84679. /**
  84680. * Gets the delay loading state of the geometry (none by default which means not delayed)
  84681. */
  84682. delayLoadState: number;
  84683. /**
  84684. * Gets the file containing the data to load when running in delay load state
  84685. */
  84686. delayLoadingFile: Nullable<string>;
  84687. /**
  84688. * Callback called when the geometry is updated
  84689. */
  84690. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  84691. private _scene;
  84692. private _engine;
  84693. private _meshes;
  84694. private _totalVertices;
  84695. /** @hidden */
  84696. _indices: IndicesArray;
  84697. /** @hidden */
  84698. _vertexBuffers: {
  84699. [key: string]: VertexBuffer;
  84700. };
  84701. private _isDisposed;
  84702. private _extend;
  84703. private _boundingBias;
  84704. /** @hidden */
  84705. _delayInfo: Array<string>;
  84706. private _indexBuffer;
  84707. private _indexBufferIsUpdatable;
  84708. /** @hidden */
  84709. _boundingInfo: Nullable<BoundingInfo>;
  84710. /** @hidden */
  84711. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  84712. /** @hidden */
  84713. _softwareSkinningFrameId: number;
  84714. private _vertexArrayObjects;
  84715. private _updatable;
  84716. /** @hidden */
  84717. _positions: Nullable<Vector3[]>;
  84718. /**
  84719. * 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
  84720. */
  84721. /**
  84722. * 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
  84723. */
  84724. boundingBias: Vector2;
  84725. /**
  84726. * Static function used to attach a new empty geometry to a mesh
  84727. * @param mesh defines the mesh to attach the geometry to
  84728. * @returns the new Geometry
  84729. */
  84730. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  84731. /**
  84732. * Creates a new geometry
  84733. * @param id defines the unique ID
  84734. * @param scene defines the hosting scene
  84735. * @param vertexData defines the VertexData used to get geometry data
  84736. * @param updatable defines if geometry must be updatable (false by default)
  84737. * @param mesh defines the mesh that will be associated with the geometry
  84738. */
  84739. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  84740. /**
  84741. * Gets the current extend of the geometry
  84742. */
  84743. readonly extend: {
  84744. minimum: Vector3;
  84745. maximum: Vector3;
  84746. };
  84747. /**
  84748. * Gets the hosting scene
  84749. * @returns the hosting Scene
  84750. */
  84751. getScene(): Scene;
  84752. /**
  84753. * Gets the hosting engine
  84754. * @returns the hosting Engine
  84755. */
  84756. getEngine(): Engine;
  84757. /**
  84758. * Defines if the geometry is ready to use
  84759. * @returns true if the geometry is ready to be used
  84760. */
  84761. isReady(): boolean;
  84762. /**
  84763. * Gets a value indicating that the geometry should not be serialized
  84764. */
  84765. readonly doNotSerialize: boolean;
  84766. /** @hidden */
  84767. _rebuild(): void;
  84768. /**
  84769. * Affects all geometry data in one call
  84770. * @param vertexData defines the geometry data
  84771. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  84772. */
  84773. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  84774. /**
  84775. * Set specific vertex data
  84776. * @param kind defines the data kind (Position, normal, etc...)
  84777. * @param data defines the vertex data to use
  84778. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84779. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84780. */
  84781. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  84782. /**
  84783. * Removes a specific vertex data
  84784. * @param kind defines the data kind (Position, normal, etc...)
  84785. */
  84786. removeVerticesData(kind: string): void;
  84787. /**
  84788. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  84789. * @param buffer defines the vertex buffer to use
  84790. * @param totalVertices defines the total number of vertices for position kind (could be null)
  84791. */
  84792. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  84793. /**
  84794. * Update a specific vertex buffer
  84795. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  84796. * It will do nothing if the buffer is not updatable
  84797. * @param kind defines the data kind (Position, normal, etc...)
  84798. * @param data defines the data to use
  84799. * @param offset defines the offset in the target buffer where to store the data
  84800. * @param useBytes set to true if the offset is in bytes
  84801. */
  84802. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  84803. /**
  84804. * Update a specific vertex buffer
  84805. * This function will create a new buffer if the current one is not updatable
  84806. * @param kind defines the data kind (Position, normal, etc...)
  84807. * @param data defines the data to use
  84808. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  84809. */
  84810. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  84811. private _updateBoundingInfo;
  84812. /** @hidden */
  84813. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  84814. /**
  84815. * Gets total number of vertices
  84816. * @returns the total number of vertices
  84817. */
  84818. getTotalVertices(): number;
  84819. /**
  84820. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84821. * @param kind defines the data kind (Position, normal, etc...)
  84822. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84823. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84824. * @returns a float array containing vertex data
  84825. */
  84826. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84827. /**
  84828. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  84829. * @param kind defines the data kind (Position, normal, etc...)
  84830. * @returns true if the vertex buffer with the specified kind is updatable
  84831. */
  84832. isVertexBufferUpdatable(kind: string): boolean;
  84833. /**
  84834. * Gets a specific vertex buffer
  84835. * @param kind defines the data kind (Position, normal, etc...)
  84836. * @returns a VertexBuffer
  84837. */
  84838. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  84839. /**
  84840. * Returns all vertex buffers
  84841. * @return an object holding all vertex buffers indexed by kind
  84842. */
  84843. getVertexBuffers(): Nullable<{
  84844. [key: string]: VertexBuffer;
  84845. }>;
  84846. /**
  84847. * Gets a boolean indicating if specific vertex buffer is present
  84848. * @param kind defines the data kind (Position, normal, etc...)
  84849. * @returns true if data is present
  84850. */
  84851. isVerticesDataPresent(kind: string): boolean;
  84852. /**
  84853. * Gets a list of all attached data kinds (Position, normal, etc...)
  84854. * @returns a list of string containing all kinds
  84855. */
  84856. getVerticesDataKinds(): string[];
  84857. /**
  84858. * Update index buffer
  84859. * @param indices defines the indices to store in the index buffer
  84860. * @param offset defines the offset in the target buffer where to store the data
  84861. * @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)
  84862. */
  84863. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  84864. /**
  84865. * Creates a new index buffer
  84866. * @param indices defines the indices to store in the index buffer
  84867. * @param totalVertices defines the total number of vertices (could be null)
  84868. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84869. */
  84870. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  84871. /**
  84872. * Return the total number of indices
  84873. * @returns the total number of indices
  84874. */
  84875. getTotalIndices(): number;
  84876. /**
  84877. * Gets the index buffer array
  84878. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84879. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84880. * @returns the index buffer array
  84881. */
  84882. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84883. /**
  84884. * Gets the index buffer
  84885. * @return the index buffer
  84886. */
  84887. getIndexBuffer(): Nullable<DataBuffer>;
  84888. /** @hidden */
  84889. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  84890. /**
  84891. * Release the associated resources for a specific mesh
  84892. * @param mesh defines the source mesh
  84893. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  84894. */
  84895. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  84896. /**
  84897. * Apply current geometry to a given mesh
  84898. * @param mesh defines the mesh to apply geometry to
  84899. */
  84900. applyToMesh(mesh: Mesh): void;
  84901. private _updateExtend;
  84902. private _applyToMesh;
  84903. private notifyUpdate;
  84904. /**
  84905. * Load the geometry if it was flagged as delay loaded
  84906. * @param scene defines the hosting scene
  84907. * @param onLoaded defines a callback called when the geometry is loaded
  84908. */
  84909. load(scene: Scene, onLoaded?: () => void): void;
  84910. private _queueLoad;
  84911. /**
  84912. * Invert the geometry to move from a right handed system to a left handed one.
  84913. */
  84914. toLeftHanded(): void;
  84915. /** @hidden */
  84916. _resetPointsArrayCache(): void;
  84917. /** @hidden */
  84918. _generatePointsArray(): boolean;
  84919. /**
  84920. * Gets a value indicating if the geometry is disposed
  84921. * @returns true if the geometry was disposed
  84922. */
  84923. isDisposed(): boolean;
  84924. private _disposeVertexArrayObjects;
  84925. /**
  84926. * Free all associated resources
  84927. */
  84928. dispose(): void;
  84929. /**
  84930. * Clone the current geometry into a new geometry
  84931. * @param id defines the unique ID of the new geometry
  84932. * @returns a new geometry object
  84933. */
  84934. copy(id: string): Geometry;
  84935. /**
  84936. * Serialize the current geometry info (and not the vertices data) into a JSON object
  84937. * @return a JSON representation of the current geometry data (without the vertices data)
  84938. */
  84939. serialize(): any;
  84940. private toNumberArray;
  84941. /**
  84942. * Serialize all vertices data into a JSON oject
  84943. * @returns a JSON representation of the current geometry data
  84944. */
  84945. serializeVerticeData(): any;
  84946. /**
  84947. * Extracts a clone of a mesh geometry
  84948. * @param mesh defines the source mesh
  84949. * @param id defines the unique ID of the new geometry object
  84950. * @returns the new geometry object
  84951. */
  84952. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  84953. /**
  84954. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  84955. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  84956. * Be aware Math.random() could cause collisions, but:
  84957. * "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"
  84958. * @returns a string containing a new GUID
  84959. */
  84960. static RandomId(): string;
  84961. /** @hidden */
  84962. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  84963. private static _CleanMatricesWeights;
  84964. /**
  84965. * Create a new geometry from persisted data (Using .babylon file format)
  84966. * @param parsedVertexData defines the persisted data
  84967. * @param scene defines the hosting scene
  84968. * @param rootUrl defines the root url to use to load assets (like delayed data)
  84969. * @returns the new geometry object
  84970. */
  84971. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  84972. }
  84973. }
  84974. declare module BABYLON {
  84975. /**
  84976. * Define an interface for all classes that will get and set the data on vertices
  84977. */
  84978. export interface IGetSetVerticesData {
  84979. /**
  84980. * Gets a boolean indicating if specific vertex data is present
  84981. * @param kind defines the vertex data kind to use
  84982. * @returns true is data kind is present
  84983. */
  84984. isVerticesDataPresent(kind: string): boolean;
  84985. /**
  84986. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84987. * @param kind defines the data kind (Position, normal, etc...)
  84988. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84989. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84990. * @returns a float array containing vertex data
  84991. */
  84992. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84993. /**
  84994. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84995. * @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.
  84996. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84997. * @returns the indices array or an empty array if the mesh has no geometry
  84998. */
  84999. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85000. /**
  85001. * Set specific vertex data
  85002. * @param kind defines the data kind (Position, normal, etc...)
  85003. * @param data defines the vertex data to use
  85004. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85005. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85006. */
  85007. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85008. /**
  85009. * Update a specific associated vertex buffer
  85010. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85011. * - VertexBuffer.PositionKind
  85012. * - VertexBuffer.UVKind
  85013. * - VertexBuffer.UV2Kind
  85014. * - VertexBuffer.UV3Kind
  85015. * - VertexBuffer.UV4Kind
  85016. * - VertexBuffer.UV5Kind
  85017. * - VertexBuffer.UV6Kind
  85018. * - VertexBuffer.ColorKind
  85019. * - VertexBuffer.MatricesIndicesKind
  85020. * - VertexBuffer.MatricesIndicesExtraKind
  85021. * - VertexBuffer.MatricesWeightsKind
  85022. * - VertexBuffer.MatricesWeightsExtraKind
  85023. * @param data defines the data source
  85024. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85025. * @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)
  85026. */
  85027. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85028. /**
  85029. * Creates a new index buffer
  85030. * @param indices defines the indices to store in the index buffer
  85031. * @param totalVertices defines the total number of vertices (could be null)
  85032. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85033. */
  85034. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85035. }
  85036. /**
  85037. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85038. */
  85039. export class VertexData {
  85040. /**
  85041. * Mesh side orientation : usually the external or front surface
  85042. */
  85043. static readonly FRONTSIDE: number;
  85044. /**
  85045. * Mesh side orientation : usually the internal or back surface
  85046. */
  85047. static readonly BACKSIDE: number;
  85048. /**
  85049. * Mesh side orientation : both internal and external or front and back surfaces
  85050. */
  85051. static readonly DOUBLESIDE: number;
  85052. /**
  85053. * Mesh side orientation : by default, `FRONTSIDE`
  85054. */
  85055. static readonly DEFAULTSIDE: number;
  85056. /**
  85057. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85058. */
  85059. positions: Nullable<FloatArray>;
  85060. /**
  85061. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85062. */
  85063. normals: Nullable<FloatArray>;
  85064. /**
  85065. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85066. */
  85067. tangents: Nullable<FloatArray>;
  85068. /**
  85069. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85070. */
  85071. uvs: Nullable<FloatArray>;
  85072. /**
  85073. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85074. */
  85075. uvs2: Nullable<FloatArray>;
  85076. /**
  85077. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85078. */
  85079. uvs3: Nullable<FloatArray>;
  85080. /**
  85081. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85082. */
  85083. uvs4: Nullable<FloatArray>;
  85084. /**
  85085. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85086. */
  85087. uvs5: Nullable<FloatArray>;
  85088. /**
  85089. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85090. */
  85091. uvs6: Nullable<FloatArray>;
  85092. /**
  85093. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85094. */
  85095. colors: Nullable<FloatArray>;
  85096. /**
  85097. * 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).
  85098. */
  85099. matricesIndices: Nullable<FloatArray>;
  85100. /**
  85101. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85102. */
  85103. matricesWeights: Nullable<FloatArray>;
  85104. /**
  85105. * An array extending the number of possible indices
  85106. */
  85107. matricesIndicesExtra: Nullable<FloatArray>;
  85108. /**
  85109. * An array extending the number of possible weights when the number of indices is extended
  85110. */
  85111. matricesWeightsExtra: Nullable<FloatArray>;
  85112. /**
  85113. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85114. */
  85115. indices: Nullable<IndicesArray>;
  85116. /**
  85117. * Uses the passed data array to set the set the values for the specified kind of data
  85118. * @param data a linear array of floating numbers
  85119. * @param kind the type of data that is being set, eg positions, colors etc
  85120. */
  85121. set(data: FloatArray, kind: string): void;
  85122. /**
  85123. * Associates the vertexData to the passed Mesh.
  85124. * Sets it as updatable or not (default `false`)
  85125. * @param mesh the mesh the vertexData is applied to
  85126. * @param updatable when used and having the value true allows new data to update the vertexData
  85127. * @returns the VertexData
  85128. */
  85129. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85130. /**
  85131. * Associates the vertexData to the passed Geometry.
  85132. * Sets it as updatable or not (default `false`)
  85133. * @param geometry the geometry the vertexData is applied to
  85134. * @param updatable when used and having the value true allows new data to update the vertexData
  85135. * @returns VertexData
  85136. */
  85137. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85138. /**
  85139. * Updates the associated mesh
  85140. * @param mesh the mesh to be updated
  85141. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85142. * @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
  85143. * @returns VertexData
  85144. */
  85145. updateMesh(mesh: Mesh): VertexData;
  85146. /**
  85147. * Updates the associated geometry
  85148. * @param geometry the geometry to be updated
  85149. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85150. * @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
  85151. * @returns VertexData.
  85152. */
  85153. updateGeometry(geometry: Geometry): VertexData;
  85154. private _applyTo;
  85155. private _update;
  85156. /**
  85157. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85158. * @param matrix the transforming matrix
  85159. * @returns the VertexData
  85160. */
  85161. transform(matrix: Matrix): VertexData;
  85162. /**
  85163. * Merges the passed VertexData into the current one
  85164. * @param other the VertexData to be merged into the current one
  85165. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85166. * @returns the modified VertexData
  85167. */
  85168. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85169. private _mergeElement;
  85170. private _validate;
  85171. /**
  85172. * Serializes the VertexData
  85173. * @returns a serialized object
  85174. */
  85175. serialize(): any;
  85176. /**
  85177. * Extracts the vertexData from a mesh
  85178. * @param mesh the mesh from which to extract the VertexData
  85179. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85180. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85181. * @returns the object VertexData associated to the passed mesh
  85182. */
  85183. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85184. /**
  85185. * Extracts the vertexData from the geometry
  85186. * @param geometry the geometry from which to extract the VertexData
  85187. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85188. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85189. * @returns the object VertexData associated to the passed mesh
  85190. */
  85191. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85192. private static _ExtractFrom;
  85193. /**
  85194. * Creates the VertexData for a Ribbon
  85195. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85196. * * pathArray array of paths, each of which an array of successive Vector3
  85197. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85198. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85199. * * 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
  85200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85201. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  85202. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  85203. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85204. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85205. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85206. * @returns the VertexData of the ribbon
  85207. */
  85208. static CreateRibbon(options: {
  85209. pathArray: Vector3[][];
  85210. closeArray?: boolean;
  85211. closePath?: boolean;
  85212. offset?: number;
  85213. sideOrientation?: number;
  85214. frontUVs?: Vector4;
  85215. backUVs?: Vector4;
  85216. invertUV?: boolean;
  85217. uvs?: Vector2[];
  85218. colors?: Color4[];
  85219. }): VertexData;
  85220. /**
  85221. * Creates the VertexData for a box
  85222. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85223. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85224. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85225. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85226. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85227. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85228. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85229. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85230. * * 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)
  85231. * * 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)
  85232. * @returns the VertexData of the box
  85233. */
  85234. static CreateBox(options: {
  85235. size?: number;
  85236. width?: number;
  85237. height?: number;
  85238. depth?: number;
  85239. faceUV?: Vector4[];
  85240. faceColors?: Color4[];
  85241. sideOrientation?: number;
  85242. frontUVs?: Vector4;
  85243. backUVs?: Vector4;
  85244. }): VertexData;
  85245. /**
  85246. * Creates the VertexData for a tiled box
  85247. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85248. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85249. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85250. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85251. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85252. * @returns the VertexData of the box
  85253. */
  85254. static CreateTiledBox(options: {
  85255. pattern?: number;
  85256. width?: number;
  85257. height?: number;
  85258. depth?: number;
  85259. tileSize?: number;
  85260. tileWidth?: number;
  85261. tileHeight?: number;
  85262. alignHorizontal?: number;
  85263. alignVertical?: number;
  85264. faceUV?: Vector4[];
  85265. faceColors?: Color4[];
  85266. sideOrientation?: number;
  85267. }): VertexData;
  85268. /**
  85269. * Creates the VertexData for a tiled plane
  85270. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85271. * * pattern a limited pattern arrangement depending on the number
  85272. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85273. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85274. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85275. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85276. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  85277. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  85278. * @returns the VertexData of the tiled plane
  85279. */
  85280. static CreateTiledPlane(options: {
  85281. pattern?: number;
  85282. tileSize?: number;
  85283. tileWidth?: number;
  85284. tileHeight?: number;
  85285. size?: number;
  85286. width?: number;
  85287. height?: number;
  85288. alignHorizontal?: number;
  85289. alignVertical?: number;
  85290. sideOrientation?: number;
  85291. frontUVs?: Vector4;
  85292. backUVs?: Vector4;
  85293. }): VertexData;
  85294. /**
  85295. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85296. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85297. * * segments sets the number of horizontal strips optional, default 32
  85298. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85299. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85300. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85301. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85302. * * 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
  85303. * * 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
  85304. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85305. * * 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)
  85306. * * 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)
  85307. * @returns the VertexData of the ellipsoid
  85308. */
  85309. static CreateSphere(options: {
  85310. segments?: number;
  85311. diameter?: number;
  85312. diameterX?: number;
  85313. diameterY?: number;
  85314. diameterZ?: number;
  85315. arc?: number;
  85316. slice?: number;
  85317. sideOrientation?: number;
  85318. frontUVs?: Vector4;
  85319. backUVs?: Vector4;
  85320. }): VertexData;
  85321. /**
  85322. * Creates the VertexData for a cylinder, cone or prism
  85323. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85324. * * height sets the height (y direction) of the cylinder, optional, default 2
  85325. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85326. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85327. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85328. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85329. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85330. * * 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
  85331. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85332. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85333. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85334. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85336. * * 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)
  85337. * * 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)
  85338. * @returns the VertexData of the cylinder, cone or prism
  85339. */
  85340. static CreateCylinder(options: {
  85341. height?: number;
  85342. diameterTop?: number;
  85343. diameterBottom?: number;
  85344. diameter?: number;
  85345. tessellation?: number;
  85346. subdivisions?: number;
  85347. arc?: number;
  85348. faceColors?: Color4[];
  85349. faceUV?: Vector4[];
  85350. hasRings?: boolean;
  85351. enclose?: boolean;
  85352. sideOrientation?: number;
  85353. frontUVs?: Vector4;
  85354. backUVs?: Vector4;
  85355. }): VertexData;
  85356. /**
  85357. * Creates the VertexData for a torus
  85358. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85359. * * diameter the diameter of the torus, optional default 1
  85360. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85361. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85362. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85363. * * 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)
  85364. * * 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)
  85365. * @returns the VertexData of the torus
  85366. */
  85367. static CreateTorus(options: {
  85368. diameter?: number;
  85369. thickness?: number;
  85370. tessellation?: number;
  85371. sideOrientation?: number;
  85372. frontUVs?: Vector4;
  85373. backUVs?: Vector4;
  85374. }): VertexData;
  85375. /**
  85376. * Creates the VertexData of the LineSystem
  85377. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85378. * - lines an array of lines, each line being an array of successive Vector3
  85379. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85380. * @returns the VertexData of the LineSystem
  85381. */
  85382. static CreateLineSystem(options: {
  85383. lines: Vector3[][];
  85384. colors?: Nullable<Color4[][]>;
  85385. }): VertexData;
  85386. /**
  85387. * Create the VertexData for a DashedLines
  85388. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85389. * - points an array successive Vector3
  85390. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85391. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85392. * - dashNb the intended total number of dashes, optional, default 200
  85393. * @returns the VertexData for the DashedLines
  85394. */
  85395. static CreateDashedLines(options: {
  85396. points: Vector3[];
  85397. dashSize?: number;
  85398. gapSize?: number;
  85399. dashNb?: number;
  85400. }): VertexData;
  85401. /**
  85402. * Creates the VertexData for a Ground
  85403. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85404. * - width the width (x direction) of the ground, optional, default 1
  85405. * - height the height (z direction) of the ground, optional, default 1
  85406. * - subdivisions the number of subdivisions per side, optional, default 1
  85407. * @returns the VertexData of the Ground
  85408. */
  85409. static CreateGround(options: {
  85410. width?: number;
  85411. height?: number;
  85412. subdivisions?: number;
  85413. subdivisionsX?: number;
  85414. subdivisionsY?: number;
  85415. }): VertexData;
  85416. /**
  85417. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85418. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85419. * * xmin the ground minimum X coordinate, optional, default -1
  85420. * * zmin the ground minimum Z coordinate, optional, default -1
  85421. * * xmax the ground maximum X coordinate, optional, default 1
  85422. * * zmax the ground maximum Z coordinate, optional, default 1
  85423. * * 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}
  85424. * * 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}
  85425. * @returns the VertexData of the TiledGround
  85426. */
  85427. static CreateTiledGround(options: {
  85428. xmin: number;
  85429. zmin: number;
  85430. xmax: number;
  85431. zmax: number;
  85432. subdivisions?: {
  85433. w: number;
  85434. h: number;
  85435. };
  85436. precision?: {
  85437. w: number;
  85438. h: number;
  85439. };
  85440. }): VertexData;
  85441. /**
  85442. * Creates the VertexData of the Ground designed from a heightmap
  85443. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85444. * * width the width (x direction) of the ground
  85445. * * height the height (z direction) of the ground
  85446. * * subdivisions the number of subdivisions per side
  85447. * * minHeight the minimum altitude on the ground, optional, default 0
  85448. * * maxHeight the maximum altitude on the ground, optional default 1
  85449. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85450. * * buffer the array holding the image color data
  85451. * * bufferWidth the width of image
  85452. * * bufferHeight the height of image
  85453. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85454. * @returns the VertexData of the Ground designed from a heightmap
  85455. */
  85456. static CreateGroundFromHeightMap(options: {
  85457. width: number;
  85458. height: number;
  85459. subdivisions: number;
  85460. minHeight: number;
  85461. maxHeight: number;
  85462. colorFilter: Color3;
  85463. buffer: Uint8Array;
  85464. bufferWidth: number;
  85465. bufferHeight: number;
  85466. alphaFilter: number;
  85467. }): VertexData;
  85468. /**
  85469. * Creates the VertexData for a Plane
  85470. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85471. * * size sets the width and height of the plane to the value of size, optional default 1
  85472. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85473. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85475. * * 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)
  85476. * * 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)
  85477. * @returns the VertexData of the box
  85478. */
  85479. static CreatePlane(options: {
  85480. size?: number;
  85481. width?: number;
  85482. height?: number;
  85483. sideOrientation?: number;
  85484. frontUVs?: Vector4;
  85485. backUVs?: Vector4;
  85486. }): VertexData;
  85487. /**
  85488. * Creates the VertexData of the Disc or regular Polygon
  85489. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85490. * * radius the radius of the disc, optional default 0.5
  85491. * * tessellation the number of polygon sides, optional, default 64
  85492. * * 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
  85493. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85494. * * 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)
  85495. * * 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)
  85496. * @returns the VertexData of the box
  85497. */
  85498. static CreateDisc(options: {
  85499. radius?: number;
  85500. tessellation?: number;
  85501. arc?: number;
  85502. sideOrientation?: number;
  85503. frontUVs?: Vector4;
  85504. backUVs?: Vector4;
  85505. }): VertexData;
  85506. /**
  85507. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85508. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85509. * @param polygon a mesh built from polygonTriangulation.build()
  85510. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85511. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85512. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85513. * @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)
  85514. * @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)
  85515. * @returns the VertexData of the Polygon
  85516. */
  85517. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  85518. /**
  85519. * Creates the VertexData of the IcoSphere
  85520. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85521. * * radius the radius of the IcoSphere, optional default 1
  85522. * * radiusX allows stretching in the x direction, optional, default radius
  85523. * * radiusY allows stretching in the y direction, optional, default radius
  85524. * * radiusZ allows stretching in the z direction, optional, default radius
  85525. * * flat when true creates a flat shaded mesh, optional, default true
  85526. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85528. * * 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)
  85529. * * 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)
  85530. * @returns the VertexData of the IcoSphere
  85531. */
  85532. static CreateIcoSphere(options: {
  85533. radius?: number;
  85534. radiusX?: number;
  85535. radiusY?: number;
  85536. radiusZ?: number;
  85537. flat?: boolean;
  85538. subdivisions?: number;
  85539. sideOrientation?: number;
  85540. frontUVs?: Vector4;
  85541. backUVs?: Vector4;
  85542. }): VertexData;
  85543. /**
  85544. * Creates the VertexData for a Polyhedron
  85545. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85546. * * type provided types are:
  85547. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85548. * * 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)
  85549. * * size the size of the IcoSphere, optional default 1
  85550. * * sizeX allows stretching in the x direction, optional, default size
  85551. * * sizeY allows stretching in the y direction, optional, default size
  85552. * * sizeZ allows stretching in the z direction, optional, default size
  85553. * * 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
  85554. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85555. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85556. * * flat when true creates a flat shaded mesh, optional, default true
  85557. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85558. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85559. * * 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)
  85560. * * 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)
  85561. * @returns the VertexData of the Polyhedron
  85562. */
  85563. static CreatePolyhedron(options: {
  85564. type?: number;
  85565. size?: number;
  85566. sizeX?: number;
  85567. sizeY?: number;
  85568. sizeZ?: number;
  85569. custom?: any;
  85570. faceUV?: Vector4[];
  85571. faceColors?: Color4[];
  85572. flat?: boolean;
  85573. sideOrientation?: number;
  85574. frontUVs?: Vector4;
  85575. backUVs?: Vector4;
  85576. }): VertexData;
  85577. /**
  85578. * Creates the VertexData for a TorusKnot
  85579. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  85580. * * radius the radius of the torus knot, optional, default 2
  85581. * * tube the thickness of the tube, optional, default 0.5
  85582. * * radialSegments the number of sides on each tube segments, optional, default 32
  85583. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  85584. * * p the number of windings around the z axis, optional, default 2
  85585. * * q the number of windings around the x axis, optional, default 3
  85586. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85587. * * 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)
  85588. * * 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)
  85589. * @returns the VertexData of the Torus Knot
  85590. */
  85591. static CreateTorusKnot(options: {
  85592. radius?: number;
  85593. tube?: number;
  85594. radialSegments?: number;
  85595. tubularSegments?: number;
  85596. p?: number;
  85597. q?: number;
  85598. sideOrientation?: number;
  85599. frontUVs?: Vector4;
  85600. backUVs?: Vector4;
  85601. }): VertexData;
  85602. /**
  85603. * Compute normals for given positions and indices
  85604. * @param positions an array of vertex positions, [...., x, y, z, ......]
  85605. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  85606. * @param normals an array of vertex normals, [...., x, y, z, ......]
  85607. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  85608. * * facetNormals : optional array of facet normals (vector3)
  85609. * * facetPositions : optional array of facet positions (vector3)
  85610. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  85611. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  85612. * * bInfo : optional bounding info, required for facetPartitioning computation
  85613. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  85614. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  85615. * * useRightHandedSystem: optional boolean to for right handed system computation
  85616. * * depthSort : optional boolean to enable the facet depth sort computation
  85617. * * distanceTo : optional Vector3 to compute the facet depth from this location
  85618. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  85619. */
  85620. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  85621. facetNormals?: any;
  85622. facetPositions?: any;
  85623. facetPartitioning?: any;
  85624. ratio?: number;
  85625. bInfo?: any;
  85626. bbSize?: Vector3;
  85627. subDiv?: any;
  85628. useRightHandedSystem?: boolean;
  85629. depthSort?: boolean;
  85630. distanceTo?: Vector3;
  85631. depthSortedFacets?: any;
  85632. }): void;
  85633. /** @hidden */
  85634. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  85635. /**
  85636. * Applies VertexData created from the imported parameters to the geometry
  85637. * @param parsedVertexData the parsed data from an imported file
  85638. * @param geometry the geometry to apply the VertexData to
  85639. */
  85640. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  85641. }
  85642. }
  85643. declare module BABYLON {
  85644. /**
  85645. * Defines a target to use with MorphTargetManager
  85646. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85647. */
  85648. export class MorphTarget implements IAnimatable {
  85649. /** defines the name of the target */
  85650. name: string;
  85651. /**
  85652. * Gets or sets the list of animations
  85653. */
  85654. animations: Animation[];
  85655. private _scene;
  85656. private _positions;
  85657. private _normals;
  85658. private _tangents;
  85659. private _uvs;
  85660. private _influence;
  85661. /**
  85662. * Observable raised when the influence changes
  85663. */
  85664. onInfluenceChanged: Observable<boolean>;
  85665. /** @hidden */
  85666. _onDataLayoutChanged: Observable<void>;
  85667. /**
  85668. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  85669. */
  85670. influence: number;
  85671. /**
  85672. * Gets or sets the id of the morph Target
  85673. */
  85674. id: string;
  85675. private _animationPropertiesOverride;
  85676. /**
  85677. * Gets or sets the animation properties override
  85678. */
  85679. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85680. /**
  85681. * Creates a new MorphTarget
  85682. * @param name defines the name of the target
  85683. * @param influence defines the influence to use
  85684. * @param scene defines the scene the morphtarget belongs to
  85685. */
  85686. constructor(
  85687. /** defines the name of the target */
  85688. name: string, influence?: number, scene?: Nullable<Scene>);
  85689. /**
  85690. * Gets a boolean defining if the target contains position data
  85691. */
  85692. readonly hasPositions: boolean;
  85693. /**
  85694. * Gets a boolean defining if the target contains normal data
  85695. */
  85696. readonly hasNormals: boolean;
  85697. /**
  85698. * Gets a boolean defining if the target contains tangent data
  85699. */
  85700. readonly hasTangents: boolean;
  85701. /**
  85702. * Gets a boolean defining if the target contains texture coordinates data
  85703. */
  85704. readonly hasUVs: boolean;
  85705. /**
  85706. * Affects position data to this target
  85707. * @param data defines the position data to use
  85708. */
  85709. setPositions(data: Nullable<FloatArray>): void;
  85710. /**
  85711. * Gets the position data stored in this target
  85712. * @returns a FloatArray containing the position data (or null if not present)
  85713. */
  85714. getPositions(): Nullable<FloatArray>;
  85715. /**
  85716. * Affects normal data to this target
  85717. * @param data defines the normal data to use
  85718. */
  85719. setNormals(data: Nullable<FloatArray>): void;
  85720. /**
  85721. * Gets the normal data stored in this target
  85722. * @returns a FloatArray containing the normal data (or null if not present)
  85723. */
  85724. getNormals(): Nullable<FloatArray>;
  85725. /**
  85726. * Affects tangent data to this target
  85727. * @param data defines the tangent data to use
  85728. */
  85729. setTangents(data: Nullable<FloatArray>): void;
  85730. /**
  85731. * Gets the tangent data stored in this target
  85732. * @returns a FloatArray containing the tangent data (or null if not present)
  85733. */
  85734. getTangents(): Nullable<FloatArray>;
  85735. /**
  85736. * Affects texture coordinates data to this target
  85737. * @param data defines the texture coordinates data to use
  85738. */
  85739. setUVs(data: Nullable<FloatArray>): void;
  85740. /**
  85741. * Gets the texture coordinates data stored in this target
  85742. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  85743. */
  85744. getUVs(): Nullable<FloatArray>;
  85745. /**
  85746. * Serializes the current target into a Serialization object
  85747. * @returns the serialized object
  85748. */
  85749. serialize(): any;
  85750. /**
  85751. * Returns the string "MorphTarget"
  85752. * @returns "MorphTarget"
  85753. */
  85754. getClassName(): string;
  85755. /**
  85756. * Creates a new target from serialized data
  85757. * @param serializationObject defines the serialized data to use
  85758. * @returns a new MorphTarget
  85759. */
  85760. static Parse(serializationObject: any): MorphTarget;
  85761. /**
  85762. * Creates a MorphTarget from mesh data
  85763. * @param mesh defines the source mesh
  85764. * @param name defines the name to use for the new target
  85765. * @param influence defines the influence to attach to the target
  85766. * @returns a new MorphTarget
  85767. */
  85768. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  85769. }
  85770. }
  85771. declare module BABYLON {
  85772. /**
  85773. * This class is used to deform meshes using morphing between different targets
  85774. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85775. */
  85776. export class MorphTargetManager {
  85777. private _targets;
  85778. private _targetInfluenceChangedObservers;
  85779. private _targetDataLayoutChangedObservers;
  85780. private _activeTargets;
  85781. private _scene;
  85782. private _influences;
  85783. private _supportsNormals;
  85784. private _supportsTangents;
  85785. private _supportsUVs;
  85786. private _vertexCount;
  85787. private _uniqueId;
  85788. private _tempInfluences;
  85789. /**
  85790. * Gets or sets a boolean indicating if normals must be morphed
  85791. */
  85792. enableNormalMorphing: boolean;
  85793. /**
  85794. * Gets or sets a boolean indicating if tangents must be morphed
  85795. */
  85796. enableTangentMorphing: boolean;
  85797. /**
  85798. * Gets or sets a boolean indicating if UV must be morphed
  85799. */
  85800. enableUVMorphing: boolean;
  85801. /**
  85802. * Creates a new MorphTargetManager
  85803. * @param scene defines the current scene
  85804. */
  85805. constructor(scene?: Nullable<Scene>);
  85806. /**
  85807. * Gets the unique ID of this manager
  85808. */
  85809. readonly uniqueId: number;
  85810. /**
  85811. * Gets the number of vertices handled by this manager
  85812. */
  85813. readonly vertexCount: number;
  85814. /**
  85815. * Gets a boolean indicating if this manager supports morphing of normals
  85816. */
  85817. readonly supportsNormals: boolean;
  85818. /**
  85819. * Gets a boolean indicating if this manager supports morphing of tangents
  85820. */
  85821. readonly supportsTangents: boolean;
  85822. /**
  85823. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  85824. */
  85825. readonly supportsUVs: boolean;
  85826. /**
  85827. * Gets the number of targets stored in this manager
  85828. */
  85829. readonly numTargets: number;
  85830. /**
  85831. * Gets the number of influencers (ie. the number of targets with influences > 0)
  85832. */
  85833. readonly numInfluencers: number;
  85834. /**
  85835. * Gets the list of influences (one per target)
  85836. */
  85837. readonly influences: Float32Array;
  85838. /**
  85839. * Gets the active target at specified index. An active target is a target with an influence > 0
  85840. * @param index defines the index to check
  85841. * @returns the requested target
  85842. */
  85843. getActiveTarget(index: number): MorphTarget;
  85844. /**
  85845. * Gets the target at specified index
  85846. * @param index defines the index to check
  85847. * @returns the requested target
  85848. */
  85849. getTarget(index: number): MorphTarget;
  85850. /**
  85851. * Add a new target to this manager
  85852. * @param target defines the target to add
  85853. */
  85854. addTarget(target: MorphTarget): void;
  85855. /**
  85856. * Removes a target from the manager
  85857. * @param target defines the target to remove
  85858. */
  85859. removeTarget(target: MorphTarget): void;
  85860. /**
  85861. * Serializes the current manager into a Serialization object
  85862. * @returns the serialized object
  85863. */
  85864. serialize(): any;
  85865. private _syncActiveTargets;
  85866. /**
  85867. * Syncrhonize the targets with all the meshes using this morph target manager
  85868. */
  85869. synchronize(): void;
  85870. /**
  85871. * Creates a new MorphTargetManager from serialized data
  85872. * @param serializationObject defines the serialized data
  85873. * @param scene defines the hosting scene
  85874. * @returns the new MorphTargetManager
  85875. */
  85876. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  85877. }
  85878. }
  85879. declare module BABYLON {
  85880. /**
  85881. * Class used to represent a specific level of detail of a mesh
  85882. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  85883. */
  85884. export class MeshLODLevel {
  85885. /** Defines the distance where this level should star being displayed */
  85886. distance: number;
  85887. /** Defines the mesh to use to render this level */
  85888. mesh: Nullable<Mesh>;
  85889. /**
  85890. * Creates a new LOD level
  85891. * @param distance defines the distance where this level should star being displayed
  85892. * @param mesh defines the mesh to use to render this level
  85893. */
  85894. constructor(
  85895. /** Defines the distance where this level should star being displayed */
  85896. distance: number,
  85897. /** Defines the mesh to use to render this level */
  85898. mesh: Nullable<Mesh>);
  85899. }
  85900. }
  85901. declare module BABYLON {
  85902. /**
  85903. * Mesh representing the gorund
  85904. */
  85905. export class GroundMesh extends Mesh {
  85906. /** If octree should be generated */
  85907. generateOctree: boolean;
  85908. private _heightQuads;
  85909. /** @hidden */
  85910. _subdivisionsX: number;
  85911. /** @hidden */
  85912. _subdivisionsY: number;
  85913. /** @hidden */
  85914. _width: number;
  85915. /** @hidden */
  85916. _height: number;
  85917. /** @hidden */
  85918. _minX: number;
  85919. /** @hidden */
  85920. _maxX: number;
  85921. /** @hidden */
  85922. _minZ: number;
  85923. /** @hidden */
  85924. _maxZ: number;
  85925. constructor(name: string, scene: Scene);
  85926. /**
  85927. * "GroundMesh"
  85928. * @returns "GroundMesh"
  85929. */
  85930. getClassName(): string;
  85931. /**
  85932. * The minimum of x and y subdivisions
  85933. */
  85934. readonly subdivisions: number;
  85935. /**
  85936. * X subdivisions
  85937. */
  85938. readonly subdivisionsX: number;
  85939. /**
  85940. * Y subdivisions
  85941. */
  85942. readonly subdivisionsY: number;
  85943. /**
  85944. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  85945. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  85946. * @param chunksCount the number of subdivisions for x and y
  85947. * @param octreeBlocksSize (Default: 32)
  85948. */
  85949. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  85950. /**
  85951. * Returns a height (y) value in the Worl system :
  85952. * the ground altitude at the coordinates (x, z) expressed in the World system.
  85953. * @param x x coordinate
  85954. * @param z z coordinate
  85955. * @returns the ground y position if (x, z) are outside the ground surface.
  85956. */
  85957. getHeightAtCoordinates(x: number, z: number): number;
  85958. /**
  85959. * Returns a normalized vector (Vector3) orthogonal to the ground
  85960. * at the ground coordinates (x, z) expressed in the World system.
  85961. * @param x x coordinate
  85962. * @param z z coordinate
  85963. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  85964. */
  85965. getNormalAtCoordinates(x: number, z: number): Vector3;
  85966. /**
  85967. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  85968. * at the ground coordinates (x, z) expressed in the World system.
  85969. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  85970. * @param x x coordinate
  85971. * @param z z coordinate
  85972. * @param ref vector to store the result
  85973. * @returns the GroundMesh.
  85974. */
  85975. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  85976. /**
  85977. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  85978. * if the ground has been updated.
  85979. * This can be used in the render loop.
  85980. * @returns the GroundMesh.
  85981. */
  85982. updateCoordinateHeights(): GroundMesh;
  85983. private _getFacetAt;
  85984. private _initHeightQuads;
  85985. private _computeHeightQuads;
  85986. /**
  85987. * Serializes this ground mesh
  85988. * @param serializationObject object to write serialization to
  85989. */
  85990. serialize(serializationObject: any): void;
  85991. /**
  85992. * Parses a serialized ground mesh
  85993. * @param parsedMesh the serialized mesh
  85994. * @param scene the scene to create the ground mesh in
  85995. * @returns the created ground mesh
  85996. */
  85997. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  85998. }
  85999. }
  86000. declare module BABYLON {
  86001. /**
  86002. * Interface for Physics-Joint data
  86003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86004. */
  86005. export interface PhysicsJointData {
  86006. /**
  86007. * The main pivot of the joint
  86008. */
  86009. mainPivot?: Vector3;
  86010. /**
  86011. * The connected pivot of the joint
  86012. */
  86013. connectedPivot?: Vector3;
  86014. /**
  86015. * The main axis of the joint
  86016. */
  86017. mainAxis?: Vector3;
  86018. /**
  86019. * The connected axis of the joint
  86020. */
  86021. connectedAxis?: Vector3;
  86022. /**
  86023. * The collision of the joint
  86024. */
  86025. collision?: boolean;
  86026. /**
  86027. * Native Oimo/Cannon/Energy data
  86028. */
  86029. nativeParams?: any;
  86030. }
  86031. /**
  86032. * This is a holder class for the physics joint created by the physics plugin
  86033. * It holds a set of functions to control the underlying joint
  86034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86035. */
  86036. export class PhysicsJoint {
  86037. /**
  86038. * The type of the physics joint
  86039. */
  86040. type: number;
  86041. /**
  86042. * The data for the physics joint
  86043. */
  86044. jointData: PhysicsJointData;
  86045. private _physicsJoint;
  86046. protected _physicsPlugin: IPhysicsEnginePlugin;
  86047. /**
  86048. * Initializes the physics joint
  86049. * @param type The type of the physics joint
  86050. * @param jointData The data for the physics joint
  86051. */
  86052. constructor(
  86053. /**
  86054. * The type of the physics joint
  86055. */
  86056. type: number,
  86057. /**
  86058. * The data for the physics joint
  86059. */
  86060. jointData: PhysicsJointData);
  86061. /**
  86062. * Gets the physics joint
  86063. */
  86064. /**
  86065. * Sets the physics joint
  86066. */
  86067. physicsJoint: any;
  86068. /**
  86069. * Sets the physics plugin
  86070. */
  86071. physicsPlugin: IPhysicsEnginePlugin;
  86072. /**
  86073. * Execute a function that is physics-plugin specific.
  86074. * @param {Function} func the function that will be executed.
  86075. * It accepts two parameters: the physics world and the physics joint
  86076. */
  86077. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  86078. /**
  86079. * Distance-Joint type
  86080. */
  86081. static DistanceJoint: number;
  86082. /**
  86083. * Hinge-Joint type
  86084. */
  86085. static HingeJoint: number;
  86086. /**
  86087. * Ball-and-Socket joint type
  86088. */
  86089. static BallAndSocketJoint: number;
  86090. /**
  86091. * Wheel-Joint type
  86092. */
  86093. static WheelJoint: number;
  86094. /**
  86095. * Slider-Joint type
  86096. */
  86097. static SliderJoint: number;
  86098. /**
  86099. * Prismatic-Joint type
  86100. */
  86101. static PrismaticJoint: number;
  86102. /**
  86103. * Universal-Joint type
  86104. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  86105. */
  86106. static UniversalJoint: number;
  86107. /**
  86108. * Hinge-Joint 2 type
  86109. */
  86110. static Hinge2Joint: number;
  86111. /**
  86112. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  86113. */
  86114. static PointToPointJoint: number;
  86115. /**
  86116. * Spring-Joint type
  86117. */
  86118. static SpringJoint: number;
  86119. /**
  86120. * Lock-Joint type
  86121. */
  86122. static LockJoint: number;
  86123. }
  86124. /**
  86125. * A class representing a physics distance joint
  86126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86127. */
  86128. export class DistanceJoint extends PhysicsJoint {
  86129. /**
  86130. *
  86131. * @param jointData The data for the Distance-Joint
  86132. */
  86133. constructor(jointData: DistanceJointData);
  86134. /**
  86135. * Update the predefined distance.
  86136. * @param maxDistance The maximum preferred distance
  86137. * @param minDistance The minimum preferred distance
  86138. */
  86139. updateDistance(maxDistance: number, minDistance?: number): void;
  86140. }
  86141. /**
  86142. * Represents a Motor-Enabled Joint
  86143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86144. */
  86145. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  86146. /**
  86147. * Initializes the Motor-Enabled Joint
  86148. * @param type The type of the joint
  86149. * @param jointData The physica joint data for the joint
  86150. */
  86151. constructor(type: number, jointData: PhysicsJointData);
  86152. /**
  86153. * Set the motor values.
  86154. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86155. * @param force the force to apply
  86156. * @param maxForce max force for this motor.
  86157. */
  86158. setMotor(force?: number, maxForce?: number): void;
  86159. /**
  86160. * Set the motor's limits.
  86161. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86162. * @param upperLimit The upper limit of the motor
  86163. * @param lowerLimit The lower limit of the motor
  86164. */
  86165. setLimit(upperLimit: number, lowerLimit?: number): void;
  86166. }
  86167. /**
  86168. * This class represents a single physics Hinge-Joint
  86169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86170. */
  86171. export class HingeJoint extends MotorEnabledJoint {
  86172. /**
  86173. * Initializes the Hinge-Joint
  86174. * @param jointData The joint data for the Hinge-Joint
  86175. */
  86176. constructor(jointData: PhysicsJointData);
  86177. /**
  86178. * Set the motor values.
  86179. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86180. * @param {number} force the force to apply
  86181. * @param {number} maxForce max force for this motor.
  86182. */
  86183. setMotor(force?: number, maxForce?: number): void;
  86184. /**
  86185. * Set the motor's limits.
  86186. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86187. * @param upperLimit The upper limit of the motor
  86188. * @param lowerLimit The lower limit of the motor
  86189. */
  86190. setLimit(upperLimit: number, lowerLimit?: number): void;
  86191. }
  86192. /**
  86193. * This class represents a dual hinge physics joint (same as wheel joint)
  86194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86195. */
  86196. export class Hinge2Joint extends MotorEnabledJoint {
  86197. /**
  86198. * Initializes the Hinge2-Joint
  86199. * @param jointData The joint data for the Hinge2-Joint
  86200. */
  86201. constructor(jointData: PhysicsJointData);
  86202. /**
  86203. * Set the motor values.
  86204. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86205. * @param {number} targetSpeed the speed the motor is to reach
  86206. * @param {number} maxForce max force for this motor.
  86207. * @param {motorIndex} the motor's index, 0 or 1.
  86208. */
  86209. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  86210. /**
  86211. * Set the motor limits.
  86212. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86213. * @param {number} upperLimit the upper limit
  86214. * @param {number} lowerLimit lower limit
  86215. * @param {motorIndex} the motor's index, 0 or 1.
  86216. */
  86217. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86218. }
  86219. /**
  86220. * Interface for a motor enabled joint
  86221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86222. */
  86223. export interface IMotorEnabledJoint {
  86224. /**
  86225. * Physics joint
  86226. */
  86227. physicsJoint: any;
  86228. /**
  86229. * Sets the motor of the motor-enabled joint
  86230. * @param force The force of the motor
  86231. * @param maxForce The maximum force of the motor
  86232. * @param motorIndex The index of the motor
  86233. */
  86234. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  86235. /**
  86236. * Sets the limit of the motor
  86237. * @param upperLimit The upper limit of the motor
  86238. * @param lowerLimit The lower limit of the motor
  86239. * @param motorIndex The index of the motor
  86240. */
  86241. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86242. }
  86243. /**
  86244. * Joint data for a Distance-Joint
  86245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86246. */
  86247. export interface DistanceJointData extends PhysicsJointData {
  86248. /**
  86249. * Max distance the 2 joint objects can be apart
  86250. */
  86251. maxDistance: number;
  86252. }
  86253. /**
  86254. * Joint data from a spring joint
  86255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86256. */
  86257. export interface SpringJointData extends PhysicsJointData {
  86258. /**
  86259. * Length of the spring
  86260. */
  86261. length: number;
  86262. /**
  86263. * Stiffness of the spring
  86264. */
  86265. stiffness: number;
  86266. /**
  86267. * Damping of the spring
  86268. */
  86269. damping: number;
  86270. /** this callback will be called when applying the force to the impostors. */
  86271. forceApplicationCallback: () => void;
  86272. }
  86273. }
  86274. declare module BABYLON {
  86275. /**
  86276. * Holds the data for the raycast result
  86277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86278. */
  86279. export class PhysicsRaycastResult {
  86280. private _hasHit;
  86281. private _hitDistance;
  86282. private _hitNormalWorld;
  86283. private _hitPointWorld;
  86284. private _rayFromWorld;
  86285. private _rayToWorld;
  86286. /**
  86287. * Gets if there was a hit
  86288. */
  86289. readonly hasHit: boolean;
  86290. /**
  86291. * Gets the distance from the hit
  86292. */
  86293. readonly hitDistance: number;
  86294. /**
  86295. * Gets the hit normal/direction in the world
  86296. */
  86297. readonly hitNormalWorld: Vector3;
  86298. /**
  86299. * Gets the hit point in the world
  86300. */
  86301. readonly hitPointWorld: Vector3;
  86302. /**
  86303. * Gets the ray "start point" of the ray in the world
  86304. */
  86305. readonly rayFromWorld: Vector3;
  86306. /**
  86307. * Gets the ray "end point" of the ray in the world
  86308. */
  86309. readonly rayToWorld: Vector3;
  86310. /**
  86311. * Sets the hit data (normal & point in world space)
  86312. * @param hitNormalWorld defines the normal in world space
  86313. * @param hitPointWorld defines the point in world space
  86314. */
  86315. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  86316. /**
  86317. * Sets the distance from the start point to the hit point
  86318. * @param distance
  86319. */
  86320. setHitDistance(distance: number): void;
  86321. /**
  86322. * Calculates the distance manually
  86323. */
  86324. calculateHitDistance(): void;
  86325. /**
  86326. * Resets all the values to default
  86327. * @param from The from point on world space
  86328. * @param to The to point on world space
  86329. */
  86330. reset(from?: Vector3, to?: Vector3): void;
  86331. }
  86332. /**
  86333. * Interface for the size containing width and height
  86334. */
  86335. interface IXYZ {
  86336. /**
  86337. * X
  86338. */
  86339. x: number;
  86340. /**
  86341. * Y
  86342. */
  86343. y: number;
  86344. /**
  86345. * Z
  86346. */
  86347. z: number;
  86348. }
  86349. }
  86350. declare module BABYLON {
  86351. /**
  86352. * Interface used to describe a physics joint
  86353. */
  86354. export interface PhysicsImpostorJoint {
  86355. /** Defines the main impostor to which the joint is linked */
  86356. mainImpostor: PhysicsImpostor;
  86357. /** Defines the impostor that is connected to the main impostor using this joint */
  86358. connectedImpostor: PhysicsImpostor;
  86359. /** Defines the joint itself */
  86360. joint: PhysicsJoint;
  86361. }
  86362. /** @hidden */
  86363. export interface IPhysicsEnginePlugin {
  86364. world: any;
  86365. name: string;
  86366. setGravity(gravity: Vector3): void;
  86367. setTimeStep(timeStep: number): void;
  86368. getTimeStep(): number;
  86369. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  86370. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86371. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86372. generatePhysicsBody(impostor: PhysicsImpostor): void;
  86373. removePhysicsBody(impostor: PhysicsImpostor): void;
  86374. generateJoint(joint: PhysicsImpostorJoint): void;
  86375. removeJoint(joint: PhysicsImpostorJoint): void;
  86376. isSupported(): boolean;
  86377. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  86378. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  86379. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86380. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86381. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86382. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86383. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  86384. getBodyMass(impostor: PhysicsImpostor): number;
  86385. getBodyFriction(impostor: PhysicsImpostor): number;
  86386. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  86387. getBodyRestitution(impostor: PhysicsImpostor): number;
  86388. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  86389. getBodyPressure?(impostor: PhysicsImpostor): number;
  86390. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  86391. getBodyStiffness?(impostor: PhysicsImpostor): number;
  86392. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  86393. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  86394. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  86395. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  86396. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  86397. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86398. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86399. sleepBody(impostor: PhysicsImpostor): void;
  86400. wakeUpBody(impostor: PhysicsImpostor): void;
  86401. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86402. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  86403. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  86404. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86405. getRadius(impostor: PhysicsImpostor): number;
  86406. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  86407. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  86408. dispose(): void;
  86409. }
  86410. /**
  86411. * Interface used to define a physics engine
  86412. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  86413. */
  86414. export interface IPhysicsEngine {
  86415. /**
  86416. * Gets the gravity vector used by the simulation
  86417. */
  86418. gravity: Vector3;
  86419. /**
  86420. * Sets the gravity vector used by the simulation
  86421. * @param gravity defines the gravity vector to use
  86422. */
  86423. setGravity(gravity: Vector3): void;
  86424. /**
  86425. * Set the time step of the physics engine.
  86426. * Default is 1/60.
  86427. * To slow it down, enter 1/600 for example.
  86428. * To speed it up, 1/30
  86429. * @param newTimeStep the new timestep to apply to this world.
  86430. */
  86431. setTimeStep(newTimeStep: number): void;
  86432. /**
  86433. * Get the time step of the physics engine.
  86434. * @returns the current time step
  86435. */
  86436. getTimeStep(): number;
  86437. /**
  86438. * Release all resources
  86439. */
  86440. dispose(): void;
  86441. /**
  86442. * Gets the name of the current physics plugin
  86443. * @returns the name of the plugin
  86444. */
  86445. getPhysicsPluginName(): string;
  86446. /**
  86447. * Adding a new impostor for the impostor tracking.
  86448. * This will be done by the impostor itself.
  86449. * @param impostor the impostor to add
  86450. */
  86451. addImpostor(impostor: PhysicsImpostor): void;
  86452. /**
  86453. * Remove an impostor from the engine.
  86454. * This impostor and its mesh will not longer be updated by the physics engine.
  86455. * @param impostor the impostor to remove
  86456. */
  86457. removeImpostor(impostor: PhysicsImpostor): void;
  86458. /**
  86459. * Add a joint to the physics engine
  86460. * @param mainImpostor defines the main impostor to which the joint is added.
  86461. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  86462. * @param joint defines the joint that will connect both impostors.
  86463. */
  86464. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86465. /**
  86466. * Removes a joint from the simulation
  86467. * @param mainImpostor defines the impostor used with the joint
  86468. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  86469. * @param joint defines the joint to remove
  86470. */
  86471. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86472. /**
  86473. * Gets the current plugin used to run the simulation
  86474. * @returns current plugin
  86475. */
  86476. getPhysicsPlugin(): IPhysicsEnginePlugin;
  86477. /**
  86478. * Gets the list of physic impostors
  86479. * @returns an array of PhysicsImpostor
  86480. */
  86481. getImpostors(): Array<PhysicsImpostor>;
  86482. /**
  86483. * Gets the impostor for a physics enabled object
  86484. * @param object defines the object impersonated by the impostor
  86485. * @returns the PhysicsImpostor or null if not found
  86486. */
  86487. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86488. /**
  86489. * Gets the impostor for a physics body object
  86490. * @param body defines physics body used by the impostor
  86491. * @returns the PhysicsImpostor or null if not found
  86492. */
  86493. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  86494. /**
  86495. * Does a raycast in the physics world
  86496. * @param from when should the ray start?
  86497. * @param to when should the ray end?
  86498. * @returns PhysicsRaycastResult
  86499. */
  86500. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86501. /**
  86502. * Called by the scene. No need to call it.
  86503. * @param delta defines the timespam between frames
  86504. */
  86505. _step(delta: number): void;
  86506. }
  86507. }
  86508. declare module BABYLON {
  86509. /**
  86510. * The interface for the physics imposter parameters
  86511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86512. */
  86513. export interface PhysicsImpostorParameters {
  86514. /**
  86515. * The mass of the physics imposter
  86516. */
  86517. mass: number;
  86518. /**
  86519. * The friction of the physics imposter
  86520. */
  86521. friction?: number;
  86522. /**
  86523. * The coefficient of restitution of the physics imposter
  86524. */
  86525. restitution?: number;
  86526. /**
  86527. * The native options of the physics imposter
  86528. */
  86529. nativeOptions?: any;
  86530. /**
  86531. * Specifies if the parent should be ignored
  86532. */
  86533. ignoreParent?: boolean;
  86534. /**
  86535. * Specifies if bi-directional transformations should be disabled
  86536. */
  86537. disableBidirectionalTransformation?: boolean;
  86538. /**
  86539. * The pressure inside the physics imposter, soft object only
  86540. */
  86541. pressure?: number;
  86542. /**
  86543. * The stiffness the physics imposter, soft object only
  86544. */
  86545. stiffness?: number;
  86546. /**
  86547. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  86548. */
  86549. velocityIterations?: number;
  86550. /**
  86551. * The number of iterations used in maintaining consistent vertex positions, soft object only
  86552. */
  86553. positionIterations?: number;
  86554. /**
  86555. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  86556. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  86557. * Add to fix multiple points
  86558. */
  86559. fixedPoints?: number;
  86560. /**
  86561. * The collision margin around a soft object
  86562. */
  86563. margin?: number;
  86564. /**
  86565. * The collision margin around a soft object
  86566. */
  86567. damping?: number;
  86568. /**
  86569. * The path for a rope based on an extrusion
  86570. */
  86571. path?: any;
  86572. /**
  86573. * The shape of an extrusion used for a rope based on an extrusion
  86574. */
  86575. shape?: any;
  86576. }
  86577. /**
  86578. * Interface for a physics-enabled object
  86579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86580. */
  86581. export interface IPhysicsEnabledObject {
  86582. /**
  86583. * The position of the physics-enabled object
  86584. */
  86585. position: Vector3;
  86586. /**
  86587. * The rotation of the physics-enabled object
  86588. */
  86589. rotationQuaternion: Nullable<Quaternion>;
  86590. /**
  86591. * The scale of the physics-enabled object
  86592. */
  86593. scaling: Vector3;
  86594. /**
  86595. * The rotation of the physics-enabled object
  86596. */
  86597. rotation?: Vector3;
  86598. /**
  86599. * The parent of the physics-enabled object
  86600. */
  86601. parent?: any;
  86602. /**
  86603. * The bounding info of the physics-enabled object
  86604. * @returns The bounding info of the physics-enabled object
  86605. */
  86606. getBoundingInfo(): BoundingInfo;
  86607. /**
  86608. * Computes the world matrix
  86609. * @param force Specifies if the world matrix should be computed by force
  86610. * @returns A world matrix
  86611. */
  86612. computeWorldMatrix(force: boolean): Matrix;
  86613. /**
  86614. * Gets the world matrix
  86615. * @returns A world matrix
  86616. */
  86617. getWorldMatrix?(): Matrix;
  86618. /**
  86619. * Gets the child meshes
  86620. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  86621. * @returns An array of abstract meshes
  86622. */
  86623. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  86624. /**
  86625. * Gets the vertex data
  86626. * @param kind The type of vertex data
  86627. * @returns A nullable array of numbers, or a float32 array
  86628. */
  86629. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  86630. /**
  86631. * Gets the indices from the mesh
  86632. * @returns A nullable array of index arrays
  86633. */
  86634. getIndices?(): Nullable<IndicesArray>;
  86635. /**
  86636. * Gets the scene from the mesh
  86637. * @returns the indices array or null
  86638. */
  86639. getScene?(): Scene;
  86640. /**
  86641. * Gets the absolute position from the mesh
  86642. * @returns the absolute position
  86643. */
  86644. getAbsolutePosition(): Vector3;
  86645. /**
  86646. * Gets the absolute pivot point from the mesh
  86647. * @returns the absolute pivot point
  86648. */
  86649. getAbsolutePivotPoint(): Vector3;
  86650. /**
  86651. * Rotates the mesh
  86652. * @param axis The axis of rotation
  86653. * @param amount The amount of rotation
  86654. * @param space The space of the rotation
  86655. * @returns The rotation transform node
  86656. */
  86657. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  86658. /**
  86659. * Translates the mesh
  86660. * @param axis The axis of translation
  86661. * @param distance The distance of translation
  86662. * @param space The space of the translation
  86663. * @returns The transform node
  86664. */
  86665. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  86666. /**
  86667. * Sets the absolute position of the mesh
  86668. * @param absolutePosition The absolute position of the mesh
  86669. * @returns The transform node
  86670. */
  86671. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86672. /**
  86673. * Gets the class name of the mesh
  86674. * @returns The class name
  86675. */
  86676. getClassName(): string;
  86677. }
  86678. /**
  86679. * Represents a physics imposter
  86680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86681. */
  86682. export class PhysicsImpostor {
  86683. /**
  86684. * The physics-enabled object used as the physics imposter
  86685. */
  86686. object: IPhysicsEnabledObject;
  86687. /**
  86688. * The type of the physics imposter
  86689. */
  86690. type: number;
  86691. private _options;
  86692. private _scene?;
  86693. /**
  86694. * The default object size of the imposter
  86695. */
  86696. static DEFAULT_OBJECT_SIZE: Vector3;
  86697. /**
  86698. * The identity quaternion of the imposter
  86699. */
  86700. static IDENTITY_QUATERNION: Quaternion;
  86701. /** @hidden */
  86702. _pluginData: any;
  86703. private _physicsEngine;
  86704. private _physicsBody;
  86705. private _bodyUpdateRequired;
  86706. private _onBeforePhysicsStepCallbacks;
  86707. private _onAfterPhysicsStepCallbacks;
  86708. /** @hidden */
  86709. _onPhysicsCollideCallbacks: Array<{
  86710. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  86711. otherImpostors: Array<PhysicsImpostor>;
  86712. }>;
  86713. private _deltaPosition;
  86714. private _deltaRotation;
  86715. private _deltaRotationConjugated;
  86716. /** @hidden */
  86717. _isFromLine: boolean;
  86718. private _parent;
  86719. private _isDisposed;
  86720. private static _tmpVecs;
  86721. private static _tmpQuat;
  86722. /**
  86723. * Specifies if the physics imposter is disposed
  86724. */
  86725. readonly isDisposed: boolean;
  86726. /**
  86727. * Gets the mass of the physics imposter
  86728. */
  86729. mass: number;
  86730. /**
  86731. * Gets the coefficient of friction
  86732. */
  86733. /**
  86734. * Sets the coefficient of friction
  86735. */
  86736. friction: number;
  86737. /**
  86738. * Gets the coefficient of restitution
  86739. */
  86740. /**
  86741. * Sets the coefficient of restitution
  86742. */
  86743. restitution: number;
  86744. /**
  86745. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  86746. */
  86747. /**
  86748. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  86749. */
  86750. pressure: number;
  86751. /**
  86752. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  86753. */
  86754. /**
  86755. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  86756. */
  86757. stiffness: number;
  86758. /**
  86759. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  86760. */
  86761. /**
  86762. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  86763. */
  86764. velocityIterations: number;
  86765. /**
  86766. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  86767. */
  86768. /**
  86769. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  86770. */
  86771. positionIterations: number;
  86772. /**
  86773. * The unique id of the physics imposter
  86774. * set by the physics engine when adding this impostor to the array
  86775. */
  86776. uniqueId: number;
  86777. /**
  86778. * @hidden
  86779. */
  86780. soft: boolean;
  86781. /**
  86782. * @hidden
  86783. */
  86784. segments: number;
  86785. private _joints;
  86786. /**
  86787. * Initializes the physics imposter
  86788. * @param object The physics-enabled object used as the physics imposter
  86789. * @param type The type of the physics imposter
  86790. * @param _options The options for the physics imposter
  86791. * @param _scene The Babylon scene
  86792. */
  86793. constructor(
  86794. /**
  86795. * The physics-enabled object used as the physics imposter
  86796. */
  86797. object: IPhysicsEnabledObject,
  86798. /**
  86799. * The type of the physics imposter
  86800. */
  86801. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  86802. /**
  86803. * This function will completly initialize this impostor.
  86804. * It will create a new body - but only if this mesh has no parent.
  86805. * If it has, this impostor will not be used other than to define the impostor
  86806. * of the child mesh.
  86807. * @hidden
  86808. */
  86809. _init(): void;
  86810. private _getPhysicsParent;
  86811. /**
  86812. * Should a new body be generated.
  86813. * @returns boolean specifying if body initialization is required
  86814. */
  86815. isBodyInitRequired(): boolean;
  86816. /**
  86817. * Sets the updated scaling
  86818. * @param updated Specifies if the scaling is updated
  86819. */
  86820. setScalingUpdated(): void;
  86821. /**
  86822. * Force a regeneration of this or the parent's impostor's body.
  86823. * Use under cautious - This will remove all joints already implemented.
  86824. */
  86825. forceUpdate(): void;
  86826. /**
  86827. * Gets the body that holds this impostor. Either its own, or its parent.
  86828. */
  86829. /**
  86830. * Set the physics body. Used mainly by the physics engine/plugin
  86831. */
  86832. physicsBody: any;
  86833. /**
  86834. * Get the parent of the physics imposter
  86835. * @returns Physics imposter or null
  86836. */
  86837. /**
  86838. * Sets the parent of the physics imposter
  86839. */
  86840. parent: Nullable<PhysicsImpostor>;
  86841. /**
  86842. * Resets the update flags
  86843. */
  86844. resetUpdateFlags(): void;
  86845. /**
  86846. * Gets the object extend size
  86847. * @returns the object extend size
  86848. */
  86849. getObjectExtendSize(): Vector3;
  86850. /**
  86851. * Gets the object center
  86852. * @returns The object center
  86853. */
  86854. getObjectCenter(): Vector3;
  86855. /**
  86856. * Get a specific parametes from the options parameter
  86857. * @param paramName The object parameter name
  86858. * @returns The object parameter
  86859. */
  86860. getParam(paramName: string): any;
  86861. /**
  86862. * Sets a specific parameter in the options given to the physics plugin
  86863. * @param paramName The parameter name
  86864. * @param value The value of the parameter
  86865. */
  86866. setParam(paramName: string, value: number): void;
  86867. /**
  86868. * Specifically change the body's mass option. Won't recreate the physics body object
  86869. * @param mass The mass of the physics imposter
  86870. */
  86871. setMass(mass: number): void;
  86872. /**
  86873. * Gets the linear velocity
  86874. * @returns linear velocity or null
  86875. */
  86876. getLinearVelocity(): Nullable<Vector3>;
  86877. /**
  86878. * Sets the linear velocity
  86879. * @param velocity linear velocity or null
  86880. */
  86881. setLinearVelocity(velocity: Nullable<Vector3>): void;
  86882. /**
  86883. * Gets the angular velocity
  86884. * @returns angular velocity or null
  86885. */
  86886. getAngularVelocity(): Nullable<Vector3>;
  86887. /**
  86888. * Sets the angular velocity
  86889. * @param velocity The velocity or null
  86890. */
  86891. setAngularVelocity(velocity: Nullable<Vector3>): void;
  86892. /**
  86893. * Execute a function with the physics plugin native code
  86894. * Provide a function the will have two variables - the world object and the physics body object
  86895. * @param func The function to execute with the physics plugin native code
  86896. */
  86897. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  86898. /**
  86899. * Register a function that will be executed before the physics world is stepping forward
  86900. * @param func The function to execute before the physics world is stepped forward
  86901. */
  86902. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86903. /**
  86904. * Unregister a function that will be executed before the physics world is stepping forward
  86905. * @param func The function to execute before the physics world is stepped forward
  86906. */
  86907. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86908. /**
  86909. * Register a function that will be executed after the physics step
  86910. * @param func The function to execute after physics step
  86911. */
  86912. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86913. /**
  86914. * Unregisters a function that will be executed after the physics step
  86915. * @param func The function to execute after physics step
  86916. */
  86917. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86918. /**
  86919. * register a function that will be executed when this impostor collides against a different body
  86920. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  86921. * @param func Callback that is executed on collision
  86922. */
  86923. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  86924. /**
  86925. * Unregisters the physics imposter on contact
  86926. * @param collideAgainst The physics object to collide against
  86927. * @param func Callback to execute on collision
  86928. */
  86929. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  86930. private _tmpQuat;
  86931. private _tmpQuat2;
  86932. /**
  86933. * Get the parent rotation
  86934. * @returns The parent rotation
  86935. */
  86936. getParentsRotation(): Quaternion;
  86937. /**
  86938. * this function is executed by the physics engine.
  86939. */
  86940. beforeStep: () => void;
  86941. /**
  86942. * this function is executed by the physics engine
  86943. */
  86944. afterStep: () => void;
  86945. /**
  86946. * Legacy collision detection event support
  86947. */
  86948. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  86949. /**
  86950. * event and body object due to cannon's event-based architecture.
  86951. */
  86952. onCollide: (e: {
  86953. body: any;
  86954. }) => void;
  86955. /**
  86956. * Apply a force
  86957. * @param force The force to apply
  86958. * @param contactPoint The contact point for the force
  86959. * @returns The physics imposter
  86960. */
  86961. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  86962. /**
  86963. * Apply an impulse
  86964. * @param force The impulse force
  86965. * @param contactPoint The contact point for the impulse force
  86966. * @returns The physics imposter
  86967. */
  86968. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  86969. /**
  86970. * A help function to create a joint
  86971. * @param otherImpostor A physics imposter used to create a joint
  86972. * @param jointType The type of joint
  86973. * @param jointData The data for the joint
  86974. * @returns The physics imposter
  86975. */
  86976. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  86977. /**
  86978. * Add a joint to this impostor with a different impostor
  86979. * @param otherImpostor A physics imposter used to add a joint
  86980. * @param joint The joint to add
  86981. * @returns The physics imposter
  86982. */
  86983. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  86984. /**
  86985. * Add an anchor to a cloth impostor
  86986. * @param otherImpostor rigid impostor to anchor to
  86987. * @param width ratio across width from 0 to 1
  86988. * @param height ratio up height from 0 to 1
  86989. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  86990. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  86991. * @returns impostor the soft imposter
  86992. */
  86993. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  86994. /**
  86995. * Add a hook to a rope impostor
  86996. * @param otherImpostor rigid impostor to anchor to
  86997. * @param length ratio across rope from 0 to 1
  86998. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  86999. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  87000. * @returns impostor the rope imposter
  87001. */
  87002. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87003. /**
  87004. * Will keep this body still, in a sleep mode.
  87005. * @returns the physics imposter
  87006. */
  87007. sleep(): PhysicsImpostor;
  87008. /**
  87009. * Wake the body up.
  87010. * @returns The physics imposter
  87011. */
  87012. wakeUp(): PhysicsImpostor;
  87013. /**
  87014. * Clones the physics imposter
  87015. * @param newObject The physics imposter clones to this physics-enabled object
  87016. * @returns A nullable physics imposter
  87017. */
  87018. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87019. /**
  87020. * Disposes the physics imposter
  87021. */
  87022. dispose(): void;
  87023. /**
  87024. * Sets the delta position
  87025. * @param position The delta position amount
  87026. */
  87027. setDeltaPosition(position: Vector3): void;
  87028. /**
  87029. * Sets the delta rotation
  87030. * @param rotation The delta rotation amount
  87031. */
  87032. setDeltaRotation(rotation: Quaternion): void;
  87033. /**
  87034. * Gets the box size of the physics imposter and stores the result in the input parameter
  87035. * @param result Stores the box size
  87036. * @returns The physics imposter
  87037. */
  87038. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  87039. /**
  87040. * Gets the radius of the physics imposter
  87041. * @returns Radius of the physics imposter
  87042. */
  87043. getRadius(): number;
  87044. /**
  87045. * Sync a bone with this impostor
  87046. * @param bone The bone to sync to the impostor.
  87047. * @param boneMesh The mesh that the bone is influencing.
  87048. * @param jointPivot The pivot of the joint / bone in local space.
  87049. * @param distToJoint Optional distance from the impostor to the joint.
  87050. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87051. */
  87052. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  87053. /**
  87054. * Sync impostor to a bone
  87055. * @param bone The bone that the impostor will be synced to.
  87056. * @param boneMesh The mesh that the bone is influencing.
  87057. * @param jointPivot The pivot of the joint / bone in local space.
  87058. * @param distToJoint Optional distance from the impostor to the joint.
  87059. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87060. * @param boneAxis Optional vector3 axis the bone is aligned with
  87061. */
  87062. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  87063. /**
  87064. * No-Imposter type
  87065. */
  87066. static NoImpostor: number;
  87067. /**
  87068. * Sphere-Imposter type
  87069. */
  87070. static SphereImpostor: number;
  87071. /**
  87072. * Box-Imposter type
  87073. */
  87074. static BoxImpostor: number;
  87075. /**
  87076. * Plane-Imposter type
  87077. */
  87078. static PlaneImpostor: number;
  87079. /**
  87080. * Mesh-imposter type
  87081. */
  87082. static MeshImpostor: number;
  87083. /**
  87084. * Capsule-Impostor type (Ammo.js plugin only)
  87085. */
  87086. static CapsuleImpostor: number;
  87087. /**
  87088. * Cylinder-Imposter type
  87089. */
  87090. static CylinderImpostor: number;
  87091. /**
  87092. * Particle-Imposter type
  87093. */
  87094. static ParticleImpostor: number;
  87095. /**
  87096. * Heightmap-Imposter type
  87097. */
  87098. static HeightmapImpostor: number;
  87099. /**
  87100. * ConvexHull-Impostor type (Ammo.js plugin only)
  87101. */
  87102. static ConvexHullImpostor: number;
  87103. /**
  87104. * Rope-Imposter type
  87105. */
  87106. static RopeImpostor: number;
  87107. /**
  87108. * Cloth-Imposter type
  87109. */
  87110. static ClothImpostor: number;
  87111. /**
  87112. * Softbody-Imposter type
  87113. */
  87114. static SoftbodyImpostor: number;
  87115. }
  87116. }
  87117. declare module BABYLON {
  87118. /**
  87119. * @hidden
  87120. **/
  87121. export class _CreationDataStorage {
  87122. closePath?: boolean;
  87123. closeArray?: boolean;
  87124. idx: number[];
  87125. dashSize: number;
  87126. gapSize: number;
  87127. path3D: Path3D;
  87128. pathArray: Vector3[][];
  87129. arc: number;
  87130. radius: number;
  87131. cap: number;
  87132. tessellation: number;
  87133. }
  87134. /**
  87135. * @hidden
  87136. **/
  87137. class _InstanceDataStorage {
  87138. visibleInstances: any;
  87139. batchCache: _InstancesBatch;
  87140. instancesBufferSize: number;
  87141. instancesBuffer: Nullable<Buffer>;
  87142. instancesData: Float32Array;
  87143. overridenInstanceCount: number;
  87144. isFrozen: boolean;
  87145. previousBatch: Nullable<_InstancesBatch>;
  87146. hardwareInstancedRendering: boolean;
  87147. sideOrientation: number;
  87148. }
  87149. /**
  87150. * @hidden
  87151. **/
  87152. export class _InstancesBatch {
  87153. mustReturn: boolean;
  87154. visibleInstances: Nullable<InstancedMesh[]>[];
  87155. renderSelf: boolean[];
  87156. hardwareInstancedRendering: boolean[];
  87157. }
  87158. /**
  87159. * Class used to represent renderable models
  87160. */
  87161. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  87162. /**
  87163. * Mesh side orientation : usually the external or front surface
  87164. */
  87165. static readonly FRONTSIDE: number;
  87166. /**
  87167. * Mesh side orientation : usually the internal or back surface
  87168. */
  87169. static readonly BACKSIDE: number;
  87170. /**
  87171. * Mesh side orientation : both internal and external or front and back surfaces
  87172. */
  87173. static readonly DOUBLESIDE: number;
  87174. /**
  87175. * Mesh side orientation : by default, `FRONTSIDE`
  87176. */
  87177. static readonly DEFAULTSIDE: number;
  87178. /**
  87179. * Mesh cap setting : no cap
  87180. */
  87181. static readonly NO_CAP: number;
  87182. /**
  87183. * Mesh cap setting : one cap at the beginning of the mesh
  87184. */
  87185. static readonly CAP_START: number;
  87186. /**
  87187. * Mesh cap setting : one cap at the end of the mesh
  87188. */
  87189. static readonly CAP_END: number;
  87190. /**
  87191. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  87192. */
  87193. static readonly CAP_ALL: number;
  87194. /**
  87195. * Mesh pattern setting : no flip or rotate
  87196. */
  87197. static readonly NO_FLIP: number;
  87198. /**
  87199. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  87200. */
  87201. static readonly FLIP_TILE: number;
  87202. /**
  87203. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  87204. */
  87205. static readonly ROTATE_TILE: number;
  87206. /**
  87207. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  87208. */
  87209. static readonly FLIP_ROW: number;
  87210. /**
  87211. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  87212. */
  87213. static readonly ROTATE_ROW: number;
  87214. /**
  87215. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  87216. */
  87217. static readonly FLIP_N_ROTATE_TILE: number;
  87218. /**
  87219. * Mesh pattern setting : rotate pattern and rotate
  87220. */
  87221. static readonly FLIP_N_ROTATE_ROW: number;
  87222. /**
  87223. * Mesh tile positioning : part tiles same on left/right or top/bottom
  87224. */
  87225. static readonly CENTER: number;
  87226. /**
  87227. * Mesh tile positioning : part tiles on left
  87228. */
  87229. static readonly LEFT: number;
  87230. /**
  87231. * Mesh tile positioning : part tiles on right
  87232. */
  87233. static readonly RIGHT: number;
  87234. /**
  87235. * Mesh tile positioning : part tiles on top
  87236. */
  87237. static readonly TOP: number;
  87238. /**
  87239. * Mesh tile positioning : part tiles on bottom
  87240. */
  87241. static readonly BOTTOM: number;
  87242. /**
  87243. * Gets the default side orientation.
  87244. * @param orientation the orientation to value to attempt to get
  87245. * @returns the default orientation
  87246. * @hidden
  87247. */
  87248. static _GetDefaultSideOrientation(orientation?: number): number;
  87249. private _internalMeshDataInfo;
  87250. /**
  87251. * An event triggered before rendering the mesh
  87252. */
  87253. readonly onBeforeRenderObservable: Observable<Mesh>;
  87254. /**
  87255. * An event triggered before binding the mesh
  87256. */
  87257. readonly onBeforeBindObservable: Observable<Mesh>;
  87258. /**
  87259. * An event triggered after rendering the mesh
  87260. */
  87261. readonly onAfterRenderObservable: Observable<Mesh>;
  87262. /**
  87263. * An event triggered before drawing the mesh
  87264. */
  87265. readonly onBeforeDrawObservable: Observable<Mesh>;
  87266. private _onBeforeDrawObserver;
  87267. /**
  87268. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  87269. */
  87270. onBeforeDraw: () => void;
  87271. /**
  87272. * Gets the delay loading state of the mesh (when delay loading is turned on)
  87273. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  87274. */
  87275. delayLoadState: number;
  87276. /**
  87277. * Gets the list of instances created from this mesh
  87278. * it is not supposed to be modified manually.
  87279. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  87280. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87281. */
  87282. instances: InstancedMesh[];
  87283. /**
  87284. * Gets the file containing delay loading data for this mesh
  87285. */
  87286. delayLoadingFile: string;
  87287. /** @hidden */
  87288. _binaryInfo: any;
  87289. /**
  87290. * User defined function used to change how LOD level selection is done
  87291. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87292. */
  87293. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  87294. /**
  87295. * Gets or sets the morph target manager
  87296. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87297. */
  87298. morphTargetManager: Nullable<MorphTargetManager>;
  87299. /** @hidden */
  87300. _creationDataStorage: Nullable<_CreationDataStorage>;
  87301. /** @hidden */
  87302. _geometry: Nullable<Geometry>;
  87303. /** @hidden */
  87304. _delayInfo: Array<string>;
  87305. /** @hidden */
  87306. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  87307. /** @hidden */
  87308. _instanceDataStorage: _InstanceDataStorage;
  87309. private _effectiveMaterial;
  87310. /** @hidden */
  87311. _shouldGenerateFlatShading: boolean;
  87312. /** @hidden */
  87313. _originalBuilderSideOrientation: number;
  87314. /**
  87315. * Use this property to change the original side orientation defined at construction time
  87316. */
  87317. overrideMaterialSideOrientation: Nullable<number>;
  87318. /**
  87319. * Gets the source mesh (the one used to clone this one from)
  87320. */
  87321. readonly source: Nullable<Mesh>;
  87322. /**
  87323. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87324. */
  87325. isUnIndexed: boolean;
  87326. /**
  87327. * @constructor
  87328. * @param name The value used by scene.getMeshByName() to do a lookup.
  87329. * @param scene The scene to add this mesh to.
  87330. * @param parent The parent of this mesh, if it has one
  87331. * @param source An optional Mesh from which geometry is shared, cloned.
  87332. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87333. * When false, achieved by calling a clone(), also passing False.
  87334. * This will make creation of children, recursive.
  87335. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87336. */
  87337. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  87338. /**
  87339. * Gets the class name
  87340. * @returns the string "Mesh".
  87341. */
  87342. getClassName(): string;
  87343. /** @hidden */
  87344. readonly _isMesh: boolean;
  87345. /**
  87346. * Returns a description of this mesh
  87347. * @param fullDetails define if full details about this mesh must be used
  87348. * @returns a descriptive string representing this mesh
  87349. */
  87350. toString(fullDetails?: boolean): string;
  87351. /** @hidden */
  87352. _unBindEffect(): void;
  87353. /**
  87354. * Gets a boolean indicating if this mesh has LOD
  87355. */
  87356. readonly hasLODLevels: boolean;
  87357. /**
  87358. * Gets the list of MeshLODLevel associated with the current mesh
  87359. * @returns an array of MeshLODLevel
  87360. */
  87361. getLODLevels(): MeshLODLevel[];
  87362. private _sortLODLevels;
  87363. /**
  87364. * Add a mesh as LOD level triggered at the given distance.
  87365. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87366. * @param distance The distance from the center of the object to show this level
  87367. * @param mesh The mesh to be added as LOD level (can be null)
  87368. * @return This mesh (for chaining)
  87369. */
  87370. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  87371. /**
  87372. * Returns the LOD level mesh at the passed distance or null if not found.
  87373. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87374. * @param distance The distance from the center of the object to show this level
  87375. * @returns a Mesh or `null`
  87376. */
  87377. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  87378. /**
  87379. * Remove a mesh from the LOD array
  87380. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87381. * @param mesh defines the mesh to be removed
  87382. * @return This mesh (for chaining)
  87383. */
  87384. removeLODLevel(mesh: Mesh): Mesh;
  87385. /**
  87386. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  87387. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87388. * @param camera defines the camera to use to compute distance
  87389. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  87390. * @return This mesh (for chaining)
  87391. */
  87392. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  87393. /**
  87394. * Gets the mesh internal Geometry object
  87395. */
  87396. readonly geometry: Nullable<Geometry>;
  87397. /**
  87398. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  87399. * @returns the total number of vertices
  87400. */
  87401. getTotalVertices(): number;
  87402. /**
  87403. * Returns the content of an associated vertex buffer
  87404. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87405. * - VertexBuffer.PositionKind
  87406. * - VertexBuffer.UVKind
  87407. * - VertexBuffer.UV2Kind
  87408. * - VertexBuffer.UV3Kind
  87409. * - VertexBuffer.UV4Kind
  87410. * - VertexBuffer.UV5Kind
  87411. * - VertexBuffer.UV6Kind
  87412. * - VertexBuffer.ColorKind
  87413. * - VertexBuffer.MatricesIndicesKind
  87414. * - VertexBuffer.MatricesIndicesExtraKind
  87415. * - VertexBuffer.MatricesWeightsKind
  87416. * - VertexBuffer.MatricesWeightsExtraKind
  87417. * @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
  87418. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  87419. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  87420. */
  87421. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87422. /**
  87423. * Returns the mesh VertexBuffer object from the requested `kind`
  87424. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87425. * - VertexBuffer.PositionKind
  87426. * - VertexBuffer.NormalKind
  87427. * - VertexBuffer.UVKind
  87428. * - VertexBuffer.UV2Kind
  87429. * - VertexBuffer.UV3Kind
  87430. * - VertexBuffer.UV4Kind
  87431. * - VertexBuffer.UV5Kind
  87432. * - VertexBuffer.UV6Kind
  87433. * - VertexBuffer.ColorKind
  87434. * - VertexBuffer.MatricesIndicesKind
  87435. * - VertexBuffer.MatricesIndicesExtraKind
  87436. * - VertexBuffer.MatricesWeightsKind
  87437. * - VertexBuffer.MatricesWeightsExtraKind
  87438. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  87439. */
  87440. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87441. /**
  87442. * Tests if a specific vertex buffer is associated with this mesh
  87443. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87444. * - VertexBuffer.PositionKind
  87445. * - VertexBuffer.NormalKind
  87446. * - VertexBuffer.UVKind
  87447. * - VertexBuffer.UV2Kind
  87448. * - VertexBuffer.UV3Kind
  87449. * - VertexBuffer.UV4Kind
  87450. * - VertexBuffer.UV5Kind
  87451. * - VertexBuffer.UV6Kind
  87452. * - VertexBuffer.ColorKind
  87453. * - VertexBuffer.MatricesIndicesKind
  87454. * - VertexBuffer.MatricesIndicesExtraKind
  87455. * - VertexBuffer.MatricesWeightsKind
  87456. * - VertexBuffer.MatricesWeightsExtraKind
  87457. * @returns a boolean
  87458. */
  87459. isVerticesDataPresent(kind: string): boolean;
  87460. /**
  87461. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  87462. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87463. * - VertexBuffer.PositionKind
  87464. * - VertexBuffer.UVKind
  87465. * - VertexBuffer.UV2Kind
  87466. * - VertexBuffer.UV3Kind
  87467. * - VertexBuffer.UV4Kind
  87468. * - VertexBuffer.UV5Kind
  87469. * - VertexBuffer.UV6Kind
  87470. * - VertexBuffer.ColorKind
  87471. * - VertexBuffer.MatricesIndicesKind
  87472. * - VertexBuffer.MatricesIndicesExtraKind
  87473. * - VertexBuffer.MatricesWeightsKind
  87474. * - VertexBuffer.MatricesWeightsExtraKind
  87475. * @returns a boolean
  87476. */
  87477. isVertexBufferUpdatable(kind: string): boolean;
  87478. /**
  87479. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  87480. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87481. * - VertexBuffer.PositionKind
  87482. * - VertexBuffer.NormalKind
  87483. * - VertexBuffer.UVKind
  87484. * - VertexBuffer.UV2Kind
  87485. * - VertexBuffer.UV3Kind
  87486. * - VertexBuffer.UV4Kind
  87487. * - VertexBuffer.UV5Kind
  87488. * - VertexBuffer.UV6Kind
  87489. * - VertexBuffer.ColorKind
  87490. * - VertexBuffer.MatricesIndicesKind
  87491. * - VertexBuffer.MatricesIndicesExtraKind
  87492. * - VertexBuffer.MatricesWeightsKind
  87493. * - VertexBuffer.MatricesWeightsExtraKind
  87494. * @returns an array of strings
  87495. */
  87496. getVerticesDataKinds(): string[];
  87497. /**
  87498. * Returns a positive integer : the total number of indices in this mesh geometry.
  87499. * @returns the numner of indices or zero if the mesh has no geometry.
  87500. */
  87501. getTotalIndices(): number;
  87502. /**
  87503. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87504. * @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.
  87505. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87506. * @returns the indices array or an empty array if the mesh has no geometry
  87507. */
  87508. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87509. readonly isBlocked: boolean;
  87510. /**
  87511. * Determine if the current mesh is ready to be rendered
  87512. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87513. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  87514. * @returns true if all associated assets are ready (material, textures, shaders)
  87515. */
  87516. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  87517. /**
  87518. * 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.
  87519. */
  87520. readonly areNormalsFrozen: boolean;
  87521. /**
  87522. * 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.
  87523. * @returns the current mesh
  87524. */
  87525. freezeNormals(): Mesh;
  87526. /**
  87527. * 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
  87528. * @returns the current mesh
  87529. */
  87530. unfreezeNormals(): Mesh;
  87531. /**
  87532. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  87533. */
  87534. overridenInstanceCount: number;
  87535. /** @hidden */
  87536. _preActivate(): Mesh;
  87537. /** @hidden */
  87538. _preActivateForIntermediateRendering(renderId: number): Mesh;
  87539. /** @hidden */
  87540. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  87541. /**
  87542. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87543. * This means the mesh underlying bounding box and sphere are recomputed.
  87544. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87545. * @returns the current mesh
  87546. */
  87547. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  87548. /** @hidden */
  87549. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  87550. /**
  87551. * This function will subdivide the mesh into multiple submeshes
  87552. * @param count defines the expected number of submeshes
  87553. */
  87554. subdivide(count: number): void;
  87555. /**
  87556. * Copy a FloatArray into a specific associated vertex buffer
  87557. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87558. * - VertexBuffer.PositionKind
  87559. * - VertexBuffer.UVKind
  87560. * - VertexBuffer.UV2Kind
  87561. * - VertexBuffer.UV3Kind
  87562. * - VertexBuffer.UV4Kind
  87563. * - VertexBuffer.UV5Kind
  87564. * - VertexBuffer.UV6Kind
  87565. * - VertexBuffer.ColorKind
  87566. * - VertexBuffer.MatricesIndicesKind
  87567. * - VertexBuffer.MatricesIndicesExtraKind
  87568. * - VertexBuffer.MatricesWeightsKind
  87569. * - VertexBuffer.MatricesWeightsExtraKind
  87570. * @param data defines the data source
  87571. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87572. * @param stride defines the data stride size (can be null)
  87573. * @returns the current mesh
  87574. */
  87575. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  87576. /**
  87577. * Flags an associated vertex buffer as updatable
  87578. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  87579. * - VertexBuffer.PositionKind
  87580. * - VertexBuffer.UVKind
  87581. * - VertexBuffer.UV2Kind
  87582. * - VertexBuffer.UV3Kind
  87583. * - VertexBuffer.UV4Kind
  87584. * - VertexBuffer.UV5Kind
  87585. * - VertexBuffer.UV6Kind
  87586. * - VertexBuffer.ColorKind
  87587. * - VertexBuffer.MatricesIndicesKind
  87588. * - VertexBuffer.MatricesIndicesExtraKind
  87589. * - VertexBuffer.MatricesWeightsKind
  87590. * - VertexBuffer.MatricesWeightsExtraKind
  87591. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87592. */
  87593. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  87594. /**
  87595. * Sets the mesh global Vertex Buffer
  87596. * @param buffer defines the buffer to use
  87597. * @returns the current mesh
  87598. */
  87599. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  87600. /**
  87601. * Update a specific associated vertex buffer
  87602. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87603. * - VertexBuffer.PositionKind
  87604. * - VertexBuffer.UVKind
  87605. * - VertexBuffer.UV2Kind
  87606. * - VertexBuffer.UV3Kind
  87607. * - VertexBuffer.UV4Kind
  87608. * - VertexBuffer.UV5Kind
  87609. * - VertexBuffer.UV6Kind
  87610. * - VertexBuffer.ColorKind
  87611. * - VertexBuffer.MatricesIndicesKind
  87612. * - VertexBuffer.MatricesIndicesExtraKind
  87613. * - VertexBuffer.MatricesWeightsKind
  87614. * - VertexBuffer.MatricesWeightsExtraKind
  87615. * @param data defines the data source
  87616. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87617. * @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)
  87618. * @returns the current mesh
  87619. */
  87620. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87621. /**
  87622. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  87623. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  87624. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  87625. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  87626. * @returns the current mesh
  87627. */
  87628. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  87629. /**
  87630. * Creates a un-shared specific occurence of the geometry for the mesh.
  87631. * @returns the current mesh
  87632. */
  87633. makeGeometryUnique(): Mesh;
  87634. /**
  87635. * Set the index buffer of this mesh
  87636. * @param indices defines the source data
  87637. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  87638. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  87639. * @returns the current mesh
  87640. */
  87641. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  87642. /**
  87643. * Update the current index buffer
  87644. * @param indices defines the source data
  87645. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87646. * @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)
  87647. * @returns the current mesh
  87648. */
  87649. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  87650. /**
  87651. * Invert the geometry to move from a right handed system to a left handed one.
  87652. * @returns the current mesh
  87653. */
  87654. toLeftHanded(): Mesh;
  87655. /** @hidden */
  87656. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87657. /** @hidden */
  87658. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87659. /**
  87660. * Registers for this mesh a javascript function called just before the rendering process
  87661. * @param func defines the function to call before rendering this mesh
  87662. * @returns the current mesh
  87663. */
  87664. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87665. /**
  87666. * Disposes a previously registered javascript function called before the rendering
  87667. * @param func defines the function to remove
  87668. * @returns the current mesh
  87669. */
  87670. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87671. /**
  87672. * Registers for this mesh a javascript function called just after the rendering is complete
  87673. * @param func defines the function to call after rendering this mesh
  87674. * @returns the current mesh
  87675. */
  87676. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87677. /**
  87678. * Disposes a previously registered javascript function called after the rendering.
  87679. * @param func defines the function to remove
  87680. * @returns the current mesh
  87681. */
  87682. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87683. /** @hidden */
  87684. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  87685. /** @hidden */
  87686. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  87687. /** @hidden */
  87688. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  87689. /** @hidden */
  87690. _rebuild(): void;
  87691. /** @hidden */
  87692. _freeze(): void;
  87693. /** @hidden */
  87694. _unFreeze(): void;
  87695. /**
  87696. * 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
  87697. * @param subMesh defines the subMesh to render
  87698. * @param enableAlphaMode defines if alpha mode can be changed
  87699. * @returns the current mesh
  87700. */
  87701. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  87702. private _onBeforeDraw;
  87703. /**
  87704. * Renormalize the mesh and patch it up if there are no weights
  87705. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  87706. * However in the case of zero weights then we set just a single influence to 1.
  87707. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  87708. */
  87709. cleanMatrixWeights(): void;
  87710. private normalizeSkinFourWeights;
  87711. private normalizeSkinWeightsAndExtra;
  87712. /**
  87713. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  87714. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  87715. * the user know there was an issue with importing the mesh
  87716. * @returns a validation object with skinned, valid and report string
  87717. */
  87718. validateSkinning(): {
  87719. skinned: boolean;
  87720. valid: boolean;
  87721. report: string;
  87722. };
  87723. /** @hidden */
  87724. _checkDelayState(): Mesh;
  87725. private _queueLoad;
  87726. /**
  87727. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87728. * A mesh is in the frustum if its bounding box intersects the frustum
  87729. * @param frustumPlanes defines the frustum to test
  87730. * @returns true if the mesh is in the frustum planes
  87731. */
  87732. isInFrustum(frustumPlanes: Plane[]): boolean;
  87733. /**
  87734. * Sets the mesh material by the material or multiMaterial `id` property
  87735. * @param id is a string identifying the material or the multiMaterial
  87736. * @returns the current mesh
  87737. */
  87738. setMaterialByID(id: string): Mesh;
  87739. /**
  87740. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  87741. * @returns an array of IAnimatable
  87742. */
  87743. getAnimatables(): IAnimatable[];
  87744. /**
  87745. * Modifies the mesh geometry according to the passed transformation matrix.
  87746. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  87747. * The mesh normals are modified using the same transformation.
  87748. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87749. * @param transform defines the transform matrix to use
  87750. * @see http://doc.babylonjs.com/resources/baking_transformations
  87751. * @returns the current mesh
  87752. */
  87753. bakeTransformIntoVertices(transform: Matrix): Mesh;
  87754. /**
  87755. * Modifies the mesh geometry according to its own current World Matrix.
  87756. * The mesh World Matrix is then reset.
  87757. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  87758. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87759. * @see http://doc.babylonjs.com/resources/baking_transformations
  87760. * @returns the current mesh
  87761. */
  87762. bakeCurrentTransformIntoVertices(): Mesh;
  87763. /** @hidden */
  87764. readonly _positions: Nullable<Vector3[]>;
  87765. /** @hidden */
  87766. _resetPointsArrayCache(): Mesh;
  87767. /** @hidden */
  87768. _generatePointsArray(): boolean;
  87769. /**
  87770. * Returns a new Mesh object generated from the current mesh properties.
  87771. * This method must not get confused with createInstance()
  87772. * @param name is a string, the name given to the new mesh
  87773. * @param newParent can be any Node object (default `null`)
  87774. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  87775. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  87776. * @returns a new mesh
  87777. */
  87778. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  87779. /**
  87780. * Releases resources associated with this mesh.
  87781. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87782. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87783. */
  87784. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87785. /**
  87786. * Modifies the mesh geometry according to a displacement map.
  87787. * 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.
  87788. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87789. * @param url is a string, the URL from the image file is to be downloaded.
  87790. * @param minHeight is the lower limit of the displacement.
  87791. * @param maxHeight is the upper limit of the displacement.
  87792. * @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.
  87793. * @param uvOffset is an optional vector2 used to offset UV.
  87794. * @param uvScale is an optional vector2 used to scale UV.
  87795. * @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.
  87796. * @returns the Mesh.
  87797. */
  87798. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87799. /**
  87800. * Modifies the mesh geometry according to a displacementMap buffer.
  87801. * 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.
  87802. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87803. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  87804. * @param heightMapWidth is the width of the buffer image.
  87805. * @param heightMapHeight is the height of the buffer image.
  87806. * @param minHeight is the lower limit of the displacement.
  87807. * @param maxHeight is the upper limit of the displacement.
  87808. * @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.
  87809. * @param uvOffset is an optional vector2 used to offset UV.
  87810. * @param uvScale is an optional vector2 used to scale UV.
  87811. * @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.
  87812. * @returns the Mesh.
  87813. */
  87814. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87815. /**
  87816. * Modify the mesh to get a flat shading rendering.
  87817. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  87818. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  87819. * @returns current mesh
  87820. */
  87821. convertToFlatShadedMesh(): Mesh;
  87822. /**
  87823. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  87824. * In other words, more vertices, no more indices and a single bigger VBO.
  87825. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  87826. * @returns current mesh
  87827. */
  87828. convertToUnIndexedMesh(): Mesh;
  87829. /**
  87830. * Inverses facet orientations.
  87831. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87832. * @param flipNormals will also inverts the normals
  87833. * @returns current mesh
  87834. */
  87835. flipFaces(flipNormals?: boolean): Mesh;
  87836. /**
  87837. * Increase the number of facets and hence vertices in a mesh
  87838. * Vertex normals are interpolated from existing vertex normals
  87839. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87840. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  87841. */
  87842. increaseVertices(numberPerEdge: number): void;
  87843. /**
  87844. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  87845. * This will undo any application of covertToFlatShadedMesh
  87846. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87847. */
  87848. forceSharedVertices(): void;
  87849. /** @hidden */
  87850. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  87851. /** @hidden */
  87852. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  87853. /**
  87854. * Creates a new InstancedMesh object from the mesh model.
  87855. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87856. * @param name defines the name of the new instance
  87857. * @returns a new InstancedMesh
  87858. */
  87859. createInstance(name: string): InstancedMesh;
  87860. /**
  87861. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  87862. * After this call, all the mesh instances have the same submeshes than the current mesh.
  87863. * @returns the current mesh
  87864. */
  87865. synchronizeInstances(): Mesh;
  87866. /**
  87867. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  87868. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  87869. * This should be used together with the simplification to avoid disappearing triangles.
  87870. * @param successCallback an optional success callback to be called after the optimization finished.
  87871. * @returns the current mesh
  87872. */
  87873. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  87874. /**
  87875. * Serialize current mesh
  87876. * @param serializationObject defines the object which will receive the serialization data
  87877. */
  87878. serialize(serializationObject: any): void;
  87879. /** @hidden */
  87880. _syncGeometryWithMorphTargetManager(): void;
  87881. /** @hidden */
  87882. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  87883. /**
  87884. * Returns a new Mesh object parsed from the source provided.
  87885. * @param parsedMesh is the source
  87886. * @param scene defines the hosting scene
  87887. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  87888. * @returns a new Mesh
  87889. */
  87890. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  87891. /**
  87892. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  87893. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87894. * @param name defines the name of the mesh to create
  87895. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  87896. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  87897. * @param closePath creates a seam between the first and the last points of each path of the path array
  87898. * @param offset is taken in account only if the `pathArray` is containing a single path
  87899. * @param scene defines the hosting scene
  87900. * @param updatable defines if the mesh must be flagged as updatable
  87901. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87902. * @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)
  87903. * @returns a new Mesh
  87904. */
  87905. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87906. /**
  87907. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  87908. * @param name defines the name of the mesh to create
  87909. * @param radius sets the radius size (float) of the polygon (default 0.5)
  87910. * @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
  87911. * @param scene defines the hosting scene
  87912. * @param updatable defines if the mesh must be flagged as updatable
  87913. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87914. * @returns a new Mesh
  87915. */
  87916. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87917. /**
  87918. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  87919. * @param name defines the name of the mesh to create
  87920. * @param size sets the size (float) of each box side (default 1)
  87921. * @param scene defines the hosting scene
  87922. * @param updatable defines if the mesh must be flagged as updatable
  87923. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87924. * @returns a new Mesh
  87925. */
  87926. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87927. /**
  87928. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  87929. * @param name defines the name of the mesh to create
  87930. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87931. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87932. * @param scene defines the hosting scene
  87933. * @param updatable defines if the mesh must be flagged as updatable
  87934. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87935. * @returns a new Mesh
  87936. */
  87937. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87938. /**
  87939. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  87940. * @param name defines the name of the mesh to create
  87941. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87942. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87943. * @param scene defines the hosting scene
  87944. * @returns a new Mesh
  87945. */
  87946. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  87947. /**
  87948. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  87949. * @param name defines the name of the mesh to create
  87950. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  87951. * @param diameterTop set the top cap diameter (floats, default 1)
  87952. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  87953. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  87954. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  87955. * @param scene defines the hosting scene
  87956. * @param updatable defines if the mesh must be flagged as updatable
  87957. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87958. * @returns a new Mesh
  87959. */
  87960. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  87961. /**
  87962. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  87963. * @param name defines the name of the mesh to create
  87964. * @param diameter sets the diameter size (float) of the torus (default 1)
  87965. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  87966. * @param tessellation sets the number of torus sides (postive integer, default 16)
  87967. * @param scene defines the hosting scene
  87968. * @param updatable defines if the mesh must be flagged as updatable
  87969. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87970. * @returns a new Mesh
  87971. */
  87972. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87973. /**
  87974. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  87975. * @param name defines the name of the mesh to create
  87976. * @param radius sets the global radius size (float) of the torus knot (default 2)
  87977. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  87978. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  87979. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  87980. * @param p the number of windings on X axis (positive integers, default 2)
  87981. * @param q the number of windings on Y axis (positive integers, default 3)
  87982. * @param scene defines the hosting scene
  87983. * @param updatable defines if the mesh must be flagged as updatable
  87984. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87985. * @returns a new Mesh
  87986. */
  87987. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87988. /**
  87989. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  87990. * @param name defines the name of the mesh to create
  87991. * @param points is an array successive Vector3
  87992. * @param scene defines the hosting scene
  87993. * @param updatable defines if the mesh must be flagged as updatable
  87994. * @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).
  87995. * @returns a new Mesh
  87996. */
  87997. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  87998. /**
  87999. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  88000. * @param name defines the name of the mesh to create
  88001. * @param points is an array successive Vector3
  88002. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  88003. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88004. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  88005. * @param scene defines the hosting scene
  88006. * @param updatable defines if the mesh must be flagged as updatable
  88007. * @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)
  88008. * @returns a new Mesh
  88009. */
  88010. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  88011. /**
  88012. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  88013. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  88014. * 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.
  88015. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88016. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88017. * Remember you can only change the shape positions, not their number when updating a polygon.
  88018. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  88019. * @param name defines the name of the mesh to create
  88020. * @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
  88021. * @param scene defines the hosting scene
  88022. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88023. * @param updatable defines if the mesh must be flagged as updatable
  88024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88025. * @param earcutInjection can be used to inject your own earcut reference
  88026. * @returns a new Mesh
  88027. */
  88028. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88029. /**
  88030. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  88031. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  88032. * @param name defines the name of the mesh to create
  88033. * @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
  88034. * @param depth defines the height of extrusion
  88035. * @param scene defines the hosting scene
  88036. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88037. * @param updatable defines if the mesh must be flagged as updatable
  88038. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88039. * @param earcutInjection can be used to inject your own earcut reference
  88040. * @returns a new Mesh
  88041. */
  88042. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88043. /**
  88044. * Creates an extruded shape mesh.
  88045. * 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
  88046. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88047. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88048. * @param name defines the name of the mesh to create
  88049. * @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
  88050. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88051. * @param scale is the value to scale the shape
  88052. * @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
  88053. * @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
  88054. * @param scene defines the hosting scene
  88055. * @param updatable defines if the mesh must be flagged as updatable
  88056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88057. * @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)
  88058. * @returns a new Mesh
  88059. */
  88060. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88061. /**
  88062. * Creates an custom extruded shape mesh.
  88063. * The custom extrusion is a parametric shape.
  88064. * It has no predefined shape. Its final shape will depend on the input parameters.
  88065. * Please consider using the same method from the MeshBuilder class instead
  88066. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88067. * @param name defines the name of the mesh to create
  88068. * @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
  88069. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88070. * @param scaleFunction is a custom Javascript function called on each path point
  88071. * @param rotationFunction is a custom Javascript function called on each path point
  88072. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88073. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  88074. * @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
  88075. * @param scene defines the hosting scene
  88076. * @param updatable defines if the mesh must be flagged as updatable
  88077. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88078. * @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)
  88079. * @returns a new Mesh
  88080. */
  88081. 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;
  88082. /**
  88083. * Creates lathe mesh.
  88084. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  88085. * Please consider using the same method from the MeshBuilder class instead
  88086. * @param name defines the name of the mesh to create
  88087. * @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
  88088. * @param radius is the radius value of the lathe
  88089. * @param tessellation is the side number of the lathe.
  88090. * @param scene defines the hosting scene
  88091. * @param updatable defines if the mesh must be flagged as updatable
  88092. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88093. * @returns a new Mesh
  88094. */
  88095. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88096. /**
  88097. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  88098. * @param name defines the name of the mesh to create
  88099. * @param size sets the size (float) of both sides of the plane at once (default 1)
  88100. * @param scene defines the hosting scene
  88101. * @param updatable defines if the mesh must be flagged as updatable
  88102. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88103. * @returns a new Mesh
  88104. */
  88105. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88106. /**
  88107. * Creates a ground mesh.
  88108. * Please consider using the same method from the MeshBuilder class instead
  88109. * @param name defines the name of the mesh to create
  88110. * @param width set the width of the ground
  88111. * @param height set the height of the ground
  88112. * @param subdivisions sets the number of subdivisions per side
  88113. * @param scene defines the hosting scene
  88114. * @param updatable defines if the mesh must be flagged as updatable
  88115. * @returns a new Mesh
  88116. */
  88117. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  88118. /**
  88119. * Creates a tiled ground mesh.
  88120. * Please consider using the same method from the MeshBuilder class instead
  88121. * @param name defines the name of the mesh to create
  88122. * @param xmin set the ground minimum X coordinate
  88123. * @param zmin set the ground minimum Y coordinate
  88124. * @param xmax set the ground maximum X coordinate
  88125. * @param zmax set the ground maximum Z coordinate
  88126. * @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
  88127. * @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
  88128. * @param scene defines the hosting scene
  88129. * @param updatable defines if the mesh must be flagged as updatable
  88130. * @returns a new Mesh
  88131. */
  88132. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  88133. w: number;
  88134. h: number;
  88135. }, precision: {
  88136. w: number;
  88137. h: number;
  88138. }, scene: Scene, updatable?: boolean): Mesh;
  88139. /**
  88140. * Creates a ground mesh from a height map.
  88141. * Please consider using the same method from the MeshBuilder class instead
  88142. * @see http://doc.babylonjs.com/babylon101/height_map
  88143. * @param name defines the name of the mesh to create
  88144. * @param url sets the URL of the height map image resource
  88145. * @param width set the ground width size
  88146. * @param height set the ground height size
  88147. * @param subdivisions sets the number of subdivision per side
  88148. * @param minHeight is the minimum altitude on the ground
  88149. * @param maxHeight is the maximum altitude on the ground
  88150. * @param scene defines the hosting scene
  88151. * @param updatable defines if the mesh must be flagged as updatable
  88152. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  88153. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88154. * @returns a new Mesh
  88155. */
  88156. 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;
  88157. /**
  88158. * Creates a tube mesh.
  88159. * The tube is a parametric shape.
  88160. * It has no predefined shape. Its final shape will depend on the input parameters.
  88161. * Please consider using the same method from the MeshBuilder class instead
  88162. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88163. * @param name defines the name of the mesh to create
  88164. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  88165. * @param radius sets the tube radius size
  88166. * @param tessellation is the number of sides on the tubular surface
  88167. * @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
  88168. * @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
  88169. * @param scene defines the hosting scene
  88170. * @param updatable defines if the mesh must be flagged as updatable
  88171. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88172. * @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)
  88173. * @returns a new Mesh
  88174. */
  88175. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  88176. (i: number, distance: number): number;
  88177. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88178. /**
  88179. * Creates a polyhedron mesh.
  88180. * Please consider using the same method from the MeshBuilder class instead.
  88181. * * 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
  88182. * * The parameter `size` (positive float, default 1) sets the polygon size
  88183. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88184. * * 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`
  88185. * * 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
  88186. * * 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)`)
  88187. * * 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
  88188. * * 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
  88189. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88190. * * If you create a double-sided mesh, you can choose what parts of 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
  88191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88192. * @param name defines the name of the mesh to create
  88193. * @param options defines the options used to create the mesh
  88194. * @param scene defines the hosting scene
  88195. * @returns a new Mesh
  88196. */
  88197. static CreatePolyhedron(name: string, options: {
  88198. type?: number;
  88199. size?: number;
  88200. sizeX?: number;
  88201. sizeY?: number;
  88202. sizeZ?: number;
  88203. custom?: any;
  88204. faceUV?: Vector4[];
  88205. faceColors?: Color4[];
  88206. updatable?: boolean;
  88207. sideOrientation?: number;
  88208. }, scene: Scene): Mesh;
  88209. /**
  88210. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88211. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88212. * * 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`)
  88213. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88214. * * 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
  88215. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88216. * * If you create a double-sided mesh, you can choose what parts of 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
  88217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88218. * @param name defines the name of the mesh
  88219. * @param options defines the options used to create the mesh
  88220. * @param scene defines the hosting scene
  88221. * @returns a new Mesh
  88222. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88223. */
  88224. static CreateIcoSphere(name: string, options: {
  88225. radius?: number;
  88226. flat?: boolean;
  88227. subdivisions?: number;
  88228. sideOrientation?: number;
  88229. updatable?: boolean;
  88230. }, scene: Scene): Mesh;
  88231. /**
  88232. * Creates a decal mesh.
  88233. * Please consider using the same method from the MeshBuilder class instead.
  88234. * A decal is a mesh usually applied as a model onto the surface of another mesh
  88235. * @param name defines the name of the mesh
  88236. * @param sourceMesh defines the mesh receiving the decal
  88237. * @param position sets the position of the decal in world coordinates
  88238. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  88239. * @param size sets the decal scaling
  88240. * @param angle sets the angle to rotate the decal
  88241. * @returns a new Mesh
  88242. */
  88243. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  88244. /**
  88245. * Prepare internal position array for software CPU skinning
  88246. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  88247. */
  88248. setPositionsForCPUSkinning(): Float32Array;
  88249. /**
  88250. * Prepare internal normal array for software CPU skinning
  88251. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  88252. */
  88253. setNormalsForCPUSkinning(): Float32Array;
  88254. /**
  88255. * Updates the vertex buffer by applying transformation from the bones
  88256. * @param skeleton defines the skeleton to apply to current mesh
  88257. * @returns the current mesh
  88258. */
  88259. applySkeleton(skeleton: Skeleton): Mesh;
  88260. /**
  88261. * 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
  88262. * @param meshes defines the list of meshes to scan
  88263. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  88264. */
  88265. static MinMax(meshes: AbstractMesh[]): {
  88266. min: Vector3;
  88267. max: Vector3;
  88268. };
  88269. /**
  88270. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  88271. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  88272. * @returns a vector3
  88273. */
  88274. static Center(meshesOrMinMaxVector: {
  88275. min: Vector3;
  88276. max: Vector3;
  88277. } | AbstractMesh[]): Vector3;
  88278. /**
  88279. * Merge the array of meshes into a single mesh for performance reasons.
  88280. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  88281. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  88282. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  88283. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  88284. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  88285. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  88286. * @returns a new mesh
  88287. */
  88288. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  88289. /** @hidden */
  88290. addInstance(instance: InstancedMesh): void;
  88291. /** @hidden */
  88292. removeInstance(instance: InstancedMesh): void;
  88293. }
  88294. }
  88295. declare module BABYLON {
  88296. /**
  88297. * This is the base class of all the camera used in the application.
  88298. * @see http://doc.babylonjs.com/features/cameras
  88299. */
  88300. export class Camera extends Node {
  88301. /** @hidden */
  88302. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88303. /**
  88304. * This is the default projection mode used by the cameras.
  88305. * It helps recreating a feeling of perspective and better appreciate depth.
  88306. * This is the best way to simulate real life cameras.
  88307. */
  88308. static readonly PERSPECTIVE_CAMERA: number;
  88309. /**
  88310. * This helps creating camera with an orthographic mode.
  88311. * 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.
  88312. */
  88313. static readonly ORTHOGRAPHIC_CAMERA: number;
  88314. /**
  88315. * This is the default FOV mode for perspective cameras.
  88316. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88317. */
  88318. static readonly FOVMODE_VERTICAL_FIXED: number;
  88319. /**
  88320. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88321. */
  88322. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88323. /**
  88324. * This specifies ther is no need for a camera rig.
  88325. * Basically only one eye is rendered corresponding to the camera.
  88326. */
  88327. static readonly RIG_MODE_NONE: number;
  88328. /**
  88329. * Simulates a camera Rig with one blue eye and one red eye.
  88330. * This can be use with 3d blue and red glasses.
  88331. */
  88332. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88333. /**
  88334. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88335. */
  88336. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88337. /**
  88338. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88339. */
  88340. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88341. /**
  88342. * Defines that both eyes of the camera will be rendered over under each other.
  88343. */
  88344. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88345. /**
  88346. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88347. */
  88348. static readonly RIG_MODE_VR: number;
  88349. /**
  88350. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88351. */
  88352. static readonly RIG_MODE_WEBVR: number;
  88353. /**
  88354. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88355. */
  88356. static readonly RIG_MODE_CUSTOM: number;
  88357. /**
  88358. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88359. */
  88360. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88361. /**
  88362. * Define the input manager associated with the camera.
  88363. */
  88364. inputs: CameraInputsManager<Camera>;
  88365. /** @hidden */
  88366. _position: Vector3;
  88367. /**
  88368. * Define the current local position of the camera in the scene
  88369. */
  88370. position: Vector3;
  88371. /**
  88372. * The vector the camera should consider as up.
  88373. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88374. */
  88375. upVector: Vector3;
  88376. /**
  88377. * Define the current limit on the left side for an orthographic camera
  88378. * In scene unit
  88379. */
  88380. orthoLeft: Nullable<number>;
  88381. /**
  88382. * Define the current limit on the right side for an orthographic camera
  88383. * In scene unit
  88384. */
  88385. orthoRight: Nullable<number>;
  88386. /**
  88387. * Define the current limit on the bottom side for an orthographic camera
  88388. * In scene unit
  88389. */
  88390. orthoBottom: Nullable<number>;
  88391. /**
  88392. * Define the current limit on the top side for an orthographic camera
  88393. * In scene unit
  88394. */
  88395. orthoTop: Nullable<number>;
  88396. /**
  88397. * Field Of View is set in Radians. (default is 0.8)
  88398. */
  88399. fov: number;
  88400. /**
  88401. * Define the minimum distance the camera can see from.
  88402. * This is important to note that the depth buffer are not infinite and the closer it starts
  88403. * the more your scene might encounter depth fighting issue.
  88404. */
  88405. minZ: number;
  88406. /**
  88407. * Define the maximum distance the camera can see to.
  88408. * This is important to note that the depth buffer are not infinite and the further it end
  88409. * the more your scene might encounter depth fighting issue.
  88410. */
  88411. maxZ: number;
  88412. /**
  88413. * Define the default inertia of the camera.
  88414. * This helps giving a smooth feeling to the camera movement.
  88415. */
  88416. inertia: number;
  88417. /**
  88418. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  88419. */
  88420. mode: number;
  88421. /**
  88422. * Define wether the camera is intermediate.
  88423. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88424. */
  88425. isIntermediate: boolean;
  88426. /**
  88427. * Define the viewport of the camera.
  88428. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88429. */
  88430. viewport: Viewport;
  88431. /**
  88432. * Restricts the camera to viewing objects with the same layerMask.
  88433. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88434. */
  88435. layerMask: number;
  88436. /**
  88437. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88438. */
  88439. fovMode: number;
  88440. /**
  88441. * Rig mode of the camera.
  88442. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88443. * This is normally controlled byt the camera themselves as internal use.
  88444. */
  88445. cameraRigMode: number;
  88446. /**
  88447. * Defines the distance between both "eyes" in case of a RIG
  88448. */
  88449. interaxialDistance: number;
  88450. /**
  88451. * Defines if stereoscopic rendering is done side by side or over under.
  88452. */
  88453. isStereoscopicSideBySide: boolean;
  88454. /**
  88455. * 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
  88456. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88457. * else in the scene. (Eg. security camera)
  88458. *
  88459. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  88460. */
  88461. customRenderTargets: RenderTargetTexture[];
  88462. /**
  88463. * When set, the camera will render to this render target instead of the default canvas
  88464. *
  88465. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  88466. */
  88467. outputRenderTarget: Nullable<RenderTargetTexture>;
  88468. /**
  88469. * Observable triggered when the camera view matrix has changed.
  88470. */
  88471. onViewMatrixChangedObservable: Observable<Camera>;
  88472. /**
  88473. * Observable triggered when the camera Projection matrix has changed.
  88474. */
  88475. onProjectionMatrixChangedObservable: Observable<Camera>;
  88476. /**
  88477. * Observable triggered when the inputs have been processed.
  88478. */
  88479. onAfterCheckInputsObservable: Observable<Camera>;
  88480. /**
  88481. * Observable triggered when reset has been called and applied to the camera.
  88482. */
  88483. onRestoreStateObservable: Observable<Camera>;
  88484. /** @hidden */
  88485. _cameraRigParams: any;
  88486. /** @hidden */
  88487. _rigCameras: Camera[];
  88488. /** @hidden */
  88489. _rigPostProcess: Nullable<PostProcess>;
  88490. protected _webvrViewMatrix: Matrix;
  88491. /** @hidden */
  88492. _skipRendering: boolean;
  88493. /** @hidden */
  88494. _projectionMatrix: Matrix;
  88495. /** @hidden */
  88496. _postProcesses: Nullable<PostProcess>[];
  88497. /** @hidden */
  88498. _activeMeshes: SmartArray<AbstractMesh>;
  88499. protected _globalPosition: Vector3;
  88500. /** @hidden */
  88501. _computedViewMatrix: Matrix;
  88502. private _doNotComputeProjectionMatrix;
  88503. private _transformMatrix;
  88504. private _frustumPlanes;
  88505. private _refreshFrustumPlanes;
  88506. private _storedFov;
  88507. private _stateStored;
  88508. /**
  88509. * Instantiates a new camera object.
  88510. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88511. * @see http://doc.babylonjs.com/features/cameras
  88512. * @param name Defines the name of the camera in the scene
  88513. * @param position Defines the position of the camera
  88514. * @param scene Defines the scene the camera belongs too
  88515. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88516. */
  88517. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88518. /**
  88519. * Store current camera state (fov, position, etc..)
  88520. * @returns the camera
  88521. */
  88522. storeState(): Camera;
  88523. /**
  88524. * Restores the camera state values if it has been stored. You must call storeState() first
  88525. */
  88526. protected _restoreStateValues(): boolean;
  88527. /**
  88528. * Restored camera state. You must call storeState() first.
  88529. * @returns true if restored and false otherwise
  88530. */
  88531. restoreState(): boolean;
  88532. /**
  88533. * Gets the class name of the camera.
  88534. * @returns the class name
  88535. */
  88536. getClassName(): string;
  88537. /** @hidden */
  88538. readonly _isCamera: boolean;
  88539. /**
  88540. * Gets a string representation of the camera useful for debug purpose.
  88541. * @param fullDetails Defines that a more verboe level of logging is required
  88542. * @returns the string representation
  88543. */
  88544. toString(fullDetails?: boolean): string;
  88545. /**
  88546. * Gets the current world space position of the camera.
  88547. */
  88548. readonly globalPosition: Vector3;
  88549. /**
  88550. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88551. * @returns the active meshe list
  88552. */
  88553. getActiveMeshes(): SmartArray<AbstractMesh>;
  88554. /**
  88555. * Check wether a mesh is part of the current active mesh list of the camera
  88556. * @param mesh Defines the mesh to check
  88557. * @returns true if active, false otherwise
  88558. */
  88559. isActiveMesh(mesh: Mesh): boolean;
  88560. /**
  88561. * Is this camera ready to be used/rendered
  88562. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88563. * @return true if the camera is ready
  88564. */
  88565. isReady(completeCheck?: boolean): boolean;
  88566. /** @hidden */
  88567. _initCache(): void;
  88568. /** @hidden */
  88569. _updateCache(ignoreParentClass?: boolean): void;
  88570. /** @hidden */
  88571. _isSynchronized(): boolean;
  88572. /** @hidden */
  88573. _isSynchronizedViewMatrix(): boolean;
  88574. /** @hidden */
  88575. _isSynchronizedProjectionMatrix(): boolean;
  88576. /**
  88577. * Attach the input controls to a specific dom element to get the input from.
  88578. * @param element Defines the element the controls should be listened from
  88579. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88580. */
  88581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88582. /**
  88583. * Detach the current controls from the specified dom element.
  88584. * @param element Defines the element to stop listening the inputs from
  88585. */
  88586. detachControl(element: HTMLElement): void;
  88587. /**
  88588. * Update the camera state according to the different inputs gathered during the frame.
  88589. */
  88590. update(): void;
  88591. /** @hidden */
  88592. _checkInputs(): void;
  88593. /** @hidden */
  88594. readonly rigCameras: Camera[];
  88595. /**
  88596. * Gets the post process used by the rig cameras
  88597. */
  88598. readonly rigPostProcess: Nullable<PostProcess>;
  88599. /**
  88600. * Internal, gets the first post proces.
  88601. * @returns the first post process to be run on this camera.
  88602. */
  88603. _getFirstPostProcess(): Nullable<PostProcess>;
  88604. private _cascadePostProcessesToRigCams;
  88605. /**
  88606. * Attach a post process to the camera.
  88607. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88608. * @param postProcess The post process to attach to the camera
  88609. * @param insertAt The position of the post process in case several of them are in use in the scene
  88610. * @returns the position the post process has been inserted at
  88611. */
  88612. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88613. /**
  88614. * Detach a post process to the camera.
  88615. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88616. * @param postProcess The post process to detach from the camera
  88617. */
  88618. detachPostProcess(postProcess: PostProcess): void;
  88619. /**
  88620. * Gets the current world matrix of the camera
  88621. */
  88622. getWorldMatrix(): Matrix;
  88623. /** @hidden */
  88624. _getViewMatrix(): Matrix;
  88625. /**
  88626. * Gets the current view matrix of the camera.
  88627. * @param force forces the camera to recompute the matrix without looking at the cached state
  88628. * @returns the view matrix
  88629. */
  88630. getViewMatrix(force?: boolean): Matrix;
  88631. /**
  88632. * Freeze the projection matrix.
  88633. * It will prevent the cache check of the camera projection compute and can speed up perf
  88634. * if no parameter of the camera are meant to change
  88635. * @param projection Defines manually a projection if necessary
  88636. */
  88637. freezeProjectionMatrix(projection?: Matrix): void;
  88638. /**
  88639. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88640. */
  88641. unfreezeProjectionMatrix(): void;
  88642. /**
  88643. * Gets the current projection matrix of the camera.
  88644. * @param force forces the camera to recompute the matrix without looking at the cached state
  88645. * @returns the projection matrix
  88646. */
  88647. getProjectionMatrix(force?: boolean): Matrix;
  88648. /**
  88649. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88650. * @returns a Matrix
  88651. */
  88652. getTransformationMatrix(): Matrix;
  88653. private _updateFrustumPlanes;
  88654. /**
  88655. * Checks if a cullable object (mesh...) is in the camera frustum
  88656. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88657. * @param target The object to check
  88658. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  88659. * @returns true if the object is in frustum otherwise false
  88660. */
  88661. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  88662. /**
  88663. * Checks if a cullable object (mesh...) is in the camera frustum
  88664. * Unlike isInFrustum this cheks the full bounding box
  88665. * @param target The object to check
  88666. * @returns true if the object is in frustum otherwise false
  88667. */
  88668. isCompletelyInFrustum(target: ICullable): boolean;
  88669. /**
  88670. * Gets a ray in the forward direction from the camera.
  88671. * @param length Defines the length of the ray to create
  88672. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88673. * @param origin Defines the start point of the ray which defaults to the camera position
  88674. * @returns the forward ray
  88675. */
  88676. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88677. /**
  88678. * Releases resources associated with this node.
  88679. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88680. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88681. */
  88682. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88683. /** @hidden */
  88684. _isLeftCamera: boolean;
  88685. /**
  88686. * Gets the left camera of a rig setup in case of Rigged Camera
  88687. */
  88688. readonly isLeftCamera: boolean;
  88689. /** @hidden */
  88690. _isRightCamera: boolean;
  88691. /**
  88692. * Gets the right camera of a rig setup in case of Rigged Camera
  88693. */
  88694. readonly isRightCamera: boolean;
  88695. /**
  88696. * Gets the left camera of a rig setup in case of Rigged Camera
  88697. */
  88698. readonly leftCamera: Nullable<FreeCamera>;
  88699. /**
  88700. * Gets the right camera of a rig setup in case of Rigged Camera
  88701. */
  88702. readonly rightCamera: Nullable<FreeCamera>;
  88703. /**
  88704. * Gets the left camera target of a rig setup in case of Rigged Camera
  88705. * @returns the target position
  88706. */
  88707. getLeftTarget(): Nullable<Vector3>;
  88708. /**
  88709. * Gets the right camera target of a rig setup in case of Rigged Camera
  88710. * @returns the target position
  88711. */
  88712. getRightTarget(): Nullable<Vector3>;
  88713. /**
  88714. * @hidden
  88715. */
  88716. setCameraRigMode(mode: number, rigParams: any): void;
  88717. /** @hidden */
  88718. static _setStereoscopicRigMode(camera: Camera): void;
  88719. /** @hidden */
  88720. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  88721. /** @hidden */
  88722. static _setVRRigMode(camera: Camera, rigParams: any): void;
  88723. /** @hidden */
  88724. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  88725. /** @hidden */
  88726. _getVRProjectionMatrix(): Matrix;
  88727. protected _updateCameraRotationMatrix(): void;
  88728. protected _updateWebVRCameraRotationMatrix(): void;
  88729. /**
  88730. * This function MUST be overwritten by the different WebVR cameras available.
  88731. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88732. * @hidden
  88733. */
  88734. _getWebVRProjectionMatrix(): Matrix;
  88735. /**
  88736. * This function MUST be overwritten by the different WebVR cameras available.
  88737. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88738. * @hidden
  88739. */
  88740. _getWebVRViewMatrix(): Matrix;
  88741. /** @hidden */
  88742. setCameraRigParameter(name: string, value: any): void;
  88743. /**
  88744. * needs to be overridden by children so sub has required properties to be copied
  88745. * @hidden
  88746. */
  88747. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  88748. /**
  88749. * May need to be overridden by children
  88750. * @hidden
  88751. */
  88752. _updateRigCameras(): void;
  88753. /** @hidden */
  88754. _setupInputs(): void;
  88755. /**
  88756. * Serialiaze the camera setup to a json represention
  88757. * @returns the JSON representation
  88758. */
  88759. serialize(): any;
  88760. /**
  88761. * Clones the current camera.
  88762. * @param name The cloned camera name
  88763. * @returns the cloned camera
  88764. */
  88765. clone(name: string): Camera;
  88766. /**
  88767. * Gets the direction of the camera relative to a given local axis.
  88768. * @param localAxis Defines the reference axis to provide a relative direction.
  88769. * @return the direction
  88770. */
  88771. getDirection(localAxis: Vector3): Vector3;
  88772. /**
  88773. * Gets the direction of the camera relative to a given local axis into a passed vector.
  88774. * @param localAxis Defines the reference axis to provide a relative direction.
  88775. * @param result Defines the vector to store the result in
  88776. */
  88777. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  88778. /**
  88779. * Gets a camera constructor for a given camera type
  88780. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  88781. * @param name The name of the camera the result will be able to instantiate
  88782. * @param scene The scene the result will construct the camera in
  88783. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  88784. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  88785. * @returns a factory method to construc the camera
  88786. */
  88787. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  88788. /**
  88789. * Compute the world matrix of the camera.
  88790. * @returns the camera workd matrix
  88791. */
  88792. computeWorldMatrix(): Matrix;
  88793. /**
  88794. * Parse a JSON and creates the camera from the parsed information
  88795. * @param parsedCamera The JSON to parse
  88796. * @param scene The scene to instantiate the camera in
  88797. * @returns the newly constructed camera
  88798. */
  88799. static Parse(parsedCamera: any, scene: Scene): Camera;
  88800. }
  88801. }
  88802. declare module BABYLON {
  88803. /**
  88804. * Class containing static functions to help procedurally build meshes
  88805. */
  88806. export class DiscBuilder {
  88807. /**
  88808. * Creates a plane polygonal mesh. By default, this is a disc
  88809. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  88810. * * 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
  88811. * * 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
  88812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  88814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88815. * @param name defines the name of the mesh
  88816. * @param options defines the options used to create the mesh
  88817. * @param scene defines the hosting scene
  88818. * @returns the plane polygonal mesh
  88819. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  88820. */
  88821. static CreateDisc(name: string, options: {
  88822. radius?: number;
  88823. tessellation?: number;
  88824. arc?: number;
  88825. updatable?: boolean;
  88826. sideOrientation?: number;
  88827. frontUVs?: Vector4;
  88828. backUVs?: Vector4;
  88829. }, scene?: Nullable<Scene>): Mesh;
  88830. }
  88831. }
  88832. declare module BABYLON {
  88833. /**
  88834. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  88835. *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.
  88836. * The SPS is also a particle system. It provides some methods to manage the particles.
  88837. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  88838. *
  88839. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  88840. */
  88841. export class SolidParticleSystem implements IDisposable {
  88842. /**
  88843. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  88844. * Example : var p = SPS.particles[i];
  88845. */
  88846. particles: SolidParticle[];
  88847. /**
  88848. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  88849. */
  88850. nbParticles: number;
  88851. /**
  88852. * If the particles must ever face the camera (default false). Useful for planar particles.
  88853. */
  88854. billboard: boolean;
  88855. /**
  88856. * Recompute normals when adding a shape
  88857. */
  88858. recomputeNormals: boolean;
  88859. /**
  88860. * This a counter ofr your own usage. It's not set by any SPS functions.
  88861. */
  88862. counter: number;
  88863. /**
  88864. * The SPS name. This name is also given to the underlying mesh.
  88865. */
  88866. name: string;
  88867. /**
  88868. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  88869. */
  88870. mesh: Mesh;
  88871. /**
  88872. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  88873. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  88874. */
  88875. vars: any;
  88876. /**
  88877. * This array is populated when the SPS is set as 'pickable'.
  88878. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  88879. * Each element of this array is an object `{idx: int, faceId: int}`.
  88880. * `idx` is the picked particle index in the `SPS.particles` array
  88881. * `faceId` is the picked face index counted within this particle.
  88882. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  88883. */
  88884. pickedParticles: {
  88885. idx: number;
  88886. faceId: number;
  88887. }[];
  88888. /**
  88889. * This array is populated when `enableDepthSort` is set to true.
  88890. * Each element of this array is an instance of the class DepthSortedParticle.
  88891. */
  88892. depthSortedParticles: DepthSortedParticle[];
  88893. /**
  88894. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  88895. * @hidden
  88896. */
  88897. _bSphereOnly: boolean;
  88898. /**
  88899. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  88900. * @hidden
  88901. */
  88902. _bSphereRadiusFactor: number;
  88903. private _scene;
  88904. private _positions;
  88905. private _indices;
  88906. private _normals;
  88907. private _colors;
  88908. private _uvs;
  88909. private _indices32;
  88910. private _positions32;
  88911. private _normals32;
  88912. private _fixedNormal32;
  88913. private _colors32;
  88914. private _uvs32;
  88915. private _index;
  88916. private _updatable;
  88917. private _pickable;
  88918. private _isVisibilityBoxLocked;
  88919. private _alwaysVisible;
  88920. private _depthSort;
  88921. private _shapeCounter;
  88922. private _copy;
  88923. private _color;
  88924. private _computeParticleColor;
  88925. private _computeParticleTexture;
  88926. private _computeParticleRotation;
  88927. private _computeParticleVertex;
  88928. private _computeBoundingBox;
  88929. private _depthSortParticles;
  88930. private _camera;
  88931. private _mustUnrotateFixedNormals;
  88932. private _particlesIntersect;
  88933. private _needs32Bits;
  88934. /**
  88935. * Creates a SPS (Solid Particle System) object.
  88936. * @param name (String) is the SPS name, this will be the underlying mesh name.
  88937. * @param scene (Scene) is the scene in which the SPS is added.
  88938. * @param options defines the options of the sps e.g.
  88939. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  88940. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  88941. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  88942. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  88943. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  88944. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  88945. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  88946. */
  88947. constructor(name: string, scene: Scene, options?: {
  88948. updatable?: boolean;
  88949. isPickable?: boolean;
  88950. enableDepthSort?: boolean;
  88951. particleIntersection?: boolean;
  88952. boundingSphereOnly?: boolean;
  88953. bSphereRadiusFactor?: number;
  88954. });
  88955. /**
  88956. * Builds the SPS underlying mesh. Returns a standard Mesh.
  88957. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  88958. * @returns the created mesh
  88959. */
  88960. buildMesh(): Mesh;
  88961. /**
  88962. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  88963. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  88964. * Thus the particles generated from `digest()` have their property `position` set yet.
  88965. * @param mesh ( Mesh ) is the mesh to be digested
  88966. * @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
  88967. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  88968. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  88969. * @returns the current SPS
  88970. */
  88971. digest(mesh: Mesh, options?: {
  88972. facetNb?: number;
  88973. number?: number;
  88974. delta?: number;
  88975. }): SolidParticleSystem;
  88976. private _unrotateFixedNormals;
  88977. private _resetCopy;
  88978. private _meshBuilder;
  88979. private _posToShape;
  88980. private _uvsToShapeUV;
  88981. private _addParticle;
  88982. /**
  88983. * Adds some particles to the SPS from the model shape. Returns the shape id.
  88984. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  88985. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  88986. * @param nb (positive integer) the number of particles to be created from this model
  88987. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  88988. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  88989. * @returns the number of shapes in the system
  88990. */
  88991. addShape(mesh: Mesh, nb: number, options?: {
  88992. positionFunction?: any;
  88993. vertexFunction?: any;
  88994. }): number;
  88995. private _rebuildParticle;
  88996. /**
  88997. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  88998. * @returns the SPS.
  88999. */
  89000. rebuildMesh(): SolidParticleSystem;
  89001. /**
  89002. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  89003. * This method calls `updateParticle()` for each particle of the SPS.
  89004. * For an animated SPS, it is usually called within the render loop.
  89005. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  89006. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  89007. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  89008. * @returns the SPS.
  89009. */
  89010. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  89011. /**
  89012. * Disposes the SPS.
  89013. */
  89014. dispose(): void;
  89015. /**
  89016. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  89017. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89018. * @returns the SPS.
  89019. */
  89020. refreshVisibleSize(): SolidParticleSystem;
  89021. /**
  89022. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  89023. * @param size the size (float) of the visibility box
  89024. * note : this doesn't lock the SPS mesh bounding box.
  89025. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89026. */
  89027. setVisibilityBox(size: number): void;
  89028. /**
  89029. * Gets whether the SPS as always visible or not
  89030. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89031. */
  89032. /**
  89033. * Sets the SPS as always visible or not
  89034. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89035. */
  89036. isAlwaysVisible: boolean;
  89037. /**
  89038. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89039. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89040. */
  89041. /**
  89042. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89043. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89044. */
  89045. isVisibilityBoxLocked: boolean;
  89046. /**
  89047. * Tells to `setParticles()` to compute the particle rotations or not.
  89048. * Default value : true. The SPS is faster when it's set to false.
  89049. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89050. */
  89051. /**
  89052. * Gets if `setParticles()` computes the particle rotations or not.
  89053. * Default value : true. The SPS is faster when it's set to false.
  89054. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89055. */
  89056. computeParticleRotation: boolean;
  89057. /**
  89058. * Tells to `setParticles()` to compute the particle colors or not.
  89059. * Default value : true. The SPS is faster when it's set to false.
  89060. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89061. */
  89062. /**
  89063. * Gets if `setParticles()` computes the particle colors or not.
  89064. * Default value : true. The SPS is faster when it's set to false.
  89065. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89066. */
  89067. computeParticleColor: boolean;
  89068. /**
  89069. * Gets if `setParticles()` computes the particle textures or not.
  89070. * Default value : true. The SPS is faster when it's set to false.
  89071. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  89072. */
  89073. computeParticleTexture: boolean;
  89074. /**
  89075. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  89076. * Default value : false. The SPS is faster when it's set to false.
  89077. * Note : the particle custom vertex positions aren't stored values.
  89078. */
  89079. /**
  89080. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  89081. * Default value : false. The SPS is faster when it's set to false.
  89082. * Note : the particle custom vertex positions aren't stored values.
  89083. */
  89084. computeParticleVertex: boolean;
  89085. /**
  89086. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  89087. */
  89088. /**
  89089. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  89090. */
  89091. computeBoundingBox: boolean;
  89092. /**
  89093. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  89094. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89095. * Default : `true`
  89096. */
  89097. /**
  89098. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  89099. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89100. * Default : `true`
  89101. */
  89102. depthSortParticles: boolean;
  89103. /**
  89104. * This function does nothing. It may be overwritten to set all the particle first values.
  89105. * The SPS doesn't call this function, you may have to call it by your own.
  89106. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89107. */
  89108. initParticles(): void;
  89109. /**
  89110. * This function does nothing. It may be overwritten to recycle a particle.
  89111. * The SPS doesn't call this function, you may have to call it by your own.
  89112. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89113. * @param particle The particle to recycle
  89114. * @returns the recycled particle
  89115. */
  89116. recycleParticle(particle: SolidParticle): SolidParticle;
  89117. /**
  89118. * Updates a particle : this function should be overwritten by the user.
  89119. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  89120. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89121. * @example : just set a particle position or velocity and recycle conditions
  89122. * @param particle The particle to update
  89123. * @returns the updated particle
  89124. */
  89125. updateParticle(particle: SolidParticle): SolidParticle;
  89126. /**
  89127. * Updates a vertex of a particle : it can be overwritten by the user.
  89128. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  89129. * @param particle the current particle
  89130. * @param vertex the current index of the current particle
  89131. * @param pt the index of the current vertex in the particle shape
  89132. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  89133. * @example : just set a vertex particle position
  89134. * @returns the updated vertex
  89135. */
  89136. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  89137. /**
  89138. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  89139. * This does nothing and may be overwritten by the user.
  89140. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89141. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89142. * @param update the boolean update value actually passed to setParticles()
  89143. */
  89144. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89145. /**
  89146. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  89147. * This will be passed three parameters.
  89148. * This does nothing and may be overwritten by the user.
  89149. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89150. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89151. * @param update the boolean update value actually passed to setParticles()
  89152. */
  89153. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89154. }
  89155. }
  89156. declare module BABYLON {
  89157. /**
  89158. * Represents one particle of a solid particle system.
  89159. */
  89160. export class SolidParticle {
  89161. /**
  89162. * particle global index
  89163. */
  89164. idx: number;
  89165. /**
  89166. * The color of the particle
  89167. */
  89168. color: Nullable<Color4>;
  89169. /**
  89170. * The world space position of the particle.
  89171. */
  89172. position: Vector3;
  89173. /**
  89174. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  89175. */
  89176. rotation: Vector3;
  89177. /**
  89178. * The world space rotation quaternion of the particle.
  89179. */
  89180. rotationQuaternion: Nullable<Quaternion>;
  89181. /**
  89182. * The scaling of the particle.
  89183. */
  89184. scaling: Vector3;
  89185. /**
  89186. * The uvs of the particle.
  89187. */
  89188. uvs: Vector4;
  89189. /**
  89190. * The current speed of the particle.
  89191. */
  89192. velocity: Vector3;
  89193. /**
  89194. * The pivot point in the particle local space.
  89195. */
  89196. pivot: Vector3;
  89197. /**
  89198. * Must the particle be translated from its pivot point in its local space ?
  89199. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  89200. * Default : false
  89201. */
  89202. translateFromPivot: boolean;
  89203. /**
  89204. * Is the particle active or not ?
  89205. */
  89206. alive: boolean;
  89207. /**
  89208. * Is the particle visible or not ?
  89209. */
  89210. isVisible: boolean;
  89211. /**
  89212. * Index of this particle in the global "positions" array (Internal use)
  89213. * @hidden
  89214. */
  89215. _pos: number;
  89216. /**
  89217. * @hidden Index of this particle in the global "indices" array (Internal use)
  89218. */
  89219. _ind: number;
  89220. /**
  89221. * @hidden ModelShape of this particle (Internal use)
  89222. */
  89223. _model: ModelShape;
  89224. /**
  89225. * ModelShape id of this particle
  89226. */
  89227. shapeId: number;
  89228. /**
  89229. * Index of the particle in its shape id (Internal use)
  89230. */
  89231. idxInShape: number;
  89232. /**
  89233. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  89234. */
  89235. _modelBoundingInfo: BoundingInfo;
  89236. /**
  89237. * @hidden Particle BoundingInfo object (Internal use)
  89238. */
  89239. _boundingInfo: BoundingInfo;
  89240. /**
  89241. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  89242. */
  89243. _sps: SolidParticleSystem;
  89244. /**
  89245. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  89246. */
  89247. _stillInvisible: boolean;
  89248. /**
  89249. * @hidden Last computed particle rotation matrix
  89250. */
  89251. _rotationMatrix: number[];
  89252. /**
  89253. * Parent particle Id, if any.
  89254. * Default null.
  89255. */
  89256. parentId: Nullable<number>;
  89257. /**
  89258. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  89259. * The possible values are :
  89260. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89261. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89262. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89263. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89264. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89265. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  89266. * */
  89267. cullingStrategy: number;
  89268. /**
  89269. * @hidden Internal global position in the SPS.
  89270. */
  89271. _globalPosition: Vector3;
  89272. /**
  89273. * Creates a Solid Particle object.
  89274. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  89275. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  89276. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  89277. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  89278. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  89279. * @param shapeId (integer) is the model shape identifier in the SPS.
  89280. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  89281. * @param sps defines the sps it is associated to
  89282. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  89283. */
  89284. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  89285. /**
  89286. * Legacy support, changed scale to scaling
  89287. */
  89288. /**
  89289. * Legacy support, changed scale to scaling
  89290. */
  89291. scale: Vector3;
  89292. /**
  89293. * Legacy support, changed quaternion to rotationQuaternion
  89294. */
  89295. /**
  89296. * Legacy support, changed quaternion to rotationQuaternion
  89297. */
  89298. quaternion: Nullable<Quaternion>;
  89299. /**
  89300. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  89301. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  89302. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  89303. * @returns true if it intersects
  89304. */
  89305. intersectsMesh(target: Mesh | SolidParticle): boolean;
  89306. /**
  89307. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  89308. * A particle is in the frustum if its bounding box intersects the frustum
  89309. * @param frustumPlanes defines the frustum to test
  89310. * @returns true if the particle is in the frustum planes
  89311. */
  89312. isInFrustum(frustumPlanes: Plane[]): boolean;
  89313. /**
  89314. * get the rotation matrix of the particle
  89315. * @hidden
  89316. */
  89317. getRotationMatrix(m: Matrix): void;
  89318. }
  89319. /**
  89320. * Represents the shape of the model used by one particle of a solid particle system.
  89321. * SPS internal tool, don't use it manually.
  89322. */
  89323. export class ModelShape {
  89324. /**
  89325. * The shape id
  89326. * @hidden
  89327. */
  89328. shapeID: number;
  89329. /**
  89330. * flat array of model positions (internal use)
  89331. * @hidden
  89332. */
  89333. _shape: Vector3[];
  89334. /**
  89335. * flat array of model UVs (internal use)
  89336. * @hidden
  89337. */
  89338. _shapeUV: number[];
  89339. /**
  89340. * length of the shape in the model indices array (internal use)
  89341. * @hidden
  89342. */
  89343. _indicesLength: number;
  89344. /**
  89345. * Custom position function (internal use)
  89346. * @hidden
  89347. */
  89348. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  89349. /**
  89350. * Custom vertex function (internal use)
  89351. * @hidden
  89352. */
  89353. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  89354. /**
  89355. * 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.
  89356. * SPS internal tool, don't use it manually.
  89357. * @hidden
  89358. */
  89359. 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>);
  89360. }
  89361. /**
  89362. * Represents a Depth Sorted Particle in the solid particle system.
  89363. */
  89364. export class DepthSortedParticle {
  89365. /**
  89366. * Index of the particle in the "indices" array
  89367. */
  89368. ind: number;
  89369. /**
  89370. * Length of the particle shape in the "indices" array
  89371. */
  89372. indicesLength: number;
  89373. /**
  89374. * Squared distance from the particle to the camera
  89375. */
  89376. sqDistance: number;
  89377. }
  89378. }
  89379. declare module BABYLON {
  89380. /**
  89381. * @hidden
  89382. */
  89383. export class _MeshCollisionData {
  89384. _checkCollisions: boolean;
  89385. _collisionMask: number;
  89386. _collisionGroup: number;
  89387. _collider: Nullable<Collider>;
  89388. _oldPositionForCollisions: Vector3;
  89389. _diffPositionForCollisions: Vector3;
  89390. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  89391. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  89392. }
  89393. }
  89394. declare module BABYLON {
  89395. /** @hidden */
  89396. class _FacetDataStorage {
  89397. facetPositions: Vector3[];
  89398. facetNormals: Vector3[];
  89399. facetPartitioning: number[][];
  89400. facetNb: number;
  89401. partitioningSubdivisions: number;
  89402. partitioningBBoxRatio: number;
  89403. facetDataEnabled: boolean;
  89404. facetParameters: any;
  89405. bbSize: Vector3;
  89406. subDiv: {
  89407. max: number;
  89408. X: number;
  89409. Y: number;
  89410. Z: number;
  89411. };
  89412. facetDepthSort: boolean;
  89413. facetDepthSortEnabled: boolean;
  89414. depthSortedIndices: IndicesArray;
  89415. depthSortedFacets: {
  89416. ind: number;
  89417. sqDistance: number;
  89418. }[];
  89419. facetDepthSortFunction: (f1: {
  89420. ind: number;
  89421. sqDistance: number;
  89422. }, f2: {
  89423. ind: number;
  89424. sqDistance: number;
  89425. }) => number;
  89426. facetDepthSortFrom: Vector3;
  89427. facetDepthSortOrigin: Vector3;
  89428. invertedMatrix: Matrix;
  89429. }
  89430. /**
  89431. * @hidden
  89432. **/
  89433. class _InternalAbstractMeshDataInfo {
  89434. _hasVertexAlpha: boolean;
  89435. _useVertexColors: boolean;
  89436. _numBoneInfluencers: number;
  89437. _applyFog: boolean;
  89438. _receiveShadows: boolean;
  89439. _facetData: _FacetDataStorage;
  89440. _visibility: number;
  89441. _skeleton: Nullable<Skeleton>;
  89442. _layerMask: number;
  89443. _computeBonesUsingShaders: boolean;
  89444. _isActive: boolean;
  89445. _onlyForInstances: boolean;
  89446. _isActiveIntermediate: boolean;
  89447. _onlyForInstancesIntermediate: boolean;
  89448. }
  89449. /**
  89450. * Class used to store all common mesh properties
  89451. */
  89452. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  89453. /** No occlusion */
  89454. static OCCLUSION_TYPE_NONE: number;
  89455. /** Occlusion set to optimisitic */
  89456. static OCCLUSION_TYPE_OPTIMISTIC: number;
  89457. /** Occlusion set to strict */
  89458. static OCCLUSION_TYPE_STRICT: number;
  89459. /** Use an accurante occlusion algorithm */
  89460. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  89461. /** Use a conservative occlusion algorithm */
  89462. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  89463. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  89464. * Test order :
  89465. * Is the bounding sphere outside the frustum ?
  89466. * If not, are the bounding box vertices outside the frustum ?
  89467. * It not, then the cullable object is in the frustum.
  89468. */
  89469. static readonly CULLINGSTRATEGY_STANDARD: number;
  89470. /** Culling strategy : Bounding Sphere Only.
  89471. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  89472. * It's also less accurate than the standard because some not visible objects can still be selected.
  89473. * Test : is the bounding sphere outside the frustum ?
  89474. * If not, then the cullable object is in the frustum.
  89475. */
  89476. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  89477. /** Culling strategy : Optimistic Inclusion.
  89478. * This in an inclusion test first, then the standard exclusion test.
  89479. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  89480. * 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.
  89481. * Anyway, it's as accurate as the standard strategy.
  89482. * Test :
  89483. * Is the cullable object bounding sphere center in the frustum ?
  89484. * If not, apply the default culling strategy.
  89485. */
  89486. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  89487. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  89488. * This in an inclusion test first, then the bounding sphere only exclusion test.
  89489. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  89490. * 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.
  89491. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  89492. * Test :
  89493. * Is the cullable object bounding sphere center in the frustum ?
  89494. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  89495. */
  89496. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  89497. /**
  89498. * No billboard
  89499. */
  89500. static readonly BILLBOARDMODE_NONE: number;
  89501. /** Billboard on X axis */
  89502. static readonly BILLBOARDMODE_X: number;
  89503. /** Billboard on Y axis */
  89504. static readonly BILLBOARDMODE_Y: number;
  89505. /** Billboard on Z axis */
  89506. static readonly BILLBOARDMODE_Z: number;
  89507. /** Billboard on all axes */
  89508. static readonly BILLBOARDMODE_ALL: number;
  89509. /** @hidden */
  89510. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  89511. /**
  89512. * The culling strategy to use to check whether the mesh must be rendered or not.
  89513. * This value can be changed at any time and will be used on the next render mesh selection.
  89514. * The possible values are :
  89515. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89516. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89517. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89518. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89519. * Please read each static variable documentation to get details about the culling process.
  89520. * */
  89521. cullingStrategy: number;
  89522. /**
  89523. * Gets the number of facets in the mesh
  89524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89525. */
  89526. readonly facetNb: number;
  89527. /**
  89528. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  89529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89530. */
  89531. partitioningSubdivisions: number;
  89532. /**
  89533. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  89534. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  89535. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89536. */
  89537. partitioningBBoxRatio: number;
  89538. /**
  89539. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  89540. * Works only for updatable meshes.
  89541. * Doesn't work with multi-materials
  89542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89543. */
  89544. mustDepthSortFacets: boolean;
  89545. /**
  89546. * The location (Vector3) where the facet depth sort must be computed from.
  89547. * By default, the active camera position.
  89548. * Used only when facet depth sort is enabled
  89549. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89550. */
  89551. facetDepthSortFrom: Vector3;
  89552. /**
  89553. * gets a boolean indicating if facetData is enabled
  89554. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89555. */
  89556. readonly isFacetDataEnabled: boolean;
  89557. /** @hidden */
  89558. _updateNonUniformScalingState(value: boolean): boolean;
  89559. /**
  89560. * An event triggered when this mesh collides with another one
  89561. */
  89562. onCollideObservable: Observable<AbstractMesh>;
  89563. /** Set a function to call when this mesh collides with another one */
  89564. onCollide: () => void;
  89565. /**
  89566. * An event triggered when the collision's position changes
  89567. */
  89568. onCollisionPositionChangeObservable: Observable<Vector3>;
  89569. /** Set a function to call when the collision's position changes */
  89570. onCollisionPositionChange: () => void;
  89571. /**
  89572. * An event triggered when material is changed
  89573. */
  89574. onMaterialChangedObservable: Observable<AbstractMesh>;
  89575. /**
  89576. * Gets or sets the orientation for POV movement & rotation
  89577. */
  89578. definedFacingForward: boolean;
  89579. /** @hidden */
  89580. _occlusionQuery: Nullable<WebGLQuery>;
  89581. /** @hidden */
  89582. _renderingGroup: Nullable<RenderingGroup>;
  89583. /**
  89584. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89585. */
  89586. /**
  89587. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89588. */
  89589. visibility: number;
  89590. /** Gets or sets the alpha index used to sort transparent meshes
  89591. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  89592. */
  89593. alphaIndex: number;
  89594. /**
  89595. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  89596. */
  89597. isVisible: boolean;
  89598. /**
  89599. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89600. */
  89601. isPickable: boolean;
  89602. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  89603. showSubMeshesBoundingBox: boolean;
  89604. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  89605. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  89606. */
  89607. isBlocker: boolean;
  89608. /**
  89609. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  89610. */
  89611. enablePointerMoveEvents: boolean;
  89612. /**
  89613. * Specifies the rendering group id for this mesh (0 by default)
  89614. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89615. */
  89616. renderingGroupId: number;
  89617. private _material;
  89618. /** Gets or sets current material */
  89619. material: Nullable<Material>;
  89620. /**
  89621. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  89622. * @see http://doc.babylonjs.com/babylon101/shadows
  89623. */
  89624. receiveShadows: boolean;
  89625. /** Defines color to use when rendering outline */
  89626. outlineColor: Color3;
  89627. /** Define width to use when rendering outline */
  89628. outlineWidth: number;
  89629. /** Defines color to use when rendering overlay */
  89630. overlayColor: Color3;
  89631. /** Defines alpha to use when rendering overlay */
  89632. overlayAlpha: number;
  89633. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  89634. hasVertexAlpha: boolean;
  89635. /** 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) */
  89636. useVertexColors: boolean;
  89637. /**
  89638. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  89639. */
  89640. computeBonesUsingShaders: boolean;
  89641. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  89642. numBoneInfluencers: number;
  89643. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  89644. applyFog: boolean;
  89645. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  89646. useOctreeForRenderingSelection: boolean;
  89647. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  89648. useOctreeForPicking: boolean;
  89649. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  89650. useOctreeForCollisions: boolean;
  89651. /**
  89652. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  89653. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  89654. */
  89655. layerMask: number;
  89656. /**
  89657. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  89658. */
  89659. alwaysSelectAsActiveMesh: boolean;
  89660. /**
  89661. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  89662. */
  89663. doNotSyncBoundingInfo: boolean;
  89664. /**
  89665. * Gets or sets the current action manager
  89666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89667. */
  89668. actionManager: Nullable<AbstractActionManager>;
  89669. private _meshCollisionData;
  89670. /**
  89671. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  89672. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89673. */
  89674. ellipsoid: Vector3;
  89675. /**
  89676. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  89677. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89678. */
  89679. ellipsoidOffset: Vector3;
  89680. /**
  89681. * Gets or sets a collision mask used to mask collisions (default is -1).
  89682. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89683. */
  89684. collisionMask: number;
  89685. /**
  89686. * Gets or sets the current collision group mask (-1 by default).
  89687. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89688. */
  89689. collisionGroup: number;
  89690. /**
  89691. * Defines edge width used when edgesRenderer is enabled
  89692. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89693. */
  89694. edgesWidth: number;
  89695. /**
  89696. * Defines edge color used when edgesRenderer is enabled
  89697. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89698. */
  89699. edgesColor: Color4;
  89700. /** @hidden */
  89701. _edgesRenderer: Nullable<IEdgesRenderer>;
  89702. /** @hidden */
  89703. _masterMesh: Nullable<AbstractMesh>;
  89704. /** @hidden */
  89705. _boundingInfo: Nullable<BoundingInfo>;
  89706. /** @hidden */
  89707. _renderId: number;
  89708. /**
  89709. * Gets or sets the list of subMeshes
  89710. * @see http://doc.babylonjs.com/how_to/multi_materials
  89711. */
  89712. subMeshes: SubMesh[];
  89713. /** @hidden */
  89714. _intersectionsInProgress: AbstractMesh[];
  89715. /** @hidden */
  89716. _unIndexed: boolean;
  89717. /** @hidden */
  89718. _lightSources: Light[];
  89719. /** Gets the list of lights affecting that mesh */
  89720. readonly lightSources: Light[];
  89721. /** @hidden */
  89722. readonly _positions: Nullable<Vector3[]>;
  89723. /** @hidden */
  89724. _waitingData: {
  89725. lods: Nullable<any>;
  89726. actions: Nullable<any>;
  89727. freezeWorldMatrix: Nullable<boolean>;
  89728. };
  89729. /** @hidden */
  89730. _bonesTransformMatrices: Nullable<Float32Array>;
  89731. /** @hidden */
  89732. _transformMatrixTexture: Nullable<RawTexture>;
  89733. /**
  89734. * Gets or sets a skeleton to apply skining transformations
  89735. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89736. */
  89737. skeleton: Nullable<Skeleton>;
  89738. /**
  89739. * An event triggered when the mesh is rebuilt.
  89740. */
  89741. onRebuildObservable: Observable<AbstractMesh>;
  89742. /**
  89743. * Creates a new AbstractMesh
  89744. * @param name defines the name of the mesh
  89745. * @param scene defines the hosting scene
  89746. */
  89747. constructor(name: string, scene?: Nullable<Scene>);
  89748. /**
  89749. * Returns the string "AbstractMesh"
  89750. * @returns "AbstractMesh"
  89751. */
  89752. getClassName(): string;
  89753. /**
  89754. * Gets a string representation of the current mesh
  89755. * @param fullDetails defines a boolean indicating if full details must be included
  89756. * @returns a string representation of the current mesh
  89757. */
  89758. toString(fullDetails?: boolean): string;
  89759. /**
  89760. * @hidden
  89761. */
  89762. protected _getEffectiveParent(): Nullable<Node>;
  89763. /** @hidden */
  89764. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  89765. /** @hidden */
  89766. _rebuild(): void;
  89767. /** @hidden */
  89768. _resyncLightSources(): void;
  89769. /** @hidden */
  89770. _resyncLighSource(light: Light): void;
  89771. /** @hidden */
  89772. _unBindEffect(): void;
  89773. /** @hidden */
  89774. _removeLightSource(light: Light): void;
  89775. private _markSubMeshesAsDirty;
  89776. /** @hidden */
  89777. _markSubMeshesAsLightDirty(): void;
  89778. /** @hidden */
  89779. _markSubMeshesAsAttributesDirty(): void;
  89780. /** @hidden */
  89781. _markSubMeshesAsMiscDirty(): void;
  89782. /**
  89783. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  89784. */
  89785. scaling: Vector3;
  89786. /**
  89787. * Returns true if the mesh is blocked. Implemented by child classes
  89788. */
  89789. readonly isBlocked: boolean;
  89790. /**
  89791. * Returns the mesh itself by default. Implemented by child classes
  89792. * @param camera defines the camera to use to pick the right LOD level
  89793. * @returns the currentAbstractMesh
  89794. */
  89795. getLOD(camera: Camera): Nullable<AbstractMesh>;
  89796. /**
  89797. * Returns 0 by default. Implemented by child classes
  89798. * @returns an integer
  89799. */
  89800. getTotalVertices(): number;
  89801. /**
  89802. * Returns a positive integer : the total number of indices in this mesh geometry.
  89803. * @returns the numner of indices or zero if the mesh has no geometry.
  89804. */
  89805. getTotalIndices(): number;
  89806. /**
  89807. * Returns null by default. Implemented by child classes
  89808. * @returns null
  89809. */
  89810. getIndices(): Nullable<IndicesArray>;
  89811. /**
  89812. * Returns the array of the requested vertex data kind. Implemented by child classes
  89813. * @param kind defines the vertex data kind to use
  89814. * @returns null
  89815. */
  89816. getVerticesData(kind: string): Nullable<FloatArray>;
  89817. /**
  89818. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89819. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89820. * Note that a new underlying VertexBuffer object is created each call.
  89821. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89822. * @param kind defines vertex data kind:
  89823. * * VertexBuffer.PositionKind
  89824. * * VertexBuffer.UVKind
  89825. * * VertexBuffer.UV2Kind
  89826. * * VertexBuffer.UV3Kind
  89827. * * VertexBuffer.UV4Kind
  89828. * * VertexBuffer.UV5Kind
  89829. * * VertexBuffer.UV6Kind
  89830. * * VertexBuffer.ColorKind
  89831. * * VertexBuffer.MatricesIndicesKind
  89832. * * VertexBuffer.MatricesIndicesExtraKind
  89833. * * VertexBuffer.MatricesWeightsKind
  89834. * * VertexBuffer.MatricesWeightsExtraKind
  89835. * @param data defines the data source
  89836. * @param updatable defines if the data must be flagged as updatable (or static)
  89837. * @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
  89838. * @returns the current mesh
  89839. */
  89840. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89841. /**
  89842. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89843. * If the mesh has no geometry, it is simply returned as it is.
  89844. * @param kind defines vertex data kind:
  89845. * * VertexBuffer.PositionKind
  89846. * * VertexBuffer.UVKind
  89847. * * VertexBuffer.UV2Kind
  89848. * * VertexBuffer.UV3Kind
  89849. * * VertexBuffer.UV4Kind
  89850. * * VertexBuffer.UV5Kind
  89851. * * VertexBuffer.UV6Kind
  89852. * * VertexBuffer.ColorKind
  89853. * * VertexBuffer.MatricesIndicesKind
  89854. * * VertexBuffer.MatricesIndicesExtraKind
  89855. * * VertexBuffer.MatricesWeightsKind
  89856. * * VertexBuffer.MatricesWeightsExtraKind
  89857. * @param data defines the data source
  89858. * @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
  89859. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  89860. * @returns the current mesh
  89861. */
  89862. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89863. /**
  89864. * Sets the mesh indices,
  89865. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89866. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  89867. * @param totalVertices Defines the total number of vertices
  89868. * @returns the current mesh
  89869. */
  89870. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  89871. /**
  89872. * Gets a boolean indicating if specific vertex data is present
  89873. * @param kind defines the vertex data kind to use
  89874. * @returns true is data kind is present
  89875. */
  89876. isVerticesDataPresent(kind: string): boolean;
  89877. /**
  89878. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  89879. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  89880. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  89881. * @returns a BoundingInfo
  89882. */
  89883. getBoundingInfo(): BoundingInfo;
  89884. /**
  89885. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  89886. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  89887. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  89888. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  89889. * @returns the current mesh
  89890. */
  89891. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  89892. /**
  89893. * Overwrite the current bounding info
  89894. * @param boundingInfo defines the new bounding info
  89895. * @returns the current mesh
  89896. */
  89897. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  89898. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  89899. readonly useBones: boolean;
  89900. /** @hidden */
  89901. _preActivate(): void;
  89902. /** @hidden */
  89903. _preActivateForIntermediateRendering(renderId: number): void;
  89904. /** @hidden */
  89905. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89906. /** @hidden */
  89907. _postActivate(): void;
  89908. /** @hidden */
  89909. _freeze(): void;
  89910. /** @hidden */
  89911. _unFreeze(): void;
  89912. /**
  89913. * Gets the current world matrix
  89914. * @returns a Matrix
  89915. */
  89916. getWorldMatrix(): Matrix;
  89917. /** @hidden */
  89918. _getWorldMatrixDeterminant(): number;
  89919. /**
  89920. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  89921. */
  89922. readonly isAnInstance: boolean;
  89923. /**
  89924. * Perform relative position change from the point of view of behind the front of the mesh.
  89925. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89926. * Supports definition of mesh facing forward or backward
  89927. * @param amountRight defines the distance on the right axis
  89928. * @param amountUp defines the distance on the up axis
  89929. * @param amountForward defines the distance on the forward axis
  89930. * @returns the current mesh
  89931. */
  89932. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  89933. /**
  89934. * Calculate relative position change from the point of view of behind the front of the mesh.
  89935. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89936. * Supports definition of mesh facing forward or backward
  89937. * @param amountRight defines the distance on the right axis
  89938. * @param amountUp defines the distance on the up axis
  89939. * @param amountForward defines the distance on the forward axis
  89940. * @returns the new displacement vector
  89941. */
  89942. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  89943. /**
  89944. * Perform relative rotation change from the point of view of behind the front of the mesh.
  89945. * Supports definition of mesh facing forward or backward
  89946. * @param flipBack defines the flip
  89947. * @param twirlClockwise defines the twirl
  89948. * @param tiltRight defines the tilt
  89949. * @returns the current mesh
  89950. */
  89951. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  89952. /**
  89953. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  89954. * Supports definition of mesh facing forward or backward.
  89955. * @param flipBack defines the flip
  89956. * @param twirlClockwise defines the twirl
  89957. * @param tiltRight defines the tilt
  89958. * @returns the new rotation vector
  89959. */
  89960. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  89961. /**
  89962. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89963. * This means the mesh underlying bounding box and sphere are recomputed.
  89964. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89965. * @returns the current mesh
  89966. */
  89967. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  89968. /** @hidden */
  89969. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  89970. /** @hidden */
  89971. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  89972. /** @hidden */
  89973. _updateBoundingInfo(): AbstractMesh;
  89974. /** @hidden */
  89975. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  89976. /** @hidden */
  89977. protected _afterComputeWorldMatrix(): void;
  89978. /** @hidden */
  89979. readonly _effectiveMesh: AbstractMesh;
  89980. /**
  89981. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89982. * A mesh is in the frustum if its bounding box intersects the frustum
  89983. * @param frustumPlanes defines the frustum to test
  89984. * @returns true if the mesh is in the frustum planes
  89985. */
  89986. isInFrustum(frustumPlanes: Plane[]): boolean;
  89987. /**
  89988. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  89989. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  89990. * @param frustumPlanes defines the frustum to test
  89991. * @returns true if the mesh is completely in the frustum planes
  89992. */
  89993. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89994. /**
  89995. * True if the mesh intersects another mesh or a SolidParticle object
  89996. * @param mesh defines a target mesh or SolidParticle to test
  89997. * @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)
  89998. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  89999. * @returns true if there is an intersection
  90000. */
  90001. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  90002. /**
  90003. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  90004. * @param point defines the point to test
  90005. * @returns true if there is an intersection
  90006. */
  90007. intersectsPoint(point: Vector3): boolean;
  90008. /**
  90009. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  90010. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90011. */
  90012. checkCollisions: boolean;
  90013. /**
  90014. * Gets Collider object used to compute collisions (not physics)
  90015. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90016. */
  90017. readonly collider: Nullable<Collider>;
  90018. /**
  90019. * Move the mesh using collision engine
  90020. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90021. * @param displacement defines the requested displacement vector
  90022. * @returns the current mesh
  90023. */
  90024. moveWithCollisions(displacement: Vector3): AbstractMesh;
  90025. private _onCollisionPositionChange;
  90026. /** @hidden */
  90027. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  90028. /** @hidden */
  90029. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  90030. /** @hidden */
  90031. _checkCollision(collider: Collider): AbstractMesh;
  90032. /** @hidden */
  90033. _generatePointsArray(): boolean;
  90034. /**
  90035. * Checks if the passed Ray intersects with the mesh
  90036. * @param ray defines the ray to use
  90037. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  90038. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90039. * @returns the picking info
  90040. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  90041. */
  90042. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  90043. /**
  90044. * Clones the current mesh
  90045. * @param name defines the mesh name
  90046. * @param newParent defines the new mesh parent
  90047. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  90048. * @returns the new mesh
  90049. */
  90050. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90051. /**
  90052. * Disposes all the submeshes of the current meshnp
  90053. * @returns the current mesh
  90054. */
  90055. releaseSubMeshes(): AbstractMesh;
  90056. /**
  90057. * Releases resources associated with this abstract mesh.
  90058. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90059. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90060. */
  90061. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90062. /**
  90063. * Adds the passed mesh as a child to the current mesh
  90064. * @param mesh defines the child mesh
  90065. * @returns the current mesh
  90066. */
  90067. addChild(mesh: AbstractMesh): AbstractMesh;
  90068. /**
  90069. * Removes the passed mesh from the current mesh children list
  90070. * @param mesh defines the child mesh
  90071. * @returns the current mesh
  90072. */
  90073. removeChild(mesh: AbstractMesh): AbstractMesh;
  90074. /** @hidden */
  90075. private _initFacetData;
  90076. /**
  90077. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  90078. * This method can be called within the render loop.
  90079. * 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
  90080. * @returns the current mesh
  90081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90082. */
  90083. updateFacetData(): AbstractMesh;
  90084. /**
  90085. * Returns the facetLocalNormals array.
  90086. * The normals are expressed in the mesh local spac
  90087. * @returns an array of Vector3
  90088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90089. */
  90090. getFacetLocalNormals(): Vector3[];
  90091. /**
  90092. * Returns the facetLocalPositions array.
  90093. * The facet positions are expressed in the mesh local space
  90094. * @returns an array of Vector3
  90095. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90096. */
  90097. getFacetLocalPositions(): Vector3[];
  90098. /**
  90099. * Returns the facetLocalPartioning array
  90100. * @returns an array of array of numbers
  90101. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90102. */
  90103. getFacetLocalPartitioning(): number[][];
  90104. /**
  90105. * Returns the i-th facet position in the world system.
  90106. * This method allocates a new Vector3 per call
  90107. * @param i defines the facet index
  90108. * @returns a new Vector3
  90109. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90110. */
  90111. getFacetPosition(i: number): Vector3;
  90112. /**
  90113. * Sets the reference Vector3 with the i-th facet position in the world system
  90114. * @param i defines the facet index
  90115. * @param ref defines the target vector
  90116. * @returns the current mesh
  90117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90118. */
  90119. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  90120. /**
  90121. * Returns the i-th facet normal in the world system.
  90122. * This method allocates a new Vector3 per call
  90123. * @param i defines the facet index
  90124. * @returns a new Vector3
  90125. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90126. */
  90127. getFacetNormal(i: number): Vector3;
  90128. /**
  90129. * Sets the reference Vector3 with the i-th facet normal in the world system
  90130. * @param i defines the facet index
  90131. * @param ref defines the target vector
  90132. * @returns the current mesh
  90133. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90134. */
  90135. getFacetNormalToRef(i: number, ref: Vector3): this;
  90136. /**
  90137. * 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)
  90138. * @param x defines x coordinate
  90139. * @param y defines y coordinate
  90140. * @param z defines z coordinate
  90141. * @returns the array of facet indexes
  90142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90143. */
  90144. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  90145. /**
  90146. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  90147. * @param projected sets as the (x,y,z) world projection on the facet
  90148. * @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
  90149. * @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
  90150. * @param x defines x coordinate
  90151. * @param y defines y coordinate
  90152. * @param z defines z coordinate
  90153. * @returns the face index if found (or null instead)
  90154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90155. */
  90156. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90157. /**
  90158. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  90159. * @param projected sets as the (x,y,z) local projection on the facet
  90160. * @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
  90161. * @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
  90162. * @param x defines x coordinate
  90163. * @param y defines y coordinate
  90164. * @param z defines z coordinate
  90165. * @returns the face index if found (or null instead)
  90166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90167. */
  90168. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90169. /**
  90170. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  90171. * @returns the parameters
  90172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90173. */
  90174. getFacetDataParameters(): any;
  90175. /**
  90176. * Disables the feature FacetData and frees the related memory
  90177. * @returns the current mesh
  90178. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90179. */
  90180. disableFacetData(): AbstractMesh;
  90181. /**
  90182. * Updates the AbstractMesh indices array
  90183. * @param indices defines the data source
  90184. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90185. * @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)
  90186. * @returns the current mesh
  90187. */
  90188. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90189. /**
  90190. * Creates new normals data for the mesh
  90191. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  90192. * @returns the current mesh
  90193. */
  90194. createNormals(updatable: boolean): AbstractMesh;
  90195. /**
  90196. * Align the mesh with a normal
  90197. * @param normal defines the normal to use
  90198. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  90199. * @returns the current mesh
  90200. */
  90201. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  90202. /** @hidden */
  90203. _checkOcclusionQuery(): boolean;
  90204. /**
  90205. * Disables the mesh edge rendering mode
  90206. * @returns the currentAbstractMesh
  90207. */
  90208. disableEdgesRendering(): AbstractMesh;
  90209. /**
  90210. * Enables the edge rendering mode on the mesh.
  90211. * This mode makes the mesh edges visible
  90212. * @param epsilon defines the maximal distance between two angles to detect a face
  90213. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90214. * @returns the currentAbstractMesh
  90215. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90216. */
  90217. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90218. }
  90219. }
  90220. declare module BABYLON {
  90221. /**
  90222. * Interface used to define ActionEvent
  90223. */
  90224. export interface IActionEvent {
  90225. /** The mesh or sprite that triggered the action */
  90226. source: any;
  90227. /** The X mouse cursor position at the time of the event */
  90228. pointerX: number;
  90229. /** The Y mouse cursor position at the time of the event */
  90230. pointerY: number;
  90231. /** The mesh that is currently pointed at (can be null) */
  90232. meshUnderPointer: Nullable<AbstractMesh>;
  90233. /** the original (browser) event that triggered the ActionEvent */
  90234. sourceEvent?: any;
  90235. /** additional data for the event */
  90236. additionalData?: any;
  90237. }
  90238. /**
  90239. * ActionEvent is the event being sent when an action is triggered.
  90240. */
  90241. export class ActionEvent implements IActionEvent {
  90242. /** The mesh or sprite that triggered the action */
  90243. source: any;
  90244. /** The X mouse cursor position at the time of the event */
  90245. pointerX: number;
  90246. /** The Y mouse cursor position at the time of the event */
  90247. pointerY: number;
  90248. /** The mesh that is currently pointed at (can be null) */
  90249. meshUnderPointer: Nullable<AbstractMesh>;
  90250. /** the original (browser) event that triggered the ActionEvent */
  90251. sourceEvent?: any;
  90252. /** additional data for the event */
  90253. additionalData?: any;
  90254. /**
  90255. * Creates a new ActionEvent
  90256. * @param source The mesh or sprite that triggered the action
  90257. * @param pointerX The X mouse cursor position at the time of the event
  90258. * @param pointerY The Y mouse cursor position at the time of the event
  90259. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  90260. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  90261. * @param additionalData additional data for the event
  90262. */
  90263. constructor(
  90264. /** The mesh or sprite that triggered the action */
  90265. source: any,
  90266. /** The X mouse cursor position at the time of the event */
  90267. pointerX: number,
  90268. /** The Y mouse cursor position at the time of the event */
  90269. pointerY: number,
  90270. /** The mesh that is currently pointed at (can be null) */
  90271. meshUnderPointer: Nullable<AbstractMesh>,
  90272. /** the original (browser) event that triggered the ActionEvent */
  90273. sourceEvent?: any,
  90274. /** additional data for the event */
  90275. additionalData?: any);
  90276. /**
  90277. * Helper function to auto-create an ActionEvent from a source mesh.
  90278. * @param source The source mesh that triggered the event
  90279. * @param evt The original (browser) event
  90280. * @param additionalData additional data for the event
  90281. * @returns the new ActionEvent
  90282. */
  90283. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  90284. /**
  90285. * Helper function to auto-create an ActionEvent from a source sprite
  90286. * @param source The source sprite that triggered the event
  90287. * @param scene Scene associated with the sprite
  90288. * @param evt The original (browser) event
  90289. * @param additionalData additional data for the event
  90290. * @returns the new ActionEvent
  90291. */
  90292. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  90293. /**
  90294. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  90295. * @param scene the scene where the event occurred
  90296. * @param evt The original (browser) event
  90297. * @returns the new ActionEvent
  90298. */
  90299. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  90300. /**
  90301. * Helper function to auto-create an ActionEvent from a primitive
  90302. * @param prim defines the target primitive
  90303. * @param pointerPos defines the pointer position
  90304. * @param evt The original (browser) event
  90305. * @param additionalData additional data for the event
  90306. * @returns the new ActionEvent
  90307. */
  90308. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  90309. }
  90310. }
  90311. declare module BABYLON {
  90312. /**
  90313. * Abstract class used to decouple action Manager from scene and meshes.
  90314. * Do not instantiate.
  90315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90316. */
  90317. export abstract class AbstractActionManager implements IDisposable {
  90318. /** Gets the list of active triggers */
  90319. static Triggers: {
  90320. [key: string]: number;
  90321. };
  90322. /** Gets the cursor to use when hovering items */
  90323. hoverCursor: string;
  90324. /** Gets the list of actions */
  90325. actions: IAction[];
  90326. /**
  90327. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  90328. */
  90329. isRecursive: boolean;
  90330. /**
  90331. * Releases all associated resources
  90332. */
  90333. abstract dispose(): void;
  90334. /**
  90335. * Does this action manager has pointer triggers
  90336. */
  90337. abstract readonly hasPointerTriggers: boolean;
  90338. /**
  90339. * Does this action manager has pick triggers
  90340. */
  90341. abstract readonly hasPickTriggers: boolean;
  90342. /**
  90343. * Process a specific trigger
  90344. * @param trigger defines the trigger to process
  90345. * @param evt defines the event details to be processed
  90346. */
  90347. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  90348. /**
  90349. * Does this action manager handles actions of any of the given triggers
  90350. * @param triggers defines the triggers to be tested
  90351. * @return a boolean indicating whether one (or more) of the triggers is handled
  90352. */
  90353. abstract hasSpecificTriggers(triggers: number[]): boolean;
  90354. /**
  90355. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90356. * speed.
  90357. * @param triggerA defines the trigger to be tested
  90358. * @param triggerB defines the trigger to be tested
  90359. * @return a boolean indicating whether one (or more) of the triggers is handled
  90360. */
  90361. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90362. /**
  90363. * Does this action manager handles actions of a given trigger
  90364. * @param trigger defines the trigger to be tested
  90365. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90366. * @return whether the trigger is handled
  90367. */
  90368. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90369. /**
  90370. * Serialize this manager to a JSON object
  90371. * @param name defines the property name to store this manager
  90372. * @returns a JSON representation of this manager
  90373. */
  90374. abstract serialize(name: string): any;
  90375. /**
  90376. * Registers an action to this action manager
  90377. * @param action defines the action to be registered
  90378. * @return the action amended (prepared) after registration
  90379. */
  90380. abstract registerAction(action: IAction): Nullable<IAction>;
  90381. /**
  90382. * Unregisters an action to this action manager
  90383. * @param action defines the action to be unregistered
  90384. * @return a boolean indicating whether the action has been unregistered
  90385. */
  90386. abstract unregisterAction(action: IAction): Boolean;
  90387. /**
  90388. * Does exist one action manager with at least one trigger
  90389. **/
  90390. static readonly HasTriggers: boolean;
  90391. /**
  90392. * Does exist one action manager with at least one pick trigger
  90393. **/
  90394. static readonly HasPickTriggers: boolean;
  90395. /**
  90396. * Does exist one action manager that handles actions of a given trigger
  90397. * @param trigger defines the trigger to be tested
  90398. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  90399. **/
  90400. static HasSpecificTrigger(trigger: number): boolean;
  90401. }
  90402. }
  90403. declare module BABYLON {
  90404. /**
  90405. * Defines how a node can be built from a string name.
  90406. */
  90407. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  90408. /**
  90409. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  90410. */
  90411. export class Node implements IBehaviorAware<Node> {
  90412. /** @hidden */
  90413. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  90414. private static _NodeConstructors;
  90415. /**
  90416. * Add a new node constructor
  90417. * @param type defines the type name of the node to construct
  90418. * @param constructorFunc defines the constructor function
  90419. */
  90420. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  90421. /**
  90422. * Returns a node constructor based on type name
  90423. * @param type defines the type name
  90424. * @param name defines the new node name
  90425. * @param scene defines the hosting scene
  90426. * @param options defines optional options to transmit to constructors
  90427. * @returns the new constructor or null
  90428. */
  90429. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  90430. /**
  90431. * Gets or sets the name of the node
  90432. */
  90433. name: string;
  90434. /**
  90435. * Gets or sets the id of the node
  90436. */
  90437. id: string;
  90438. /**
  90439. * Gets or sets the unique id of the node
  90440. */
  90441. uniqueId: number;
  90442. /**
  90443. * Gets or sets a string used to store user defined state for the node
  90444. */
  90445. state: string;
  90446. /**
  90447. * Gets or sets an object used to store user defined information for the node
  90448. */
  90449. metadata: any;
  90450. /**
  90451. * For internal use only. Please do not use.
  90452. */
  90453. reservedDataStore: any;
  90454. /**
  90455. * List of inspectable custom properties (used by the Inspector)
  90456. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  90457. */
  90458. inspectableCustomProperties: IInspectable[];
  90459. /**
  90460. * Gets or sets a boolean used to define if the node must be serialized
  90461. */
  90462. doNotSerialize: boolean;
  90463. /** @hidden */
  90464. _isDisposed: boolean;
  90465. /**
  90466. * Gets a list of Animations associated with the node
  90467. */
  90468. animations: Animation[];
  90469. protected _ranges: {
  90470. [name: string]: Nullable<AnimationRange>;
  90471. };
  90472. /**
  90473. * Callback raised when the node is ready to be used
  90474. */
  90475. onReady: Nullable<(node: Node) => void>;
  90476. private _isEnabled;
  90477. private _isParentEnabled;
  90478. private _isReady;
  90479. /** @hidden */
  90480. _currentRenderId: number;
  90481. private _parentUpdateId;
  90482. /** @hidden */
  90483. _childUpdateId: number;
  90484. /** @hidden */
  90485. _waitingParentId: Nullable<string>;
  90486. /** @hidden */
  90487. _scene: Scene;
  90488. /** @hidden */
  90489. _cache: any;
  90490. private _parentNode;
  90491. private _children;
  90492. /** @hidden */
  90493. _worldMatrix: Matrix;
  90494. /** @hidden */
  90495. _worldMatrixDeterminant: number;
  90496. /** @hidden */
  90497. _worldMatrixDeterminantIsDirty: boolean;
  90498. /** @hidden */
  90499. private _sceneRootNodesIndex;
  90500. /**
  90501. * Gets a boolean indicating if the node has been disposed
  90502. * @returns true if the node was disposed
  90503. */
  90504. isDisposed(): boolean;
  90505. /**
  90506. * Gets or sets the parent of the node (without keeping the current position in the scene)
  90507. * @see https://doc.babylonjs.com/how_to/parenting
  90508. */
  90509. parent: Nullable<Node>;
  90510. private addToSceneRootNodes;
  90511. private removeFromSceneRootNodes;
  90512. private _animationPropertiesOverride;
  90513. /**
  90514. * Gets or sets the animation properties override
  90515. */
  90516. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90517. /**
  90518. * Gets a string idenfifying the name of the class
  90519. * @returns "Node" string
  90520. */
  90521. getClassName(): string;
  90522. /** @hidden */
  90523. readonly _isNode: boolean;
  90524. /**
  90525. * An event triggered when the mesh is disposed
  90526. */
  90527. onDisposeObservable: Observable<Node>;
  90528. private _onDisposeObserver;
  90529. /**
  90530. * Sets a callback that will be raised when the node will be disposed
  90531. */
  90532. onDispose: () => void;
  90533. /**
  90534. * Creates a new Node
  90535. * @param name the name and id to be given to this node
  90536. * @param scene the scene this node will be added to
  90537. * @param addToRootNodes the node will be added to scene.rootNodes
  90538. */
  90539. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  90540. /**
  90541. * Gets the scene of the node
  90542. * @returns a scene
  90543. */
  90544. getScene(): Scene;
  90545. /**
  90546. * Gets the engine of the node
  90547. * @returns a Engine
  90548. */
  90549. getEngine(): Engine;
  90550. private _behaviors;
  90551. /**
  90552. * Attach a behavior to the node
  90553. * @see http://doc.babylonjs.com/features/behaviour
  90554. * @param behavior defines the behavior to attach
  90555. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  90556. * @returns the current Node
  90557. */
  90558. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  90559. /**
  90560. * Remove an attached behavior
  90561. * @see http://doc.babylonjs.com/features/behaviour
  90562. * @param behavior defines the behavior to attach
  90563. * @returns the current Node
  90564. */
  90565. removeBehavior(behavior: Behavior<Node>): Node;
  90566. /**
  90567. * Gets the list of attached behaviors
  90568. * @see http://doc.babylonjs.com/features/behaviour
  90569. */
  90570. readonly behaviors: Behavior<Node>[];
  90571. /**
  90572. * Gets an attached behavior by name
  90573. * @param name defines the name of the behavior to look for
  90574. * @see http://doc.babylonjs.com/features/behaviour
  90575. * @returns null if behavior was not found else the requested behavior
  90576. */
  90577. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  90578. /**
  90579. * Returns the latest update of the World matrix
  90580. * @returns a Matrix
  90581. */
  90582. getWorldMatrix(): Matrix;
  90583. /** @hidden */
  90584. _getWorldMatrixDeterminant(): number;
  90585. /**
  90586. * Returns directly the latest state of the mesh World matrix.
  90587. * A Matrix is returned.
  90588. */
  90589. readonly worldMatrixFromCache: Matrix;
  90590. /** @hidden */
  90591. _initCache(): void;
  90592. /** @hidden */
  90593. updateCache(force?: boolean): void;
  90594. /** @hidden */
  90595. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90596. /** @hidden */
  90597. _updateCache(ignoreParentClass?: boolean): void;
  90598. /** @hidden */
  90599. _isSynchronized(): boolean;
  90600. /** @hidden */
  90601. _markSyncedWithParent(): void;
  90602. /** @hidden */
  90603. isSynchronizedWithParent(): boolean;
  90604. /** @hidden */
  90605. isSynchronized(): boolean;
  90606. /**
  90607. * Is this node ready to be used/rendered
  90608. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90609. * @return true if the node is ready
  90610. */
  90611. isReady(completeCheck?: boolean): boolean;
  90612. /**
  90613. * Is this node enabled?
  90614. * 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
  90615. * @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
  90616. * @return whether this node (and its parent) is enabled
  90617. */
  90618. isEnabled(checkAncestors?: boolean): boolean;
  90619. /** @hidden */
  90620. protected _syncParentEnabledState(): void;
  90621. /**
  90622. * Set the enabled state of this node
  90623. * @param value defines the new enabled state
  90624. */
  90625. setEnabled(value: boolean): void;
  90626. /**
  90627. * Is this node a descendant of the given node?
  90628. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  90629. * @param ancestor defines the parent node to inspect
  90630. * @returns a boolean indicating if this node is a descendant of the given node
  90631. */
  90632. isDescendantOf(ancestor: Node): boolean;
  90633. /** @hidden */
  90634. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  90635. /**
  90636. * Will return all nodes that have this node as ascendant
  90637. * @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
  90638. * @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
  90639. * @return all children nodes of all types
  90640. */
  90641. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  90642. /**
  90643. * Get all child-meshes of this node
  90644. * @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)
  90645. * @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
  90646. * @returns an array of AbstractMesh
  90647. */
  90648. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  90649. /**
  90650. * Get all direct children of this node
  90651. * @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
  90652. * @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)
  90653. * @returns an array of Node
  90654. */
  90655. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  90656. /** @hidden */
  90657. _setReady(state: boolean): void;
  90658. /**
  90659. * Get an animation by name
  90660. * @param name defines the name of the animation to look for
  90661. * @returns null if not found else the requested animation
  90662. */
  90663. getAnimationByName(name: string): Nullable<Animation>;
  90664. /**
  90665. * Creates an animation range for this node
  90666. * @param name defines the name of the range
  90667. * @param from defines the starting key
  90668. * @param to defines the end key
  90669. */
  90670. createAnimationRange(name: string, from: number, to: number): void;
  90671. /**
  90672. * Delete a specific animation range
  90673. * @param name defines the name of the range to delete
  90674. * @param deleteFrames defines if animation frames from the range must be deleted as well
  90675. */
  90676. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  90677. /**
  90678. * Get an animation range by name
  90679. * @param name defines the name of the animation range to look for
  90680. * @returns null if not found else the requested animation range
  90681. */
  90682. getAnimationRange(name: string): Nullable<AnimationRange>;
  90683. /**
  90684. * Gets the list of all animation ranges defined on this node
  90685. * @returns an array
  90686. */
  90687. getAnimationRanges(): Nullable<AnimationRange>[];
  90688. /**
  90689. * Will start the animation sequence
  90690. * @param name defines the range frames for animation sequence
  90691. * @param loop defines if the animation should loop (false by default)
  90692. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  90693. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  90694. * @returns the object created for this animation. If range does not exist, it will return null
  90695. */
  90696. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  90697. /**
  90698. * Serialize animation ranges into a JSON compatible object
  90699. * @returns serialization object
  90700. */
  90701. serializeAnimationRanges(): any;
  90702. /**
  90703. * Computes the world matrix of the node
  90704. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90705. * @returns the world matrix
  90706. */
  90707. computeWorldMatrix(force?: boolean): Matrix;
  90708. /**
  90709. * Releases resources associated with this node.
  90710. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90711. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90712. */
  90713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90714. /**
  90715. * Parse animation range data from a serialization object and store them into a given node
  90716. * @param node defines where to store the animation ranges
  90717. * @param parsedNode defines the serialization object to read data from
  90718. * @param scene defines the hosting scene
  90719. */
  90720. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  90721. /**
  90722. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  90723. * @param includeDescendants Include bounding info from descendants as well (true by default)
  90724. * @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
  90725. * @returns the new bounding vectors
  90726. */
  90727. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  90728. min: Vector3;
  90729. max: Vector3;
  90730. };
  90731. }
  90732. }
  90733. declare module BABYLON {
  90734. /**
  90735. * @hidden
  90736. */
  90737. export class _IAnimationState {
  90738. key: number;
  90739. repeatCount: number;
  90740. workValue?: any;
  90741. loopMode?: number;
  90742. offsetValue?: any;
  90743. highLimitValue?: any;
  90744. }
  90745. /**
  90746. * Class used to store any kind of animation
  90747. */
  90748. export class Animation {
  90749. /**Name of the animation */
  90750. name: string;
  90751. /**Property to animate */
  90752. targetProperty: string;
  90753. /**The frames per second of the animation */
  90754. framePerSecond: number;
  90755. /**The data type of the animation */
  90756. dataType: number;
  90757. /**The loop mode of the animation */
  90758. loopMode?: number | undefined;
  90759. /**Specifies if blending should be enabled */
  90760. enableBlending?: boolean | undefined;
  90761. /**
  90762. * Use matrix interpolation instead of using direct key value when animating matrices
  90763. */
  90764. static AllowMatricesInterpolation: boolean;
  90765. /**
  90766. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  90767. */
  90768. static AllowMatrixDecomposeForInterpolation: boolean;
  90769. /**
  90770. * Stores the key frames of the animation
  90771. */
  90772. private _keys;
  90773. /**
  90774. * Stores the easing function of the animation
  90775. */
  90776. private _easingFunction;
  90777. /**
  90778. * @hidden Internal use only
  90779. */
  90780. _runtimeAnimations: RuntimeAnimation[];
  90781. /**
  90782. * The set of event that will be linked to this animation
  90783. */
  90784. private _events;
  90785. /**
  90786. * Stores an array of target property paths
  90787. */
  90788. targetPropertyPath: string[];
  90789. /**
  90790. * Stores the blending speed of the animation
  90791. */
  90792. blendingSpeed: number;
  90793. /**
  90794. * Stores the animation ranges for the animation
  90795. */
  90796. private _ranges;
  90797. /**
  90798. * @hidden Internal use
  90799. */
  90800. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  90801. /**
  90802. * Sets up an animation
  90803. * @param property The property to animate
  90804. * @param animationType The animation type to apply
  90805. * @param framePerSecond The frames per second of the animation
  90806. * @param easingFunction The easing function used in the animation
  90807. * @returns The created animation
  90808. */
  90809. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  90810. /**
  90811. * Create and start an animation on a node
  90812. * @param name defines the name of the global animation that will be run on all nodes
  90813. * @param node defines the root node where the animation will take place
  90814. * @param targetProperty defines property to animate
  90815. * @param framePerSecond defines the number of frame per second yo use
  90816. * @param totalFrame defines the number of frames in total
  90817. * @param from defines the initial value
  90818. * @param to defines the final value
  90819. * @param loopMode defines which loop mode you want to use (off by default)
  90820. * @param easingFunction defines the easing function to use (linear by default)
  90821. * @param onAnimationEnd defines the callback to call when animation end
  90822. * @returns the animatable created for this animation
  90823. */
  90824. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90825. /**
  90826. * Create and start an animation on a node and its descendants
  90827. * @param name defines the name of the global animation that will be run on all nodes
  90828. * @param node defines the root node where the animation will take place
  90829. * @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
  90830. * @param targetProperty defines property to animate
  90831. * @param framePerSecond defines the number of frame per second to use
  90832. * @param totalFrame defines the number of frames in total
  90833. * @param from defines the initial value
  90834. * @param to defines the final value
  90835. * @param loopMode defines which loop mode you want to use (off by default)
  90836. * @param easingFunction defines the easing function to use (linear by default)
  90837. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90838. * @returns the list of animatables created for all nodes
  90839. * @example https://www.babylonjs-playground.com/#MH0VLI
  90840. */
  90841. 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[]>;
  90842. /**
  90843. * Creates a new animation, merges it with the existing animations and starts it
  90844. * @param name Name of the animation
  90845. * @param node Node which contains the scene that begins the animations
  90846. * @param targetProperty Specifies which property to animate
  90847. * @param framePerSecond The frames per second of the animation
  90848. * @param totalFrame The total number of frames
  90849. * @param from The frame at the beginning of the animation
  90850. * @param to The frame at the end of the animation
  90851. * @param loopMode Specifies the loop mode of the animation
  90852. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  90853. * @param onAnimationEnd Callback to run once the animation is complete
  90854. * @returns Nullable animation
  90855. */
  90856. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90857. /**
  90858. * Transition property of an host to the target Value
  90859. * @param property The property to transition
  90860. * @param targetValue The target Value of the property
  90861. * @param host The object where the property to animate belongs
  90862. * @param scene Scene used to run the animation
  90863. * @param frameRate Framerate (in frame/s) to use
  90864. * @param transition The transition type we want to use
  90865. * @param duration The duration of the animation, in milliseconds
  90866. * @param onAnimationEnd Callback trigger at the end of the animation
  90867. * @returns Nullable animation
  90868. */
  90869. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  90870. /**
  90871. * Return the array of runtime animations currently using this animation
  90872. */
  90873. readonly runtimeAnimations: RuntimeAnimation[];
  90874. /**
  90875. * Specifies if any of the runtime animations are currently running
  90876. */
  90877. readonly hasRunningRuntimeAnimations: boolean;
  90878. /**
  90879. * Initializes the animation
  90880. * @param name Name of the animation
  90881. * @param targetProperty Property to animate
  90882. * @param framePerSecond The frames per second of the animation
  90883. * @param dataType The data type of the animation
  90884. * @param loopMode The loop mode of the animation
  90885. * @param enableBlending Specifies if blending should be enabled
  90886. */
  90887. constructor(
  90888. /**Name of the animation */
  90889. name: string,
  90890. /**Property to animate */
  90891. targetProperty: string,
  90892. /**The frames per second of the animation */
  90893. framePerSecond: number,
  90894. /**The data type of the animation */
  90895. dataType: number,
  90896. /**The loop mode of the animation */
  90897. loopMode?: number | undefined,
  90898. /**Specifies if blending should be enabled */
  90899. enableBlending?: boolean | undefined);
  90900. /**
  90901. * Converts the animation to a string
  90902. * @param fullDetails support for multiple levels of logging within scene loading
  90903. * @returns String form of the animation
  90904. */
  90905. toString(fullDetails?: boolean): string;
  90906. /**
  90907. * Add an event to this animation
  90908. * @param event Event to add
  90909. */
  90910. addEvent(event: AnimationEvent): void;
  90911. /**
  90912. * Remove all events found at the given frame
  90913. * @param frame The frame to remove events from
  90914. */
  90915. removeEvents(frame: number): void;
  90916. /**
  90917. * Retrieves all the events from the animation
  90918. * @returns Events from the animation
  90919. */
  90920. getEvents(): AnimationEvent[];
  90921. /**
  90922. * Creates an animation range
  90923. * @param name Name of the animation range
  90924. * @param from Starting frame of the animation range
  90925. * @param to Ending frame of the animation
  90926. */
  90927. createRange(name: string, from: number, to: number): void;
  90928. /**
  90929. * Deletes an animation range by name
  90930. * @param name Name of the animation range to delete
  90931. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  90932. */
  90933. deleteRange(name: string, deleteFrames?: boolean): void;
  90934. /**
  90935. * Gets the animation range by name, or null if not defined
  90936. * @param name Name of the animation range
  90937. * @returns Nullable animation range
  90938. */
  90939. getRange(name: string): Nullable<AnimationRange>;
  90940. /**
  90941. * Gets the key frames from the animation
  90942. * @returns The key frames of the animation
  90943. */
  90944. getKeys(): Array<IAnimationKey>;
  90945. /**
  90946. * Gets the highest frame rate of the animation
  90947. * @returns Highest frame rate of the animation
  90948. */
  90949. getHighestFrame(): number;
  90950. /**
  90951. * Gets the easing function of the animation
  90952. * @returns Easing function of the animation
  90953. */
  90954. getEasingFunction(): IEasingFunction;
  90955. /**
  90956. * Sets the easing function of the animation
  90957. * @param easingFunction A custom mathematical formula for animation
  90958. */
  90959. setEasingFunction(easingFunction: EasingFunction): void;
  90960. /**
  90961. * Interpolates a scalar linearly
  90962. * @param startValue Start value of the animation curve
  90963. * @param endValue End value of the animation curve
  90964. * @param gradient Scalar amount to interpolate
  90965. * @returns Interpolated scalar value
  90966. */
  90967. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  90968. /**
  90969. * Interpolates a scalar cubically
  90970. * @param startValue Start value of the animation curve
  90971. * @param outTangent End tangent of the animation
  90972. * @param endValue End value of the animation curve
  90973. * @param inTangent Start tangent of the animation curve
  90974. * @param gradient Scalar amount to interpolate
  90975. * @returns Interpolated scalar value
  90976. */
  90977. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  90978. /**
  90979. * Interpolates a quaternion using a spherical linear interpolation
  90980. * @param startValue Start value of the animation curve
  90981. * @param endValue End value of the animation curve
  90982. * @param gradient Scalar amount to interpolate
  90983. * @returns Interpolated quaternion value
  90984. */
  90985. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  90986. /**
  90987. * Interpolates a quaternion cubically
  90988. * @param startValue Start value of the animation curve
  90989. * @param outTangent End tangent of the animation curve
  90990. * @param endValue End value of the animation curve
  90991. * @param inTangent Start tangent of the animation curve
  90992. * @param gradient Scalar amount to interpolate
  90993. * @returns Interpolated quaternion value
  90994. */
  90995. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  90996. /**
  90997. * Interpolates a Vector3 linearl
  90998. * @param startValue Start value of the animation curve
  90999. * @param endValue End value of the animation curve
  91000. * @param gradient Scalar amount to interpolate
  91001. * @returns Interpolated scalar value
  91002. */
  91003. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  91004. /**
  91005. * Interpolates a Vector3 cubically
  91006. * @param startValue Start value of the animation curve
  91007. * @param outTangent End tangent of the animation
  91008. * @param endValue End value of the animation curve
  91009. * @param inTangent Start tangent of the animation curve
  91010. * @param gradient Scalar amount to interpolate
  91011. * @returns InterpolatedVector3 value
  91012. */
  91013. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  91014. /**
  91015. * Interpolates a Vector2 linearly
  91016. * @param startValue Start value of the animation curve
  91017. * @param endValue End value of the animation curve
  91018. * @param gradient Scalar amount to interpolate
  91019. * @returns Interpolated Vector2 value
  91020. */
  91021. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  91022. /**
  91023. * Interpolates a Vector2 cubically
  91024. * @param startValue Start value of the animation curve
  91025. * @param outTangent End tangent of the animation
  91026. * @param endValue End value of the animation curve
  91027. * @param inTangent Start tangent of the animation curve
  91028. * @param gradient Scalar amount to interpolate
  91029. * @returns Interpolated Vector2 value
  91030. */
  91031. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  91032. /**
  91033. * Interpolates a size linearly
  91034. * @param startValue Start value of the animation curve
  91035. * @param endValue End value of the animation curve
  91036. * @param gradient Scalar amount to interpolate
  91037. * @returns Interpolated Size value
  91038. */
  91039. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  91040. /**
  91041. * Interpolates a Color3 linearly
  91042. * @param startValue Start value of the animation curve
  91043. * @param endValue End value of the animation curve
  91044. * @param gradient Scalar amount to interpolate
  91045. * @returns Interpolated Color3 value
  91046. */
  91047. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  91048. /**
  91049. * @hidden Internal use only
  91050. */
  91051. _getKeyValue(value: any): any;
  91052. /**
  91053. * @hidden Internal use only
  91054. */
  91055. _interpolate(currentFrame: number, state: _IAnimationState): any;
  91056. /**
  91057. * Defines the function to use to interpolate matrices
  91058. * @param startValue defines the start matrix
  91059. * @param endValue defines the end matrix
  91060. * @param gradient defines the gradient between both matrices
  91061. * @param result defines an optional target matrix where to store the interpolation
  91062. * @returns the interpolated matrix
  91063. */
  91064. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  91065. /**
  91066. * Makes a copy of the animation
  91067. * @returns Cloned animation
  91068. */
  91069. clone(): Animation;
  91070. /**
  91071. * Sets the key frames of the animation
  91072. * @param values The animation key frames to set
  91073. */
  91074. setKeys(values: Array<IAnimationKey>): void;
  91075. /**
  91076. * Serializes the animation to an object
  91077. * @returns Serialized object
  91078. */
  91079. serialize(): any;
  91080. /**
  91081. * Float animation type
  91082. */
  91083. private static _ANIMATIONTYPE_FLOAT;
  91084. /**
  91085. * Vector3 animation type
  91086. */
  91087. private static _ANIMATIONTYPE_VECTOR3;
  91088. /**
  91089. * Quaternion animation type
  91090. */
  91091. private static _ANIMATIONTYPE_QUATERNION;
  91092. /**
  91093. * Matrix animation type
  91094. */
  91095. private static _ANIMATIONTYPE_MATRIX;
  91096. /**
  91097. * Color3 animation type
  91098. */
  91099. private static _ANIMATIONTYPE_COLOR3;
  91100. /**
  91101. * Vector2 animation type
  91102. */
  91103. private static _ANIMATIONTYPE_VECTOR2;
  91104. /**
  91105. * Size animation type
  91106. */
  91107. private static _ANIMATIONTYPE_SIZE;
  91108. /**
  91109. * Relative Loop Mode
  91110. */
  91111. private static _ANIMATIONLOOPMODE_RELATIVE;
  91112. /**
  91113. * Cycle Loop Mode
  91114. */
  91115. private static _ANIMATIONLOOPMODE_CYCLE;
  91116. /**
  91117. * Constant Loop Mode
  91118. */
  91119. private static _ANIMATIONLOOPMODE_CONSTANT;
  91120. /**
  91121. * Get the float animation type
  91122. */
  91123. static readonly ANIMATIONTYPE_FLOAT: number;
  91124. /**
  91125. * Get the Vector3 animation type
  91126. */
  91127. static readonly ANIMATIONTYPE_VECTOR3: number;
  91128. /**
  91129. * Get the Vector2 animation type
  91130. */
  91131. static readonly ANIMATIONTYPE_VECTOR2: number;
  91132. /**
  91133. * Get the Size animation type
  91134. */
  91135. static readonly ANIMATIONTYPE_SIZE: number;
  91136. /**
  91137. * Get the Quaternion animation type
  91138. */
  91139. static readonly ANIMATIONTYPE_QUATERNION: number;
  91140. /**
  91141. * Get the Matrix animation type
  91142. */
  91143. static readonly ANIMATIONTYPE_MATRIX: number;
  91144. /**
  91145. * Get the Color3 animation type
  91146. */
  91147. static readonly ANIMATIONTYPE_COLOR3: number;
  91148. /**
  91149. * Get the Relative Loop Mode
  91150. */
  91151. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  91152. /**
  91153. * Get the Cycle Loop Mode
  91154. */
  91155. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  91156. /**
  91157. * Get the Constant Loop Mode
  91158. */
  91159. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  91160. /** @hidden */
  91161. static _UniversalLerp(left: any, right: any, amount: number): any;
  91162. /**
  91163. * Parses an animation object and creates an animation
  91164. * @param parsedAnimation Parsed animation object
  91165. * @returns Animation object
  91166. */
  91167. static Parse(parsedAnimation: any): Animation;
  91168. /**
  91169. * Appends the serialized animations from the source animations
  91170. * @param source Source containing the animations
  91171. * @param destination Target to store the animations
  91172. */
  91173. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91174. }
  91175. }
  91176. declare module BABYLON {
  91177. /**
  91178. * Interface containing an array of animations
  91179. */
  91180. export interface IAnimatable {
  91181. /**
  91182. * Array of animations
  91183. */
  91184. animations: Nullable<Array<Animation>>;
  91185. }
  91186. }
  91187. declare module BABYLON {
  91188. /**
  91189. * This represents all the required information to add a fresnel effect on a material:
  91190. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  91191. */
  91192. export class FresnelParameters {
  91193. private _isEnabled;
  91194. /**
  91195. * Define if the fresnel effect is enable or not.
  91196. */
  91197. isEnabled: boolean;
  91198. /**
  91199. * Define the color used on edges (grazing angle)
  91200. */
  91201. leftColor: Color3;
  91202. /**
  91203. * Define the color used on center
  91204. */
  91205. rightColor: Color3;
  91206. /**
  91207. * Define bias applied to computed fresnel term
  91208. */
  91209. bias: number;
  91210. /**
  91211. * Defined the power exponent applied to fresnel term
  91212. */
  91213. power: number;
  91214. /**
  91215. * Clones the current fresnel and its valuues
  91216. * @returns a clone fresnel configuration
  91217. */
  91218. clone(): FresnelParameters;
  91219. /**
  91220. * Serializes the current fresnel parameters to a JSON representation.
  91221. * @return the JSON serialization
  91222. */
  91223. serialize(): any;
  91224. /**
  91225. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  91226. * @param parsedFresnelParameters Define the JSON representation
  91227. * @returns the parsed parameters
  91228. */
  91229. static Parse(parsedFresnelParameters: any): FresnelParameters;
  91230. }
  91231. }
  91232. declare module BABYLON {
  91233. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  91234. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91235. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91236. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91237. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91238. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91239. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91240. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91241. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91242. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91243. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91244. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91245. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91246. /**
  91247. * Decorator used to define property that can be serialized as reference to a camera
  91248. * @param sourceName defines the name of the property to decorate
  91249. */
  91250. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91251. /**
  91252. * Class used to help serialization objects
  91253. */
  91254. export class SerializationHelper {
  91255. /** @hidden */
  91256. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  91257. /** @hidden */
  91258. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  91259. /** @hidden */
  91260. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  91261. /** @hidden */
  91262. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  91263. /**
  91264. * Appends the serialized animations from the source animations
  91265. * @param source Source containing the animations
  91266. * @param destination Target to store the animations
  91267. */
  91268. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91269. /**
  91270. * Static function used to serialized a specific entity
  91271. * @param entity defines the entity to serialize
  91272. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  91273. * @returns a JSON compatible object representing the serialization of the entity
  91274. */
  91275. static Serialize<T>(entity: T, serializationObject?: any): any;
  91276. /**
  91277. * Creates a new entity from a serialization data object
  91278. * @param creationFunction defines a function used to instanciated the new entity
  91279. * @param source defines the source serialization data
  91280. * @param scene defines the hosting scene
  91281. * @param rootUrl defines the root url for resources
  91282. * @returns a new entity
  91283. */
  91284. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  91285. /**
  91286. * Clones an object
  91287. * @param creationFunction defines the function used to instanciate the new object
  91288. * @param source defines the source object
  91289. * @returns the cloned object
  91290. */
  91291. static Clone<T>(creationFunction: () => T, source: T): T;
  91292. /**
  91293. * Instanciates a new object based on a source one (some data will be shared between both object)
  91294. * @param creationFunction defines the function used to instanciate the new object
  91295. * @param source defines the source object
  91296. * @returns the new object
  91297. */
  91298. static Instanciate<T>(creationFunction: () => T, source: T): T;
  91299. }
  91300. }
  91301. declare module BABYLON {
  91302. /**
  91303. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  91304. */
  91305. export interface CubeMapInfo {
  91306. /**
  91307. * The pixel array for the front face.
  91308. * This is stored in format, left to right, up to down format.
  91309. */
  91310. front: Nullable<ArrayBufferView>;
  91311. /**
  91312. * The pixel array for the back face.
  91313. * This is stored in format, left to right, up to down format.
  91314. */
  91315. back: Nullable<ArrayBufferView>;
  91316. /**
  91317. * The pixel array for the left face.
  91318. * This is stored in format, left to right, up to down format.
  91319. */
  91320. left: Nullable<ArrayBufferView>;
  91321. /**
  91322. * The pixel array for the right face.
  91323. * This is stored in format, left to right, up to down format.
  91324. */
  91325. right: Nullable<ArrayBufferView>;
  91326. /**
  91327. * The pixel array for the up face.
  91328. * This is stored in format, left to right, up to down format.
  91329. */
  91330. up: Nullable<ArrayBufferView>;
  91331. /**
  91332. * The pixel array for the down face.
  91333. * This is stored in format, left to right, up to down format.
  91334. */
  91335. down: Nullable<ArrayBufferView>;
  91336. /**
  91337. * The size of the cubemap stored.
  91338. *
  91339. * Each faces will be size * size pixels.
  91340. */
  91341. size: number;
  91342. /**
  91343. * The format of the texture.
  91344. *
  91345. * RGBA, RGB.
  91346. */
  91347. format: number;
  91348. /**
  91349. * The type of the texture data.
  91350. *
  91351. * UNSIGNED_INT, FLOAT.
  91352. */
  91353. type: number;
  91354. /**
  91355. * Specifies whether the texture is in gamma space.
  91356. */
  91357. gammaSpace: boolean;
  91358. }
  91359. /**
  91360. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91361. */
  91362. export class PanoramaToCubeMapTools {
  91363. private static FACE_FRONT;
  91364. private static FACE_BACK;
  91365. private static FACE_RIGHT;
  91366. private static FACE_LEFT;
  91367. private static FACE_DOWN;
  91368. private static FACE_UP;
  91369. /**
  91370. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91371. *
  91372. * @param float32Array The source data.
  91373. * @param inputWidth The width of the input panorama.
  91374. * @param inputHeight The height of the input panorama.
  91375. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91376. * @return The cubemap data
  91377. */
  91378. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  91379. private static CreateCubemapTexture;
  91380. private static CalcProjectionSpherical;
  91381. }
  91382. }
  91383. declare module BABYLON {
  91384. /**
  91385. * Helper class dealing with the extraction of spherical polynomial dataArray
  91386. * from a cube map.
  91387. */
  91388. export class CubeMapToSphericalPolynomialTools {
  91389. private static FileFaces;
  91390. /**
  91391. * Converts a texture to the according Spherical Polynomial data.
  91392. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91393. *
  91394. * @param texture The texture to extract the information from.
  91395. * @return The Spherical Polynomial data.
  91396. */
  91397. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  91398. /**
  91399. * Converts a cubemap to the according Spherical Polynomial data.
  91400. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91401. *
  91402. * @param cubeInfo The Cube map to extract the information from.
  91403. * @return The Spherical Polynomial data.
  91404. */
  91405. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  91406. }
  91407. }
  91408. declare module BABYLON {
  91409. /**
  91410. * Class used to manipulate GUIDs
  91411. */
  91412. export class GUID {
  91413. /**
  91414. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91415. * Be aware Math.random() could cause collisions, but:
  91416. * "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"
  91417. * @returns a pseudo random id
  91418. */
  91419. static RandomId(): string;
  91420. }
  91421. }
  91422. declare module BABYLON {
  91423. /**
  91424. * Base class of all the textures in babylon.
  91425. * It groups all the common properties the materials, post process, lights... might need
  91426. * in order to make a correct use of the texture.
  91427. */
  91428. export class BaseTexture implements IAnimatable {
  91429. /**
  91430. * Default anisotropic filtering level for the application.
  91431. * It is set to 4 as a good tradeoff between perf and quality.
  91432. */
  91433. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  91434. /**
  91435. * Gets or sets the unique id of the texture
  91436. */
  91437. uniqueId: number;
  91438. /**
  91439. * Define the name of the texture.
  91440. */
  91441. name: string;
  91442. /**
  91443. * Gets or sets an object used to store user defined information.
  91444. */
  91445. metadata: any;
  91446. /**
  91447. * For internal use only. Please do not use.
  91448. */
  91449. reservedDataStore: any;
  91450. private _hasAlpha;
  91451. /**
  91452. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  91453. */
  91454. hasAlpha: boolean;
  91455. /**
  91456. * Defines if the alpha value should be determined via the rgb values.
  91457. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  91458. */
  91459. getAlphaFromRGB: boolean;
  91460. /**
  91461. * Intensity or strength of the texture.
  91462. * It is commonly used by materials to fine tune the intensity of the texture
  91463. */
  91464. level: number;
  91465. /**
  91466. * Define the UV chanel to use starting from 0 and defaulting to 0.
  91467. * This is part of the texture as textures usually maps to one uv set.
  91468. */
  91469. coordinatesIndex: number;
  91470. private _coordinatesMode;
  91471. /**
  91472. * How a texture is mapped.
  91473. *
  91474. * | Value | Type | Description |
  91475. * | ----- | ----------------------------------- | ----------- |
  91476. * | 0 | EXPLICIT_MODE | |
  91477. * | 1 | SPHERICAL_MODE | |
  91478. * | 2 | PLANAR_MODE | |
  91479. * | 3 | CUBIC_MODE | |
  91480. * | 4 | PROJECTION_MODE | |
  91481. * | 5 | SKYBOX_MODE | |
  91482. * | 6 | INVCUBIC_MODE | |
  91483. * | 7 | EQUIRECTANGULAR_MODE | |
  91484. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  91485. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  91486. */
  91487. coordinatesMode: number;
  91488. /**
  91489. * | Value | Type | Description |
  91490. * | ----- | ------------------ | ----------- |
  91491. * | 0 | CLAMP_ADDRESSMODE | |
  91492. * | 1 | WRAP_ADDRESSMODE | |
  91493. * | 2 | MIRROR_ADDRESSMODE | |
  91494. */
  91495. wrapU: number;
  91496. /**
  91497. * | Value | Type | Description |
  91498. * | ----- | ------------------ | ----------- |
  91499. * | 0 | CLAMP_ADDRESSMODE | |
  91500. * | 1 | WRAP_ADDRESSMODE | |
  91501. * | 2 | MIRROR_ADDRESSMODE | |
  91502. */
  91503. wrapV: number;
  91504. /**
  91505. * | Value | Type | Description |
  91506. * | ----- | ------------------ | ----------- |
  91507. * | 0 | CLAMP_ADDRESSMODE | |
  91508. * | 1 | WRAP_ADDRESSMODE | |
  91509. * | 2 | MIRROR_ADDRESSMODE | |
  91510. */
  91511. wrapR: number;
  91512. /**
  91513. * With compliant hardware and browser (supporting anisotropic filtering)
  91514. * this defines the level of anisotropic filtering in the texture.
  91515. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  91516. */
  91517. anisotropicFilteringLevel: number;
  91518. /**
  91519. * Define if the texture is a cube texture or if false a 2d texture.
  91520. */
  91521. isCube: boolean;
  91522. /**
  91523. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  91524. */
  91525. is3D: boolean;
  91526. /**
  91527. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  91528. * HDR texture are usually stored in linear space.
  91529. * This only impacts the PBR and Background materials
  91530. */
  91531. gammaSpace: boolean;
  91532. /**
  91533. * Gets whether or not the texture contains RGBD data.
  91534. */
  91535. readonly isRGBD: boolean;
  91536. /**
  91537. * Is Z inverted in the texture (useful in a cube texture).
  91538. */
  91539. invertZ: boolean;
  91540. /**
  91541. * Are mip maps generated for this texture or not.
  91542. */
  91543. readonly noMipmap: boolean;
  91544. /**
  91545. * @hidden
  91546. */
  91547. lodLevelInAlpha: boolean;
  91548. /**
  91549. * With prefiltered texture, defined the offset used during the prefiltering steps.
  91550. */
  91551. lodGenerationOffset: number;
  91552. /**
  91553. * With prefiltered texture, defined the scale used during the prefiltering steps.
  91554. */
  91555. lodGenerationScale: number;
  91556. /**
  91557. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  91558. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  91559. * average roughness values.
  91560. */
  91561. linearSpecularLOD: boolean;
  91562. /**
  91563. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  91564. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  91565. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  91566. */
  91567. irradianceTexture: Nullable<BaseTexture>;
  91568. /**
  91569. * Define if the texture is a render target.
  91570. */
  91571. isRenderTarget: boolean;
  91572. /**
  91573. * Define the unique id of the texture in the scene.
  91574. */
  91575. readonly uid: string;
  91576. /**
  91577. * Return a string representation of the texture.
  91578. * @returns the texture as a string
  91579. */
  91580. toString(): string;
  91581. /**
  91582. * Get the class name of the texture.
  91583. * @returns "BaseTexture"
  91584. */
  91585. getClassName(): string;
  91586. /**
  91587. * Define the list of animation attached to the texture.
  91588. */
  91589. animations: Animation[];
  91590. /**
  91591. * An event triggered when the texture is disposed.
  91592. */
  91593. onDisposeObservable: Observable<BaseTexture>;
  91594. private _onDisposeObserver;
  91595. /**
  91596. * Callback triggered when the texture has been disposed.
  91597. * Kept for back compatibility, you can use the onDisposeObservable instead.
  91598. */
  91599. onDispose: () => void;
  91600. /**
  91601. * Define the current state of the loading sequence when in delayed load mode.
  91602. */
  91603. delayLoadState: number;
  91604. private _scene;
  91605. /** @hidden */
  91606. _texture: Nullable<InternalTexture>;
  91607. private _uid;
  91608. /**
  91609. * Define if the texture is preventinga material to render or not.
  91610. * If not and the texture is not ready, the engine will use a default black texture instead.
  91611. */
  91612. readonly isBlocking: boolean;
  91613. /**
  91614. * Instantiates a new BaseTexture.
  91615. * Base class of all the textures in babylon.
  91616. * It groups all the common properties the materials, post process, lights... might need
  91617. * in order to make a correct use of the texture.
  91618. * @param scene Define the scene the texture blongs to
  91619. */
  91620. constructor(scene: Nullable<Scene>);
  91621. /**
  91622. * Get the scene the texture belongs to.
  91623. * @returns the scene or null if undefined
  91624. */
  91625. getScene(): Nullable<Scene>;
  91626. /**
  91627. * Get the texture transform matrix used to offset tile the texture for istance.
  91628. * @returns the transformation matrix
  91629. */
  91630. getTextureMatrix(): Matrix;
  91631. /**
  91632. * Get the texture reflection matrix used to rotate/transform the reflection.
  91633. * @returns the reflection matrix
  91634. */
  91635. getReflectionTextureMatrix(): Matrix;
  91636. /**
  91637. * Get the underlying lower level texture from Babylon.
  91638. * @returns the insternal texture
  91639. */
  91640. getInternalTexture(): Nullable<InternalTexture>;
  91641. /**
  91642. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  91643. * @returns true if ready or not blocking
  91644. */
  91645. isReadyOrNotBlocking(): boolean;
  91646. /**
  91647. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  91648. * @returns true if fully ready
  91649. */
  91650. isReady(): boolean;
  91651. private _cachedSize;
  91652. /**
  91653. * Get the size of the texture.
  91654. * @returns the texture size.
  91655. */
  91656. getSize(): ISize;
  91657. /**
  91658. * Get the base size of the texture.
  91659. * It can be different from the size if the texture has been resized for POT for instance
  91660. * @returns the base size
  91661. */
  91662. getBaseSize(): ISize;
  91663. /**
  91664. * Update the sampling mode of the texture.
  91665. * Default is Trilinear mode.
  91666. *
  91667. * | Value | Type | Description |
  91668. * | ----- | ------------------ | ----------- |
  91669. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  91670. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  91671. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  91672. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  91673. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  91674. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  91675. * | 7 | NEAREST_LINEAR | |
  91676. * | 8 | NEAREST_NEAREST | |
  91677. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  91678. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  91679. * | 11 | LINEAR_LINEAR | |
  91680. * | 12 | LINEAR_NEAREST | |
  91681. *
  91682. * > _mag_: magnification filter (close to the viewer)
  91683. * > _min_: minification filter (far from the viewer)
  91684. * > _mip_: filter used between mip map levels
  91685. *@param samplingMode Define the new sampling mode of the texture
  91686. */
  91687. updateSamplingMode(samplingMode: number): void;
  91688. /**
  91689. * Scales the texture if is `canRescale()`
  91690. * @param ratio the resize factor we want to use to rescale
  91691. */
  91692. scale(ratio: number): void;
  91693. /**
  91694. * Get if the texture can rescale.
  91695. */
  91696. readonly canRescale: boolean;
  91697. /** @hidden */
  91698. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  91699. /** @hidden */
  91700. _rebuild(): void;
  91701. /**
  91702. * Triggers the load sequence in delayed load mode.
  91703. */
  91704. delayLoad(): void;
  91705. /**
  91706. * Clones the texture.
  91707. * @returns the cloned texture
  91708. */
  91709. clone(): Nullable<BaseTexture>;
  91710. /**
  91711. * Get the texture underlying type (INT, FLOAT...)
  91712. */
  91713. readonly textureType: number;
  91714. /**
  91715. * Get the texture underlying format (RGB, RGBA...)
  91716. */
  91717. readonly textureFormat: number;
  91718. /**
  91719. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  91720. * This will returns an RGBA array buffer containing either in values (0-255) or
  91721. * float values (0-1) depending of the underlying buffer type.
  91722. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  91723. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  91724. * @param buffer defines a user defined buffer to fill with data (can be null)
  91725. * @returns The Array buffer containing the pixels data.
  91726. */
  91727. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  91728. /**
  91729. * Release and destroy the underlying lower level texture aka internalTexture.
  91730. */
  91731. releaseInternalTexture(): void;
  91732. /**
  91733. * Get the polynomial representation of the texture data.
  91734. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  91735. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  91736. */
  91737. sphericalPolynomial: Nullable<SphericalPolynomial>;
  91738. /** @hidden */
  91739. readonly _lodTextureHigh: Nullable<BaseTexture>;
  91740. /** @hidden */
  91741. readonly _lodTextureMid: Nullable<BaseTexture>;
  91742. /** @hidden */
  91743. readonly _lodTextureLow: Nullable<BaseTexture>;
  91744. /**
  91745. * Dispose the texture and release its associated resources.
  91746. */
  91747. dispose(): void;
  91748. /**
  91749. * Serialize the texture into a JSON representation that can be parsed later on.
  91750. * @returns the JSON representation of the texture
  91751. */
  91752. serialize(): any;
  91753. /**
  91754. * Helper function to be called back once a list of texture contains only ready textures.
  91755. * @param textures Define the list of textures to wait for
  91756. * @param callback Define the callback triggered once the entire list will be ready
  91757. */
  91758. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  91759. }
  91760. }
  91761. declare module BABYLON {
  91762. /**
  91763. * Class used to store data associated with WebGL texture data for the engine
  91764. * This class should not be used directly
  91765. */
  91766. export class InternalTexture {
  91767. /** @hidden */
  91768. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  91769. /**
  91770. * The source of the texture data is unknown
  91771. */
  91772. static DATASOURCE_UNKNOWN: number;
  91773. /**
  91774. * Texture data comes from an URL
  91775. */
  91776. static DATASOURCE_URL: number;
  91777. /**
  91778. * Texture data is only used for temporary storage
  91779. */
  91780. static DATASOURCE_TEMP: number;
  91781. /**
  91782. * Texture data comes from raw data (ArrayBuffer)
  91783. */
  91784. static DATASOURCE_RAW: number;
  91785. /**
  91786. * Texture content is dynamic (video or dynamic texture)
  91787. */
  91788. static DATASOURCE_DYNAMIC: number;
  91789. /**
  91790. * Texture content is generated by rendering to it
  91791. */
  91792. static DATASOURCE_RENDERTARGET: number;
  91793. /**
  91794. * Texture content is part of a multi render target process
  91795. */
  91796. static DATASOURCE_MULTIRENDERTARGET: number;
  91797. /**
  91798. * Texture data comes from a cube data file
  91799. */
  91800. static DATASOURCE_CUBE: number;
  91801. /**
  91802. * Texture data comes from a raw cube data
  91803. */
  91804. static DATASOURCE_CUBERAW: number;
  91805. /**
  91806. * Texture data come from a prefiltered cube data file
  91807. */
  91808. static DATASOURCE_CUBEPREFILTERED: number;
  91809. /**
  91810. * Texture content is raw 3D data
  91811. */
  91812. static DATASOURCE_RAW3D: number;
  91813. /**
  91814. * Texture content is a depth texture
  91815. */
  91816. static DATASOURCE_DEPTHTEXTURE: number;
  91817. /**
  91818. * Texture data comes from a raw cube data encoded with RGBD
  91819. */
  91820. static DATASOURCE_CUBERAW_RGBD: number;
  91821. /**
  91822. * Defines if the texture is ready
  91823. */
  91824. isReady: boolean;
  91825. /**
  91826. * Defines if the texture is a cube texture
  91827. */
  91828. isCube: boolean;
  91829. /**
  91830. * Defines if the texture contains 3D data
  91831. */
  91832. is3D: boolean;
  91833. /**
  91834. * Defines if the texture contains multiview data
  91835. */
  91836. isMultiview: boolean;
  91837. /**
  91838. * Gets the URL used to load this texture
  91839. */
  91840. url: string;
  91841. /**
  91842. * Gets the sampling mode of the texture
  91843. */
  91844. samplingMode: number;
  91845. /**
  91846. * Gets a boolean indicating if the texture needs mipmaps generation
  91847. */
  91848. generateMipMaps: boolean;
  91849. /**
  91850. * Gets the number of samples used by the texture (WebGL2+ only)
  91851. */
  91852. samples: number;
  91853. /**
  91854. * Gets the type of the texture (int, float...)
  91855. */
  91856. type: number;
  91857. /**
  91858. * Gets the format of the texture (RGB, RGBA...)
  91859. */
  91860. format: number;
  91861. /**
  91862. * Observable called when the texture is loaded
  91863. */
  91864. onLoadedObservable: Observable<InternalTexture>;
  91865. /**
  91866. * Gets the width of the texture
  91867. */
  91868. width: number;
  91869. /**
  91870. * Gets the height of the texture
  91871. */
  91872. height: number;
  91873. /**
  91874. * Gets the depth of the texture
  91875. */
  91876. depth: number;
  91877. /**
  91878. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  91879. */
  91880. baseWidth: number;
  91881. /**
  91882. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  91883. */
  91884. baseHeight: number;
  91885. /**
  91886. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  91887. */
  91888. baseDepth: number;
  91889. /**
  91890. * Gets a boolean indicating if the texture is inverted on Y axis
  91891. */
  91892. invertY: boolean;
  91893. /** @hidden */
  91894. _invertVScale: boolean;
  91895. /** @hidden */
  91896. _associatedChannel: number;
  91897. /** @hidden */
  91898. _dataSource: number;
  91899. /** @hidden */
  91900. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  91901. /** @hidden */
  91902. _bufferView: Nullable<ArrayBufferView>;
  91903. /** @hidden */
  91904. _bufferViewArray: Nullable<ArrayBufferView[]>;
  91905. /** @hidden */
  91906. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  91907. /** @hidden */
  91908. _size: number;
  91909. /** @hidden */
  91910. _extension: string;
  91911. /** @hidden */
  91912. _files: Nullable<string[]>;
  91913. /** @hidden */
  91914. _workingCanvas: Nullable<HTMLCanvasElement>;
  91915. /** @hidden */
  91916. _workingContext: Nullable<CanvasRenderingContext2D>;
  91917. /** @hidden */
  91918. _framebuffer: Nullable<WebGLFramebuffer>;
  91919. /** @hidden */
  91920. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  91921. /** @hidden */
  91922. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  91923. /** @hidden */
  91924. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  91925. /** @hidden */
  91926. _attachments: Nullable<number[]>;
  91927. /** @hidden */
  91928. _cachedCoordinatesMode: Nullable<number>;
  91929. /** @hidden */
  91930. _cachedWrapU: Nullable<number>;
  91931. /** @hidden */
  91932. _cachedWrapV: Nullable<number>;
  91933. /** @hidden */
  91934. _cachedWrapR: Nullable<number>;
  91935. /** @hidden */
  91936. _cachedAnisotropicFilteringLevel: Nullable<number>;
  91937. /** @hidden */
  91938. _isDisabled: boolean;
  91939. /** @hidden */
  91940. _compression: Nullable<string>;
  91941. /** @hidden */
  91942. _generateStencilBuffer: boolean;
  91943. /** @hidden */
  91944. _generateDepthBuffer: boolean;
  91945. /** @hidden */
  91946. _comparisonFunction: number;
  91947. /** @hidden */
  91948. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  91949. /** @hidden */
  91950. _lodGenerationScale: number;
  91951. /** @hidden */
  91952. _lodGenerationOffset: number;
  91953. /** @hidden */
  91954. _colorTextureArray: Nullable<WebGLTexture>;
  91955. /** @hidden */
  91956. _depthStencilTextureArray: Nullable<WebGLTexture>;
  91957. /** @hidden */
  91958. _lodTextureHigh: Nullable<BaseTexture>;
  91959. /** @hidden */
  91960. _lodTextureMid: Nullable<BaseTexture>;
  91961. /** @hidden */
  91962. _lodTextureLow: Nullable<BaseTexture>;
  91963. /** @hidden */
  91964. _isRGBD: boolean;
  91965. /** @hidden */
  91966. _linearSpecularLOD: boolean;
  91967. /** @hidden */
  91968. _irradianceTexture: Nullable<BaseTexture>;
  91969. /** @hidden */
  91970. _webGLTexture: Nullable<WebGLTexture>;
  91971. /** @hidden */
  91972. _references: number;
  91973. private _engine;
  91974. /**
  91975. * Gets the Engine the texture belongs to.
  91976. * @returns The babylon engine
  91977. */
  91978. getEngine(): Engine;
  91979. /**
  91980. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  91981. */
  91982. readonly dataSource: number;
  91983. /**
  91984. * Creates a new InternalTexture
  91985. * @param engine defines the engine to use
  91986. * @param dataSource defines the type of data that will be used
  91987. * @param delayAllocation if the texture allocation should be delayed (default: false)
  91988. */
  91989. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  91990. /**
  91991. * Increments the number of references (ie. the number of Texture that point to it)
  91992. */
  91993. incrementReferences(): void;
  91994. /**
  91995. * Change the size of the texture (not the size of the content)
  91996. * @param width defines the new width
  91997. * @param height defines the new height
  91998. * @param depth defines the new depth (1 by default)
  91999. */
  92000. updateSize(width: int, height: int, depth?: int): void;
  92001. /** @hidden */
  92002. _rebuild(): void;
  92003. /** @hidden */
  92004. _swapAndDie(target: InternalTexture): void;
  92005. /**
  92006. * Dispose the current allocated resources
  92007. */
  92008. dispose(): void;
  92009. }
  92010. }
  92011. declare module BABYLON {
  92012. /**
  92013. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92014. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92015. */
  92016. export class EffectFallbacks {
  92017. private _defines;
  92018. private _currentRank;
  92019. private _maxRank;
  92020. private _mesh;
  92021. /**
  92022. * Removes the fallback from the bound mesh.
  92023. */
  92024. unBindMesh(): void;
  92025. /**
  92026. * Adds a fallback on the specified property.
  92027. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92028. * @param define The name of the define in the shader
  92029. */
  92030. addFallback(rank: number, define: string): void;
  92031. /**
  92032. * Sets the mesh to use CPU skinning when needing to fallback.
  92033. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92034. * @param mesh The mesh to use the fallbacks.
  92035. */
  92036. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92037. /**
  92038. * Checks to see if more fallbacks are still availible.
  92039. */
  92040. readonly isMoreFallbacks: boolean;
  92041. /**
  92042. * Removes the defines that should be removed when falling back.
  92043. * @param currentDefines defines the current define statements for the shader.
  92044. * @param effect defines the current effect we try to compile
  92045. * @returns The resulting defines with defines of the current rank removed.
  92046. */
  92047. reduce(currentDefines: string, effect: Effect): string;
  92048. }
  92049. /**
  92050. * Options to be used when creating an effect.
  92051. */
  92052. export class EffectCreationOptions {
  92053. /**
  92054. * Atrributes that will be used in the shader.
  92055. */
  92056. attributes: string[];
  92057. /**
  92058. * Uniform varible names that will be set in the shader.
  92059. */
  92060. uniformsNames: string[];
  92061. /**
  92062. * Uniform buffer varible names that will be set in the shader.
  92063. */
  92064. uniformBuffersNames: string[];
  92065. /**
  92066. * Sampler texture variable names that will be set in the shader.
  92067. */
  92068. samplers: string[];
  92069. /**
  92070. * Define statements that will be set in the shader.
  92071. */
  92072. defines: any;
  92073. /**
  92074. * Possible fallbacks for this effect to improve performance when needed.
  92075. */
  92076. fallbacks: Nullable<EffectFallbacks>;
  92077. /**
  92078. * Callback that will be called when the shader is compiled.
  92079. */
  92080. onCompiled: Nullable<(effect: Effect) => void>;
  92081. /**
  92082. * Callback that will be called if an error occurs during shader compilation.
  92083. */
  92084. onError: Nullable<(effect: Effect, errors: string) => void>;
  92085. /**
  92086. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92087. */
  92088. indexParameters: any;
  92089. /**
  92090. * Max number of lights that can be used in the shader.
  92091. */
  92092. maxSimultaneousLights: number;
  92093. /**
  92094. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92095. */
  92096. transformFeedbackVaryings: Nullable<string[]>;
  92097. }
  92098. /**
  92099. * Effect containing vertex and fragment shader that can be executed on an object.
  92100. */
  92101. export class Effect implements IDisposable {
  92102. /**
  92103. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92104. */
  92105. static ShadersRepository: string;
  92106. /**
  92107. * Name of the effect.
  92108. */
  92109. name: any;
  92110. /**
  92111. * String container all the define statements that should be set on the shader.
  92112. */
  92113. defines: string;
  92114. /**
  92115. * Callback that will be called when the shader is compiled.
  92116. */
  92117. onCompiled: Nullable<(effect: Effect) => void>;
  92118. /**
  92119. * Callback that will be called if an error occurs during shader compilation.
  92120. */
  92121. onError: Nullable<(effect: Effect, errors: string) => void>;
  92122. /**
  92123. * Callback that will be called when effect is bound.
  92124. */
  92125. onBind: Nullable<(effect: Effect) => void>;
  92126. /**
  92127. * Unique ID of the effect.
  92128. */
  92129. uniqueId: number;
  92130. /**
  92131. * Observable that will be called when the shader is compiled.
  92132. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92133. */
  92134. onCompileObservable: Observable<Effect>;
  92135. /**
  92136. * Observable that will be called if an error occurs during shader compilation.
  92137. */
  92138. onErrorObservable: Observable<Effect>;
  92139. /** @hidden */
  92140. _onBindObservable: Nullable<Observable<Effect>>;
  92141. /**
  92142. * Observable that will be called when effect is bound.
  92143. */
  92144. readonly onBindObservable: Observable<Effect>;
  92145. /** @hidden */
  92146. _bonesComputationForcedToCPU: boolean;
  92147. private static _uniqueIdSeed;
  92148. private _engine;
  92149. private _uniformBuffersNames;
  92150. private _uniformsNames;
  92151. private _samplerList;
  92152. private _samplers;
  92153. private _isReady;
  92154. private _compilationError;
  92155. private _attributesNames;
  92156. private _attributes;
  92157. private _uniforms;
  92158. /**
  92159. * Key for the effect.
  92160. * @hidden
  92161. */
  92162. _key: string;
  92163. private _indexParameters;
  92164. private _fallbacks;
  92165. private _vertexSourceCode;
  92166. private _fragmentSourceCode;
  92167. private _vertexSourceCodeOverride;
  92168. private _fragmentSourceCodeOverride;
  92169. private _transformFeedbackVaryings;
  92170. /**
  92171. * Compiled shader to webGL program.
  92172. * @hidden
  92173. */
  92174. _pipelineContext: Nullable<IPipelineContext>;
  92175. private _valueCache;
  92176. private static _baseCache;
  92177. /**
  92178. * Instantiates an effect.
  92179. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92180. * @param baseName Name of the effect.
  92181. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92182. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92183. * @param samplers List of sampler variables that will be passed to the shader.
  92184. * @param engine Engine to be used to render the effect
  92185. * @param defines Define statements to be added to the shader.
  92186. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92187. * @param onCompiled Callback that will be called when the shader is compiled.
  92188. * @param onError Callback that will be called if an error occurs during shader compilation.
  92189. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92190. */
  92191. 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);
  92192. private _useFinalCode;
  92193. /**
  92194. * Unique key for this effect
  92195. */
  92196. readonly key: string;
  92197. /**
  92198. * If the effect has been compiled and prepared.
  92199. * @returns if the effect is compiled and prepared.
  92200. */
  92201. isReady(): boolean;
  92202. /**
  92203. * The engine the effect was initialized with.
  92204. * @returns the engine.
  92205. */
  92206. getEngine(): Engine;
  92207. /**
  92208. * The pipeline context for this effect
  92209. * @returns the associated pipeline context
  92210. */
  92211. getPipelineContext(): Nullable<IPipelineContext>;
  92212. /**
  92213. * The set of names of attribute variables for the shader.
  92214. * @returns An array of attribute names.
  92215. */
  92216. getAttributesNames(): string[];
  92217. /**
  92218. * Returns the attribute at the given index.
  92219. * @param index The index of the attribute.
  92220. * @returns The location of the attribute.
  92221. */
  92222. getAttributeLocation(index: number): number;
  92223. /**
  92224. * Returns the attribute based on the name of the variable.
  92225. * @param name of the attribute to look up.
  92226. * @returns the attribute location.
  92227. */
  92228. getAttributeLocationByName(name: string): number;
  92229. /**
  92230. * The number of attributes.
  92231. * @returns the numnber of attributes.
  92232. */
  92233. getAttributesCount(): number;
  92234. /**
  92235. * Gets the index of a uniform variable.
  92236. * @param uniformName of the uniform to look up.
  92237. * @returns the index.
  92238. */
  92239. getUniformIndex(uniformName: string): number;
  92240. /**
  92241. * Returns the attribute based on the name of the variable.
  92242. * @param uniformName of the uniform to look up.
  92243. * @returns the location of the uniform.
  92244. */
  92245. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92246. /**
  92247. * Returns an array of sampler variable names
  92248. * @returns The array of sampler variable neames.
  92249. */
  92250. getSamplers(): string[];
  92251. /**
  92252. * The error from the last compilation.
  92253. * @returns the error string.
  92254. */
  92255. getCompilationError(): string;
  92256. /**
  92257. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92258. * @param func The callback to be used.
  92259. */
  92260. executeWhenCompiled(func: (effect: Effect) => void): void;
  92261. private _checkIsReady;
  92262. /** @hidden */
  92263. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92264. /** @hidden */
  92265. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92266. /** @hidden */
  92267. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92268. /**
  92269. * Recompiles the webGL program
  92270. * @param vertexSourceCode The source code for the vertex shader.
  92271. * @param fragmentSourceCode The source code for the fragment shader.
  92272. * @param onCompiled Callback called when completed.
  92273. * @param onError Callback called on error.
  92274. * @hidden
  92275. */
  92276. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92277. /**
  92278. * Prepares the effect
  92279. * @hidden
  92280. */
  92281. _prepareEffect(): void;
  92282. /**
  92283. * Checks if the effect is supported. (Must be called after compilation)
  92284. */
  92285. readonly isSupported: boolean;
  92286. /**
  92287. * Binds a texture to the engine to be used as output of the shader.
  92288. * @param channel Name of the output variable.
  92289. * @param texture Texture to bind.
  92290. * @hidden
  92291. */
  92292. _bindTexture(channel: string, texture: InternalTexture): void;
  92293. /**
  92294. * Sets a texture on the engine to be used in the shader.
  92295. * @param channel Name of the sampler variable.
  92296. * @param texture Texture to set.
  92297. */
  92298. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92299. /**
  92300. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92301. * @param channel Name of the sampler variable.
  92302. * @param texture Texture to set.
  92303. */
  92304. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92305. /**
  92306. * Sets an array of textures on the engine to be used in the shader.
  92307. * @param channel Name of the variable.
  92308. * @param textures Textures to set.
  92309. */
  92310. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92311. /**
  92312. * 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)
  92313. * @param channel Name of the sampler variable.
  92314. * @param postProcess Post process to get the input texture from.
  92315. */
  92316. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92317. /**
  92318. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92319. * 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)
  92320. * @param channel Name of the sampler variable.
  92321. * @param postProcess Post process to get the output texture from.
  92322. */
  92323. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92324. /** @hidden */
  92325. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92326. /** @hidden */
  92327. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92328. /** @hidden */
  92329. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92330. /** @hidden */
  92331. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92332. /**
  92333. * Binds a buffer to a uniform.
  92334. * @param buffer Buffer to bind.
  92335. * @param name Name of the uniform variable to bind to.
  92336. */
  92337. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92338. /**
  92339. * Binds block to a uniform.
  92340. * @param blockName Name of the block to bind.
  92341. * @param index Index to bind.
  92342. */
  92343. bindUniformBlock(blockName: string, index: number): void;
  92344. /**
  92345. * Sets an interger value on a uniform variable.
  92346. * @param uniformName Name of the variable.
  92347. * @param value Value to be set.
  92348. * @returns this effect.
  92349. */
  92350. setInt(uniformName: string, value: number): Effect;
  92351. /**
  92352. * Sets an int array on a uniform variable.
  92353. * @param uniformName Name of the variable.
  92354. * @param array array to be set.
  92355. * @returns this effect.
  92356. */
  92357. setIntArray(uniformName: string, array: Int32Array): Effect;
  92358. /**
  92359. * 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)
  92360. * @param uniformName Name of the variable.
  92361. * @param array array to be set.
  92362. * @returns this effect.
  92363. */
  92364. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92365. /**
  92366. * 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)
  92367. * @param uniformName Name of the variable.
  92368. * @param array array to be set.
  92369. * @returns this effect.
  92370. */
  92371. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92372. /**
  92373. * 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)
  92374. * @param uniformName Name of the variable.
  92375. * @param array array to be set.
  92376. * @returns this effect.
  92377. */
  92378. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92379. /**
  92380. * Sets an float array on a uniform variable.
  92381. * @param uniformName Name of the variable.
  92382. * @param array array to be set.
  92383. * @returns this effect.
  92384. */
  92385. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92386. /**
  92387. * 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)
  92388. * @param uniformName Name of the variable.
  92389. * @param array array to be set.
  92390. * @returns this effect.
  92391. */
  92392. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92393. /**
  92394. * 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)
  92395. * @param uniformName Name of the variable.
  92396. * @param array array to be set.
  92397. * @returns this effect.
  92398. */
  92399. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92400. /**
  92401. * 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)
  92402. * @param uniformName Name of the variable.
  92403. * @param array array to be set.
  92404. * @returns this effect.
  92405. */
  92406. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92407. /**
  92408. * Sets an array on a uniform variable.
  92409. * @param uniformName Name of the variable.
  92410. * @param array array to be set.
  92411. * @returns this effect.
  92412. */
  92413. setArray(uniformName: string, array: number[]): Effect;
  92414. /**
  92415. * 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)
  92416. * @param uniformName Name of the variable.
  92417. * @param array array to be set.
  92418. * @returns this effect.
  92419. */
  92420. setArray2(uniformName: string, array: number[]): Effect;
  92421. /**
  92422. * 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)
  92423. * @param uniformName Name of the variable.
  92424. * @param array array to be set.
  92425. * @returns this effect.
  92426. */
  92427. setArray3(uniformName: string, array: number[]): Effect;
  92428. /**
  92429. * 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)
  92430. * @param uniformName Name of the variable.
  92431. * @param array array to be set.
  92432. * @returns this effect.
  92433. */
  92434. setArray4(uniformName: string, array: number[]): Effect;
  92435. /**
  92436. * Sets matrices on a uniform variable.
  92437. * @param uniformName Name of the variable.
  92438. * @param matrices matrices to be set.
  92439. * @returns this effect.
  92440. */
  92441. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92442. /**
  92443. * Sets matrix on a uniform variable.
  92444. * @param uniformName Name of the variable.
  92445. * @param matrix matrix to be set.
  92446. * @returns this effect.
  92447. */
  92448. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  92449. /**
  92450. * 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)
  92451. * @param uniformName Name of the variable.
  92452. * @param matrix matrix to be set.
  92453. * @returns this effect.
  92454. */
  92455. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92456. /**
  92457. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92458. * @param uniformName Name of the variable.
  92459. * @param matrix matrix to be set.
  92460. * @returns this effect.
  92461. */
  92462. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92463. /**
  92464. * Sets a float on a uniform variable.
  92465. * @param uniformName Name of the variable.
  92466. * @param value value to be set.
  92467. * @returns this effect.
  92468. */
  92469. setFloat(uniformName: string, value: number): Effect;
  92470. /**
  92471. * Sets a boolean on a uniform variable.
  92472. * @param uniformName Name of the variable.
  92473. * @param bool value to be set.
  92474. * @returns this effect.
  92475. */
  92476. setBool(uniformName: string, bool: boolean): Effect;
  92477. /**
  92478. * Sets a Vector2 on a uniform variable.
  92479. * @param uniformName Name of the variable.
  92480. * @param vector2 vector2 to be set.
  92481. * @returns this effect.
  92482. */
  92483. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  92484. /**
  92485. * Sets a float2 on a uniform variable.
  92486. * @param uniformName Name of the variable.
  92487. * @param x First float in float2.
  92488. * @param y Second float in float2.
  92489. * @returns this effect.
  92490. */
  92491. setFloat2(uniformName: string, x: number, y: number): Effect;
  92492. /**
  92493. * Sets a Vector3 on a uniform variable.
  92494. * @param uniformName Name of the variable.
  92495. * @param vector3 Value to be set.
  92496. * @returns this effect.
  92497. */
  92498. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  92499. /**
  92500. * Sets a float3 on a uniform variable.
  92501. * @param uniformName Name of the variable.
  92502. * @param x First float in float3.
  92503. * @param y Second float in float3.
  92504. * @param z Third float in float3.
  92505. * @returns this effect.
  92506. */
  92507. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92508. /**
  92509. * Sets a Vector4 on a uniform variable.
  92510. * @param uniformName Name of the variable.
  92511. * @param vector4 Value to be set.
  92512. * @returns this effect.
  92513. */
  92514. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  92515. /**
  92516. * Sets a float4 on a uniform variable.
  92517. * @param uniformName Name of the variable.
  92518. * @param x First float in float4.
  92519. * @param y Second float in float4.
  92520. * @param z Third float in float4.
  92521. * @param w Fourth float in float4.
  92522. * @returns this effect.
  92523. */
  92524. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92525. /**
  92526. * Sets a Color3 on a uniform variable.
  92527. * @param uniformName Name of the variable.
  92528. * @param color3 Value to be set.
  92529. * @returns this effect.
  92530. */
  92531. setColor3(uniformName: string, color3: IColor3Like): Effect;
  92532. /**
  92533. * Sets a Color4 on a uniform variable.
  92534. * @param uniformName Name of the variable.
  92535. * @param color3 Value to be set.
  92536. * @param alpha Alpha value to be set.
  92537. * @returns this effect.
  92538. */
  92539. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  92540. /**
  92541. * Sets a Color4 on a uniform variable
  92542. * @param uniformName defines the name of the variable
  92543. * @param color4 defines the value to be set
  92544. * @returns this effect.
  92545. */
  92546. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  92547. /** Release all associated resources */
  92548. dispose(): void;
  92549. /**
  92550. * This function will add a new shader to the shader store
  92551. * @param name the name of the shader
  92552. * @param pixelShader optional pixel shader content
  92553. * @param vertexShader optional vertex shader content
  92554. */
  92555. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92556. /**
  92557. * Store of each shader (The can be looked up using effect.key)
  92558. */
  92559. static ShadersStore: {
  92560. [key: string]: string;
  92561. };
  92562. /**
  92563. * Store of each included file for a shader (The can be looked up using effect.key)
  92564. */
  92565. static IncludesShadersStore: {
  92566. [key: string]: string;
  92567. };
  92568. /**
  92569. * Resets the cache of effects.
  92570. */
  92571. static ResetCache(): void;
  92572. }
  92573. }
  92574. declare module BABYLON {
  92575. /**
  92576. * Uniform buffer objects.
  92577. *
  92578. * Handles blocks of uniform on the GPU.
  92579. *
  92580. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92581. *
  92582. * For more information, please refer to :
  92583. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92584. */
  92585. export class UniformBuffer {
  92586. private _engine;
  92587. private _buffer;
  92588. private _data;
  92589. private _bufferData;
  92590. private _dynamic?;
  92591. private _uniformLocations;
  92592. private _uniformSizes;
  92593. private _uniformLocationPointer;
  92594. private _needSync;
  92595. private _noUBO;
  92596. private _currentEffect;
  92597. private static _MAX_UNIFORM_SIZE;
  92598. private static _tempBuffer;
  92599. /**
  92600. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  92601. * This is dynamic to allow compat with webgl 1 and 2.
  92602. * You will need to pass the name of the uniform as well as the value.
  92603. */
  92604. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  92605. /**
  92606. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  92607. * This is dynamic to allow compat with webgl 1 and 2.
  92608. * You will need to pass the name of the uniform as well as the value.
  92609. */
  92610. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  92611. /**
  92612. * Lambda to Update a single float in a uniform buffer.
  92613. * This is dynamic to allow compat with webgl 1 and 2.
  92614. * You will need to pass the name of the uniform as well as the value.
  92615. */
  92616. updateFloat: (name: string, x: number) => void;
  92617. /**
  92618. * Lambda to Update a vec2 of float in a uniform buffer.
  92619. * This is dynamic to allow compat with webgl 1 and 2.
  92620. * You will need to pass the name of the uniform as well as the value.
  92621. */
  92622. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  92623. /**
  92624. * Lambda to Update a vec3 of float in a uniform buffer.
  92625. * This is dynamic to allow compat with webgl 1 and 2.
  92626. * You will need to pass the name of the uniform as well as the value.
  92627. */
  92628. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  92629. /**
  92630. * Lambda to Update a vec4 of float in a uniform buffer.
  92631. * This is dynamic to allow compat with webgl 1 and 2.
  92632. * You will need to pass the name of the uniform as well as the value.
  92633. */
  92634. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  92635. /**
  92636. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  92637. * This is dynamic to allow compat with webgl 1 and 2.
  92638. * You will need to pass the name of the uniform as well as the value.
  92639. */
  92640. updateMatrix: (name: string, mat: Matrix) => void;
  92641. /**
  92642. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  92643. * This is dynamic to allow compat with webgl 1 and 2.
  92644. * You will need to pass the name of the uniform as well as the value.
  92645. */
  92646. updateVector3: (name: string, vector: Vector3) => void;
  92647. /**
  92648. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  92649. * This is dynamic to allow compat with webgl 1 and 2.
  92650. * You will need to pass the name of the uniform as well as the value.
  92651. */
  92652. updateVector4: (name: string, vector: Vector4) => void;
  92653. /**
  92654. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  92655. * This is dynamic to allow compat with webgl 1 and 2.
  92656. * You will need to pass the name of the uniform as well as the value.
  92657. */
  92658. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  92659. /**
  92660. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  92661. * This is dynamic to allow compat with webgl 1 and 2.
  92662. * You will need to pass the name of the uniform as well as the value.
  92663. */
  92664. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  92665. /**
  92666. * Instantiates a new Uniform buffer objects.
  92667. *
  92668. * Handles blocks of uniform on the GPU.
  92669. *
  92670. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92671. *
  92672. * For more information, please refer to :
  92673. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92674. * @param engine Define the engine the buffer is associated with
  92675. * @param data Define the data contained in the buffer
  92676. * @param dynamic Define if the buffer is updatable
  92677. */
  92678. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  92679. /**
  92680. * Indicates if the buffer is using the WebGL2 UBO implementation,
  92681. * or just falling back on setUniformXXX calls.
  92682. */
  92683. readonly useUbo: boolean;
  92684. /**
  92685. * Indicates if the WebGL underlying uniform buffer is in sync
  92686. * with the javascript cache data.
  92687. */
  92688. readonly isSync: boolean;
  92689. /**
  92690. * Indicates if the WebGL underlying uniform buffer is dynamic.
  92691. * Also, a dynamic UniformBuffer will disable cache verification and always
  92692. * update the underlying WebGL uniform buffer to the GPU.
  92693. * @returns if Dynamic, otherwise false
  92694. */
  92695. isDynamic(): boolean;
  92696. /**
  92697. * The data cache on JS side.
  92698. * @returns the underlying data as a float array
  92699. */
  92700. getData(): Float32Array;
  92701. /**
  92702. * The underlying WebGL Uniform buffer.
  92703. * @returns the webgl buffer
  92704. */
  92705. getBuffer(): Nullable<DataBuffer>;
  92706. /**
  92707. * std140 layout specifies how to align data within an UBO structure.
  92708. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  92709. * for specs.
  92710. */
  92711. private _fillAlignment;
  92712. /**
  92713. * Adds an uniform in the buffer.
  92714. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  92715. * for the layout to be correct !
  92716. * @param name Name of the uniform, as used in the uniform block in the shader.
  92717. * @param size Data size, or data directly.
  92718. */
  92719. addUniform(name: string, size: number | number[]): void;
  92720. /**
  92721. * Adds a Matrix 4x4 to the uniform buffer.
  92722. * @param name Name of the uniform, as used in the uniform block in the shader.
  92723. * @param mat A 4x4 matrix.
  92724. */
  92725. addMatrix(name: string, mat: Matrix): void;
  92726. /**
  92727. * Adds a vec2 to the uniform buffer.
  92728. * @param name Name of the uniform, as used in the uniform block in the shader.
  92729. * @param x Define the x component value of the vec2
  92730. * @param y Define the y component value of the vec2
  92731. */
  92732. addFloat2(name: string, x: number, y: number): void;
  92733. /**
  92734. * Adds a vec3 to the uniform buffer.
  92735. * @param name Name of the uniform, as used in the uniform block in the shader.
  92736. * @param x Define the x component value of the vec3
  92737. * @param y Define the y component value of the vec3
  92738. * @param z Define the z component value of the vec3
  92739. */
  92740. addFloat3(name: string, x: number, y: number, z: number): void;
  92741. /**
  92742. * Adds a vec3 to the uniform buffer.
  92743. * @param name Name of the uniform, as used in the uniform block in the shader.
  92744. * @param color Define the vec3 from a Color
  92745. */
  92746. addColor3(name: string, color: Color3): void;
  92747. /**
  92748. * Adds a vec4 to the uniform buffer.
  92749. * @param name Name of the uniform, as used in the uniform block in the shader.
  92750. * @param color Define the rgb components from a Color
  92751. * @param alpha Define the a component of the vec4
  92752. */
  92753. addColor4(name: string, color: Color3, alpha: number): void;
  92754. /**
  92755. * Adds a vec3 to the uniform buffer.
  92756. * @param name Name of the uniform, as used in the uniform block in the shader.
  92757. * @param vector Define the vec3 components from a Vector
  92758. */
  92759. addVector3(name: string, vector: Vector3): void;
  92760. /**
  92761. * Adds a Matrix 3x3 to the uniform buffer.
  92762. * @param name Name of the uniform, as used in the uniform block in the shader.
  92763. */
  92764. addMatrix3x3(name: string): void;
  92765. /**
  92766. * Adds a Matrix 2x2 to the uniform buffer.
  92767. * @param name Name of the uniform, as used in the uniform block in the shader.
  92768. */
  92769. addMatrix2x2(name: string): void;
  92770. /**
  92771. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  92772. */
  92773. create(): void;
  92774. /** @hidden */
  92775. _rebuild(): void;
  92776. /**
  92777. * Updates the WebGL Uniform Buffer on the GPU.
  92778. * If the `dynamic` flag is set to true, no cache comparison is done.
  92779. * Otherwise, the buffer will be updated only if the cache differs.
  92780. */
  92781. update(): void;
  92782. /**
  92783. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  92784. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92785. * @param data Define the flattened data
  92786. * @param size Define the size of the data.
  92787. */
  92788. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  92789. private _updateMatrix3x3ForUniform;
  92790. private _updateMatrix3x3ForEffect;
  92791. private _updateMatrix2x2ForEffect;
  92792. private _updateMatrix2x2ForUniform;
  92793. private _updateFloatForEffect;
  92794. private _updateFloatForUniform;
  92795. private _updateFloat2ForEffect;
  92796. private _updateFloat2ForUniform;
  92797. private _updateFloat3ForEffect;
  92798. private _updateFloat3ForUniform;
  92799. private _updateFloat4ForEffect;
  92800. private _updateFloat4ForUniform;
  92801. private _updateMatrixForEffect;
  92802. private _updateMatrixForUniform;
  92803. private _updateVector3ForEffect;
  92804. private _updateVector3ForUniform;
  92805. private _updateVector4ForEffect;
  92806. private _updateVector4ForUniform;
  92807. private _updateColor3ForEffect;
  92808. private _updateColor3ForUniform;
  92809. private _updateColor4ForEffect;
  92810. private _updateColor4ForUniform;
  92811. /**
  92812. * Sets a sampler uniform on the effect.
  92813. * @param name Define the name of the sampler.
  92814. * @param texture Define the texture to set in the sampler
  92815. */
  92816. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  92817. /**
  92818. * Directly updates the value of the uniform in the cache AND on the GPU.
  92819. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92820. * @param data Define the flattened data
  92821. */
  92822. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  92823. /**
  92824. * Binds this uniform buffer to an effect.
  92825. * @param effect Define the effect to bind the buffer to
  92826. * @param name Name of the uniform block in the shader.
  92827. */
  92828. bindToEffect(effect: Effect, name: string): void;
  92829. /**
  92830. * Disposes the uniform buffer.
  92831. */
  92832. dispose(): void;
  92833. }
  92834. }
  92835. declare module BABYLON {
  92836. /**
  92837. * Class used to work with sound analyzer using fast fourier transform (FFT)
  92838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92839. */
  92840. export class Analyser {
  92841. /**
  92842. * Gets or sets the smoothing
  92843. * @ignorenaming
  92844. */
  92845. SMOOTHING: number;
  92846. /**
  92847. * Gets or sets the FFT table size
  92848. * @ignorenaming
  92849. */
  92850. FFT_SIZE: number;
  92851. /**
  92852. * Gets or sets the bar graph amplitude
  92853. * @ignorenaming
  92854. */
  92855. BARGRAPHAMPLITUDE: number;
  92856. /**
  92857. * Gets or sets the position of the debug canvas
  92858. * @ignorenaming
  92859. */
  92860. DEBUGCANVASPOS: {
  92861. x: number;
  92862. y: number;
  92863. };
  92864. /**
  92865. * Gets or sets the debug canvas size
  92866. * @ignorenaming
  92867. */
  92868. DEBUGCANVASSIZE: {
  92869. width: number;
  92870. height: number;
  92871. };
  92872. private _byteFreqs;
  92873. private _byteTime;
  92874. private _floatFreqs;
  92875. private _webAudioAnalyser;
  92876. private _debugCanvas;
  92877. private _debugCanvasContext;
  92878. private _scene;
  92879. private _registerFunc;
  92880. private _audioEngine;
  92881. /**
  92882. * Creates a new analyser
  92883. * @param scene defines hosting scene
  92884. */
  92885. constructor(scene: Scene);
  92886. /**
  92887. * Get the number of data values you will have to play with for the visualization
  92888. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  92889. * @returns a number
  92890. */
  92891. getFrequencyBinCount(): number;
  92892. /**
  92893. * Gets the current frequency data as a byte array
  92894. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92895. * @returns a Uint8Array
  92896. */
  92897. getByteFrequencyData(): Uint8Array;
  92898. /**
  92899. * Gets the current waveform as a byte array
  92900. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  92901. * @returns a Uint8Array
  92902. */
  92903. getByteTimeDomainData(): Uint8Array;
  92904. /**
  92905. * Gets the current frequency data as a float array
  92906. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92907. * @returns a Float32Array
  92908. */
  92909. getFloatFrequencyData(): Float32Array;
  92910. /**
  92911. * Renders the debug canvas
  92912. */
  92913. drawDebugCanvas(): void;
  92914. /**
  92915. * Stops rendering the debug canvas and removes it
  92916. */
  92917. stopDebugCanvas(): void;
  92918. /**
  92919. * Connects two audio nodes
  92920. * @param inputAudioNode defines first node to connect
  92921. * @param outputAudioNode defines second node to connect
  92922. */
  92923. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  92924. /**
  92925. * Releases all associated resources
  92926. */
  92927. dispose(): void;
  92928. }
  92929. }
  92930. declare module BABYLON {
  92931. /**
  92932. * This represents an audio engine and it is responsible
  92933. * to play, synchronize and analyse sounds throughout the application.
  92934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92935. */
  92936. export interface IAudioEngine extends IDisposable {
  92937. /**
  92938. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  92939. */
  92940. readonly canUseWebAudio: boolean;
  92941. /**
  92942. * Gets the current AudioContext if available.
  92943. */
  92944. readonly audioContext: Nullable<AudioContext>;
  92945. /**
  92946. * The master gain node defines the global audio volume of your audio engine.
  92947. */
  92948. readonly masterGain: GainNode;
  92949. /**
  92950. * Gets whether or not mp3 are supported by your browser.
  92951. */
  92952. readonly isMP3supported: boolean;
  92953. /**
  92954. * Gets whether or not ogg are supported by your browser.
  92955. */
  92956. readonly isOGGsupported: boolean;
  92957. /**
  92958. * Defines if Babylon should emit a warning if WebAudio is not supported.
  92959. * @ignoreNaming
  92960. */
  92961. WarnedWebAudioUnsupported: boolean;
  92962. /**
  92963. * Defines if the audio engine relies on a custom unlocked button.
  92964. * In this case, the embedded button will not be displayed.
  92965. */
  92966. useCustomUnlockedButton: boolean;
  92967. /**
  92968. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  92969. */
  92970. readonly unlocked: boolean;
  92971. /**
  92972. * Event raised when audio has been unlocked on the browser.
  92973. */
  92974. onAudioUnlockedObservable: Observable<AudioEngine>;
  92975. /**
  92976. * Event raised when audio has been locked on the browser.
  92977. */
  92978. onAudioLockedObservable: Observable<AudioEngine>;
  92979. /**
  92980. * Flags the audio engine in Locked state.
  92981. * This happens due to new browser policies preventing audio to autoplay.
  92982. */
  92983. lock(): void;
  92984. /**
  92985. * Unlocks the audio engine once a user action has been done on the dom.
  92986. * This is helpful to resume play once browser policies have been satisfied.
  92987. */
  92988. unlock(): void;
  92989. }
  92990. /**
  92991. * This represents the default audio engine used in babylon.
  92992. * It is responsible to play, synchronize and analyse sounds throughout the application.
  92993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92994. */
  92995. export class AudioEngine implements IAudioEngine {
  92996. private _audioContext;
  92997. private _audioContextInitialized;
  92998. private _muteButton;
  92999. private _hostElement;
  93000. /**
  93001. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93002. */
  93003. canUseWebAudio: boolean;
  93004. /**
  93005. * The master gain node defines the global audio volume of your audio engine.
  93006. */
  93007. masterGain: GainNode;
  93008. /**
  93009. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93010. * @ignoreNaming
  93011. */
  93012. WarnedWebAudioUnsupported: boolean;
  93013. /**
  93014. * Gets whether or not mp3 are supported by your browser.
  93015. */
  93016. isMP3supported: boolean;
  93017. /**
  93018. * Gets whether or not ogg are supported by your browser.
  93019. */
  93020. isOGGsupported: boolean;
  93021. /**
  93022. * Gets whether audio has been unlocked on the device.
  93023. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  93024. * a user interaction has happened.
  93025. */
  93026. unlocked: boolean;
  93027. /**
  93028. * Defines if the audio engine relies on a custom unlocked button.
  93029. * In this case, the embedded button will not be displayed.
  93030. */
  93031. useCustomUnlockedButton: boolean;
  93032. /**
  93033. * Event raised when audio has been unlocked on the browser.
  93034. */
  93035. onAudioUnlockedObservable: Observable<AudioEngine>;
  93036. /**
  93037. * Event raised when audio has been locked on the browser.
  93038. */
  93039. onAudioLockedObservable: Observable<AudioEngine>;
  93040. /**
  93041. * Gets the current AudioContext if available.
  93042. */
  93043. readonly audioContext: Nullable<AudioContext>;
  93044. private _connectedAnalyser;
  93045. /**
  93046. * Instantiates a new audio engine.
  93047. *
  93048. * There should be only one per page as some browsers restrict the number
  93049. * of audio contexts you can create.
  93050. * @param hostElement defines the host element where to display the mute icon if necessary
  93051. */
  93052. constructor(hostElement?: Nullable<HTMLElement>);
  93053. /**
  93054. * Flags the audio engine in Locked state.
  93055. * This happens due to new browser policies preventing audio to autoplay.
  93056. */
  93057. lock(): void;
  93058. /**
  93059. * Unlocks the audio engine once a user action has been done on the dom.
  93060. * This is helpful to resume play once browser policies have been satisfied.
  93061. */
  93062. unlock(): void;
  93063. private _resumeAudioContext;
  93064. private _initializeAudioContext;
  93065. private _tryToRun;
  93066. private _triggerRunningState;
  93067. private _triggerSuspendedState;
  93068. private _displayMuteButton;
  93069. private _moveButtonToTopLeft;
  93070. private _onResize;
  93071. private _hideMuteButton;
  93072. /**
  93073. * Destroy and release the resources associated with the audio ccontext.
  93074. */
  93075. dispose(): void;
  93076. /**
  93077. * Gets the global volume sets on the master gain.
  93078. * @returns the global volume if set or -1 otherwise
  93079. */
  93080. getGlobalVolume(): number;
  93081. /**
  93082. * Sets the global volume of your experience (sets on the master gain).
  93083. * @param newVolume Defines the new global volume of the application
  93084. */
  93085. setGlobalVolume(newVolume: number): void;
  93086. /**
  93087. * Connect the audio engine to an audio analyser allowing some amazing
  93088. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93090. * @param analyser The analyser to connect to the engine
  93091. */
  93092. connectToAnalyser(analyser: Analyser): void;
  93093. }
  93094. }
  93095. declare module BABYLON {
  93096. /**
  93097. * Interface used to present a loading screen while loading a scene
  93098. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93099. */
  93100. export interface ILoadingScreen {
  93101. /**
  93102. * Function called to display the loading screen
  93103. */
  93104. displayLoadingUI: () => void;
  93105. /**
  93106. * Function called to hide the loading screen
  93107. */
  93108. hideLoadingUI: () => void;
  93109. /**
  93110. * Gets or sets the color to use for the background
  93111. */
  93112. loadingUIBackgroundColor: string;
  93113. /**
  93114. * Gets or sets the text to display while loading
  93115. */
  93116. loadingUIText: string;
  93117. }
  93118. /**
  93119. * Class used for the default loading screen
  93120. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93121. */
  93122. export class DefaultLoadingScreen implements ILoadingScreen {
  93123. private _renderingCanvas;
  93124. private _loadingText;
  93125. private _loadingDivBackgroundColor;
  93126. private _loadingDiv;
  93127. private _loadingTextDiv;
  93128. /** Gets or sets the logo url to use for the default loading screen */
  93129. static DefaultLogoUrl: string;
  93130. /** Gets or sets the spinner url to use for the default loading screen */
  93131. static DefaultSpinnerUrl: string;
  93132. /**
  93133. * Creates a new default loading screen
  93134. * @param _renderingCanvas defines the canvas used to render the scene
  93135. * @param _loadingText defines the default text to display
  93136. * @param _loadingDivBackgroundColor defines the default background color
  93137. */
  93138. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  93139. /**
  93140. * Function called to display the loading screen
  93141. */
  93142. displayLoadingUI(): void;
  93143. /**
  93144. * Function called to hide the loading screen
  93145. */
  93146. hideLoadingUI(): void;
  93147. /**
  93148. * Gets or sets the text to display while loading
  93149. */
  93150. loadingUIText: string;
  93151. /**
  93152. * Gets or sets the color to use for the background
  93153. */
  93154. loadingUIBackgroundColor: string;
  93155. private _resizeLoadingUI;
  93156. }
  93157. }
  93158. declare module BABYLON {
  93159. /** @hidden */
  93160. export class WebGLPipelineContext implements IPipelineContext {
  93161. engine: Engine;
  93162. program: Nullable<WebGLProgram>;
  93163. context?: WebGLRenderingContext;
  93164. vertexShader?: WebGLShader;
  93165. fragmentShader?: WebGLShader;
  93166. isParallelCompiled: boolean;
  93167. onCompiled?: () => void;
  93168. transformFeedback?: WebGLTransformFeedback | null;
  93169. readonly isAsync: boolean;
  93170. readonly isReady: boolean;
  93171. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  93172. }
  93173. }
  93174. declare module BABYLON {
  93175. /** @hidden */
  93176. export class WebGLDataBuffer extends DataBuffer {
  93177. private _buffer;
  93178. constructor(resource: WebGLBuffer);
  93179. readonly underlyingResource: any;
  93180. }
  93181. }
  93182. declare module BABYLON {
  93183. /** @hidden */
  93184. export class WebGL2ShaderProcessor implements IShaderProcessor {
  93185. attributeProcessor(attribute: string): string;
  93186. varyingProcessor(varying: string, isFragment: boolean): string;
  93187. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  93188. }
  93189. }
  93190. declare module BABYLON {
  93191. /**
  93192. * This class is used to track a performance counter which is number based.
  93193. * The user has access to many properties which give statistics of different nature.
  93194. *
  93195. * The implementer can track two kinds of Performance Counter: time and count.
  93196. * 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.
  93197. * 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.
  93198. */
  93199. export class PerfCounter {
  93200. /**
  93201. * Gets or sets a global boolean to turn on and off all the counters
  93202. */
  93203. static Enabled: boolean;
  93204. /**
  93205. * Returns the smallest value ever
  93206. */
  93207. readonly min: number;
  93208. /**
  93209. * Returns the biggest value ever
  93210. */
  93211. readonly max: number;
  93212. /**
  93213. * Returns the average value since the performance counter is running
  93214. */
  93215. readonly average: number;
  93216. /**
  93217. * Returns the average value of the last second the counter was monitored
  93218. */
  93219. readonly lastSecAverage: number;
  93220. /**
  93221. * Returns the current value
  93222. */
  93223. readonly current: number;
  93224. /**
  93225. * Gets the accumulated total
  93226. */
  93227. readonly total: number;
  93228. /**
  93229. * Gets the total value count
  93230. */
  93231. readonly count: number;
  93232. /**
  93233. * Creates a new counter
  93234. */
  93235. constructor();
  93236. /**
  93237. * Call this method to start monitoring a new frame.
  93238. * 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.
  93239. */
  93240. fetchNewFrame(): void;
  93241. /**
  93242. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  93243. * @param newCount the count value to add to the monitored count
  93244. * @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.
  93245. */
  93246. addCount(newCount: number, fetchResult: boolean): void;
  93247. /**
  93248. * Start monitoring this performance counter
  93249. */
  93250. beginMonitoring(): void;
  93251. /**
  93252. * Compute the time lapsed since the previous beginMonitoring() call.
  93253. * @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
  93254. */
  93255. endMonitoring(newFrame?: boolean): void;
  93256. private _fetchResult;
  93257. private _startMonitoringTime;
  93258. private _min;
  93259. private _max;
  93260. private _average;
  93261. private _current;
  93262. private _totalValueCount;
  93263. private _totalAccumulated;
  93264. private _lastSecAverage;
  93265. private _lastSecAccumulated;
  93266. private _lastSecTime;
  93267. private _lastSecValueCount;
  93268. }
  93269. }
  93270. declare module BABYLON {
  93271. /**
  93272. * Interface for any object that can request an animation frame
  93273. */
  93274. export interface ICustomAnimationFrameRequester {
  93275. /**
  93276. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93277. */
  93278. renderFunction?: Function;
  93279. /**
  93280. * Called to request the next frame to render to
  93281. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93282. */
  93283. requestAnimationFrame: Function;
  93284. /**
  93285. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93286. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93287. */
  93288. requestID?: number;
  93289. }
  93290. }
  93291. declare module BABYLON {
  93292. /**
  93293. * Settings for finer control over video usage
  93294. */
  93295. export interface VideoTextureSettings {
  93296. /**
  93297. * Applies `autoplay` to video, if specified
  93298. */
  93299. autoPlay?: boolean;
  93300. /**
  93301. * Applies `loop` to video, if specified
  93302. */
  93303. loop?: boolean;
  93304. /**
  93305. * Automatically updates internal texture from video at every frame in the render loop
  93306. */
  93307. autoUpdateTexture: boolean;
  93308. /**
  93309. * Image src displayed during the video loading or until the user interacts with the video.
  93310. */
  93311. poster?: string;
  93312. }
  93313. /**
  93314. * If you want to display a video in your scene, this is the special texture for that.
  93315. * This special texture works similar to other textures, with the exception of a few parameters.
  93316. * @see https://doc.babylonjs.com/how_to/video_texture
  93317. */
  93318. export class VideoTexture extends Texture {
  93319. /**
  93320. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  93321. */
  93322. readonly autoUpdateTexture: boolean;
  93323. /**
  93324. * The video instance used by the texture internally
  93325. */
  93326. readonly video: HTMLVideoElement;
  93327. private _onUserActionRequestedObservable;
  93328. /**
  93329. * Event triggerd when a dom action is required by the user to play the video.
  93330. * This happens due to recent changes in browser policies preventing video to auto start.
  93331. */
  93332. readonly onUserActionRequestedObservable: Observable<Texture>;
  93333. private _generateMipMaps;
  93334. private _engine;
  93335. private _stillImageCaptured;
  93336. private _displayingPosterTexture;
  93337. private _settings;
  93338. private _createInternalTextureOnEvent;
  93339. /**
  93340. * Creates a video texture.
  93341. * If you want to display a video in your scene, this is the special texture for that.
  93342. * This special texture works similar to other textures, with the exception of a few parameters.
  93343. * @see https://doc.babylonjs.com/how_to/video_texture
  93344. * @param name optional name, will detect from video source, if not defined
  93345. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  93346. * @param scene is obviously the current scene.
  93347. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  93348. * @param invertY is false by default but can be used to invert video on Y axis
  93349. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  93350. * @param settings allows finer control over video usage
  93351. */
  93352. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  93353. private _getName;
  93354. private _getVideo;
  93355. private _createInternalTexture;
  93356. private reset;
  93357. /**
  93358. * @hidden Internal method to initiate `update`.
  93359. */
  93360. _rebuild(): void;
  93361. /**
  93362. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  93363. */
  93364. update(): void;
  93365. /**
  93366. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  93367. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  93368. */
  93369. updateTexture(isVisible: boolean): void;
  93370. protected _updateInternalTexture: () => void;
  93371. /**
  93372. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  93373. * @param url New url.
  93374. */
  93375. updateURL(url: string): void;
  93376. /**
  93377. * Dispose the texture and release its associated resources.
  93378. */
  93379. dispose(): void;
  93380. /**
  93381. * Creates a video texture straight from a stream.
  93382. * @param scene Define the scene the texture should be created in
  93383. * @param stream Define the stream the texture should be created from
  93384. * @returns The created video texture as a promise
  93385. */
  93386. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  93387. /**
  93388. * Creates a video texture straight from your WebCam video feed.
  93389. * @param scene Define the scene the texture should be created in
  93390. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93391. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93392. * @returns The created video texture as a promise
  93393. */
  93394. static CreateFromWebCamAsync(scene: Scene, constraints: {
  93395. minWidth: number;
  93396. maxWidth: number;
  93397. minHeight: number;
  93398. maxHeight: number;
  93399. deviceId: string;
  93400. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  93401. /**
  93402. * Creates a video texture straight from your WebCam video feed.
  93403. * @param scene Define the scene the texture should be created in
  93404. * @param onReady Define a callback to triggered once the texture will be ready
  93405. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93406. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93407. */
  93408. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  93409. minWidth: number;
  93410. maxWidth: number;
  93411. minHeight: number;
  93412. maxHeight: number;
  93413. deviceId: string;
  93414. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  93415. }
  93416. }
  93417. declare module BABYLON {
  93418. /**
  93419. * Defines the interface used by objects containing a viewport (like a camera)
  93420. */
  93421. interface IViewportOwnerLike {
  93422. /**
  93423. * Gets or sets the viewport
  93424. */
  93425. viewport: IViewportLike;
  93426. }
  93427. /**
  93428. * Interface for attribute information associated with buffer instanciation
  93429. */
  93430. export class InstancingAttributeInfo {
  93431. /**
  93432. * Index/offset of the attribute in the vertex shader
  93433. */
  93434. index: number;
  93435. /**
  93436. * size of the attribute, 1, 2, 3 or 4
  93437. */
  93438. attributeSize: number;
  93439. /**
  93440. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  93441. * default is FLOAT
  93442. */
  93443. attribyteType: number;
  93444. /**
  93445. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  93446. */
  93447. normalized: boolean;
  93448. /**
  93449. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  93450. */
  93451. offset: number;
  93452. /**
  93453. * Name of the GLSL attribute, for debugging purpose only
  93454. */
  93455. attributeName: string;
  93456. }
  93457. /**
  93458. * Define options used to create a depth texture
  93459. */
  93460. export class DepthTextureCreationOptions {
  93461. /** Specifies whether or not a stencil should be allocated in the texture */
  93462. generateStencil?: boolean;
  93463. /** Specifies whether or not bilinear filtering is enable on the texture */
  93464. bilinearFiltering?: boolean;
  93465. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  93466. comparisonFunction?: number;
  93467. /** Specifies if the created texture is a cube texture */
  93468. isCube?: boolean;
  93469. }
  93470. /**
  93471. * Class used to describe the capabilities of the engine relatively to the current browser
  93472. */
  93473. export class EngineCapabilities {
  93474. /** Maximum textures units per fragment shader */
  93475. maxTexturesImageUnits: number;
  93476. /** Maximum texture units per vertex shader */
  93477. maxVertexTextureImageUnits: number;
  93478. /** Maximum textures units in the entire pipeline */
  93479. maxCombinedTexturesImageUnits: number;
  93480. /** Maximum texture size */
  93481. maxTextureSize: number;
  93482. /** Maximum cube texture size */
  93483. maxCubemapTextureSize: number;
  93484. /** Maximum render texture size */
  93485. maxRenderTextureSize: number;
  93486. /** Maximum number of vertex attributes */
  93487. maxVertexAttribs: number;
  93488. /** Maximum number of varyings */
  93489. maxVaryingVectors: number;
  93490. /** Maximum number of uniforms per vertex shader */
  93491. maxVertexUniformVectors: number;
  93492. /** Maximum number of uniforms per fragment shader */
  93493. maxFragmentUniformVectors: number;
  93494. /** Defines if standard derivates (dx/dy) are supported */
  93495. standardDerivatives: boolean;
  93496. /** Defines if s3tc texture compression is supported */
  93497. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  93498. /** Defines if pvrtc texture compression is supported */
  93499. pvrtc: any;
  93500. /** Defines if etc1 texture compression is supported */
  93501. etc1: any;
  93502. /** Defines if etc2 texture compression is supported */
  93503. etc2: any;
  93504. /** Defines if astc texture compression is supported */
  93505. astc: any;
  93506. /** Defines if float textures are supported */
  93507. textureFloat: boolean;
  93508. /** Defines if vertex array objects are supported */
  93509. vertexArrayObject: boolean;
  93510. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  93511. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  93512. /** Gets the maximum level of anisotropy supported */
  93513. maxAnisotropy: number;
  93514. /** Defines if instancing is supported */
  93515. instancedArrays: boolean;
  93516. /** Defines if 32 bits indices are supported */
  93517. uintIndices: boolean;
  93518. /** Defines if high precision shaders are supported */
  93519. highPrecisionShaderSupported: boolean;
  93520. /** Defines if depth reading in the fragment shader is supported */
  93521. fragmentDepthSupported: boolean;
  93522. /** Defines if float texture linear filtering is supported*/
  93523. textureFloatLinearFiltering: boolean;
  93524. /** Defines if rendering to float textures is supported */
  93525. textureFloatRender: boolean;
  93526. /** Defines if half float textures are supported*/
  93527. textureHalfFloat: boolean;
  93528. /** Defines if half float texture linear filtering is supported*/
  93529. textureHalfFloatLinearFiltering: boolean;
  93530. /** Defines if rendering to half float textures is supported */
  93531. textureHalfFloatRender: boolean;
  93532. /** Defines if textureLOD shader command is supported */
  93533. textureLOD: boolean;
  93534. /** Defines if draw buffers extension is supported */
  93535. drawBuffersExtension: boolean;
  93536. /** Defines if depth textures are supported */
  93537. depthTextureExtension: boolean;
  93538. /** Defines if float color buffer are supported */
  93539. colorBufferFloat: boolean;
  93540. /** Gets disjoint timer query extension (null if not supported) */
  93541. timerQuery: EXT_disjoint_timer_query;
  93542. /** Defines if timestamp can be used with timer query */
  93543. canUseTimestampForTimerQuery: boolean;
  93544. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  93545. multiview: any;
  93546. /** Function used to let the system compiles shaders in background */
  93547. parallelShaderCompile: {
  93548. COMPLETION_STATUS_KHR: number;
  93549. };
  93550. }
  93551. /** Interface defining initialization parameters for Engine class */
  93552. export interface EngineOptions extends WebGLContextAttributes {
  93553. /**
  93554. * Defines if the engine should no exceed a specified device ratio
  93555. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  93556. */
  93557. limitDeviceRatio?: number;
  93558. /**
  93559. * Defines if webvr should be enabled automatically
  93560. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93561. */
  93562. autoEnableWebVR?: boolean;
  93563. /**
  93564. * Defines if webgl2 should be turned off even if supported
  93565. * @see http://doc.babylonjs.com/features/webgl2
  93566. */
  93567. disableWebGL2Support?: boolean;
  93568. /**
  93569. * Defines if webaudio should be initialized as well
  93570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93571. */
  93572. audioEngine?: boolean;
  93573. /**
  93574. * Defines if animations should run using a deterministic lock step
  93575. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93576. */
  93577. deterministicLockstep?: boolean;
  93578. /** Defines the maximum steps to use with deterministic lock step mode */
  93579. lockstepMaxSteps?: number;
  93580. /**
  93581. * Defines that engine should ignore context lost events
  93582. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  93583. */
  93584. doNotHandleContextLost?: boolean;
  93585. /**
  93586. * Defines that engine should ignore modifying touch action attribute and style
  93587. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  93588. */
  93589. doNotHandleTouchAction?: boolean;
  93590. /**
  93591. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  93592. */
  93593. useHighPrecisionFloats?: boolean;
  93594. }
  93595. /**
  93596. * Defines the interface used by display changed events
  93597. */
  93598. export interface IDisplayChangedEventArgs {
  93599. /** Gets the vrDisplay object (if any) */
  93600. vrDisplay: Nullable<any>;
  93601. /** Gets a boolean indicating if webVR is supported */
  93602. vrSupported: boolean;
  93603. }
  93604. /**
  93605. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  93606. */
  93607. export class Engine {
  93608. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  93609. static ExceptionList: ({
  93610. key: string;
  93611. capture: string;
  93612. captureConstraint: number;
  93613. targets: string[];
  93614. } | {
  93615. key: string;
  93616. capture: null;
  93617. captureConstraint: null;
  93618. targets: string[];
  93619. })[];
  93620. /** Gets the list of created engines */
  93621. static readonly Instances: Engine[];
  93622. /**
  93623. * Gets the latest created engine
  93624. */
  93625. static readonly LastCreatedEngine: Nullable<Engine>;
  93626. /**
  93627. * Gets the latest created scene
  93628. */
  93629. static readonly LastCreatedScene: Nullable<Scene>;
  93630. /**
  93631. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  93632. * @param flag defines which part of the materials must be marked as dirty
  93633. * @param predicate defines a predicate used to filter which materials should be affected
  93634. */
  93635. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93636. /** @hidden */
  93637. static _TextureLoaders: IInternalTextureLoader[];
  93638. /** Defines that alpha blending is disabled */
  93639. static readonly ALPHA_DISABLE: number;
  93640. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  93641. static readonly ALPHA_ADD: number;
  93642. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  93643. static readonly ALPHA_COMBINE: number;
  93644. /** Defines that alpha blending to DEST - SRC * DEST */
  93645. static readonly ALPHA_SUBTRACT: number;
  93646. /** Defines that alpha blending to SRC * DEST */
  93647. static readonly ALPHA_MULTIPLY: number;
  93648. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  93649. static readonly ALPHA_MAXIMIZED: number;
  93650. /** Defines that alpha blending to SRC + DEST */
  93651. static readonly ALPHA_ONEONE: number;
  93652. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  93653. static readonly ALPHA_PREMULTIPLIED: number;
  93654. /**
  93655. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  93656. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  93657. */
  93658. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  93659. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  93660. static readonly ALPHA_INTERPOLATE: number;
  93661. /**
  93662. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  93663. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  93664. */
  93665. static readonly ALPHA_SCREENMODE: number;
  93666. /** Defines that the ressource is not delayed*/
  93667. static readonly DELAYLOADSTATE_NONE: number;
  93668. /** Defines that the ressource was successfully delay loaded */
  93669. static readonly DELAYLOADSTATE_LOADED: number;
  93670. /** Defines that the ressource is currently delay loading */
  93671. static readonly DELAYLOADSTATE_LOADING: number;
  93672. /** Defines that the ressource is delayed and has not started loading */
  93673. static readonly DELAYLOADSTATE_NOTLOADED: number;
  93674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  93675. static readonly NEVER: number;
  93676. /** 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 */
  93677. static readonly ALWAYS: number;
  93678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  93679. static readonly LESS: number;
  93680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  93681. static readonly EQUAL: number;
  93682. /** 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 */
  93683. static readonly LEQUAL: number;
  93684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  93685. static readonly GREATER: number;
  93686. /** 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 */
  93687. static readonly GEQUAL: number;
  93688. /** 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 */
  93689. static readonly NOTEQUAL: number;
  93690. /** Passed to stencilOperation to specify that stencil value must be kept */
  93691. static readonly KEEP: number;
  93692. /** Passed to stencilOperation to specify that stencil value must be replaced */
  93693. static readonly REPLACE: number;
  93694. /** Passed to stencilOperation to specify that stencil value must be incremented */
  93695. static readonly INCR: number;
  93696. /** Passed to stencilOperation to specify that stencil value must be decremented */
  93697. static readonly DECR: number;
  93698. /** Passed to stencilOperation to specify that stencil value must be inverted */
  93699. static readonly INVERT: number;
  93700. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  93701. static readonly INCR_WRAP: number;
  93702. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  93703. static readonly DECR_WRAP: number;
  93704. /** Texture is not repeating outside of 0..1 UVs */
  93705. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  93706. /** Texture is repeating outside of 0..1 UVs */
  93707. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  93708. /** Texture is repeating and mirrored */
  93709. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  93710. /** ALPHA */
  93711. static readonly TEXTUREFORMAT_ALPHA: number;
  93712. /** LUMINANCE */
  93713. static readonly TEXTUREFORMAT_LUMINANCE: number;
  93714. /** LUMINANCE_ALPHA */
  93715. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  93716. /** RGB */
  93717. static readonly TEXTUREFORMAT_RGB: number;
  93718. /** RGBA */
  93719. static readonly TEXTUREFORMAT_RGBA: number;
  93720. /** RED */
  93721. static readonly TEXTUREFORMAT_RED: number;
  93722. /** RED (2nd reference) */
  93723. static readonly TEXTUREFORMAT_R: number;
  93724. /** RG */
  93725. static readonly TEXTUREFORMAT_RG: number;
  93726. /** RED_INTEGER */
  93727. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  93728. /** RED_INTEGER (2nd reference) */
  93729. static readonly TEXTUREFORMAT_R_INTEGER: number;
  93730. /** RG_INTEGER */
  93731. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  93732. /** RGB_INTEGER */
  93733. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  93734. /** RGBA_INTEGER */
  93735. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  93736. /** UNSIGNED_BYTE */
  93737. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  93738. /** UNSIGNED_BYTE (2nd reference) */
  93739. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  93740. /** FLOAT */
  93741. static readonly TEXTURETYPE_FLOAT: number;
  93742. /** HALF_FLOAT */
  93743. static readonly TEXTURETYPE_HALF_FLOAT: number;
  93744. /** BYTE */
  93745. static readonly TEXTURETYPE_BYTE: number;
  93746. /** SHORT */
  93747. static readonly TEXTURETYPE_SHORT: number;
  93748. /** UNSIGNED_SHORT */
  93749. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  93750. /** INT */
  93751. static readonly TEXTURETYPE_INT: number;
  93752. /** UNSIGNED_INT */
  93753. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  93754. /** UNSIGNED_SHORT_4_4_4_4 */
  93755. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  93756. /** UNSIGNED_SHORT_5_5_5_1 */
  93757. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  93758. /** UNSIGNED_SHORT_5_6_5 */
  93759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  93760. /** UNSIGNED_INT_2_10_10_10_REV */
  93761. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  93762. /** UNSIGNED_INT_24_8 */
  93763. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  93764. /** UNSIGNED_INT_10F_11F_11F_REV */
  93765. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  93766. /** UNSIGNED_INT_5_9_9_9_REV */
  93767. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  93768. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  93769. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  93770. /** nearest is mag = nearest and min = nearest and mip = linear */
  93771. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  93772. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93773. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  93774. /** Trilinear is mag = linear and min = linear and mip = linear */
  93775. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  93776. /** nearest is mag = nearest and min = nearest and mip = linear */
  93777. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  93778. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93779. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  93780. /** Trilinear is mag = linear and min = linear and mip = linear */
  93781. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  93782. /** mag = nearest and min = nearest and mip = nearest */
  93783. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  93784. /** mag = nearest and min = linear and mip = nearest */
  93785. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  93786. /** mag = nearest and min = linear and mip = linear */
  93787. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  93788. /** mag = nearest and min = linear and mip = none */
  93789. static readonly TEXTURE_NEAREST_LINEAR: number;
  93790. /** mag = nearest and min = nearest and mip = none */
  93791. static readonly TEXTURE_NEAREST_NEAREST: number;
  93792. /** mag = linear and min = nearest and mip = nearest */
  93793. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  93794. /** mag = linear and min = nearest and mip = linear */
  93795. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  93796. /** mag = linear and min = linear and mip = none */
  93797. static readonly TEXTURE_LINEAR_LINEAR: number;
  93798. /** mag = linear and min = nearest and mip = none */
  93799. static readonly TEXTURE_LINEAR_NEAREST: number;
  93800. /** Explicit coordinates mode */
  93801. static readonly TEXTURE_EXPLICIT_MODE: number;
  93802. /** Spherical coordinates mode */
  93803. static readonly TEXTURE_SPHERICAL_MODE: number;
  93804. /** Planar coordinates mode */
  93805. static readonly TEXTURE_PLANAR_MODE: number;
  93806. /** Cubic coordinates mode */
  93807. static readonly TEXTURE_CUBIC_MODE: number;
  93808. /** Projection coordinates mode */
  93809. static readonly TEXTURE_PROJECTION_MODE: number;
  93810. /** Skybox coordinates mode */
  93811. static readonly TEXTURE_SKYBOX_MODE: number;
  93812. /** Inverse Cubic coordinates mode */
  93813. static readonly TEXTURE_INVCUBIC_MODE: number;
  93814. /** Equirectangular coordinates mode */
  93815. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  93816. /** Equirectangular Fixed coordinates mode */
  93817. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  93818. /** Equirectangular Fixed Mirrored coordinates mode */
  93819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93820. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  93821. static readonly SCALEMODE_FLOOR: number;
  93822. /** Defines that texture rescaling will look for the nearest power of 2 size */
  93823. static readonly SCALEMODE_NEAREST: number;
  93824. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  93825. static readonly SCALEMODE_CEILING: number;
  93826. /**
  93827. * Returns the current npm package of the sdk
  93828. */
  93829. static readonly NpmPackage: string;
  93830. /**
  93831. * Returns the current version of the framework
  93832. */
  93833. static readonly Version: string;
  93834. /**
  93835. * Returns a string describing the current engine
  93836. */
  93837. readonly description: string;
  93838. /**
  93839. * Gets or sets the epsilon value used by collision engine
  93840. */
  93841. static CollisionsEpsilon: number;
  93842. /**
  93843. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93844. */
  93845. static ShadersRepository: string;
  93846. /**
  93847. * Method called to create the default loading screen.
  93848. * This can be overriden in your own app.
  93849. * @param canvas The rendering canvas element
  93850. * @returns The loading screen
  93851. */
  93852. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  93853. /**
  93854. * Method called to create the default rescale post process on each engine.
  93855. */
  93856. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  93857. /** @hidden */
  93858. _shaderProcessor: IShaderProcessor;
  93859. /**
  93860. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  93861. */
  93862. forcePOTTextures: boolean;
  93863. /**
  93864. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  93865. */
  93866. isFullscreen: boolean;
  93867. /**
  93868. * Gets a boolean indicating if the pointer is currently locked
  93869. */
  93870. isPointerLock: boolean;
  93871. /**
  93872. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  93873. */
  93874. cullBackFaces: boolean;
  93875. /**
  93876. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  93877. */
  93878. renderEvenInBackground: boolean;
  93879. /**
  93880. * Gets or sets a boolean indicating that cache can be kept between frames
  93881. */
  93882. preventCacheWipeBetweenFrames: boolean;
  93883. /**
  93884. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  93885. **/
  93886. enableOfflineSupport: boolean;
  93887. /**
  93888. * 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)
  93889. **/
  93890. disableManifestCheck: boolean;
  93891. /**
  93892. * Gets the list of created scenes
  93893. */
  93894. scenes: Scene[];
  93895. /**
  93896. * Event raised when a new scene is created
  93897. */
  93898. onNewSceneAddedObservable: Observable<Scene>;
  93899. /**
  93900. * Gets the list of created postprocesses
  93901. */
  93902. postProcesses: PostProcess[];
  93903. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  93904. validateShaderPrograms: boolean;
  93905. /**
  93906. * Observable event triggered each time the rendering canvas is resized
  93907. */
  93908. onResizeObservable: Observable<Engine>;
  93909. /**
  93910. * Observable event triggered each time the canvas loses focus
  93911. */
  93912. onCanvasBlurObservable: Observable<Engine>;
  93913. /**
  93914. * Observable event triggered each time the canvas gains focus
  93915. */
  93916. onCanvasFocusObservable: Observable<Engine>;
  93917. /**
  93918. * Observable event triggered each time the canvas receives pointerout event
  93919. */
  93920. onCanvasPointerOutObservable: Observable<PointerEvent>;
  93921. /**
  93922. * Observable event triggered before each texture is initialized
  93923. */
  93924. onBeforeTextureInitObservable: Observable<Texture>;
  93925. /**
  93926. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  93927. */
  93928. disableUniformBuffers: boolean;
  93929. /** @hidden */
  93930. _uniformBuffers: UniformBuffer[];
  93931. /**
  93932. * Gets a boolean indicating that the engine supports uniform buffers
  93933. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93934. */
  93935. readonly supportsUniformBuffers: boolean;
  93936. /**
  93937. * Observable raised when the engine begins a new frame
  93938. */
  93939. onBeginFrameObservable: Observable<Engine>;
  93940. /**
  93941. * If set, will be used to request the next animation frame for the render loop
  93942. */
  93943. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  93944. /**
  93945. * Observable raised when the engine ends the current frame
  93946. */
  93947. onEndFrameObservable: Observable<Engine>;
  93948. /**
  93949. * Observable raised when the engine is about to compile a shader
  93950. */
  93951. onBeforeShaderCompilationObservable: Observable<Engine>;
  93952. /**
  93953. * Observable raised when the engine has jsut compiled a shader
  93954. */
  93955. onAfterShaderCompilationObservable: Observable<Engine>;
  93956. /** @hidden */
  93957. _gl: WebGLRenderingContext;
  93958. private _renderingCanvas;
  93959. private _windowIsBackground;
  93960. private _webGLVersion;
  93961. protected _highPrecisionShadersAllowed: boolean;
  93962. /** @hidden */
  93963. readonly _shouldUseHighPrecisionShader: boolean;
  93964. /**
  93965. * Gets a boolean indicating that only power of 2 textures are supported
  93966. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  93967. */
  93968. readonly needPOTTextures: boolean;
  93969. /** @hidden */
  93970. _badOS: boolean;
  93971. /** @hidden */
  93972. _badDesktopOS: boolean;
  93973. /**
  93974. * Gets the audio engine
  93975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93976. * @ignorenaming
  93977. */
  93978. static audioEngine: IAudioEngine;
  93979. /**
  93980. * Default AudioEngine factory responsible of creating the Audio Engine.
  93981. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  93982. */
  93983. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  93984. /**
  93985. * Default offline support factory responsible of creating a tool used to store data locally.
  93986. * By default, this will create a Database object if the workload has been embedded.
  93987. */
  93988. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  93989. private _onFocus;
  93990. private _onBlur;
  93991. private _onCanvasPointerOut;
  93992. private _onCanvasBlur;
  93993. private _onCanvasFocus;
  93994. private _onFullscreenChange;
  93995. private _onPointerLockChange;
  93996. private _hardwareScalingLevel;
  93997. /** @hidden */
  93998. _caps: EngineCapabilities;
  93999. private _pointerLockRequested;
  94000. private _isStencilEnable;
  94001. private _colorWrite;
  94002. private _loadingScreen;
  94003. /** @hidden */
  94004. _drawCalls: PerfCounter;
  94005. private _glVersion;
  94006. private _glRenderer;
  94007. private _glVendor;
  94008. private _videoTextureSupported;
  94009. private _renderingQueueLaunched;
  94010. private _activeRenderLoops;
  94011. private _deterministicLockstep;
  94012. private _lockstepMaxSteps;
  94013. /**
  94014. * Observable signaled when a context lost event is raised
  94015. */
  94016. onContextLostObservable: Observable<Engine>;
  94017. /**
  94018. * Observable signaled when a context restored event is raised
  94019. */
  94020. onContextRestoredObservable: Observable<Engine>;
  94021. private _onContextLost;
  94022. private _onContextRestored;
  94023. private _contextWasLost;
  94024. /** @hidden */
  94025. _doNotHandleContextLost: boolean;
  94026. /**
  94027. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  94028. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  94029. */
  94030. doNotHandleContextLost: boolean;
  94031. private _performanceMonitor;
  94032. private _fps;
  94033. private _deltaTime;
  94034. /**
  94035. * Turn this value on if you want to pause FPS computation when in background
  94036. */
  94037. disablePerformanceMonitorInBackground: boolean;
  94038. /**
  94039. * Gets the performance monitor attached to this engine
  94040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  94041. */
  94042. readonly performanceMonitor: PerformanceMonitor;
  94043. /**
  94044. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  94045. */
  94046. disableVertexArrayObjects: boolean;
  94047. /** @hidden */
  94048. protected _depthCullingState: _DepthCullingState;
  94049. /** @hidden */
  94050. protected _stencilState: _StencilState;
  94051. /** @hidden */
  94052. protected _alphaState: _AlphaState;
  94053. /** @hidden */
  94054. protected _alphaMode: number;
  94055. /** @hidden */
  94056. _internalTexturesCache: InternalTexture[];
  94057. /** @hidden */
  94058. protected _activeChannel: number;
  94059. private _currentTextureChannel;
  94060. /** @hidden */
  94061. protected _boundTexturesCache: {
  94062. [key: string]: Nullable<InternalTexture>;
  94063. };
  94064. /** @hidden */
  94065. protected _currentEffect: Nullable<Effect>;
  94066. /** @hidden */
  94067. protected _currentProgram: Nullable<WebGLProgram>;
  94068. private _compiledEffects;
  94069. private _vertexAttribArraysEnabled;
  94070. /** @hidden */
  94071. protected _cachedViewport: Nullable<IViewportLike>;
  94072. private _cachedVertexArrayObject;
  94073. /** @hidden */
  94074. protected _cachedVertexBuffers: any;
  94075. /** @hidden */
  94076. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  94077. /** @hidden */
  94078. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  94079. /** @hidden */
  94080. _currentRenderTarget: Nullable<InternalTexture>;
  94081. private _uintIndicesCurrentlySet;
  94082. private _currentBoundBuffer;
  94083. /** @hidden */
  94084. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  94085. private _currentBufferPointers;
  94086. private _currentInstanceLocations;
  94087. private _currentInstanceBuffers;
  94088. private _textureUnits;
  94089. /** @hidden */
  94090. _workingCanvas: Nullable<HTMLCanvasElement>;
  94091. /** @hidden */
  94092. _workingContext: Nullable<CanvasRenderingContext2D>;
  94093. private _rescalePostProcess;
  94094. private _dummyFramebuffer;
  94095. private _externalData;
  94096. /** @hidden */
  94097. _bindedRenderFunction: any;
  94098. private _vaoRecordInProgress;
  94099. private _mustWipeVertexAttributes;
  94100. private _emptyTexture;
  94101. private _emptyCubeTexture;
  94102. private _emptyTexture3D;
  94103. /** @hidden */
  94104. _frameHandler: number;
  94105. private _nextFreeTextureSlots;
  94106. private _maxSimultaneousTextures;
  94107. private _activeRequests;
  94108. private _texturesSupported;
  94109. /** @hidden */
  94110. _textureFormatInUse: Nullable<string>;
  94111. /**
  94112. * Gets the list of texture formats supported
  94113. */
  94114. readonly texturesSupported: Array<string>;
  94115. /**
  94116. * Gets the list of texture formats in use
  94117. */
  94118. readonly textureFormatInUse: Nullable<string>;
  94119. /**
  94120. * Gets the current viewport
  94121. */
  94122. readonly currentViewport: Nullable<IViewportLike>;
  94123. /**
  94124. * Gets the default empty texture
  94125. */
  94126. readonly emptyTexture: InternalTexture;
  94127. /**
  94128. * Gets the default empty 3D texture
  94129. */
  94130. readonly emptyTexture3D: InternalTexture;
  94131. /**
  94132. * Gets the default empty cube texture
  94133. */
  94134. readonly emptyCubeTexture: InternalTexture;
  94135. /**
  94136. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  94137. */
  94138. readonly premultipliedAlpha: boolean;
  94139. /**
  94140. * Creates a new engine
  94141. * @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
  94142. * @param antialias defines enable antialiasing (default: false)
  94143. * @param options defines further options to be sent to the getContext() function
  94144. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  94145. */
  94146. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  94147. /**
  94148. * Initializes a webVR display and starts listening to display change events
  94149. * The onVRDisplayChangedObservable will be notified upon these changes
  94150. * @returns The onVRDisplayChangedObservable
  94151. */
  94152. initWebVR(): Observable<IDisplayChangedEventArgs>;
  94153. /** @hidden */
  94154. _prepareVRComponent(): void;
  94155. /** @hidden */
  94156. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  94157. /** @hidden */
  94158. _submitVRFrame(): void;
  94159. /**
  94160. * Call this function to leave webVR mode
  94161. * Will do nothing if webVR is not supported or if there is no webVR device
  94162. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94163. */
  94164. disableVR(): void;
  94165. /**
  94166. * Gets a boolean indicating that the system is in VR mode and is presenting
  94167. * @returns true if VR mode is engaged
  94168. */
  94169. isVRPresenting(): boolean;
  94170. /** @hidden */
  94171. _requestVRFrame(): void;
  94172. private _disableTouchAction;
  94173. private _rebuildInternalTextures;
  94174. private _rebuildEffects;
  94175. /**
  94176. * Gets a boolean indicating if all created effects are ready
  94177. * @returns true if all effects are ready
  94178. */
  94179. areAllEffectsReady(): boolean;
  94180. private _rebuildBuffers;
  94181. private _initGLContext;
  94182. /**
  94183. * Gets version of the current webGL context
  94184. */
  94185. readonly webGLVersion: number;
  94186. /**
  94187. * Gets a string idenfifying the name of the class
  94188. * @returns "Engine" string
  94189. */
  94190. getClassName(): string;
  94191. /**
  94192. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  94193. */
  94194. readonly isStencilEnable: boolean;
  94195. /** @hidden */
  94196. _prepareWorkingCanvas(): void;
  94197. /**
  94198. * Reset the texture cache to empty state
  94199. */
  94200. resetTextureCache(): void;
  94201. /**
  94202. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  94203. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94204. * @returns true if engine is in deterministic lock step mode
  94205. */
  94206. isDeterministicLockStep(): boolean;
  94207. /**
  94208. * Gets the max steps when engine is running in deterministic lock step
  94209. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94210. * @returns the max steps
  94211. */
  94212. getLockstepMaxSteps(): number;
  94213. /**
  94214. * Gets an object containing information about the current webGL context
  94215. * @returns an object containing the vender, the renderer and the version of the current webGL context
  94216. */
  94217. getGlInfo(): {
  94218. vendor: string;
  94219. renderer: string;
  94220. version: string;
  94221. };
  94222. /**
  94223. * Gets current aspect ratio
  94224. * @param viewportOwner defines the camera to use to get the aspect ratio
  94225. * @param useScreen defines if screen size must be used (or the current render target if any)
  94226. * @returns a number defining the aspect ratio
  94227. */
  94228. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  94229. /**
  94230. * Gets current screen aspect ratio
  94231. * @returns a number defining the aspect ratio
  94232. */
  94233. getScreenAspectRatio(): number;
  94234. /**
  94235. * Gets the current render width
  94236. * @param useScreen defines if screen size must be used (or the current render target if any)
  94237. * @returns a number defining the current render width
  94238. */
  94239. getRenderWidth(useScreen?: boolean): number;
  94240. /**
  94241. * Gets the current render height
  94242. * @param useScreen defines if screen size must be used (or the current render target if any)
  94243. * @returns a number defining the current render height
  94244. */
  94245. getRenderHeight(useScreen?: boolean): number;
  94246. /**
  94247. * Gets the HTML canvas attached with the current webGL context
  94248. * @returns a HTML canvas
  94249. */
  94250. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  94251. /**
  94252. * Gets the client rect of the HTML canvas attached with the current webGL context
  94253. * @returns a client rectanglee
  94254. */
  94255. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  94256. /**
  94257. * Defines the hardware scaling level.
  94258. * By default the hardware scaling level is computed from the window device ratio.
  94259. * 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.
  94260. * @param level defines the level to use
  94261. */
  94262. setHardwareScalingLevel(level: number): void;
  94263. /**
  94264. * Gets the current hardware scaling level.
  94265. * By default the hardware scaling level is computed from the window device ratio.
  94266. * 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.
  94267. * @returns a number indicating the current hardware scaling level
  94268. */
  94269. getHardwareScalingLevel(): number;
  94270. /**
  94271. * Gets the list of loaded textures
  94272. * @returns an array containing all loaded textures
  94273. */
  94274. getLoadedTexturesCache(): InternalTexture[];
  94275. /**
  94276. * Gets the object containing all engine capabilities
  94277. * @returns the EngineCapabilities object
  94278. */
  94279. getCaps(): EngineCapabilities;
  94280. /**
  94281. * Gets the current depth function
  94282. * @returns a number defining the depth function
  94283. */
  94284. getDepthFunction(): Nullable<number>;
  94285. /**
  94286. * Sets the current depth function
  94287. * @param depthFunc defines the function to use
  94288. */
  94289. setDepthFunction(depthFunc: number): void;
  94290. /**
  94291. * Sets the current depth function to GREATER
  94292. */
  94293. setDepthFunctionToGreater(): void;
  94294. /**
  94295. * Sets the current depth function to GEQUAL
  94296. */
  94297. setDepthFunctionToGreaterOrEqual(): void;
  94298. /**
  94299. * Sets the current depth function to LESS
  94300. */
  94301. setDepthFunctionToLess(): void;
  94302. private _cachedStencilBuffer;
  94303. private _cachedStencilFunction;
  94304. private _cachedStencilMask;
  94305. private _cachedStencilOperationPass;
  94306. private _cachedStencilOperationFail;
  94307. private _cachedStencilOperationDepthFail;
  94308. private _cachedStencilReference;
  94309. /**
  94310. * Caches the the state of the stencil buffer
  94311. */
  94312. cacheStencilState(): void;
  94313. /**
  94314. * Restores the state of the stencil buffer
  94315. */
  94316. restoreStencilState(): void;
  94317. /**
  94318. * Sets the current depth function to LEQUAL
  94319. */
  94320. setDepthFunctionToLessOrEqual(): void;
  94321. /**
  94322. * Gets a boolean indicating if stencil buffer is enabled
  94323. * @returns the current stencil buffer state
  94324. */
  94325. getStencilBuffer(): boolean;
  94326. /**
  94327. * Enable or disable the stencil buffer
  94328. * @param enable defines if the stencil buffer must be enabled or disabled
  94329. */
  94330. setStencilBuffer(enable: boolean): void;
  94331. /**
  94332. * Gets the current stencil mask
  94333. * @returns a number defining the new stencil mask to use
  94334. */
  94335. getStencilMask(): number;
  94336. /**
  94337. * Sets the current stencil mask
  94338. * @param mask defines the new stencil mask to use
  94339. */
  94340. setStencilMask(mask: number): void;
  94341. /**
  94342. * Gets the current stencil function
  94343. * @returns a number defining the stencil function to use
  94344. */
  94345. getStencilFunction(): number;
  94346. /**
  94347. * Gets the current stencil reference value
  94348. * @returns a number defining the stencil reference value to use
  94349. */
  94350. getStencilFunctionReference(): number;
  94351. /**
  94352. * Gets the current stencil mask
  94353. * @returns a number defining the stencil mask to use
  94354. */
  94355. getStencilFunctionMask(): number;
  94356. /**
  94357. * Sets the current stencil function
  94358. * @param stencilFunc defines the new stencil function to use
  94359. */
  94360. setStencilFunction(stencilFunc: number): void;
  94361. /**
  94362. * Sets the current stencil reference
  94363. * @param reference defines the new stencil reference to use
  94364. */
  94365. setStencilFunctionReference(reference: number): void;
  94366. /**
  94367. * Sets the current stencil mask
  94368. * @param mask defines the new stencil mask to use
  94369. */
  94370. setStencilFunctionMask(mask: number): void;
  94371. /**
  94372. * Gets the current stencil operation when stencil fails
  94373. * @returns a number defining stencil operation to use when stencil fails
  94374. */
  94375. getStencilOperationFail(): number;
  94376. /**
  94377. * Gets the current stencil operation when depth fails
  94378. * @returns a number defining stencil operation to use when depth fails
  94379. */
  94380. getStencilOperationDepthFail(): number;
  94381. /**
  94382. * Gets the current stencil operation when stencil passes
  94383. * @returns a number defining stencil operation to use when stencil passes
  94384. */
  94385. getStencilOperationPass(): number;
  94386. /**
  94387. * Sets the stencil operation to use when stencil fails
  94388. * @param operation defines the stencil operation to use when stencil fails
  94389. */
  94390. setStencilOperationFail(operation: number): void;
  94391. /**
  94392. * Sets the stencil operation to use when depth fails
  94393. * @param operation defines the stencil operation to use when depth fails
  94394. */
  94395. setStencilOperationDepthFail(operation: number): void;
  94396. /**
  94397. * Sets the stencil operation to use when stencil passes
  94398. * @param operation defines the stencil operation to use when stencil passes
  94399. */
  94400. setStencilOperationPass(operation: number): void;
  94401. /**
  94402. * Sets a boolean indicating if the dithering state is enabled or disabled
  94403. * @param value defines the dithering state
  94404. */
  94405. setDitheringState(value: boolean): void;
  94406. /**
  94407. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  94408. * @param value defines the rasterizer state
  94409. */
  94410. setRasterizerState(value: boolean): void;
  94411. /**
  94412. * stop executing a render loop function and remove it from the execution array
  94413. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  94414. */
  94415. stopRenderLoop(renderFunction?: () => void): void;
  94416. /** @hidden */
  94417. _renderLoop(): void;
  94418. /**
  94419. * Register and execute a render loop. The engine can have more than one render function
  94420. * @param renderFunction defines the function to continuously execute
  94421. */
  94422. runRenderLoop(renderFunction: () => void): void;
  94423. /**
  94424. * Toggle full screen mode
  94425. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94426. */
  94427. switchFullscreen(requestPointerLock: boolean): void;
  94428. /**
  94429. * Enters full screen mode
  94430. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94431. */
  94432. enterFullscreen(requestPointerLock: boolean): void;
  94433. /**
  94434. * Exits full screen mode
  94435. */
  94436. exitFullscreen(): void;
  94437. /**
  94438. * Enters Pointerlock mode
  94439. */
  94440. enterPointerlock(): void;
  94441. /**
  94442. * Exits Pointerlock mode
  94443. */
  94444. exitPointerlock(): void;
  94445. /**
  94446. * Clear the current render buffer or the current render target (if any is set up)
  94447. * @param color defines the color to use
  94448. * @param backBuffer defines if the back buffer must be cleared
  94449. * @param depth defines if the depth buffer must be cleared
  94450. * @param stencil defines if the stencil buffer must be cleared
  94451. */
  94452. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  94453. /**
  94454. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  94455. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94456. * @param y defines the y-coordinate of the corner of the clear rectangle
  94457. * @param width defines the width of the clear rectangle
  94458. * @param height defines the height of the clear rectangle
  94459. * @param clearColor defines the clear color
  94460. */
  94461. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  94462. /**
  94463. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  94464. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94465. * @param y defines the y-coordinate of the corner of the clear rectangle
  94466. * @param width defines the width of the clear rectangle
  94467. * @param height defines the height of the clear rectangle
  94468. */
  94469. enableScissor(x: number, y: number, width: number, height: number): void;
  94470. /**
  94471. * Disable previously set scissor test rectangle
  94472. */
  94473. disableScissor(): void;
  94474. private _viewportCached;
  94475. /** @hidden */
  94476. _viewport(x: number, y: number, width: number, height: number): void;
  94477. /**
  94478. * Set the WebGL's viewport
  94479. * @param viewport defines the viewport element to be used
  94480. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  94481. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  94482. */
  94483. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  94484. /**
  94485. * Directly set the WebGL Viewport
  94486. * @param x defines the x coordinate of the viewport (in screen space)
  94487. * @param y defines the y coordinate of the viewport (in screen space)
  94488. * @param width defines the width of the viewport (in screen space)
  94489. * @param height defines the height of the viewport (in screen space)
  94490. * @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
  94491. */
  94492. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  94493. /**
  94494. * Begin a new frame
  94495. */
  94496. beginFrame(): void;
  94497. /**
  94498. * Enf the current frame
  94499. */
  94500. endFrame(): void;
  94501. /**
  94502. * Resize the view according to the canvas' size
  94503. */
  94504. resize(): void;
  94505. /**
  94506. * Force a specific size of the canvas
  94507. * @param width defines the new canvas' width
  94508. * @param height defines the new canvas' height
  94509. */
  94510. setSize(width: number, height: number): void;
  94511. /**
  94512. * Binds the frame buffer to the specified texture.
  94513. * @param texture The texture to render to or null for the default canvas
  94514. * @param faceIndex The face of the texture to render to in case of cube texture
  94515. * @param requiredWidth The width of the target to render to
  94516. * @param requiredHeight The height of the target to render to
  94517. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  94518. * @param depthStencilTexture The depth stencil texture to use to render
  94519. * @param lodLevel defines le lod level to bind to the frame buffer
  94520. */
  94521. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  94522. /** @hidden */
  94523. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  94524. /**
  94525. * Unbind the current render target texture from the webGL context
  94526. * @param texture defines the render target texture to unbind
  94527. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  94528. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  94529. */
  94530. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  94531. /**
  94532. * Force the mipmap generation for the given render target texture
  94533. * @param texture defines the render target texture to use
  94534. */
  94535. generateMipMapsForCubemap(texture: InternalTexture): void;
  94536. /**
  94537. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  94538. */
  94539. flushFramebuffer(): void;
  94540. /**
  94541. * Unbind the current render target and bind the default framebuffer
  94542. */
  94543. restoreDefaultFramebuffer(): void;
  94544. /**
  94545. * Create an uniform buffer
  94546. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94547. * @param elements defines the content of the uniform buffer
  94548. * @returns the webGL uniform buffer
  94549. */
  94550. createUniformBuffer(elements: FloatArray): DataBuffer;
  94551. /**
  94552. * Create a dynamic uniform buffer
  94553. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94554. * @param elements defines the content of the uniform buffer
  94555. * @returns the webGL uniform buffer
  94556. */
  94557. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  94558. /**
  94559. * Update an existing uniform buffer
  94560. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94561. * @param uniformBuffer defines the target uniform buffer
  94562. * @param elements defines the content to update
  94563. * @param offset defines the offset in the uniform buffer where update should start
  94564. * @param count defines the size of the data to update
  94565. */
  94566. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  94567. private _resetVertexBufferBinding;
  94568. /**
  94569. * Creates a vertex buffer
  94570. * @param data the data for the vertex buffer
  94571. * @returns the new WebGL static buffer
  94572. */
  94573. createVertexBuffer(data: DataArray): DataBuffer;
  94574. /**
  94575. * Creates a dynamic vertex buffer
  94576. * @param data the data for the dynamic vertex buffer
  94577. * @returns the new WebGL dynamic buffer
  94578. */
  94579. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  94580. /**
  94581. * Update a dynamic index buffer
  94582. * @param indexBuffer defines the target index buffer
  94583. * @param indices defines the data to update
  94584. * @param offset defines the offset in the target index buffer where update should start
  94585. */
  94586. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  94587. /**
  94588. * Updates a dynamic vertex buffer.
  94589. * @param vertexBuffer the vertex buffer to update
  94590. * @param data the data used to update the vertex buffer
  94591. * @param byteOffset the byte offset of the data
  94592. * @param byteLength the byte length of the data
  94593. */
  94594. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  94595. private _resetIndexBufferBinding;
  94596. /**
  94597. * Creates a new index buffer
  94598. * @param indices defines the content of the index buffer
  94599. * @param updatable defines if the index buffer must be updatable
  94600. * @returns a new webGL buffer
  94601. */
  94602. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  94603. /**
  94604. * Bind a webGL buffer to the webGL context
  94605. * @param buffer defines the buffer to bind
  94606. */
  94607. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  94608. /**
  94609. * Bind an uniform buffer to the current webGL context
  94610. * @param buffer defines the buffer to bind
  94611. */
  94612. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  94613. /**
  94614. * Bind a buffer to the current webGL context at a given location
  94615. * @param buffer defines the buffer to bind
  94616. * @param location defines the index where to bind the buffer
  94617. */
  94618. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  94619. /**
  94620. * Bind a specific block at a given index in a specific shader program
  94621. * @param pipelineContext defines the pipeline context to use
  94622. * @param blockName defines the block name
  94623. * @param index defines the index where to bind the block
  94624. */
  94625. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  94626. private bindIndexBuffer;
  94627. private bindBuffer;
  94628. /**
  94629. * update the bound buffer with the given data
  94630. * @param data defines the data to update
  94631. */
  94632. updateArrayBuffer(data: Float32Array): void;
  94633. private _vertexAttribPointer;
  94634. private _bindIndexBufferWithCache;
  94635. private _bindVertexBuffersAttributes;
  94636. /**
  94637. * Records a vertex array object
  94638. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94639. * @param vertexBuffers defines the list of vertex buffers to store
  94640. * @param indexBuffer defines the index buffer to store
  94641. * @param effect defines the effect to store
  94642. * @returns the new vertex array object
  94643. */
  94644. recordVertexArrayObject(vertexBuffers: {
  94645. [key: string]: VertexBuffer;
  94646. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  94647. /**
  94648. * Bind a specific vertex array object
  94649. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94650. * @param vertexArrayObject defines the vertex array object to bind
  94651. * @param indexBuffer defines the index buffer to bind
  94652. */
  94653. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  94654. /**
  94655. * Bind webGl buffers directly to the webGL context
  94656. * @param vertexBuffer defines the vertex buffer to bind
  94657. * @param indexBuffer defines the index buffer to bind
  94658. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  94659. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  94660. * @param effect defines the effect associated with the vertex buffer
  94661. */
  94662. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  94663. private _unbindVertexArrayObject;
  94664. /**
  94665. * Bind a list of vertex buffers to the webGL context
  94666. * @param vertexBuffers defines the list of vertex buffers to bind
  94667. * @param indexBuffer defines the index buffer to bind
  94668. * @param effect defines the effect associated with the vertex buffers
  94669. */
  94670. bindBuffers(vertexBuffers: {
  94671. [key: string]: Nullable<VertexBuffer>;
  94672. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  94673. /**
  94674. * Unbind all instance attributes
  94675. */
  94676. unbindInstanceAttributes(): void;
  94677. /**
  94678. * Release and free the memory of a vertex array object
  94679. * @param vao defines the vertex array object to delete
  94680. */
  94681. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  94682. /** @hidden */
  94683. _releaseBuffer(buffer: DataBuffer): boolean;
  94684. /**
  94685. * Creates a webGL buffer to use with instanciation
  94686. * @param capacity defines the size of the buffer
  94687. * @returns the webGL buffer
  94688. */
  94689. createInstancesBuffer(capacity: number): DataBuffer;
  94690. /**
  94691. * Delete a webGL buffer used with instanciation
  94692. * @param buffer defines the webGL buffer to delete
  94693. */
  94694. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  94695. /**
  94696. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  94697. * @param instancesBuffer defines the webGL buffer to update and bind
  94698. * @param data defines the data to store in the buffer
  94699. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  94700. */
  94701. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  94702. /**
  94703. * Apply all cached states (depth, culling, stencil and alpha)
  94704. */
  94705. applyStates(): void;
  94706. /**
  94707. * Send a draw order
  94708. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  94709. * @param indexStart defines the starting index
  94710. * @param indexCount defines the number of index to draw
  94711. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94712. */
  94713. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  94714. /**
  94715. * Draw a list of points
  94716. * @param verticesStart defines the index of first vertex to draw
  94717. * @param verticesCount defines the count of vertices to draw
  94718. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94719. */
  94720. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94721. /**
  94722. * Draw a list of unindexed primitives
  94723. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  94724. * @param verticesStart defines the index of first vertex to draw
  94725. * @param verticesCount defines the count of vertices to draw
  94726. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94727. */
  94728. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94729. /**
  94730. * Draw a list of indexed primitives
  94731. * @param fillMode defines the primitive to use
  94732. * @param indexStart defines the starting index
  94733. * @param indexCount defines the number of index to draw
  94734. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94735. */
  94736. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  94737. /**
  94738. * Draw a list of unindexed primitives
  94739. * @param fillMode defines the primitive to use
  94740. * @param verticesStart defines the index of first vertex to draw
  94741. * @param verticesCount defines the count of vertices to draw
  94742. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94743. */
  94744. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94745. private _drawMode;
  94746. /** @hidden */
  94747. _releaseEffect(effect: Effect): void;
  94748. /** @hidden */
  94749. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  94750. /**
  94751. * Create a new effect (used to store vertex/fragment shaders)
  94752. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  94753. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  94754. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  94755. * @param samplers defines an array of string used to represent textures
  94756. * @param defines defines the string containing the defines to use to compile the shaders
  94757. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  94758. * @param onCompiled defines a function to call when the effect creation is successful
  94759. * @param onError defines a function to call when the effect creation has failed
  94760. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  94761. * @returns the new Effect
  94762. */
  94763. 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;
  94764. private _compileShader;
  94765. private _compileRawShader;
  94766. /**
  94767. * Directly creates a webGL program
  94768. * @param pipelineContext defines the pipeline context to attach to
  94769. * @param vertexCode defines the vertex shader code to use
  94770. * @param fragmentCode defines the fragment shader code to use
  94771. * @param context defines the webGL context to use (if not set, the current one will be used)
  94772. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94773. * @returns the new webGL program
  94774. */
  94775. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94776. /**
  94777. * Creates a webGL program
  94778. * @param pipelineContext defines the pipeline context to attach to
  94779. * @param vertexCode defines the vertex shader code to use
  94780. * @param fragmentCode defines the fragment shader code to use
  94781. * @param defines defines the string containing the defines to use to compile the shaders
  94782. * @param context defines the webGL context to use (if not set, the current one will be used)
  94783. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94784. * @returns the new webGL program
  94785. */
  94786. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94787. /**
  94788. * Creates a new pipeline context
  94789. * @returns the new pipeline
  94790. */
  94791. createPipelineContext(): WebGLPipelineContext;
  94792. private _createShaderProgram;
  94793. private _finalizePipelineContext;
  94794. /** @hidden */
  94795. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  94796. /** @hidden */
  94797. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  94798. /** @hidden */
  94799. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  94800. /**
  94801. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  94802. * @param pipelineContext defines the pipeline context to use
  94803. * @param uniformsNames defines the list of uniform names
  94804. * @returns an array of webGL uniform locations
  94805. */
  94806. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  94807. /**
  94808. * Gets the lsit of active attributes for a given webGL program
  94809. * @param pipelineContext defines the pipeline context to use
  94810. * @param attributesNames defines the list of attribute names to get
  94811. * @returns an array of indices indicating the offset of each attribute
  94812. */
  94813. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  94814. /**
  94815. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  94816. * @param effect defines the effect to activate
  94817. */
  94818. enableEffect(effect: Nullable<Effect>): void;
  94819. /**
  94820. * Set the value of an uniform to an array of int32
  94821. * @param uniform defines the webGL uniform location where to store the value
  94822. * @param array defines the array of int32 to store
  94823. */
  94824. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94825. /**
  94826. * Set the value of an uniform to an array of int32 (stored as vec2)
  94827. * @param uniform defines the webGL uniform location where to store the value
  94828. * @param array defines the array of int32 to store
  94829. */
  94830. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94831. /**
  94832. * Set the value of an uniform to an array of int32 (stored as vec3)
  94833. * @param uniform defines the webGL uniform location where to store the value
  94834. * @param array defines the array of int32 to store
  94835. */
  94836. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94837. /**
  94838. * Set the value of an uniform to an array of int32 (stored as vec4)
  94839. * @param uniform defines the webGL uniform location where to store the value
  94840. * @param array defines the array of int32 to store
  94841. */
  94842. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94843. /**
  94844. * Set the value of an uniform to an array of float32
  94845. * @param uniform defines the webGL uniform location where to store the value
  94846. * @param array defines the array of float32 to store
  94847. */
  94848. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94849. /**
  94850. * Set the value of an uniform to an array of float32 (stored as vec2)
  94851. * @param uniform defines the webGL uniform location where to store the value
  94852. * @param array defines the array of float32 to store
  94853. */
  94854. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94855. /**
  94856. * Set the value of an uniform to an array of float32 (stored as vec3)
  94857. * @param uniform defines the webGL uniform location where to store the value
  94858. * @param array defines the array of float32 to store
  94859. */
  94860. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94861. /**
  94862. * Set the value of an uniform to an array of float32 (stored as vec4)
  94863. * @param uniform defines the webGL uniform location where to store the value
  94864. * @param array defines the array of float32 to store
  94865. */
  94866. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94867. /**
  94868. * Set the value of an uniform to an array of number
  94869. * @param uniform defines the webGL uniform location where to store the value
  94870. * @param array defines the array of number to store
  94871. */
  94872. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94873. /**
  94874. * Set the value of an uniform to an array of number (stored as vec2)
  94875. * @param uniform defines the webGL uniform location where to store the value
  94876. * @param array defines the array of number to store
  94877. */
  94878. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94879. /**
  94880. * Set the value of an uniform to an array of number (stored as vec3)
  94881. * @param uniform defines the webGL uniform location where to store the value
  94882. * @param array defines the array of number to store
  94883. */
  94884. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94885. /**
  94886. * Set the value of an uniform to an array of number (stored as vec4)
  94887. * @param uniform defines the webGL uniform location where to store the value
  94888. * @param array defines the array of number to store
  94889. */
  94890. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94891. /**
  94892. * Set the value of an uniform to an array of float32 (stored as matrices)
  94893. * @param uniform defines the webGL uniform location where to store the value
  94894. * @param matrices defines the array of float32 to store
  94895. */
  94896. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  94897. /**
  94898. * Set the value of an uniform to a matrix (3x3)
  94899. * @param uniform defines the webGL uniform location where to store the value
  94900. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  94901. */
  94902. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94903. /**
  94904. * Set the value of an uniform to a matrix (2x2)
  94905. * @param uniform defines the webGL uniform location where to store the value
  94906. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  94907. */
  94908. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94909. /**
  94910. * Set the value of an uniform to a number (int)
  94911. * @param uniform defines the webGL uniform location where to store the value
  94912. * @param value defines the int number to store
  94913. */
  94914. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94915. /**
  94916. * Set the value of an uniform to a number (float)
  94917. * @param uniform defines the webGL uniform location where to store the value
  94918. * @param value defines the float number to store
  94919. */
  94920. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94921. /**
  94922. * Set the value of an uniform to a vec2
  94923. * @param uniform defines the webGL uniform location where to store the value
  94924. * @param x defines the 1st component of the value
  94925. * @param y defines the 2nd component of the value
  94926. */
  94927. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  94928. /**
  94929. * Set the value of an uniform to a vec3
  94930. * @param uniform defines the webGL uniform location where to store the value
  94931. * @param x defines the 1st component of the value
  94932. * @param y defines the 2nd component of the value
  94933. * @param z defines the 3rd component of the value
  94934. */
  94935. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  94936. /**
  94937. * Set the value of an uniform to a boolean
  94938. * @param uniform defines the webGL uniform location where to store the value
  94939. * @param bool defines the boolean to store
  94940. */
  94941. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  94942. /**
  94943. * Set the value of an uniform to a vec4
  94944. * @param uniform defines the webGL uniform location where to store the value
  94945. * @param x defines the 1st component of the value
  94946. * @param y defines the 2nd component of the value
  94947. * @param z defines the 3rd component of the value
  94948. * @param w defines the 4th component of the value
  94949. */
  94950. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  94951. /**
  94952. * Sets a Color4 on a uniform variable
  94953. * @param uniform defines the uniform location
  94954. * @param color4 defines the value to be set
  94955. */
  94956. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  94957. /**
  94958. * Set various states to the webGL context
  94959. * @param culling defines backface culling state
  94960. * @param zOffset defines the value to apply to zOffset (0 by default)
  94961. * @param force defines if states must be applied even if cache is up to date
  94962. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  94963. */
  94964. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  94965. /**
  94966. * Set the z offset to apply to current rendering
  94967. * @param value defines the offset to apply
  94968. */
  94969. setZOffset(value: number): void;
  94970. /**
  94971. * Gets the current value of the zOffset
  94972. * @returns the current zOffset state
  94973. */
  94974. getZOffset(): number;
  94975. /**
  94976. * Enable or disable depth buffering
  94977. * @param enable defines the state to set
  94978. */
  94979. setDepthBuffer(enable: boolean): void;
  94980. /**
  94981. * Gets a boolean indicating if depth writing is enabled
  94982. * @returns the current depth writing state
  94983. */
  94984. getDepthWrite(): boolean;
  94985. /**
  94986. * Enable or disable depth writing
  94987. * @param enable defines the state to set
  94988. */
  94989. setDepthWrite(enable: boolean): void;
  94990. /**
  94991. * Enable or disable color writing
  94992. * @param enable defines the state to set
  94993. */
  94994. setColorWrite(enable: boolean): void;
  94995. /**
  94996. * Gets a boolean indicating if color writing is enabled
  94997. * @returns the current color writing state
  94998. */
  94999. getColorWrite(): boolean;
  95000. /**
  95001. * Sets alpha constants used by some alpha blending modes
  95002. * @param r defines the red component
  95003. * @param g defines the green component
  95004. * @param b defines the blue component
  95005. * @param a defines the alpha component
  95006. */
  95007. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  95008. /**
  95009. * Sets the current alpha mode
  95010. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  95011. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  95012. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95013. */
  95014. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  95015. /**
  95016. * Gets the current alpha mode
  95017. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95018. * @returns the current alpha mode
  95019. */
  95020. getAlphaMode(): number;
  95021. /**
  95022. * Clears the list of texture accessible through engine.
  95023. * This can help preventing texture load conflict due to name collision.
  95024. */
  95025. clearInternalTexturesCache(): void;
  95026. /**
  95027. * Force the entire cache to be cleared
  95028. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  95029. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  95030. */
  95031. wipeCaches(bruteForce?: boolean): void;
  95032. /**
  95033. * Set the compressed texture format to use, based on the formats you have, and the formats
  95034. * supported by the hardware / browser.
  95035. *
  95036. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  95037. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  95038. * to API arguments needed to compressed textures. This puts the burden on the container
  95039. * generator to house the arcane code for determining these for current & future formats.
  95040. *
  95041. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  95042. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  95043. *
  95044. * Note: The result of this call is not taken into account when a texture is base64.
  95045. *
  95046. * @param formatsAvailable defines the list of those format families you have created
  95047. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  95048. *
  95049. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  95050. * @returns The extension selected.
  95051. */
  95052. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  95053. /** @hidden */
  95054. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  95055. min: number;
  95056. mag: number;
  95057. };
  95058. /** @hidden */
  95059. _createTexture(): WebGLTexture;
  95060. /**
  95061. * Usually called from Texture.ts.
  95062. * Passed information to create a WebGLTexture
  95063. * @param urlArg defines a value which contains one of the following:
  95064. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  95065. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  95066. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  95067. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  95068. * @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)
  95069. * @param scene needed for loading to the correct scene
  95070. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  95071. * @param onLoad optional callback to be called upon successful completion
  95072. * @param onError optional callback to be called upon failure
  95073. * @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
  95074. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  95075. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  95076. * @param forcedExtension defines the extension to use to pick the right loader
  95077. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  95078. * @returns a InternalTexture for assignment back into BABYLON.Texture
  95079. */
  95080. 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;
  95081. /**
  95082. * @hidden
  95083. * Rescales a texture
  95084. * @param source input texutre
  95085. * @param destination destination texture
  95086. * @param scene scene to use to render the resize
  95087. * @param internalFormat format to use when resizing
  95088. * @param onComplete callback to be called when resize has completed
  95089. */
  95090. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  95091. private _unpackFlipYCached;
  95092. /**
  95093. * In case you are sharing the context with other applications, it might
  95094. * be interested to not cache the unpack flip y state to ensure a consistent
  95095. * value would be set.
  95096. */
  95097. enableUnpackFlipYCached: boolean;
  95098. /** @hidden */
  95099. _unpackFlipY(value: boolean): void;
  95100. /** @hidden */
  95101. _getUnpackAlignement(): number;
  95102. /**
  95103. * Creates a dynamic texture
  95104. * @param width defines the width of the texture
  95105. * @param height defines the height of the texture
  95106. * @param generateMipMaps defines if the engine should generate the mip levels
  95107. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95108. * @returns the dynamic texture inside an InternalTexture
  95109. */
  95110. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  95111. /**
  95112. * Update the sampling mode of a given texture
  95113. * @param samplingMode defines the required sampling mode
  95114. * @param texture defines the texture to update
  95115. */
  95116. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  95117. /**
  95118. * Update the content of a dynamic texture
  95119. * @param texture defines the texture to update
  95120. * @param canvas defines the canvas containing the source
  95121. * @param invertY defines if data must be stored with Y axis inverted
  95122. * @param premulAlpha defines if alpha is stored as premultiplied
  95123. * @param format defines the format of the data
  95124. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  95125. */
  95126. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  95127. /**
  95128. * Update a video texture
  95129. * @param texture defines the texture to update
  95130. * @param video defines the video element to use
  95131. * @param invertY defines if data must be stored with Y axis inverted
  95132. */
  95133. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95134. /**
  95135. * Updates a depth texture Comparison Mode and Function.
  95136. * If the comparison Function is equal to 0, the mode will be set to none.
  95137. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  95138. * @param texture The texture to set the comparison function for
  95139. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  95140. */
  95141. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  95142. /** @hidden */
  95143. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  95144. width: number;
  95145. height: number;
  95146. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  95147. /**
  95148. * Creates a depth stencil texture.
  95149. * This is only available in WebGL 2 or with the depth texture extension available.
  95150. * @param size The size of face edge in the texture.
  95151. * @param options The options defining the texture.
  95152. * @returns The texture
  95153. */
  95154. createDepthStencilTexture(size: number | {
  95155. width: number;
  95156. height: number;
  95157. }, options: DepthTextureCreationOptions): InternalTexture;
  95158. /**
  95159. * Creates a depth stencil texture.
  95160. * This is only available in WebGL 2 or with the depth texture extension available.
  95161. * @param size The size of face edge in the texture.
  95162. * @param options The options defining the texture.
  95163. * @returns The texture
  95164. */
  95165. private _createDepthStencilTexture;
  95166. /**
  95167. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  95168. * @param renderTarget The render target to set the frame buffer for
  95169. */
  95170. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  95171. /**
  95172. * Creates a new render target texture
  95173. * @param size defines the size of the texture
  95174. * @param options defines the options used to create the texture
  95175. * @returns a new render target texture stored in an InternalTexture
  95176. */
  95177. createRenderTargetTexture(size: number | {
  95178. width: number;
  95179. height: number;
  95180. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  95181. /** @hidden */
  95182. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  95183. /**
  95184. * Updates the sample count of a render target texture
  95185. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  95186. * @param texture defines the texture to update
  95187. * @param samples defines the sample count to set
  95188. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  95189. */
  95190. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  95191. /** @hidden */
  95192. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95193. /** @hidden */
  95194. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  95195. /** @hidden */
  95196. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95197. /** @hidden */
  95198. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  95199. /**
  95200. * @hidden
  95201. */
  95202. _setCubeMapTextureParams(loadMipmap: boolean): void;
  95203. private _prepareWebGLTextureContinuation;
  95204. private _prepareWebGLTexture;
  95205. /** @hidden */
  95206. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  95207. /** @hidden */
  95208. _releaseFramebufferObjects(texture: InternalTexture): void;
  95209. /** @hidden */
  95210. _releaseTexture(texture: InternalTexture): void;
  95211. private setProgram;
  95212. private _boundUniforms;
  95213. /**
  95214. * Binds an effect to the webGL context
  95215. * @param effect defines the effect to bind
  95216. */
  95217. bindSamplers(effect: Effect): void;
  95218. private _activateCurrentTexture;
  95219. /** @hidden */
  95220. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  95221. /** @hidden */
  95222. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  95223. /**
  95224. * Sets a texture to the webGL context from a postprocess
  95225. * @param channel defines the channel to use
  95226. * @param postProcess defines the source postprocess
  95227. */
  95228. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  95229. /**
  95230. * Binds the output of the passed in post process to the texture channel specified
  95231. * @param channel The channel the texture should be bound to
  95232. * @param postProcess The post process which's output should be bound
  95233. */
  95234. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  95235. /**
  95236. * Unbind all textures from the webGL context
  95237. */
  95238. unbindAllTextures(): void;
  95239. /**
  95240. * Sets a texture to the according uniform.
  95241. * @param channel The texture channel
  95242. * @param uniform The uniform to set
  95243. * @param texture The texture to apply
  95244. */
  95245. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  95246. /**
  95247. * Sets a depth stencil texture from a render target to the according uniform.
  95248. * @param channel The texture channel
  95249. * @param uniform The uniform to set
  95250. * @param texture The render target texture containing the depth stencil texture to apply
  95251. */
  95252. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  95253. private _bindSamplerUniformToChannel;
  95254. private _getTextureWrapMode;
  95255. private _setTexture;
  95256. /**
  95257. * Sets an array of texture to the webGL context
  95258. * @param channel defines the channel where the texture array must be set
  95259. * @param uniform defines the associated uniform location
  95260. * @param textures defines the array of textures to bind
  95261. */
  95262. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  95263. /** @hidden */
  95264. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  95265. private _setTextureParameterFloat;
  95266. private _setTextureParameterInteger;
  95267. /**
  95268. * Reads pixels from the current frame buffer. Please note that this function can be slow
  95269. * @param x defines the x coordinate of the rectangle where pixels must be read
  95270. * @param y defines the y coordinate of the rectangle where pixels must be read
  95271. * @param width defines the width of the rectangle where pixels must be read
  95272. * @param height defines the height of the rectangle where pixels must be read
  95273. * @returns a Uint8Array containing RGBA colors
  95274. */
  95275. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  95276. /**
  95277. * Add an externaly attached data from its key.
  95278. * This method call will fail and return false, if such key already exists.
  95279. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95280. * @param key the unique key that identifies the data
  95281. * @param data the data object to associate to the key for this Engine instance
  95282. * @return true if no such key were already present and the data was added successfully, false otherwise
  95283. */
  95284. addExternalData<T>(key: string, data: T): boolean;
  95285. /**
  95286. * Get an externaly attached data from its key
  95287. * @param key the unique key that identifies the data
  95288. * @return the associated data, if present (can be null), or undefined if not present
  95289. */
  95290. getExternalData<T>(key: string): T;
  95291. /**
  95292. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95293. * @param key the unique key that identifies the data
  95294. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95295. * @return the associated data, can be null if the factory returned null.
  95296. */
  95297. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95298. /**
  95299. * Remove an externaly attached data from the Engine instance
  95300. * @param key the unique key that identifies the data
  95301. * @return true if the data was successfully removed, false if it doesn't exist
  95302. */
  95303. removeExternalData(key: string): boolean;
  95304. /**
  95305. * Unbind all vertex attributes from the webGL context
  95306. */
  95307. unbindAllAttributes(): void;
  95308. /**
  95309. * 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
  95310. */
  95311. releaseEffects(): void;
  95312. /**
  95313. * Dispose and release all associated resources
  95314. */
  95315. dispose(): void;
  95316. /**
  95317. * Display the loading screen
  95318. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95319. */
  95320. displayLoadingUI(): void;
  95321. /**
  95322. * Hide the loading screen
  95323. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95324. */
  95325. hideLoadingUI(): void;
  95326. /**
  95327. * Gets the current loading screen object
  95328. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95329. */
  95330. /**
  95331. * Sets the current loading screen object
  95332. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95333. */
  95334. loadingScreen: ILoadingScreen;
  95335. /**
  95336. * Sets the current loading screen text
  95337. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95338. */
  95339. loadingUIText: string;
  95340. /**
  95341. * Sets the current loading screen background color
  95342. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95343. */
  95344. loadingUIBackgroundColor: string;
  95345. /**
  95346. * Attach a new callback raised when context lost event is fired
  95347. * @param callback defines the callback to call
  95348. */
  95349. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95350. /**
  95351. * Attach a new callback raised when context restored event is fired
  95352. * @param callback defines the callback to call
  95353. */
  95354. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95355. /**
  95356. * Gets the source code of the vertex shader associated with a specific webGL program
  95357. * @param program defines the program to use
  95358. * @returns a string containing the source code of the vertex shader associated with the program
  95359. */
  95360. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  95361. /**
  95362. * Gets the source code of the fragment shader associated with a specific webGL program
  95363. * @param program defines the program to use
  95364. * @returns a string containing the source code of the fragment shader associated with the program
  95365. */
  95366. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  95367. /**
  95368. * Get the current error code of the webGL context
  95369. * @returns the error code
  95370. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  95371. */
  95372. getError(): number;
  95373. /**
  95374. * Gets the current framerate
  95375. * @returns a number representing the framerate
  95376. */
  95377. getFps(): number;
  95378. /**
  95379. * Gets the time spent between current and previous frame
  95380. * @returns a number representing the delta time in ms
  95381. */
  95382. getDeltaTime(): number;
  95383. private _measureFps;
  95384. /** @hidden */
  95385. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  95386. private _canRenderToFloatFramebuffer;
  95387. private _canRenderToHalfFloatFramebuffer;
  95388. private _canRenderToFramebuffer;
  95389. /** @hidden */
  95390. _getWebGLTextureType(type: number): number;
  95391. /** @hidden */
  95392. _getInternalFormat(format: number): number;
  95393. /** @hidden */
  95394. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  95395. /** @hidden */
  95396. _getRGBAMultiSampleBufferFormat(type: number): number;
  95397. /** @hidden */
  95398. _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;
  95399. /** @hidden */
  95400. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  95401. /**
  95402. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  95403. * @returns true if the engine can be created
  95404. * @ignorenaming
  95405. */
  95406. static isSupported(): boolean;
  95407. /**
  95408. * Find the next highest power of two.
  95409. * @param x Number to start search from.
  95410. * @return Next highest power of two.
  95411. */
  95412. static CeilingPOT(x: number): number;
  95413. /**
  95414. * Find the next lowest power of two.
  95415. * @param x Number to start search from.
  95416. * @return Next lowest power of two.
  95417. */
  95418. static FloorPOT(x: number): number;
  95419. /**
  95420. * Find the nearest power of two.
  95421. * @param x Number to start search from.
  95422. * @return Next nearest power of two.
  95423. */
  95424. static NearestPOT(x: number): number;
  95425. /**
  95426. * Get the closest exponent of two
  95427. * @param value defines the value to approximate
  95428. * @param max defines the maximum value to return
  95429. * @param mode defines how to define the closest value
  95430. * @returns closest exponent of two of the given value
  95431. */
  95432. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  95433. /**
  95434. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  95435. * @param func - the function to be called
  95436. * @param requester - the object that will request the next frame. Falls back to window.
  95437. * @returns frame number
  95438. */
  95439. static QueueNewFrame(func: () => void, requester?: any): number;
  95440. /**
  95441. * Ask the browser to promote the current element to pointerlock mode
  95442. * @param element defines the DOM element to promote
  95443. */
  95444. static _RequestPointerlock(element: HTMLElement): void;
  95445. /**
  95446. * Asks the browser to exit pointerlock mode
  95447. */
  95448. static _ExitPointerlock(): void;
  95449. /**
  95450. * Ask the browser to promote the current element to fullscreen rendering mode
  95451. * @param element defines the DOM element to promote
  95452. */
  95453. static _RequestFullscreen(element: HTMLElement): void;
  95454. /**
  95455. * Asks the browser to exit fullscreen mode
  95456. */
  95457. static _ExitFullscreen(): void;
  95458. }
  95459. }
  95460. declare module BABYLON {
  95461. /**
  95462. * The engine store class is responsible to hold all the instances of Engine and Scene created
  95463. * during the life time of the application.
  95464. */
  95465. export class EngineStore {
  95466. /** Gets the list of created engines */
  95467. static Instances: Engine[];
  95468. /** @hidden */
  95469. static _LastCreatedScene: Nullable<Scene>;
  95470. /**
  95471. * Gets the latest created engine
  95472. */
  95473. static readonly LastCreatedEngine: Nullable<Engine>;
  95474. /**
  95475. * Gets the latest created scene
  95476. */
  95477. static readonly LastCreatedScene: Nullable<Scene>;
  95478. /**
  95479. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95480. * @ignorenaming
  95481. */
  95482. static UseFallbackTexture: boolean;
  95483. /**
  95484. * Texture content used if a texture cannot loaded
  95485. * @ignorenaming
  95486. */
  95487. static FallbackTexture: string;
  95488. }
  95489. }
  95490. declare module BABYLON {
  95491. /**
  95492. * Helper class that provides a small promise polyfill
  95493. */
  95494. export class PromisePolyfill {
  95495. /**
  95496. * Static function used to check if the polyfill is required
  95497. * If this is the case then the function will inject the polyfill to window.Promise
  95498. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  95499. */
  95500. static Apply(force?: boolean): void;
  95501. }
  95502. }
  95503. declare module BABYLON {
  95504. /**
  95505. * Interface for screenshot methods with describe argument called `size` as object with options
  95506. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  95507. */
  95508. export interface IScreenshotSize {
  95509. /**
  95510. * number in pixels for canvas height
  95511. */
  95512. height?: number;
  95513. /**
  95514. * multiplier allowing render at a higher or lower resolution
  95515. * If value is defined then height and width will be ignored and taken from camera
  95516. */
  95517. precision?: number;
  95518. /**
  95519. * number in pixels for canvas width
  95520. */
  95521. width?: number;
  95522. }
  95523. }
  95524. declare module BABYLON {
  95525. interface IColor4Like {
  95526. r: float;
  95527. g: float;
  95528. b: float;
  95529. a: float;
  95530. }
  95531. /**
  95532. * Class containing a set of static utilities functions
  95533. */
  95534. export class Tools {
  95535. /**
  95536. * Gets or sets the base URL to use to load assets
  95537. */
  95538. static BaseUrl: string;
  95539. /**
  95540. * Enable/Disable Custom HTTP Request Headers globally.
  95541. * default = false
  95542. * @see CustomRequestHeaders
  95543. */
  95544. static UseCustomRequestHeaders: boolean;
  95545. /**
  95546. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  95547. * i.e. when loading files, where the server/service expects an Authorization header
  95548. */
  95549. static CustomRequestHeaders: {
  95550. [key: string]: string;
  95551. };
  95552. /**
  95553. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  95554. */
  95555. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  95556. /**
  95557. * Default behaviour for cors in the application.
  95558. * It can be a string if the expected behavior is identical in the entire app.
  95559. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  95560. */
  95561. static CorsBehavior: string | ((url: string | string[]) => string);
  95562. /**
  95563. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95564. * @ignorenaming
  95565. */
  95566. static UseFallbackTexture: boolean;
  95567. /**
  95568. * Use this object to register external classes like custom textures or material
  95569. * to allow the laoders to instantiate them
  95570. */
  95571. static RegisteredExternalClasses: {
  95572. [key: string]: Object;
  95573. };
  95574. /**
  95575. * Texture content used if a texture cannot loaded
  95576. * @ignorenaming
  95577. */
  95578. static fallbackTexture: string;
  95579. /**
  95580. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  95581. * @param u defines the coordinate on X axis
  95582. * @param v defines the coordinate on Y axis
  95583. * @param width defines the width of the source data
  95584. * @param height defines the height of the source data
  95585. * @param pixels defines the source byte array
  95586. * @param color defines the output color
  95587. */
  95588. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  95589. /**
  95590. * Interpolates between a and b via alpha
  95591. * @param a The lower value (returned when alpha = 0)
  95592. * @param b The upper value (returned when alpha = 1)
  95593. * @param alpha The interpolation-factor
  95594. * @return The mixed value
  95595. */
  95596. static Mix(a: number, b: number, alpha: number): number;
  95597. /**
  95598. * Tries to instantiate a new object from a given class name
  95599. * @param className defines the class name to instantiate
  95600. * @returns the new object or null if the system was not able to do the instantiation
  95601. */
  95602. static Instantiate(className: string): any;
  95603. /**
  95604. * Provides a slice function that will work even on IE
  95605. * @param data defines the array to slice
  95606. * @param start defines the start of the data (optional)
  95607. * @param end defines the end of the data (optional)
  95608. * @returns the new sliced array
  95609. */
  95610. static Slice<T>(data: T, start?: number, end?: number): T;
  95611. /**
  95612. * Polyfill for setImmediate
  95613. * @param action defines the action to execute after the current execution block
  95614. */
  95615. static SetImmediate(action: () => void): void;
  95616. /**
  95617. * Function indicating if a number is an exponent of 2
  95618. * @param value defines the value to test
  95619. * @returns true if the value is an exponent of 2
  95620. */
  95621. static IsExponentOfTwo(value: number): boolean;
  95622. private static _tmpFloatArray;
  95623. /**
  95624. * Returns the nearest 32-bit single precision float representation of a Number
  95625. * @param value A Number. If the parameter is of a different type, it will get converted
  95626. * to a number or to NaN if it cannot be converted
  95627. * @returns number
  95628. */
  95629. static FloatRound(value: number): number;
  95630. /**
  95631. * Extracts the filename from a path
  95632. * @param path defines the path to use
  95633. * @returns the filename
  95634. */
  95635. static GetFilename(path: string): string;
  95636. /**
  95637. * Extracts the "folder" part of a path (everything before the filename).
  95638. * @param uri The URI to extract the info from
  95639. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  95640. * @returns The "folder" part of the path
  95641. */
  95642. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  95643. /**
  95644. * Extracts text content from a DOM element hierarchy
  95645. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  95646. */
  95647. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  95648. /**
  95649. * Convert an angle in radians to degrees
  95650. * @param angle defines the angle to convert
  95651. * @returns the angle in degrees
  95652. */
  95653. static ToDegrees(angle: number): number;
  95654. /**
  95655. * Convert an angle in degrees to radians
  95656. * @param angle defines the angle to convert
  95657. * @returns the angle in radians
  95658. */
  95659. static ToRadians(angle: number): number;
  95660. /**
  95661. * Encode a buffer to a base64 string
  95662. * @param buffer defines the buffer to encode
  95663. * @returns the encoded string
  95664. */
  95665. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  95666. /**
  95667. * Returns an array if obj is not an array
  95668. * @param obj defines the object to evaluate as an array
  95669. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  95670. * @returns either obj directly if obj is an array or a new array containing obj
  95671. */
  95672. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  95673. /**
  95674. * Gets the pointer prefix to use
  95675. * @returns "pointer" if touch is enabled. Else returns "mouse"
  95676. */
  95677. static GetPointerPrefix(): string;
  95678. /**
  95679. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  95680. * @param url define the url we are trying
  95681. * @param element define the dom element where to configure the cors policy
  95682. */
  95683. static SetCorsBehavior(url: string | string[], element: {
  95684. crossOrigin: string | null;
  95685. }): void;
  95686. /**
  95687. * Removes unwanted characters from an url
  95688. * @param url defines the url to clean
  95689. * @returns the cleaned url
  95690. */
  95691. static CleanUrl(url: string): string;
  95692. /**
  95693. * Gets or sets a function used to pre-process url before using them to load assets
  95694. */
  95695. static PreprocessUrl: (url: string) => string;
  95696. /**
  95697. * Loads an image as an HTMLImageElement.
  95698. * @param input url string, ArrayBuffer, or Blob to load
  95699. * @param onLoad callback called when the image successfully loads
  95700. * @param onError callback called when the image fails to load
  95701. * @param offlineProvider offline provider for caching
  95702. * @returns the HTMLImageElement of the loaded image
  95703. */
  95704. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  95705. /**
  95706. * Loads a file
  95707. * @param url url string, ArrayBuffer, or Blob to load
  95708. * @param onSuccess callback called when the file successfully loads
  95709. * @param onProgress callback called while file is loading (if the server supports this mode)
  95710. * @param offlineProvider defines the offline provider for caching
  95711. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  95712. * @param onError callback called when the file fails to load
  95713. * @returns a file request object
  95714. */
  95715. 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;
  95716. /**
  95717. * Loads a file from a url
  95718. * @param url the file url to load
  95719. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  95720. */
  95721. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  95722. /**
  95723. * Load a script (identified by an url). When the url returns, the
  95724. * content of this file is added into a new script element, attached to the DOM (body element)
  95725. * @param scriptUrl defines the url of the script to laod
  95726. * @param onSuccess defines the callback called when the script is loaded
  95727. * @param onError defines the callback to call if an error occurs
  95728. * @param scriptId defines the id of the script element
  95729. */
  95730. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  95731. /**
  95732. * Load an asynchronous script (identified by an url). When the url returns, the
  95733. * content of this file is added into a new script element, attached to the DOM (body element)
  95734. * @param scriptUrl defines the url of the script to laod
  95735. * @param scriptId defines the id of the script element
  95736. * @returns a promise request object
  95737. */
  95738. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  95739. /**
  95740. * Loads a file from a blob
  95741. * @param fileToLoad defines the blob to use
  95742. * @param callback defines the callback to call when data is loaded
  95743. * @param progressCallback defines the callback to call during loading process
  95744. * @returns a file request object
  95745. */
  95746. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  95747. /**
  95748. * Loads a file
  95749. * @param fileToLoad defines the file to load
  95750. * @param callback defines the callback to call when data is loaded
  95751. * @param progressCallBack defines the callback to call during loading process
  95752. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  95753. * @returns a file request object
  95754. */
  95755. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  95756. /**
  95757. * Creates a data url from a given string content
  95758. * @param content defines the content to convert
  95759. * @returns the new data url link
  95760. */
  95761. static FileAsURL(content: string): string;
  95762. /**
  95763. * Format the given number to a specific decimal format
  95764. * @param value defines the number to format
  95765. * @param decimals defines the number of decimals to use
  95766. * @returns the formatted string
  95767. */
  95768. static Format(value: number, decimals?: number): string;
  95769. /**
  95770. * Tries to copy an object by duplicating every property
  95771. * @param source defines the source object
  95772. * @param destination defines the target object
  95773. * @param doNotCopyList defines a list of properties to avoid
  95774. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  95775. */
  95776. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  95777. /**
  95778. * Gets a boolean indicating if the given object has no own property
  95779. * @param obj defines the object to test
  95780. * @returns true if object has no own property
  95781. */
  95782. static IsEmpty(obj: any): boolean;
  95783. /**
  95784. * Function used to register events at window level
  95785. * @param events defines the events to register
  95786. */
  95787. static RegisterTopRootEvents(events: {
  95788. name: string;
  95789. handler: Nullable<(e: FocusEvent) => any>;
  95790. }[]): void;
  95791. /**
  95792. * Function used to unregister events from window level
  95793. * @param events defines the events to unregister
  95794. */
  95795. static UnregisterTopRootEvents(events: {
  95796. name: string;
  95797. handler: Nullable<(e: FocusEvent) => any>;
  95798. }[]): void;
  95799. /**
  95800. * @ignore
  95801. */
  95802. static _ScreenshotCanvas: HTMLCanvasElement;
  95803. /**
  95804. * Dumps the current bound framebuffer
  95805. * @param width defines the rendering width
  95806. * @param height defines the rendering height
  95807. * @param engine defines the hosting engine
  95808. * @param successCallback defines the callback triggered once the data are available
  95809. * @param mimeType defines the mime type of the result
  95810. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  95811. */
  95812. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95813. /**
  95814. * Converts the canvas data to blob.
  95815. * This acts as a polyfill for browsers not supporting the to blob function.
  95816. * @param canvas Defines the canvas to extract the data from
  95817. * @param successCallback Defines the callback triggered once the data are available
  95818. * @param mimeType Defines the mime type of the result
  95819. */
  95820. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  95821. /**
  95822. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  95823. * @param successCallback defines the callback triggered once the data are available
  95824. * @param mimeType defines the mime type of the result
  95825. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  95826. */
  95827. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95828. /**
  95829. * Downloads a blob in the browser
  95830. * @param blob defines the blob to download
  95831. * @param fileName defines the name of the downloaded file
  95832. */
  95833. static Download(blob: Blob, fileName: string): void;
  95834. /**
  95835. * Captures a screenshot of the current rendering
  95836. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95837. * @param engine defines the rendering engine
  95838. * @param camera defines the source camera
  95839. * @param size This parameter can be set to a single number or to an object with the
  95840. * following (optional) properties: precision, width, height. If a single number is passed,
  95841. * it will be used for both width and height. If an object is passed, the screenshot size
  95842. * will be derived from the parameters. The precision property is a multiplier allowing
  95843. * rendering at a higher or lower resolution
  95844. * @param successCallback defines the callback receives a single parameter which contains the
  95845. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95846. * src parameter of an <img> to display it
  95847. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  95848. * Check your browser for supported MIME types
  95849. */
  95850. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  95851. /**
  95852. * Captures a screenshot of the current rendering
  95853. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95854. * @param engine defines the rendering engine
  95855. * @param camera defines the source camera
  95856. * @param size This parameter can be set to a single number or to an object with the
  95857. * following (optional) properties: precision, width, height. If a single number is passed,
  95858. * it will be used for both width and height. If an object is passed, the screenshot size
  95859. * will be derived from the parameters. The precision property is a multiplier allowing
  95860. * rendering at a higher or lower resolution
  95861. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  95862. * Check your browser for supported MIME types
  95863. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  95864. * to the src parameter of an <img> to display it
  95865. */
  95866. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  95867. /**
  95868. * Generates an image screenshot from the specified camera.
  95869. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95870. * @param engine The engine to use for rendering
  95871. * @param camera The camera to use for rendering
  95872. * @param size This parameter can be set to a single number or to an object with the
  95873. * following (optional) properties: precision, width, height. If a single number is passed,
  95874. * it will be used for both width and height. If an object is passed, the screenshot size
  95875. * will be derived from the parameters. The precision property is a multiplier allowing
  95876. * rendering at a higher or lower resolution
  95877. * @param successCallback The callback receives a single parameter which contains the
  95878. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95879. * src parameter of an <img> to display it
  95880. * @param mimeType The MIME type of the screenshot image (default: image/png).
  95881. * Check your browser for supported MIME types
  95882. * @param samples Texture samples (default: 1)
  95883. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  95884. * @param fileName A name for for the downloaded file.
  95885. */
  95886. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  95887. /**
  95888. * Generates an image screenshot from the specified camera.
  95889. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95890. * @param engine The engine to use for rendering
  95891. * @param camera The camera to use for rendering
  95892. * @param size This parameter can be set to a single number or to an object with the
  95893. * following (optional) properties: precision, width, height. If a single number is passed,
  95894. * it will be used for both width and height. If an object is passed, the screenshot size
  95895. * will be derived from the parameters. The precision property is a multiplier allowing
  95896. * rendering at a higher or lower resolution
  95897. * @param mimeType The MIME type of the screenshot image (default: image/png).
  95898. * Check your browser for supported MIME types
  95899. * @param samples Texture samples (default: 1)
  95900. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  95901. * @param fileName A name for for the downloaded file.
  95902. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  95903. * to the src parameter of an <img> to display it
  95904. */
  95905. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  95906. /**
  95907. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95908. * Be aware Math.random() could cause collisions, but:
  95909. * "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"
  95910. * @returns a pseudo random id
  95911. */
  95912. static RandomId(): string;
  95913. /**
  95914. * Test if the given uri is a base64 string
  95915. * @param uri The uri to test
  95916. * @return True if the uri is a base64 string or false otherwise
  95917. */
  95918. static IsBase64(uri: string): boolean;
  95919. /**
  95920. * Decode the given base64 uri.
  95921. * @param uri The uri to decode
  95922. * @return The decoded base64 data.
  95923. */
  95924. static DecodeBase64(uri: string): ArrayBuffer;
  95925. /**
  95926. * Gets the absolute url.
  95927. * @param url the input url
  95928. * @return the absolute url
  95929. */
  95930. static GetAbsoluteUrl(url: string): string;
  95931. /**
  95932. * No log
  95933. */
  95934. static readonly NoneLogLevel: number;
  95935. /**
  95936. * Only message logs
  95937. */
  95938. static readonly MessageLogLevel: number;
  95939. /**
  95940. * Only warning logs
  95941. */
  95942. static readonly WarningLogLevel: number;
  95943. /**
  95944. * Only error logs
  95945. */
  95946. static readonly ErrorLogLevel: number;
  95947. /**
  95948. * All logs
  95949. */
  95950. static readonly AllLogLevel: number;
  95951. /**
  95952. * Gets a value indicating the number of loading errors
  95953. * @ignorenaming
  95954. */
  95955. static readonly errorsCount: number;
  95956. /**
  95957. * Callback called when a new log is added
  95958. */
  95959. static OnNewCacheEntry: (entry: string) => void;
  95960. /**
  95961. * Log a message to the console
  95962. * @param message defines the message to log
  95963. */
  95964. static Log(message: string): void;
  95965. /**
  95966. * Write a warning message to the console
  95967. * @param message defines the message to log
  95968. */
  95969. static Warn(message: string): void;
  95970. /**
  95971. * Write an error message to the console
  95972. * @param message defines the message to log
  95973. */
  95974. static Error(message: string): void;
  95975. /**
  95976. * Gets current log cache (list of logs)
  95977. */
  95978. static readonly LogCache: string;
  95979. /**
  95980. * Clears the log cache
  95981. */
  95982. static ClearLogCache(): void;
  95983. /**
  95984. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  95985. */
  95986. static LogLevels: number;
  95987. /**
  95988. * Checks if the window object exists
  95989. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  95990. */
  95991. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  95992. /**
  95993. * No performance log
  95994. */
  95995. static readonly PerformanceNoneLogLevel: number;
  95996. /**
  95997. * Use user marks to log performance
  95998. */
  95999. static readonly PerformanceUserMarkLogLevel: number;
  96000. /**
  96001. * Log performance to the console
  96002. */
  96003. static readonly PerformanceConsoleLogLevel: number;
  96004. private static _performance;
  96005. /**
  96006. * Sets the current performance log level
  96007. */
  96008. static PerformanceLogLevel: number;
  96009. private static _StartPerformanceCounterDisabled;
  96010. private static _EndPerformanceCounterDisabled;
  96011. private static _StartUserMark;
  96012. private static _EndUserMark;
  96013. private static _StartPerformanceConsole;
  96014. private static _EndPerformanceConsole;
  96015. /**
  96016. * Starts a performance counter
  96017. */
  96018. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96019. /**
  96020. * Ends a specific performance coutner
  96021. */
  96022. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96023. /**
  96024. * Gets either window.performance.now() if supported or Date.now() else
  96025. */
  96026. static readonly Now: number;
  96027. /**
  96028. * This method will return the name of the class used to create the instance of the given object.
  96029. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  96030. * @param object the object to get the class name from
  96031. * @param isType defines if the object is actually a type
  96032. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  96033. */
  96034. static GetClassName(object: any, isType?: boolean): string;
  96035. /**
  96036. * Gets the first element of an array satisfying a given predicate
  96037. * @param array defines the array to browse
  96038. * @param predicate defines the predicate to use
  96039. * @returns null if not found or the element
  96040. */
  96041. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  96042. /**
  96043. * This method will return the name of the full name of the class, including its owning module (if any).
  96044. * 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).
  96045. * @param object the object to get the class name from
  96046. * @param isType defines if the object is actually a type
  96047. * @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.
  96048. * @ignorenaming
  96049. */
  96050. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  96051. /**
  96052. * Returns a promise that resolves after the given amount of time.
  96053. * @param delay Number of milliseconds to delay
  96054. * @returns Promise that resolves after the given amount of time
  96055. */
  96056. static DelayAsync(delay: number): Promise<void>;
  96057. }
  96058. /**
  96059. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  96060. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  96061. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  96062. * @param name The name of the class, case should be preserved
  96063. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  96064. */
  96065. export function className(name: string, module?: string): (target: Object) => void;
  96066. /**
  96067. * An implementation of a loop for asynchronous functions.
  96068. */
  96069. export class AsyncLoop {
  96070. /**
  96071. * Defines the number of iterations for the loop
  96072. */
  96073. iterations: number;
  96074. /**
  96075. * Defines the current index of the loop.
  96076. */
  96077. index: number;
  96078. private _done;
  96079. private _fn;
  96080. private _successCallback;
  96081. /**
  96082. * Constructor.
  96083. * @param iterations the number of iterations.
  96084. * @param func the function to run each iteration
  96085. * @param successCallback the callback that will be called upon succesful execution
  96086. * @param offset starting offset.
  96087. */
  96088. constructor(
  96089. /**
  96090. * Defines the number of iterations for the loop
  96091. */
  96092. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  96093. /**
  96094. * Execute the next iteration. Must be called after the last iteration was finished.
  96095. */
  96096. executeNext(): void;
  96097. /**
  96098. * Break the loop and run the success callback.
  96099. */
  96100. breakLoop(): void;
  96101. /**
  96102. * Create and run an async loop.
  96103. * @param iterations the number of iterations.
  96104. * @param fn the function to run each iteration
  96105. * @param successCallback the callback that will be called upon succesful execution
  96106. * @param offset starting offset.
  96107. * @returns the created async loop object
  96108. */
  96109. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  96110. /**
  96111. * A for-loop that will run a given number of iterations synchronous and the rest async.
  96112. * @param iterations total number of iterations
  96113. * @param syncedIterations number of synchronous iterations in each async iteration.
  96114. * @param fn the function to call each iteration.
  96115. * @param callback a success call back that will be called when iterating stops.
  96116. * @param breakFunction a break condition (optional)
  96117. * @param timeout timeout settings for the setTimeout function. default - 0.
  96118. * @returns the created async loop object
  96119. */
  96120. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  96121. }
  96122. }
  96123. declare module BABYLON {
  96124. /** @hidden */
  96125. export interface ICollisionCoordinator {
  96126. createCollider(): Collider;
  96127. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96128. init(scene: Scene): void;
  96129. }
  96130. /** @hidden */
  96131. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  96132. private _scene;
  96133. private _scaledPosition;
  96134. private _scaledVelocity;
  96135. private _finalPosition;
  96136. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96137. createCollider(): Collider;
  96138. init(scene: Scene): void;
  96139. private _collideWithWorld;
  96140. }
  96141. }
  96142. declare module BABYLON {
  96143. /**
  96144. * Class used to manage all inputs for the scene.
  96145. */
  96146. export class InputManager {
  96147. /** The distance in pixel that you have to move to prevent some events */
  96148. static DragMovementThreshold: number;
  96149. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  96150. static LongPressDelay: number;
  96151. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  96152. static DoubleClickDelay: number;
  96153. /** If you need to check double click without raising a single click at first click, enable this flag */
  96154. static ExclusiveDoubleClickMode: boolean;
  96155. private _wheelEventName;
  96156. private _onPointerMove;
  96157. private _onPointerDown;
  96158. private _onPointerUp;
  96159. private _initClickEvent;
  96160. private _initActionManager;
  96161. private _delayedSimpleClick;
  96162. private _delayedSimpleClickTimeout;
  96163. private _previousDelayedSimpleClickTimeout;
  96164. private _meshPickProceed;
  96165. private _previousButtonPressed;
  96166. private _currentPickResult;
  96167. private _previousPickResult;
  96168. private _totalPointersPressed;
  96169. private _doubleClickOccured;
  96170. private _pointerOverMesh;
  96171. private _pickedDownMesh;
  96172. private _pickedUpMesh;
  96173. private _pointerX;
  96174. private _pointerY;
  96175. private _unTranslatedPointerX;
  96176. private _unTranslatedPointerY;
  96177. private _startingPointerPosition;
  96178. private _previousStartingPointerPosition;
  96179. private _startingPointerTime;
  96180. private _previousStartingPointerTime;
  96181. private _pointerCaptures;
  96182. private _onKeyDown;
  96183. private _onKeyUp;
  96184. private _onCanvasFocusObserver;
  96185. private _onCanvasBlurObserver;
  96186. private _scene;
  96187. /**
  96188. * Creates a new InputManager
  96189. * @param scene defines the hosting scene
  96190. */
  96191. constructor(scene: Scene);
  96192. /**
  96193. * Gets the mesh that is currently under the pointer
  96194. */
  96195. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96196. /**
  96197. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  96198. */
  96199. readonly unTranslatedPointer: Vector2;
  96200. /**
  96201. * Gets or sets the current on-screen X position of the pointer
  96202. */
  96203. pointerX: number;
  96204. /**
  96205. * Gets or sets the current on-screen Y position of the pointer
  96206. */
  96207. pointerY: number;
  96208. private _updatePointerPosition;
  96209. private _processPointerMove;
  96210. private _setRayOnPointerInfo;
  96211. private _checkPrePointerObservable;
  96212. /**
  96213. * Use this method to simulate a pointer move on a mesh
  96214. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96215. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96216. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96217. */
  96218. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96219. /**
  96220. * Use this method to simulate a pointer down on a mesh
  96221. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96222. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96223. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96224. */
  96225. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96226. private _processPointerDown;
  96227. /** @hidden */
  96228. _isPointerSwiping(): boolean;
  96229. /**
  96230. * Use this method to simulate a pointer up on a mesh
  96231. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96232. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96233. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96234. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96235. */
  96236. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  96237. private _processPointerUp;
  96238. /**
  96239. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96240. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96241. * @returns true if the pointer was captured
  96242. */
  96243. isPointerCaptured(pointerId?: number): boolean;
  96244. /**
  96245. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96246. * @param attachUp defines if you want to attach events to pointerup
  96247. * @param attachDown defines if you want to attach events to pointerdown
  96248. * @param attachMove defines if you want to attach events to pointermove
  96249. */
  96250. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96251. /**
  96252. * Detaches all event handlers
  96253. */
  96254. detachControl(): void;
  96255. /**
  96256. * Force the value of meshUnderPointer
  96257. * @param mesh defines the mesh to use
  96258. */
  96259. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96260. /**
  96261. * Gets the mesh under the pointer
  96262. * @returns a Mesh or null if no mesh is under the pointer
  96263. */
  96264. getPointerOverMesh(): Nullable<AbstractMesh>;
  96265. }
  96266. }
  96267. declare module BABYLON {
  96268. /**
  96269. * Helper class used to generate session unique ID
  96270. */
  96271. export class UniqueIdGenerator {
  96272. private static _UniqueIdCounter;
  96273. /**
  96274. * Gets an unique (relatively to the current scene) Id
  96275. */
  96276. static readonly UniqueId: number;
  96277. }
  96278. }
  96279. declare module BABYLON {
  96280. /**
  96281. * This class defines the direct association between an animation and a target
  96282. */
  96283. export class TargetedAnimation {
  96284. /**
  96285. * Animation to perform
  96286. */
  96287. animation: Animation;
  96288. /**
  96289. * Target to animate
  96290. */
  96291. target: any;
  96292. /**
  96293. * Serialize the object
  96294. * @returns the JSON object representing the current entity
  96295. */
  96296. serialize(): any;
  96297. }
  96298. /**
  96299. * Use this class to create coordinated animations on multiple targets
  96300. */
  96301. export class AnimationGroup implements IDisposable {
  96302. /** The name of the animation group */
  96303. name: string;
  96304. private _scene;
  96305. private _targetedAnimations;
  96306. private _animatables;
  96307. private _from;
  96308. private _to;
  96309. private _isStarted;
  96310. private _isPaused;
  96311. private _speedRatio;
  96312. private _loopAnimation;
  96313. /**
  96314. * Gets or sets the unique id of the node
  96315. */
  96316. uniqueId: number;
  96317. /**
  96318. * This observable will notify when one animation have ended
  96319. */
  96320. onAnimationEndObservable: Observable<TargetedAnimation>;
  96321. /**
  96322. * Observer raised when one animation loops
  96323. */
  96324. onAnimationLoopObservable: Observable<TargetedAnimation>;
  96325. /**
  96326. * This observable will notify when all animations have ended.
  96327. */
  96328. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  96329. /**
  96330. * This observable will notify when all animations have paused.
  96331. */
  96332. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  96333. /**
  96334. * This observable will notify when all animations are playing.
  96335. */
  96336. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  96337. /**
  96338. * Gets the first frame
  96339. */
  96340. readonly from: number;
  96341. /**
  96342. * Gets the last frame
  96343. */
  96344. readonly to: number;
  96345. /**
  96346. * Define if the animations are started
  96347. */
  96348. readonly isStarted: boolean;
  96349. /**
  96350. * Gets a value indicating that the current group is playing
  96351. */
  96352. readonly isPlaying: boolean;
  96353. /**
  96354. * Gets or sets the speed ratio to use for all animations
  96355. */
  96356. /**
  96357. * Gets or sets the speed ratio to use for all animations
  96358. */
  96359. speedRatio: number;
  96360. /**
  96361. * Gets or sets if all animations should loop or not
  96362. */
  96363. loopAnimation: boolean;
  96364. /**
  96365. * Gets the targeted animations for this animation group
  96366. */
  96367. readonly targetedAnimations: Array<TargetedAnimation>;
  96368. /**
  96369. * returning the list of animatables controlled by this animation group.
  96370. */
  96371. readonly animatables: Array<Animatable>;
  96372. /**
  96373. * Instantiates a new Animation Group.
  96374. * This helps managing several animations at once.
  96375. * @see http://doc.babylonjs.com/how_to/group
  96376. * @param name Defines the name of the group
  96377. * @param scene Defines the scene the group belongs to
  96378. */
  96379. constructor(
  96380. /** The name of the animation group */
  96381. name: string, scene?: Nullable<Scene>);
  96382. /**
  96383. * Add an animation (with its target) in the group
  96384. * @param animation defines the animation we want to add
  96385. * @param target defines the target of the animation
  96386. * @returns the TargetedAnimation object
  96387. */
  96388. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  96389. /**
  96390. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  96391. * It can add constant keys at begin or end
  96392. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  96393. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  96394. * @returns the animation group
  96395. */
  96396. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  96397. /**
  96398. * Start all animations on given targets
  96399. * @param loop defines if animations must loop
  96400. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  96401. * @param from defines the from key (optional)
  96402. * @param to defines the to key (optional)
  96403. * @returns the current animation group
  96404. */
  96405. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  96406. /**
  96407. * Pause all animations
  96408. * @returns the animation group
  96409. */
  96410. pause(): AnimationGroup;
  96411. /**
  96412. * Play all animations to initial state
  96413. * This function will start() the animations if they were not started or will restart() them if they were paused
  96414. * @param loop defines if animations must loop
  96415. * @returns the animation group
  96416. */
  96417. play(loop?: boolean): AnimationGroup;
  96418. /**
  96419. * Reset all animations to initial state
  96420. * @returns the animation group
  96421. */
  96422. reset(): AnimationGroup;
  96423. /**
  96424. * Restart animations from key 0
  96425. * @returns the animation group
  96426. */
  96427. restart(): AnimationGroup;
  96428. /**
  96429. * Stop all animations
  96430. * @returns the animation group
  96431. */
  96432. stop(): AnimationGroup;
  96433. /**
  96434. * Set animation weight for all animatables
  96435. * @param weight defines the weight to use
  96436. * @return the animationGroup
  96437. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96438. */
  96439. setWeightForAllAnimatables(weight: number): AnimationGroup;
  96440. /**
  96441. * Synchronize and normalize all animatables with a source animatable
  96442. * @param root defines the root animatable to synchronize with
  96443. * @return the animationGroup
  96444. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96445. */
  96446. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  96447. /**
  96448. * Goes to a specific frame in this animation group
  96449. * @param frame the frame number to go to
  96450. * @return the animationGroup
  96451. */
  96452. goToFrame(frame: number): AnimationGroup;
  96453. /**
  96454. * Dispose all associated resources
  96455. */
  96456. dispose(): void;
  96457. private _checkAnimationGroupEnded;
  96458. /**
  96459. * Clone the current animation group and returns a copy
  96460. * @param newName defines the name of the new group
  96461. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  96462. * @returns the new aniamtion group
  96463. */
  96464. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  96465. /**
  96466. * Serializes the animationGroup to an object
  96467. * @returns Serialized object
  96468. */
  96469. serialize(): any;
  96470. /**
  96471. * Returns a new AnimationGroup object parsed from the source provided.
  96472. * @param parsedAnimationGroup defines the source
  96473. * @param scene defines the scene that will receive the animationGroup
  96474. * @returns a new AnimationGroup
  96475. */
  96476. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  96477. /**
  96478. * Returns the string "AnimationGroup"
  96479. * @returns "AnimationGroup"
  96480. */
  96481. getClassName(): string;
  96482. /**
  96483. * Creates a detailled string about the object
  96484. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  96485. * @returns a string representing the object
  96486. */
  96487. toString(fullDetails?: boolean): string;
  96488. }
  96489. }
  96490. declare module BABYLON {
  96491. /**
  96492. * Define an interface for all classes that will hold resources
  96493. */
  96494. export interface IDisposable {
  96495. /**
  96496. * Releases all held resources
  96497. */
  96498. dispose(): void;
  96499. }
  96500. /** Interface defining initialization parameters for Scene class */
  96501. export interface SceneOptions {
  96502. /**
  96503. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  96504. * It will improve performance when the number of geometries becomes important.
  96505. */
  96506. useGeometryUniqueIdsMap?: boolean;
  96507. /**
  96508. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  96509. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96510. */
  96511. useMaterialMeshMap?: boolean;
  96512. /**
  96513. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  96514. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96515. */
  96516. useClonedMeshhMap?: boolean;
  96517. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  96518. virtual?: boolean;
  96519. }
  96520. /**
  96521. * Represents a scene to be rendered by the engine.
  96522. * @see http://doc.babylonjs.com/features/scene
  96523. */
  96524. export class Scene extends AbstractScene implements IAnimatable {
  96525. /** The fog is deactivated */
  96526. static readonly FOGMODE_NONE: number;
  96527. /** The fog density is following an exponential function */
  96528. static readonly FOGMODE_EXP: number;
  96529. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  96530. static readonly FOGMODE_EXP2: number;
  96531. /** The fog density is following a linear function. */
  96532. static readonly FOGMODE_LINEAR: number;
  96533. /**
  96534. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  96535. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96536. */
  96537. static MinDeltaTime: number;
  96538. /**
  96539. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  96540. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96541. */
  96542. static MaxDeltaTime: number;
  96543. /**
  96544. * Factory used to create the default material.
  96545. * @param name The name of the material to create
  96546. * @param scene The scene to create the material for
  96547. * @returns The default material
  96548. */
  96549. static DefaultMaterialFactory(scene: Scene): Material;
  96550. /**
  96551. * Factory used to create the a collision coordinator.
  96552. * @returns The collision coordinator
  96553. */
  96554. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  96555. /** @hidden */
  96556. _inputManager: InputManager;
  96557. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  96558. cameraToUseForPointers: Nullable<Camera>;
  96559. /** @hidden */
  96560. readonly _isScene: boolean;
  96561. /**
  96562. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  96563. */
  96564. autoClear: boolean;
  96565. /**
  96566. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  96567. */
  96568. autoClearDepthAndStencil: boolean;
  96569. /**
  96570. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  96571. */
  96572. clearColor: Color4;
  96573. /**
  96574. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  96575. */
  96576. ambientColor: Color3;
  96577. /**
  96578. * This is use to store the default BRDF lookup for PBR materials in your scene.
  96579. * It should only be one of the following (if not the default embedded one):
  96580. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  96581. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  96582. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  96583. * The material properties need to be setup according to the type of texture in use.
  96584. */
  96585. environmentBRDFTexture: BaseTexture;
  96586. /** @hidden */
  96587. protected _environmentTexture: Nullable<BaseTexture>;
  96588. /**
  96589. * Texture used in all pbr material as the reflection texture.
  96590. * As in the majority of the scene they are the same (exception for multi room and so on),
  96591. * this is easier to reference from here than from all the materials.
  96592. */
  96593. /**
  96594. * Texture used in all pbr material as the reflection texture.
  96595. * As in the majority of the scene they are the same (exception for multi room and so on),
  96596. * this is easier to set here than in all the materials.
  96597. */
  96598. environmentTexture: Nullable<BaseTexture>;
  96599. /** @hidden */
  96600. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96601. /**
  96602. * Default image processing configuration used either in the rendering
  96603. * Forward main pass or through the imageProcessingPostProcess if present.
  96604. * As in the majority of the scene they are the same (exception for multi camera),
  96605. * this is easier to reference from here than from all the materials and post process.
  96606. *
  96607. * No setter as we it is a shared configuration, you can set the values instead.
  96608. */
  96609. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  96610. private _forceWireframe;
  96611. /**
  96612. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  96613. */
  96614. forceWireframe: boolean;
  96615. private _forcePointsCloud;
  96616. /**
  96617. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  96618. */
  96619. forcePointsCloud: boolean;
  96620. /**
  96621. * Gets or sets the active clipplane 1
  96622. */
  96623. clipPlane: Nullable<Plane>;
  96624. /**
  96625. * Gets or sets the active clipplane 2
  96626. */
  96627. clipPlane2: Nullable<Plane>;
  96628. /**
  96629. * Gets or sets the active clipplane 3
  96630. */
  96631. clipPlane3: Nullable<Plane>;
  96632. /**
  96633. * Gets or sets the active clipplane 4
  96634. */
  96635. clipPlane4: Nullable<Plane>;
  96636. /**
  96637. * Gets or sets a boolean indicating if animations are enabled
  96638. */
  96639. animationsEnabled: boolean;
  96640. private _animationPropertiesOverride;
  96641. /**
  96642. * Gets or sets the animation properties override
  96643. */
  96644. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  96645. /**
  96646. * Gets or sets a boolean indicating if a constant deltatime has to be used
  96647. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  96648. */
  96649. useConstantAnimationDeltaTime: boolean;
  96650. /**
  96651. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  96652. * Please note that it requires to run a ray cast through the scene on every frame
  96653. */
  96654. constantlyUpdateMeshUnderPointer: boolean;
  96655. /**
  96656. * Defines the HTML cursor to use when hovering over interactive elements
  96657. */
  96658. hoverCursor: string;
  96659. /**
  96660. * Defines the HTML default cursor to use (empty by default)
  96661. */
  96662. defaultCursor: string;
  96663. /**
  96664. * This is used to call preventDefault() on pointer down
  96665. * in order to block unwanted artifacts like system double clicks
  96666. */
  96667. preventDefaultOnPointerDown: boolean;
  96668. /**
  96669. * This is used to call preventDefault() on pointer up
  96670. * in order to block unwanted artifacts like system double clicks
  96671. */
  96672. preventDefaultOnPointerUp: boolean;
  96673. /**
  96674. * Gets or sets user defined metadata
  96675. */
  96676. metadata: any;
  96677. /**
  96678. * For internal use only. Please do not use.
  96679. */
  96680. reservedDataStore: any;
  96681. /**
  96682. * Gets the name of the plugin used to load this scene (null by default)
  96683. */
  96684. loadingPluginName: string;
  96685. /**
  96686. * Use this array to add regular expressions used to disable offline support for specific urls
  96687. */
  96688. disableOfflineSupportExceptionRules: RegExp[];
  96689. /**
  96690. * An event triggered when the scene is disposed.
  96691. */
  96692. onDisposeObservable: Observable<Scene>;
  96693. private _onDisposeObserver;
  96694. /** Sets a function to be executed when this scene is disposed. */
  96695. onDispose: () => void;
  96696. /**
  96697. * An event triggered before rendering the scene (right after animations and physics)
  96698. */
  96699. onBeforeRenderObservable: Observable<Scene>;
  96700. private _onBeforeRenderObserver;
  96701. /** Sets a function to be executed before rendering this scene */
  96702. beforeRender: Nullable<() => void>;
  96703. /**
  96704. * An event triggered after rendering the scene
  96705. */
  96706. onAfterRenderObservable: Observable<Scene>;
  96707. /**
  96708. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  96709. */
  96710. onAfterRenderCameraObservable: Observable<Camera>;
  96711. private _onAfterRenderObserver;
  96712. /** Sets a function to be executed after rendering this scene */
  96713. afterRender: Nullable<() => void>;
  96714. /**
  96715. * An event triggered before animating the scene
  96716. */
  96717. onBeforeAnimationsObservable: Observable<Scene>;
  96718. /**
  96719. * An event triggered after animations processing
  96720. */
  96721. onAfterAnimationsObservable: Observable<Scene>;
  96722. /**
  96723. * An event triggered before draw calls are ready to be sent
  96724. */
  96725. onBeforeDrawPhaseObservable: Observable<Scene>;
  96726. /**
  96727. * An event triggered after draw calls have been sent
  96728. */
  96729. onAfterDrawPhaseObservable: Observable<Scene>;
  96730. /**
  96731. * An event triggered when the scene is ready
  96732. */
  96733. onReadyObservable: Observable<Scene>;
  96734. /**
  96735. * An event triggered before rendering a camera
  96736. */
  96737. onBeforeCameraRenderObservable: Observable<Camera>;
  96738. private _onBeforeCameraRenderObserver;
  96739. /** Sets a function to be executed before rendering a camera*/
  96740. beforeCameraRender: () => void;
  96741. /**
  96742. * An event triggered after rendering a camera
  96743. */
  96744. onAfterCameraRenderObservable: Observable<Camera>;
  96745. private _onAfterCameraRenderObserver;
  96746. /** Sets a function to be executed after rendering a camera*/
  96747. afterCameraRender: () => void;
  96748. /**
  96749. * An event triggered when active meshes evaluation is about to start
  96750. */
  96751. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  96752. /**
  96753. * An event triggered when active meshes evaluation is done
  96754. */
  96755. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  96756. /**
  96757. * An event triggered when particles rendering is about to start
  96758. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  96759. */
  96760. onBeforeParticlesRenderingObservable: Observable<Scene>;
  96761. /**
  96762. * An event triggered when particles rendering is done
  96763. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  96764. */
  96765. onAfterParticlesRenderingObservable: Observable<Scene>;
  96766. /**
  96767. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  96768. */
  96769. onDataLoadedObservable: Observable<Scene>;
  96770. /**
  96771. * An event triggered when a camera is created
  96772. */
  96773. onNewCameraAddedObservable: Observable<Camera>;
  96774. /**
  96775. * An event triggered when a camera is removed
  96776. */
  96777. onCameraRemovedObservable: Observable<Camera>;
  96778. /**
  96779. * An event triggered when a light is created
  96780. */
  96781. onNewLightAddedObservable: Observable<Light>;
  96782. /**
  96783. * An event triggered when a light is removed
  96784. */
  96785. onLightRemovedObservable: Observable<Light>;
  96786. /**
  96787. * An event triggered when a geometry is created
  96788. */
  96789. onNewGeometryAddedObservable: Observable<Geometry>;
  96790. /**
  96791. * An event triggered when a geometry is removed
  96792. */
  96793. onGeometryRemovedObservable: Observable<Geometry>;
  96794. /**
  96795. * An event triggered when a transform node is created
  96796. */
  96797. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  96798. /**
  96799. * An event triggered when a transform node is removed
  96800. */
  96801. onTransformNodeRemovedObservable: Observable<TransformNode>;
  96802. /**
  96803. * An event triggered when a mesh is created
  96804. */
  96805. onNewMeshAddedObservable: Observable<AbstractMesh>;
  96806. /**
  96807. * An event triggered when a mesh is removed
  96808. */
  96809. onMeshRemovedObservable: Observable<AbstractMesh>;
  96810. /**
  96811. * An event triggered when a skeleton is created
  96812. */
  96813. onNewSkeletonAddedObservable: Observable<Skeleton>;
  96814. /**
  96815. * An event triggered when a skeleton is removed
  96816. */
  96817. onSkeletonRemovedObservable: Observable<Skeleton>;
  96818. /**
  96819. * An event triggered when a material is created
  96820. */
  96821. onNewMaterialAddedObservable: Observable<Material>;
  96822. /**
  96823. * An event triggered when a material is removed
  96824. */
  96825. onMaterialRemovedObservable: Observable<Material>;
  96826. /**
  96827. * An event triggered when a texture is created
  96828. */
  96829. onNewTextureAddedObservable: Observable<BaseTexture>;
  96830. /**
  96831. * An event triggered when a texture is removed
  96832. */
  96833. onTextureRemovedObservable: Observable<BaseTexture>;
  96834. /**
  96835. * An event triggered when render targets are about to be rendered
  96836. * Can happen multiple times per frame.
  96837. */
  96838. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  96839. /**
  96840. * An event triggered when render targets were rendered.
  96841. * Can happen multiple times per frame.
  96842. */
  96843. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  96844. /**
  96845. * An event triggered before calculating deterministic simulation step
  96846. */
  96847. onBeforeStepObservable: Observable<Scene>;
  96848. /**
  96849. * An event triggered after calculating deterministic simulation step
  96850. */
  96851. onAfterStepObservable: Observable<Scene>;
  96852. /**
  96853. * An event triggered when the activeCamera property is updated
  96854. */
  96855. onActiveCameraChanged: Observable<Scene>;
  96856. /**
  96857. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  96858. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96859. * 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)
  96860. */
  96861. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96862. /**
  96863. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  96864. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96865. * 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)
  96866. */
  96867. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96868. /**
  96869. * This Observable will when a mesh has been imported into the scene.
  96870. */
  96871. onMeshImportedObservable: Observable<AbstractMesh>;
  96872. /**
  96873. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  96874. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  96875. */
  96876. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  96877. /** @hidden */
  96878. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  96879. /**
  96880. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  96881. */
  96882. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  96883. /**
  96884. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  96885. */
  96886. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  96887. /**
  96888. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  96889. */
  96890. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  96891. /** Callback called when a pointer move is detected */
  96892. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96893. /** Callback called when a pointer down is detected */
  96894. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96895. /** Callback called when a pointer up is detected */
  96896. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  96897. /** Callback called when a pointer pick is detected */
  96898. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  96899. /**
  96900. * 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).
  96901. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  96902. */
  96903. onPrePointerObservable: Observable<PointerInfoPre>;
  96904. /**
  96905. * Observable event triggered each time an input event is received from the rendering canvas
  96906. */
  96907. onPointerObservable: Observable<PointerInfo>;
  96908. /**
  96909. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  96910. */
  96911. readonly unTranslatedPointer: Vector2;
  96912. /**
  96913. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  96914. */
  96915. static DragMovementThreshold: number;
  96916. /**
  96917. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  96918. */
  96919. static LongPressDelay: number;
  96920. /**
  96921. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  96922. */
  96923. static DoubleClickDelay: number;
  96924. /** If you need to check double click without raising a single click at first click, enable this flag */
  96925. static ExclusiveDoubleClickMode: boolean;
  96926. /** @hidden */
  96927. _mirroredCameraPosition: Nullable<Vector3>;
  96928. /**
  96929. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  96930. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  96931. */
  96932. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  96933. /**
  96934. * Observable event triggered each time an keyboard event is received from the hosting window
  96935. */
  96936. onKeyboardObservable: Observable<KeyboardInfo>;
  96937. private _useRightHandedSystem;
  96938. /**
  96939. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  96940. */
  96941. useRightHandedSystem: boolean;
  96942. private _timeAccumulator;
  96943. private _currentStepId;
  96944. private _currentInternalStep;
  96945. /**
  96946. * Sets the step Id used by deterministic lock step
  96947. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96948. * @param newStepId defines the step Id
  96949. */
  96950. setStepId(newStepId: number): void;
  96951. /**
  96952. * Gets the step Id used by deterministic lock step
  96953. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96954. * @returns the step Id
  96955. */
  96956. getStepId(): number;
  96957. /**
  96958. * Gets the internal step used by deterministic lock step
  96959. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96960. * @returns the internal step
  96961. */
  96962. getInternalStep(): number;
  96963. private _fogEnabled;
  96964. /**
  96965. * Gets or sets a boolean indicating if fog is enabled on this scene
  96966. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96967. * (Default is true)
  96968. */
  96969. fogEnabled: boolean;
  96970. private _fogMode;
  96971. /**
  96972. * Gets or sets the fog mode to use
  96973. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96974. * | mode | value |
  96975. * | --- | --- |
  96976. * | FOGMODE_NONE | 0 |
  96977. * | FOGMODE_EXP | 1 |
  96978. * | FOGMODE_EXP2 | 2 |
  96979. * | FOGMODE_LINEAR | 3 |
  96980. */
  96981. fogMode: number;
  96982. /**
  96983. * Gets or sets the fog color to use
  96984. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96985. * (Default is Color3(0.2, 0.2, 0.3))
  96986. */
  96987. fogColor: Color3;
  96988. /**
  96989. * Gets or sets the fog density to use
  96990. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96991. * (Default is 0.1)
  96992. */
  96993. fogDensity: number;
  96994. /**
  96995. * Gets or sets the fog start distance to use
  96996. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96997. * (Default is 0)
  96998. */
  96999. fogStart: number;
  97000. /**
  97001. * Gets or sets the fog end distance to use
  97002. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97003. * (Default is 1000)
  97004. */
  97005. fogEnd: number;
  97006. private _shadowsEnabled;
  97007. /**
  97008. * Gets or sets a boolean indicating if shadows are enabled on this scene
  97009. */
  97010. shadowsEnabled: boolean;
  97011. private _lightsEnabled;
  97012. /**
  97013. * Gets or sets a boolean indicating if lights are enabled on this scene
  97014. */
  97015. lightsEnabled: boolean;
  97016. /** All of the active cameras added to this scene. */
  97017. activeCameras: Camera[];
  97018. /** @hidden */
  97019. _activeCamera: Nullable<Camera>;
  97020. /** Gets or sets the current active camera */
  97021. activeCamera: Nullable<Camera>;
  97022. private _defaultMaterial;
  97023. /** The default material used on meshes when no material is affected */
  97024. /** The default material used on meshes when no material is affected */
  97025. defaultMaterial: Material;
  97026. private _texturesEnabled;
  97027. /**
  97028. * Gets or sets a boolean indicating if textures are enabled on this scene
  97029. */
  97030. texturesEnabled: boolean;
  97031. /**
  97032. * Gets or sets a boolean indicating if particles are enabled on this scene
  97033. */
  97034. particlesEnabled: boolean;
  97035. /**
  97036. * Gets or sets a boolean indicating if sprites are enabled on this scene
  97037. */
  97038. spritesEnabled: boolean;
  97039. private _skeletonsEnabled;
  97040. /**
  97041. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  97042. */
  97043. skeletonsEnabled: boolean;
  97044. /**
  97045. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  97046. */
  97047. lensFlaresEnabled: boolean;
  97048. /**
  97049. * Gets or sets a boolean indicating if collisions are enabled on this scene
  97050. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97051. */
  97052. collisionsEnabled: boolean;
  97053. private _collisionCoordinator;
  97054. /** @hidden */
  97055. readonly collisionCoordinator: ICollisionCoordinator;
  97056. /**
  97057. * Defines the gravity applied to this scene (used only for collisions)
  97058. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97059. */
  97060. gravity: Vector3;
  97061. /**
  97062. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  97063. */
  97064. postProcessesEnabled: boolean;
  97065. /**
  97066. * The list of postprocesses added to the scene
  97067. */
  97068. postProcesses: PostProcess[];
  97069. /**
  97070. * Gets the current postprocess manager
  97071. */
  97072. postProcessManager: PostProcessManager;
  97073. /**
  97074. * Gets or sets a boolean indicating if render targets are enabled on this scene
  97075. */
  97076. renderTargetsEnabled: boolean;
  97077. /**
  97078. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  97079. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  97080. */
  97081. dumpNextRenderTargets: boolean;
  97082. /**
  97083. * The list of user defined render targets added to the scene
  97084. */
  97085. customRenderTargets: RenderTargetTexture[];
  97086. /**
  97087. * Defines if texture loading must be delayed
  97088. * If true, textures will only be loaded when they need to be rendered
  97089. */
  97090. useDelayedTextureLoading: boolean;
  97091. /**
  97092. * Gets the list of meshes imported to the scene through SceneLoader
  97093. */
  97094. importedMeshesFiles: String[];
  97095. /**
  97096. * Gets or sets a boolean indicating if probes are enabled on this scene
  97097. */
  97098. probesEnabled: boolean;
  97099. /**
  97100. * Gets or sets the current offline provider to use to store scene data
  97101. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  97102. */
  97103. offlineProvider: IOfflineProvider;
  97104. /**
  97105. * Gets or sets the action manager associated with the scene
  97106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97107. */
  97108. actionManager: AbstractActionManager;
  97109. private _meshesForIntersections;
  97110. /**
  97111. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  97112. */
  97113. proceduralTexturesEnabled: boolean;
  97114. private _engine;
  97115. private _totalVertices;
  97116. /** @hidden */
  97117. _activeIndices: PerfCounter;
  97118. /** @hidden */
  97119. _activeParticles: PerfCounter;
  97120. /** @hidden */
  97121. _activeBones: PerfCounter;
  97122. private _animationRatio;
  97123. /** @hidden */
  97124. _animationTimeLast: number;
  97125. /** @hidden */
  97126. _animationTime: number;
  97127. /**
  97128. * Gets or sets a general scale for animation speed
  97129. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  97130. */
  97131. animationTimeScale: number;
  97132. /** @hidden */
  97133. _cachedMaterial: Nullable<Material>;
  97134. /** @hidden */
  97135. _cachedEffect: Nullable<Effect>;
  97136. /** @hidden */
  97137. _cachedVisibility: Nullable<number>;
  97138. private _renderId;
  97139. private _frameId;
  97140. private _executeWhenReadyTimeoutId;
  97141. private _intermediateRendering;
  97142. private _viewUpdateFlag;
  97143. private _projectionUpdateFlag;
  97144. /** @hidden */
  97145. _toBeDisposed: Nullable<IDisposable>[];
  97146. private _activeRequests;
  97147. /** @hidden */
  97148. _pendingData: any[];
  97149. private _isDisposed;
  97150. /**
  97151. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  97152. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  97153. */
  97154. dispatchAllSubMeshesOfActiveMeshes: boolean;
  97155. private _activeMeshes;
  97156. private _processedMaterials;
  97157. private _renderTargets;
  97158. /** @hidden */
  97159. _activeParticleSystems: SmartArray<IParticleSystem>;
  97160. private _activeSkeletons;
  97161. private _softwareSkinnedMeshes;
  97162. private _renderingManager;
  97163. /** @hidden */
  97164. _activeAnimatables: Animatable[];
  97165. private _transformMatrix;
  97166. private _sceneUbo;
  97167. /** @hidden */
  97168. _viewMatrix: Matrix;
  97169. private _projectionMatrix;
  97170. /** @hidden */
  97171. _forcedViewPosition: Nullable<Vector3>;
  97172. /** @hidden */
  97173. _frustumPlanes: Plane[];
  97174. /**
  97175. * Gets the list of frustum planes (built from the active camera)
  97176. */
  97177. readonly frustumPlanes: Plane[];
  97178. /**
  97179. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  97180. * This is useful if there are more lights that the maximum simulteanous authorized
  97181. */
  97182. requireLightSorting: boolean;
  97183. /** @hidden */
  97184. readonly useMaterialMeshMap: boolean;
  97185. /** @hidden */
  97186. readonly useClonedMeshhMap: boolean;
  97187. private _externalData;
  97188. private _uid;
  97189. /**
  97190. * @hidden
  97191. * Backing store of defined scene components.
  97192. */
  97193. _components: ISceneComponent[];
  97194. /**
  97195. * @hidden
  97196. * Backing store of defined scene components.
  97197. */
  97198. _serializableComponents: ISceneSerializableComponent[];
  97199. /**
  97200. * List of components to register on the next registration step.
  97201. */
  97202. private _transientComponents;
  97203. /**
  97204. * Registers the transient components if needed.
  97205. */
  97206. private _registerTransientComponents;
  97207. /**
  97208. * @hidden
  97209. * Add a component to the scene.
  97210. * Note that the ccomponent could be registered on th next frame if this is called after
  97211. * the register component stage.
  97212. * @param component Defines the component to add to the scene
  97213. */
  97214. _addComponent(component: ISceneComponent): void;
  97215. /**
  97216. * @hidden
  97217. * Gets a component from the scene.
  97218. * @param name defines the name of the component to retrieve
  97219. * @returns the component or null if not present
  97220. */
  97221. _getComponent(name: string): Nullable<ISceneComponent>;
  97222. /**
  97223. * @hidden
  97224. * Defines the actions happening before camera updates.
  97225. */
  97226. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  97227. /**
  97228. * @hidden
  97229. * Defines the actions happening before clear the canvas.
  97230. */
  97231. _beforeClearStage: Stage<SimpleStageAction>;
  97232. /**
  97233. * @hidden
  97234. * Defines the actions when collecting render targets for the frame.
  97235. */
  97236. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97237. /**
  97238. * @hidden
  97239. * Defines the actions happening for one camera in the frame.
  97240. */
  97241. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97242. /**
  97243. * @hidden
  97244. * Defines the actions happening during the per mesh ready checks.
  97245. */
  97246. _isReadyForMeshStage: Stage<MeshStageAction>;
  97247. /**
  97248. * @hidden
  97249. * Defines the actions happening before evaluate active mesh checks.
  97250. */
  97251. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  97252. /**
  97253. * @hidden
  97254. * Defines the actions happening during the evaluate sub mesh checks.
  97255. */
  97256. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  97257. /**
  97258. * @hidden
  97259. * Defines the actions happening during the active mesh stage.
  97260. */
  97261. _activeMeshStage: Stage<ActiveMeshStageAction>;
  97262. /**
  97263. * @hidden
  97264. * Defines the actions happening during the per camera render target step.
  97265. */
  97266. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  97267. /**
  97268. * @hidden
  97269. * Defines the actions happening just before the active camera is drawing.
  97270. */
  97271. _beforeCameraDrawStage: Stage<CameraStageAction>;
  97272. /**
  97273. * @hidden
  97274. * Defines the actions happening just before a render target is drawing.
  97275. */
  97276. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97277. /**
  97278. * @hidden
  97279. * Defines the actions happening just before a rendering group is drawing.
  97280. */
  97281. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97282. /**
  97283. * @hidden
  97284. * Defines the actions happening just before a mesh is drawing.
  97285. */
  97286. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97287. /**
  97288. * @hidden
  97289. * Defines the actions happening just after a mesh has been drawn.
  97290. */
  97291. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97292. /**
  97293. * @hidden
  97294. * Defines the actions happening just after a rendering group has been drawn.
  97295. */
  97296. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97297. /**
  97298. * @hidden
  97299. * Defines the actions happening just after the active camera has been drawn.
  97300. */
  97301. _afterCameraDrawStage: Stage<CameraStageAction>;
  97302. /**
  97303. * @hidden
  97304. * Defines the actions happening just after a render target has been drawn.
  97305. */
  97306. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97307. /**
  97308. * @hidden
  97309. * Defines the actions happening just after rendering all cameras and computing intersections.
  97310. */
  97311. _afterRenderStage: Stage<SimpleStageAction>;
  97312. /**
  97313. * @hidden
  97314. * Defines the actions happening when a pointer move event happens.
  97315. */
  97316. _pointerMoveStage: Stage<PointerMoveStageAction>;
  97317. /**
  97318. * @hidden
  97319. * Defines the actions happening when a pointer down event happens.
  97320. */
  97321. _pointerDownStage: Stage<PointerUpDownStageAction>;
  97322. /**
  97323. * @hidden
  97324. * Defines the actions happening when a pointer up event happens.
  97325. */
  97326. _pointerUpStage: Stage<PointerUpDownStageAction>;
  97327. /**
  97328. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  97329. */
  97330. private geometriesByUniqueId;
  97331. /**
  97332. * Creates a new Scene
  97333. * @param engine defines the engine to use to render this scene
  97334. * @param options defines the scene options
  97335. */
  97336. constructor(engine: Engine, options?: SceneOptions);
  97337. /**
  97338. * Gets a string idenfifying the name of the class
  97339. * @returns "Scene" string
  97340. */
  97341. getClassName(): string;
  97342. private _defaultMeshCandidates;
  97343. /**
  97344. * @hidden
  97345. */
  97346. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97347. private _defaultSubMeshCandidates;
  97348. /**
  97349. * @hidden
  97350. */
  97351. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97352. /**
  97353. * Sets the default candidate providers for the scene.
  97354. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  97355. * and getCollidingSubMeshCandidates to their default function
  97356. */
  97357. setDefaultCandidateProviders(): void;
  97358. /**
  97359. * Gets the mesh that is currently under the pointer
  97360. */
  97361. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97362. /**
  97363. * Gets or sets the current on-screen X position of the pointer
  97364. */
  97365. pointerX: number;
  97366. /**
  97367. * Gets or sets the current on-screen Y position of the pointer
  97368. */
  97369. pointerY: number;
  97370. /**
  97371. * Gets the cached material (ie. the latest rendered one)
  97372. * @returns the cached material
  97373. */
  97374. getCachedMaterial(): Nullable<Material>;
  97375. /**
  97376. * Gets the cached effect (ie. the latest rendered one)
  97377. * @returns the cached effect
  97378. */
  97379. getCachedEffect(): Nullable<Effect>;
  97380. /**
  97381. * Gets the cached visibility state (ie. the latest rendered one)
  97382. * @returns the cached visibility state
  97383. */
  97384. getCachedVisibility(): Nullable<number>;
  97385. /**
  97386. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  97387. * @param material defines the current material
  97388. * @param effect defines the current effect
  97389. * @param visibility defines the current visibility state
  97390. * @returns true if one parameter is not cached
  97391. */
  97392. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  97393. /**
  97394. * Gets the engine associated with the scene
  97395. * @returns an Engine
  97396. */
  97397. getEngine(): Engine;
  97398. /**
  97399. * Gets the total number of vertices rendered per frame
  97400. * @returns the total number of vertices rendered per frame
  97401. */
  97402. getTotalVertices(): number;
  97403. /**
  97404. * Gets the performance counter for total vertices
  97405. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97406. */
  97407. readonly totalVerticesPerfCounter: PerfCounter;
  97408. /**
  97409. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  97410. * @returns the total number of active indices rendered per frame
  97411. */
  97412. getActiveIndices(): number;
  97413. /**
  97414. * Gets the performance counter for active indices
  97415. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97416. */
  97417. readonly totalActiveIndicesPerfCounter: PerfCounter;
  97418. /**
  97419. * Gets the total number of active particles rendered per frame
  97420. * @returns the total number of active particles rendered per frame
  97421. */
  97422. getActiveParticles(): number;
  97423. /**
  97424. * Gets the performance counter for active particles
  97425. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97426. */
  97427. readonly activeParticlesPerfCounter: PerfCounter;
  97428. /**
  97429. * Gets the total number of active bones rendered per frame
  97430. * @returns the total number of active bones rendered per frame
  97431. */
  97432. getActiveBones(): number;
  97433. /**
  97434. * Gets the performance counter for active bones
  97435. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97436. */
  97437. readonly activeBonesPerfCounter: PerfCounter;
  97438. /**
  97439. * Gets the array of active meshes
  97440. * @returns an array of AbstractMesh
  97441. */
  97442. getActiveMeshes(): SmartArray<AbstractMesh>;
  97443. /**
  97444. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  97445. * @returns a number
  97446. */
  97447. getAnimationRatio(): number;
  97448. /**
  97449. * Gets an unique Id for the current render phase
  97450. * @returns a number
  97451. */
  97452. getRenderId(): number;
  97453. /**
  97454. * Gets an unique Id for the current frame
  97455. * @returns a number
  97456. */
  97457. getFrameId(): number;
  97458. /** Call this function if you want to manually increment the render Id*/
  97459. incrementRenderId(): void;
  97460. private _createUbo;
  97461. /**
  97462. * Use this method to simulate a pointer move on a mesh
  97463. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97464. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97465. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97466. * @returns the current scene
  97467. */
  97468. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97469. /**
  97470. * Use this method to simulate a pointer down on a mesh
  97471. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97472. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97473. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97474. * @returns the current scene
  97475. */
  97476. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97477. /**
  97478. * Use this method to simulate a pointer up on a mesh
  97479. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97480. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97481. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97482. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97483. * @returns the current scene
  97484. */
  97485. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  97486. /**
  97487. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97488. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97489. * @returns true if the pointer was captured
  97490. */
  97491. isPointerCaptured(pointerId?: number): boolean;
  97492. /**
  97493. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97494. * @param attachUp defines if you want to attach events to pointerup
  97495. * @param attachDown defines if you want to attach events to pointerdown
  97496. * @param attachMove defines if you want to attach events to pointermove
  97497. */
  97498. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97499. /** Detaches all event handlers*/
  97500. detachControl(): void;
  97501. /**
  97502. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  97503. * Delay loaded resources are not taking in account
  97504. * @return true if all required resources are ready
  97505. */
  97506. isReady(): boolean;
  97507. /** Resets all cached information relative to material (including effect and visibility) */
  97508. resetCachedMaterial(): void;
  97509. /**
  97510. * Registers a function to be called before every frame render
  97511. * @param func defines the function to register
  97512. */
  97513. registerBeforeRender(func: () => void): void;
  97514. /**
  97515. * Unregisters a function called before every frame render
  97516. * @param func defines the function to unregister
  97517. */
  97518. unregisterBeforeRender(func: () => void): void;
  97519. /**
  97520. * Registers a function to be called after every frame render
  97521. * @param func defines the function to register
  97522. */
  97523. registerAfterRender(func: () => void): void;
  97524. /**
  97525. * Unregisters a function called after every frame render
  97526. * @param func defines the function to unregister
  97527. */
  97528. unregisterAfterRender(func: () => void): void;
  97529. private _executeOnceBeforeRender;
  97530. /**
  97531. * The provided function will run before render once and will be disposed afterwards.
  97532. * A timeout delay can be provided so that the function will be executed in N ms.
  97533. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  97534. * @param func The function to be executed.
  97535. * @param timeout optional delay in ms
  97536. */
  97537. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  97538. /** @hidden */
  97539. _addPendingData(data: any): void;
  97540. /** @hidden */
  97541. _removePendingData(data: any): void;
  97542. /**
  97543. * Returns the number of items waiting to be loaded
  97544. * @returns the number of items waiting to be loaded
  97545. */
  97546. getWaitingItemsCount(): number;
  97547. /**
  97548. * Returns a boolean indicating if the scene is still loading data
  97549. */
  97550. readonly isLoading: boolean;
  97551. /**
  97552. * Registers a function to be executed when the scene is ready
  97553. * @param {Function} func - the function to be executed
  97554. */
  97555. executeWhenReady(func: () => void): void;
  97556. /**
  97557. * Returns a promise that resolves when the scene is ready
  97558. * @returns A promise that resolves when the scene is ready
  97559. */
  97560. whenReadyAsync(): Promise<void>;
  97561. /** @hidden */
  97562. _checkIsReady(): void;
  97563. /**
  97564. * Gets all animatable attached to the scene
  97565. */
  97566. readonly animatables: Animatable[];
  97567. /**
  97568. * Resets the last animation time frame.
  97569. * Useful to override when animations start running when loading a scene for the first time.
  97570. */
  97571. resetLastAnimationTimeFrame(): void;
  97572. /**
  97573. * Gets the current view matrix
  97574. * @returns a Matrix
  97575. */
  97576. getViewMatrix(): Matrix;
  97577. /**
  97578. * Gets the current projection matrix
  97579. * @returns a Matrix
  97580. */
  97581. getProjectionMatrix(): Matrix;
  97582. /**
  97583. * Gets the current transform matrix
  97584. * @returns a Matrix made of View * Projection
  97585. */
  97586. getTransformMatrix(): Matrix;
  97587. /**
  97588. * Sets the current transform matrix
  97589. * @param viewL defines the View matrix to use
  97590. * @param projectionL defines the Projection matrix to use
  97591. * @param viewR defines the right View matrix to use (if provided)
  97592. * @param projectionR defines the right Projection matrix to use (if provided)
  97593. */
  97594. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  97595. /**
  97596. * Gets the uniform buffer used to store scene data
  97597. * @returns a UniformBuffer
  97598. */
  97599. getSceneUniformBuffer(): UniformBuffer;
  97600. /**
  97601. * Gets an unique (relatively to the current scene) Id
  97602. * @returns an unique number for the scene
  97603. */
  97604. getUniqueId(): number;
  97605. /**
  97606. * Add a mesh to the list of scene's meshes
  97607. * @param newMesh defines the mesh to add
  97608. * @param recursive if all child meshes should also be added to the scene
  97609. */
  97610. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  97611. /**
  97612. * Remove a mesh for the list of scene's meshes
  97613. * @param toRemove defines the mesh to remove
  97614. * @param recursive if all child meshes should also be removed from the scene
  97615. * @returns the index where the mesh was in the mesh list
  97616. */
  97617. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  97618. /**
  97619. * Add a transform node to the list of scene's transform nodes
  97620. * @param newTransformNode defines the transform node to add
  97621. */
  97622. addTransformNode(newTransformNode: TransformNode): void;
  97623. /**
  97624. * Remove a transform node for the list of scene's transform nodes
  97625. * @param toRemove defines the transform node to remove
  97626. * @returns the index where the transform node was in the transform node list
  97627. */
  97628. removeTransformNode(toRemove: TransformNode): number;
  97629. /**
  97630. * Remove a skeleton for the list of scene's skeletons
  97631. * @param toRemove defines the skeleton to remove
  97632. * @returns the index where the skeleton was in the skeleton list
  97633. */
  97634. removeSkeleton(toRemove: Skeleton): number;
  97635. /**
  97636. * Remove a morph target for the list of scene's morph targets
  97637. * @param toRemove defines the morph target to remove
  97638. * @returns the index where the morph target was in the morph target list
  97639. */
  97640. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  97641. /**
  97642. * Remove a light for the list of scene's lights
  97643. * @param toRemove defines the light to remove
  97644. * @returns the index where the light was in the light list
  97645. */
  97646. removeLight(toRemove: Light): number;
  97647. /**
  97648. * Remove a camera for the list of scene's cameras
  97649. * @param toRemove defines the camera to remove
  97650. * @returns the index where the camera was in the camera list
  97651. */
  97652. removeCamera(toRemove: Camera): number;
  97653. /**
  97654. * Remove a particle system for the list of scene's particle systems
  97655. * @param toRemove defines the particle system to remove
  97656. * @returns the index where the particle system was in the particle system list
  97657. */
  97658. removeParticleSystem(toRemove: IParticleSystem): number;
  97659. /**
  97660. * Remove a animation for the list of scene's animations
  97661. * @param toRemove defines the animation to remove
  97662. * @returns the index where the animation was in the animation list
  97663. */
  97664. removeAnimation(toRemove: Animation): number;
  97665. /**
  97666. * Will stop the animation of the given target
  97667. * @param target - the target
  97668. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  97669. * @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)
  97670. */
  97671. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  97672. /**
  97673. * Removes the given animation group from this scene.
  97674. * @param toRemove The animation group to remove
  97675. * @returns The index of the removed animation group
  97676. */
  97677. removeAnimationGroup(toRemove: AnimationGroup): number;
  97678. /**
  97679. * Removes the given multi-material from this scene.
  97680. * @param toRemove The multi-material to remove
  97681. * @returns The index of the removed multi-material
  97682. */
  97683. removeMultiMaterial(toRemove: MultiMaterial): number;
  97684. /**
  97685. * Removes the given material from this scene.
  97686. * @param toRemove The material to remove
  97687. * @returns The index of the removed material
  97688. */
  97689. removeMaterial(toRemove: Material): number;
  97690. /**
  97691. * Removes the given action manager from this scene.
  97692. * @param toRemove The action manager to remove
  97693. * @returns The index of the removed action manager
  97694. */
  97695. removeActionManager(toRemove: AbstractActionManager): number;
  97696. /**
  97697. * Removes the given texture from this scene.
  97698. * @param toRemove The texture to remove
  97699. * @returns The index of the removed texture
  97700. */
  97701. removeTexture(toRemove: BaseTexture): number;
  97702. /**
  97703. * Adds the given light to this scene
  97704. * @param newLight The light to add
  97705. */
  97706. addLight(newLight: Light): void;
  97707. /**
  97708. * Sorts the list list based on light priorities
  97709. */
  97710. sortLightsByPriority(): void;
  97711. /**
  97712. * Adds the given camera to this scene
  97713. * @param newCamera The camera to add
  97714. */
  97715. addCamera(newCamera: Camera): void;
  97716. /**
  97717. * Adds the given skeleton to this scene
  97718. * @param newSkeleton The skeleton to add
  97719. */
  97720. addSkeleton(newSkeleton: Skeleton): void;
  97721. /**
  97722. * Adds the given particle system to this scene
  97723. * @param newParticleSystem The particle system to add
  97724. */
  97725. addParticleSystem(newParticleSystem: IParticleSystem): void;
  97726. /**
  97727. * Adds the given animation to this scene
  97728. * @param newAnimation The animation to add
  97729. */
  97730. addAnimation(newAnimation: Animation): void;
  97731. /**
  97732. * Adds the given animation group to this scene.
  97733. * @param newAnimationGroup The animation group to add
  97734. */
  97735. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  97736. /**
  97737. * Adds the given multi-material to this scene
  97738. * @param newMultiMaterial The multi-material to add
  97739. */
  97740. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  97741. /**
  97742. * Adds the given material to this scene
  97743. * @param newMaterial The material to add
  97744. */
  97745. addMaterial(newMaterial: Material): void;
  97746. /**
  97747. * Adds the given morph target to this scene
  97748. * @param newMorphTargetManager The morph target to add
  97749. */
  97750. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  97751. /**
  97752. * Adds the given geometry to this scene
  97753. * @param newGeometry The geometry to add
  97754. */
  97755. addGeometry(newGeometry: Geometry): void;
  97756. /**
  97757. * Adds the given action manager to this scene
  97758. * @param newActionManager The action manager to add
  97759. */
  97760. addActionManager(newActionManager: AbstractActionManager): void;
  97761. /**
  97762. * Adds the given texture to this scene.
  97763. * @param newTexture The texture to add
  97764. */
  97765. addTexture(newTexture: BaseTexture): void;
  97766. /**
  97767. * Switch active camera
  97768. * @param newCamera defines the new active camera
  97769. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  97770. */
  97771. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  97772. /**
  97773. * sets the active camera of the scene using its ID
  97774. * @param id defines the camera's ID
  97775. * @return the new active camera or null if none found.
  97776. */
  97777. setActiveCameraByID(id: string): Nullable<Camera>;
  97778. /**
  97779. * sets the active camera of the scene using its name
  97780. * @param name defines the camera's name
  97781. * @returns the new active camera or null if none found.
  97782. */
  97783. setActiveCameraByName(name: string): Nullable<Camera>;
  97784. /**
  97785. * get an animation group using its name
  97786. * @param name defines the material's name
  97787. * @return the animation group or null if none found.
  97788. */
  97789. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  97790. /**
  97791. * Get a material using its unique id
  97792. * @param uniqueId defines the material's unique id
  97793. * @return the material or null if none found.
  97794. */
  97795. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  97796. /**
  97797. * get a material using its id
  97798. * @param id defines the material's ID
  97799. * @return the material or null if none found.
  97800. */
  97801. getMaterialByID(id: string): Nullable<Material>;
  97802. /**
  97803. * Gets a the last added material using a given id
  97804. * @param id defines the material's ID
  97805. * @return the last material with the given id or null if none found.
  97806. */
  97807. getLastMaterialByID(id: string): Nullable<Material>;
  97808. /**
  97809. * Gets a material using its name
  97810. * @param name defines the material's name
  97811. * @return the material or null if none found.
  97812. */
  97813. getMaterialByName(name: string): Nullable<Material>;
  97814. /**
  97815. * Get a texture using its unique id
  97816. * @param uniqueId defines the texture's unique id
  97817. * @return the texture or null if none found.
  97818. */
  97819. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  97820. /**
  97821. * Gets a camera using its id
  97822. * @param id defines the id to look for
  97823. * @returns the camera or null if not found
  97824. */
  97825. getCameraByID(id: string): Nullable<Camera>;
  97826. /**
  97827. * Gets a camera using its unique id
  97828. * @param uniqueId defines the unique id to look for
  97829. * @returns the camera or null if not found
  97830. */
  97831. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  97832. /**
  97833. * Gets a camera using its name
  97834. * @param name defines the camera's name
  97835. * @return the camera or null if none found.
  97836. */
  97837. getCameraByName(name: string): Nullable<Camera>;
  97838. /**
  97839. * Gets a bone using its id
  97840. * @param id defines the bone's id
  97841. * @return the bone or null if not found
  97842. */
  97843. getBoneByID(id: string): Nullable<Bone>;
  97844. /**
  97845. * Gets a bone using its id
  97846. * @param name defines the bone's name
  97847. * @return the bone or null if not found
  97848. */
  97849. getBoneByName(name: string): Nullable<Bone>;
  97850. /**
  97851. * Gets a light node using its name
  97852. * @param name defines the the light's name
  97853. * @return the light or null if none found.
  97854. */
  97855. getLightByName(name: string): Nullable<Light>;
  97856. /**
  97857. * Gets a light node using its id
  97858. * @param id defines the light's id
  97859. * @return the light or null if none found.
  97860. */
  97861. getLightByID(id: string): Nullable<Light>;
  97862. /**
  97863. * Gets a light node using its scene-generated unique ID
  97864. * @param uniqueId defines the light's unique id
  97865. * @return the light or null if none found.
  97866. */
  97867. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  97868. /**
  97869. * Gets a particle system by id
  97870. * @param id defines the particle system id
  97871. * @return the corresponding system or null if none found
  97872. */
  97873. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  97874. /**
  97875. * Gets a geometry using its ID
  97876. * @param id defines the geometry's id
  97877. * @return the geometry or null if none found.
  97878. */
  97879. getGeometryByID(id: string): Nullable<Geometry>;
  97880. private _getGeometryByUniqueID;
  97881. /**
  97882. * Add a new geometry to this scene
  97883. * @param geometry defines the geometry to be added to the scene.
  97884. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  97885. * @return a boolean defining if the geometry was added or not
  97886. */
  97887. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  97888. /**
  97889. * Removes an existing geometry
  97890. * @param geometry defines the geometry to be removed from the scene
  97891. * @return a boolean defining if the geometry was removed or not
  97892. */
  97893. removeGeometry(geometry: Geometry): boolean;
  97894. /**
  97895. * Gets the list of geometries attached to the scene
  97896. * @returns an array of Geometry
  97897. */
  97898. getGeometries(): Geometry[];
  97899. /**
  97900. * Gets the first added mesh found of a given ID
  97901. * @param id defines the id to search for
  97902. * @return the mesh found or null if not found at all
  97903. */
  97904. getMeshByID(id: string): Nullable<AbstractMesh>;
  97905. /**
  97906. * Gets a list of meshes using their id
  97907. * @param id defines the id to search for
  97908. * @returns a list of meshes
  97909. */
  97910. getMeshesByID(id: string): Array<AbstractMesh>;
  97911. /**
  97912. * Gets the first added transform node found of a given ID
  97913. * @param id defines the id to search for
  97914. * @return the found transform node or null if not found at all.
  97915. */
  97916. getTransformNodeByID(id: string): Nullable<TransformNode>;
  97917. /**
  97918. * Gets a transform node with its auto-generated unique id
  97919. * @param uniqueId efines the unique id to search for
  97920. * @return the found transform node or null if not found at all.
  97921. */
  97922. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  97923. /**
  97924. * Gets a list of transform nodes using their id
  97925. * @param id defines the id to search for
  97926. * @returns a list of transform nodes
  97927. */
  97928. getTransformNodesByID(id: string): Array<TransformNode>;
  97929. /**
  97930. * Gets a mesh with its auto-generated unique id
  97931. * @param uniqueId defines the unique id to search for
  97932. * @return the found mesh or null if not found at all.
  97933. */
  97934. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  97935. /**
  97936. * Gets a the last added mesh using a given id
  97937. * @param id defines the id to search for
  97938. * @return the found mesh or null if not found at all.
  97939. */
  97940. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  97941. /**
  97942. * Gets a the last added node (Mesh, Camera, Light) using a given id
  97943. * @param id defines the id to search for
  97944. * @return the found node or null if not found at all
  97945. */
  97946. getLastEntryByID(id: string): Nullable<Node>;
  97947. /**
  97948. * Gets a node (Mesh, Camera, Light) using a given id
  97949. * @param id defines the id to search for
  97950. * @return the found node or null if not found at all
  97951. */
  97952. getNodeByID(id: string): Nullable<Node>;
  97953. /**
  97954. * Gets a node (Mesh, Camera, Light) using a given name
  97955. * @param name defines the name to search for
  97956. * @return the found node or null if not found at all.
  97957. */
  97958. getNodeByName(name: string): Nullable<Node>;
  97959. /**
  97960. * Gets a mesh using a given name
  97961. * @param name defines the name to search for
  97962. * @return the found mesh or null if not found at all.
  97963. */
  97964. getMeshByName(name: string): Nullable<AbstractMesh>;
  97965. /**
  97966. * Gets a transform node using a given name
  97967. * @param name defines the name to search for
  97968. * @return the found transform node or null if not found at all.
  97969. */
  97970. getTransformNodeByName(name: string): Nullable<TransformNode>;
  97971. /**
  97972. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  97973. * @param id defines the id to search for
  97974. * @return the found skeleton or null if not found at all.
  97975. */
  97976. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  97977. /**
  97978. * Gets a skeleton using a given auto generated unique id
  97979. * @param uniqueId defines the unique id to search for
  97980. * @return the found skeleton or null if not found at all.
  97981. */
  97982. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  97983. /**
  97984. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  97985. * @param id defines the id to search for
  97986. * @return the found skeleton or null if not found at all.
  97987. */
  97988. getSkeletonById(id: string): Nullable<Skeleton>;
  97989. /**
  97990. * Gets a skeleton using a given name
  97991. * @param name defines the name to search for
  97992. * @return the found skeleton or null if not found at all.
  97993. */
  97994. getSkeletonByName(name: string): Nullable<Skeleton>;
  97995. /**
  97996. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  97997. * @param id defines the id to search for
  97998. * @return the found morph target manager or null if not found at all.
  97999. */
  98000. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  98001. /**
  98002. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  98003. * @param id defines the id to search for
  98004. * @return the found morph target or null if not found at all.
  98005. */
  98006. getMorphTargetById(id: string): Nullable<MorphTarget>;
  98007. /**
  98008. * Gets a boolean indicating if the given mesh is active
  98009. * @param mesh defines the mesh to look for
  98010. * @returns true if the mesh is in the active list
  98011. */
  98012. isActiveMesh(mesh: AbstractMesh): boolean;
  98013. /**
  98014. * Return a unique id as a string which can serve as an identifier for the scene
  98015. */
  98016. readonly uid: string;
  98017. /**
  98018. * Add an externaly attached data from its key.
  98019. * This method call will fail and return false, if such key already exists.
  98020. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  98021. * @param key the unique key that identifies the data
  98022. * @param data the data object to associate to the key for this Engine instance
  98023. * @return true if no such key were already present and the data was added successfully, false otherwise
  98024. */
  98025. addExternalData<T>(key: string, data: T): boolean;
  98026. /**
  98027. * Get an externaly attached data from its key
  98028. * @param key the unique key that identifies the data
  98029. * @return the associated data, if present (can be null), or undefined if not present
  98030. */
  98031. getExternalData<T>(key: string): Nullable<T>;
  98032. /**
  98033. * Get an externaly attached data from its key, create it using a factory if it's not already present
  98034. * @param key the unique key that identifies the data
  98035. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  98036. * @return the associated data, can be null if the factory returned null.
  98037. */
  98038. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  98039. /**
  98040. * Remove an externaly attached data from the Engine instance
  98041. * @param key the unique key that identifies the data
  98042. * @return true if the data was successfully removed, false if it doesn't exist
  98043. */
  98044. removeExternalData(key: string): boolean;
  98045. private _evaluateSubMesh;
  98046. /**
  98047. * Clear the processed materials smart array preventing retention point in material dispose.
  98048. */
  98049. freeProcessedMaterials(): void;
  98050. private _preventFreeActiveMeshesAndRenderingGroups;
  98051. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  98052. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  98053. * when disposing several meshes in a row or a hierarchy of meshes.
  98054. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  98055. */
  98056. blockfreeActiveMeshesAndRenderingGroups: boolean;
  98057. /**
  98058. * Clear the active meshes smart array preventing retention point in mesh dispose.
  98059. */
  98060. freeActiveMeshes(): void;
  98061. /**
  98062. * Clear the info related to rendering groups preventing retention points during dispose.
  98063. */
  98064. freeRenderingGroups(): void;
  98065. /** @hidden */
  98066. _isInIntermediateRendering(): boolean;
  98067. /**
  98068. * Lambda returning the list of potentially active meshes.
  98069. */
  98070. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  98071. /**
  98072. * Lambda returning the list of potentially active sub meshes.
  98073. */
  98074. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  98075. /**
  98076. * Lambda returning the list of potentially intersecting sub meshes.
  98077. */
  98078. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  98079. /**
  98080. * Lambda returning the list of potentially colliding sub meshes.
  98081. */
  98082. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  98083. private _activeMeshesFrozen;
  98084. /**
  98085. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  98086. * @returns the current scene
  98087. */
  98088. freezeActiveMeshes(): Scene;
  98089. /**
  98090. * Use this function to restart evaluating active meshes on every frame
  98091. * @returns the current scene
  98092. */
  98093. unfreezeActiveMeshes(): Scene;
  98094. private _evaluateActiveMeshes;
  98095. private _activeMesh;
  98096. /**
  98097. * Update the transform matrix to update from the current active camera
  98098. * @param force defines a boolean used to force the update even if cache is up to date
  98099. */
  98100. updateTransformMatrix(force?: boolean): void;
  98101. private _bindFrameBuffer;
  98102. /** @hidden */
  98103. _allowPostProcessClearColor: boolean;
  98104. /** @hidden */
  98105. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  98106. private _processSubCameras;
  98107. private _checkIntersections;
  98108. /** @hidden */
  98109. _advancePhysicsEngineStep(step: number): void;
  98110. /**
  98111. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  98112. */
  98113. getDeterministicFrameTime: () => number;
  98114. /** @hidden */
  98115. _animate(): void;
  98116. /** Execute all animations (for a frame) */
  98117. animate(): void;
  98118. /**
  98119. * Render the scene
  98120. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  98121. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  98122. */
  98123. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  98124. /**
  98125. * Freeze all materials
  98126. * A frozen material will not be updatable but should be faster to render
  98127. */
  98128. freezeMaterials(): void;
  98129. /**
  98130. * Unfreeze all materials
  98131. * A frozen material will not be updatable but should be faster to render
  98132. */
  98133. unfreezeMaterials(): void;
  98134. /**
  98135. * Releases all held ressources
  98136. */
  98137. dispose(): void;
  98138. /**
  98139. * Gets if the scene is already disposed
  98140. */
  98141. readonly isDisposed: boolean;
  98142. /**
  98143. * Call this function to reduce memory footprint of the scene.
  98144. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  98145. */
  98146. clearCachedVertexData(): void;
  98147. /**
  98148. * This function will remove the local cached buffer data from texture.
  98149. * It will save memory but will prevent the texture from being rebuilt
  98150. */
  98151. cleanCachedTextureBuffer(): void;
  98152. /**
  98153. * Get the world extend vectors with an optional filter
  98154. *
  98155. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  98156. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  98157. */
  98158. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  98159. min: Vector3;
  98160. max: Vector3;
  98161. };
  98162. /**
  98163. * Creates a ray that can be used to pick in the scene
  98164. * @param x defines the x coordinate of the origin (on-screen)
  98165. * @param y defines the y coordinate of the origin (on-screen)
  98166. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98167. * @param camera defines the camera to use for the picking
  98168. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98169. * @returns a Ray
  98170. */
  98171. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  98172. /**
  98173. * Creates a ray that can be used to pick in the scene
  98174. * @param x defines the x coordinate of the origin (on-screen)
  98175. * @param y defines the y coordinate of the origin (on-screen)
  98176. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98177. * @param result defines the ray where to store the picking ray
  98178. * @param camera defines the camera to use for the picking
  98179. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98180. * @returns the current scene
  98181. */
  98182. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  98183. /**
  98184. * Creates a ray that can be used to pick in the scene
  98185. * @param x defines the x coordinate of the origin (on-screen)
  98186. * @param y defines the y coordinate of the origin (on-screen)
  98187. * @param camera defines the camera to use for the picking
  98188. * @returns a Ray
  98189. */
  98190. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  98191. /**
  98192. * Creates a ray that can be used to pick in the scene
  98193. * @param x defines the x coordinate of the origin (on-screen)
  98194. * @param y defines the y coordinate of the origin (on-screen)
  98195. * @param result defines the ray where to store the picking ray
  98196. * @param camera defines the camera to use for the picking
  98197. * @returns the current scene
  98198. */
  98199. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  98200. /** Launch a ray to try to pick a mesh in the scene
  98201. * @param x position on screen
  98202. * @param y position on screen
  98203. * @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
  98204. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  98205. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98206. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98207. * @returns a PickingInfo
  98208. */
  98209. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98210. /** Use the given ray to pick a mesh in the scene
  98211. * @param ray The ray to use to pick meshes
  98212. * @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
  98213. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  98214. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98215. * @returns a PickingInfo
  98216. */
  98217. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98218. /**
  98219. * Launch a ray to try to pick a mesh in the scene
  98220. * @param x X position on screen
  98221. * @param y Y position on screen
  98222. * @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
  98223. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98224. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98225. * @returns an array of PickingInfo
  98226. */
  98227. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98228. /**
  98229. * Launch a ray to try to pick a mesh in the scene
  98230. * @param ray Ray to use
  98231. * @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
  98232. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98233. * @returns an array of PickingInfo
  98234. */
  98235. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98236. /**
  98237. * Force the value of meshUnderPointer
  98238. * @param mesh defines the mesh to use
  98239. */
  98240. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98241. /**
  98242. * Gets the mesh under the pointer
  98243. * @returns a Mesh or null if no mesh is under the pointer
  98244. */
  98245. getPointerOverMesh(): Nullable<AbstractMesh>;
  98246. /** @hidden */
  98247. _rebuildGeometries(): void;
  98248. /** @hidden */
  98249. _rebuildTextures(): void;
  98250. private _getByTags;
  98251. /**
  98252. * Get a list of meshes by tags
  98253. * @param tagsQuery defines the tags query to use
  98254. * @param forEach defines a predicate used to filter results
  98255. * @returns an array of Mesh
  98256. */
  98257. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  98258. /**
  98259. * Get a list of cameras by tags
  98260. * @param tagsQuery defines the tags query to use
  98261. * @param forEach defines a predicate used to filter results
  98262. * @returns an array of Camera
  98263. */
  98264. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  98265. /**
  98266. * Get a list of lights by tags
  98267. * @param tagsQuery defines the tags query to use
  98268. * @param forEach defines a predicate used to filter results
  98269. * @returns an array of Light
  98270. */
  98271. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  98272. /**
  98273. * Get a list of materials by tags
  98274. * @param tagsQuery defines the tags query to use
  98275. * @param forEach defines a predicate used to filter results
  98276. * @returns an array of Material
  98277. */
  98278. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  98279. /**
  98280. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98281. * This allowed control for front to back rendering or reversly depending of the special needs.
  98282. *
  98283. * @param renderingGroupId The rendering group id corresponding to its index
  98284. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98285. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98286. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98287. */
  98288. 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;
  98289. /**
  98290. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98291. *
  98292. * @param renderingGroupId The rendering group id corresponding to its index
  98293. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98294. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98295. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98296. */
  98297. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98298. /**
  98299. * Gets the current auto clear configuration for one rendering group of the rendering
  98300. * manager.
  98301. * @param index the rendering group index to get the information for
  98302. * @returns The auto clear setup for the requested rendering group
  98303. */
  98304. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98305. private _blockMaterialDirtyMechanism;
  98306. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  98307. blockMaterialDirtyMechanism: boolean;
  98308. /**
  98309. * Will flag all materials as dirty to trigger new shader compilation
  98310. * @param flag defines the flag used to specify which material part must be marked as dirty
  98311. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  98312. */
  98313. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98314. /** @hidden */
  98315. _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;
  98316. /** @hidden */
  98317. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98318. }
  98319. }
  98320. declare module BABYLON {
  98321. /**
  98322. * Set of assets to keep when moving a scene into an asset container.
  98323. */
  98324. export class KeepAssets extends AbstractScene {
  98325. }
  98326. /**
  98327. * Container with a set of assets that can be added or removed from a scene.
  98328. */
  98329. export class AssetContainer extends AbstractScene {
  98330. /**
  98331. * The scene the AssetContainer belongs to.
  98332. */
  98333. scene: Scene;
  98334. /**
  98335. * Instantiates an AssetContainer.
  98336. * @param scene The scene the AssetContainer belongs to.
  98337. */
  98338. constructor(scene: Scene);
  98339. /**
  98340. * Adds all the assets from the container to the scene.
  98341. */
  98342. addAllToScene(): void;
  98343. /**
  98344. * Removes all the assets in the container from the scene
  98345. */
  98346. removeAllFromScene(): void;
  98347. /**
  98348. * Disposes all the assets in the container
  98349. */
  98350. dispose(): void;
  98351. private _moveAssets;
  98352. /**
  98353. * Removes all the assets contained in the scene and adds them to the container.
  98354. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  98355. */
  98356. moveAllFromScene(keepAssets?: KeepAssets): void;
  98357. /**
  98358. * 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.
  98359. * @returns the root mesh
  98360. */
  98361. createRootMesh(): Mesh;
  98362. }
  98363. }
  98364. declare module BABYLON {
  98365. /**
  98366. * Defines how the parser contract is defined.
  98367. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  98368. */
  98369. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  98370. /**
  98371. * Defines how the individual parser contract is defined.
  98372. * These parser can parse an individual asset
  98373. */
  98374. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  98375. /**
  98376. * Base class of the scene acting as a container for the different elements composing a scene.
  98377. * This class is dynamically extended by the different components of the scene increasing
  98378. * flexibility and reducing coupling
  98379. */
  98380. export abstract class AbstractScene {
  98381. /**
  98382. * Stores the list of available parsers in the application.
  98383. */
  98384. private static _BabylonFileParsers;
  98385. /**
  98386. * Stores the list of available individual parsers in the application.
  98387. */
  98388. private static _IndividualBabylonFileParsers;
  98389. /**
  98390. * Adds a parser in the list of available ones
  98391. * @param name Defines the name of the parser
  98392. * @param parser Defines the parser to add
  98393. */
  98394. static AddParser(name: string, parser: BabylonFileParser): void;
  98395. /**
  98396. * Gets a general parser from the list of avaialble ones
  98397. * @param name Defines the name of the parser
  98398. * @returns the requested parser or null
  98399. */
  98400. static GetParser(name: string): Nullable<BabylonFileParser>;
  98401. /**
  98402. * Adds n individual parser in the list of available ones
  98403. * @param name Defines the name of the parser
  98404. * @param parser Defines the parser to add
  98405. */
  98406. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  98407. /**
  98408. * Gets an individual parser from the list of avaialble ones
  98409. * @param name Defines the name of the parser
  98410. * @returns the requested parser or null
  98411. */
  98412. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  98413. /**
  98414. * Parser json data and populate both a scene and its associated container object
  98415. * @param jsonData Defines the data to parse
  98416. * @param scene Defines the scene to parse the data for
  98417. * @param container Defines the container attached to the parsing sequence
  98418. * @param rootUrl Defines the root url of the data
  98419. */
  98420. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  98421. /**
  98422. * Gets the list of root nodes (ie. nodes with no parent)
  98423. */
  98424. rootNodes: Node[];
  98425. /** All of the cameras added to this scene
  98426. * @see http://doc.babylonjs.com/babylon101/cameras
  98427. */
  98428. cameras: Camera[];
  98429. /**
  98430. * All of the lights added to this scene
  98431. * @see http://doc.babylonjs.com/babylon101/lights
  98432. */
  98433. lights: Light[];
  98434. /**
  98435. * All of the (abstract) meshes added to this scene
  98436. */
  98437. meshes: AbstractMesh[];
  98438. /**
  98439. * The list of skeletons added to the scene
  98440. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98441. */
  98442. skeletons: Skeleton[];
  98443. /**
  98444. * All of the particle systems added to this scene
  98445. * @see http://doc.babylonjs.com/babylon101/particles
  98446. */
  98447. particleSystems: IParticleSystem[];
  98448. /**
  98449. * Gets a list of Animations associated with the scene
  98450. */
  98451. animations: Animation[];
  98452. /**
  98453. * All of the animation groups added to this scene
  98454. * @see http://doc.babylonjs.com/how_to/group
  98455. */
  98456. animationGroups: AnimationGroup[];
  98457. /**
  98458. * All of the multi-materials added to this scene
  98459. * @see http://doc.babylonjs.com/how_to/multi_materials
  98460. */
  98461. multiMaterials: MultiMaterial[];
  98462. /**
  98463. * All of the materials added to this scene
  98464. * In the context of a Scene, it is not supposed to be modified manually.
  98465. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  98466. * Note also that the order of the Material wihin the array is not significant and might change.
  98467. * @see http://doc.babylonjs.com/babylon101/materials
  98468. */
  98469. materials: Material[];
  98470. /**
  98471. * The list of morph target managers added to the scene
  98472. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  98473. */
  98474. morphTargetManagers: MorphTargetManager[];
  98475. /**
  98476. * The list of geometries used in the scene.
  98477. */
  98478. geometries: Geometry[];
  98479. /**
  98480. * All of the tranform nodes added to this scene
  98481. * In the context of a Scene, it is not supposed to be modified manually.
  98482. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  98483. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  98484. * @see http://doc.babylonjs.com/how_to/transformnode
  98485. */
  98486. transformNodes: TransformNode[];
  98487. /**
  98488. * ActionManagers available on the scene.
  98489. */
  98490. actionManagers: AbstractActionManager[];
  98491. /**
  98492. * Textures to keep.
  98493. */
  98494. textures: BaseTexture[];
  98495. /**
  98496. * Environment texture for the scene
  98497. */
  98498. environmentTexture: Nullable<BaseTexture>;
  98499. }
  98500. }
  98501. declare module BABYLON {
  98502. /**
  98503. * Interface used to define options for Sound class
  98504. */
  98505. export interface ISoundOptions {
  98506. /**
  98507. * Does the sound autoplay once loaded.
  98508. */
  98509. autoplay?: boolean;
  98510. /**
  98511. * Does the sound loop after it finishes playing once.
  98512. */
  98513. loop?: boolean;
  98514. /**
  98515. * Sound's volume
  98516. */
  98517. volume?: number;
  98518. /**
  98519. * Is it a spatial sound?
  98520. */
  98521. spatialSound?: boolean;
  98522. /**
  98523. * Maximum distance to hear that sound
  98524. */
  98525. maxDistance?: number;
  98526. /**
  98527. * Uses user defined attenuation function
  98528. */
  98529. useCustomAttenuation?: boolean;
  98530. /**
  98531. * Define the roll off factor of spatial sounds.
  98532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98533. */
  98534. rolloffFactor?: number;
  98535. /**
  98536. * Define the reference distance the sound should be heard perfectly.
  98537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98538. */
  98539. refDistance?: number;
  98540. /**
  98541. * Define the distance attenuation model the sound will follow.
  98542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98543. */
  98544. distanceModel?: string;
  98545. /**
  98546. * Defines the playback speed (1 by default)
  98547. */
  98548. playbackRate?: number;
  98549. /**
  98550. * Defines if the sound is from a streaming source
  98551. */
  98552. streaming?: boolean;
  98553. /**
  98554. * Defines an optional length (in seconds) inside the sound file
  98555. */
  98556. length?: number;
  98557. /**
  98558. * Defines an optional offset (in seconds) inside the sound file
  98559. */
  98560. offset?: number;
  98561. /**
  98562. * If true, URLs will not be required to state the audio file codec to use.
  98563. */
  98564. skipCodecCheck?: boolean;
  98565. }
  98566. /**
  98567. * Defines a sound that can be played in the application.
  98568. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  98569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98570. */
  98571. export class Sound {
  98572. /**
  98573. * The name of the sound in the scene.
  98574. */
  98575. name: string;
  98576. /**
  98577. * Does the sound autoplay once loaded.
  98578. */
  98579. autoplay: boolean;
  98580. /**
  98581. * Does the sound loop after it finishes playing once.
  98582. */
  98583. loop: boolean;
  98584. /**
  98585. * Does the sound use a custom attenuation curve to simulate the falloff
  98586. * happening when the source gets further away from the camera.
  98587. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98588. */
  98589. useCustomAttenuation: boolean;
  98590. /**
  98591. * The sound track id this sound belongs to.
  98592. */
  98593. soundTrackId: number;
  98594. /**
  98595. * Is this sound currently played.
  98596. */
  98597. isPlaying: boolean;
  98598. /**
  98599. * Is this sound currently paused.
  98600. */
  98601. isPaused: boolean;
  98602. /**
  98603. * Does this sound enables spatial sound.
  98604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98605. */
  98606. spatialSound: boolean;
  98607. /**
  98608. * Define the reference distance the sound should be heard perfectly.
  98609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98610. */
  98611. refDistance: number;
  98612. /**
  98613. * Define the roll off factor of spatial sounds.
  98614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98615. */
  98616. rolloffFactor: number;
  98617. /**
  98618. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  98619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98620. */
  98621. maxDistance: number;
  98622. /**
  98623. * Define the distance attenuation model the sound will follow.
  98624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98625. */
  98626. distanceModel: string;
  98627. /**
  98628. * @hidden
  98629. * Back Compat
  98630. **/
  98631. onended: () => any;
  98632. /**
  98633. * Observable event when the current playing sound finishes.
  98634. */
  98635. onEndedObservable: Observable<Sound>;
  98636. private _panningModel;
  98637. private _playbackRate;
  98638. private _streaming;
  98639. private _startTime;
  98640. private _startOffset;
  98641. private _position;
  98642. /** @hidden */
  98643. _positionInEmitterSpace: boolean;
  98644. private _localDirection;
  98645. private _volume;
  98646. private _isReadyToPlay;
  98647. private _isDirectional;
  98648. private _readyToPlayCallback;
  98649. private _audioBuffer;
  98650. private _soundSource;
  98651. private _streamingSource;
  98652. private _soundPanner;
  98653. private _soundGain;
  98654. private _inputAudioNode;
  98655. private _outputAudioNode;
  98656. private _coneInnerAngle;
  98657. private _coneOuterAngle;
  98658. private _coneOuterGain;
  98659. private _scene;
  98660. private _connectedTransformNode;
  98661. private _customAttenuationFunction;
  98662. private _registerFunc;
  98663. private _isOutputConnected;
  98664. private _htmlAudioElement;
  98665. private _urlType;
  98666. private _length?;
  98667. private _offset?;
  98668. /** @hidden */
  98669. static _SceneComponentInitialization: (scene: Scene) => void;
  98670. /**
  98671. * Create a sound and attach it to a scene
  98672. * @param name Name of your sound
  98673. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  98674. * @param scene defines the scene the sound belongs to
  98675. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  98676. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  98677. */
  98678. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  98679. /**
  98680. * Release the sound and its associated resources
  98681. */
  98682. dispose(): void;
  98683. /**
  98684. * Gets if the sounds is ready to be played or not.
  98685. * @returns true if ready, otherwise false
  98686. */
  98687. isReady(): boolean;
  98688. private _soundLoaded;
  98689. /**
  98690. * Sets the data of the sound from an audiobuffer
  98691. * @param audioBuffer The audioBuffer containing the data
  98692. */
  98693. setAudioBuffer(audioBuffer: AudioBuffer): void;
  98694. /**
  98695. * Updates the current sounds options such as maxdistance, loop...
  98696. * @param options A JSON object containing values named as the object properties
  98697. */
  98698. updateOptions(options: ISoundOptions): void;
  98699. private _createSpatialParameters;
  98700. private _updateSpatialParameters;
  98701. /**
  98702. * Switch the panning model to HRTF:
  98703. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  98704. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98705. */
  98706. switchPanningModelToHRTF(): void;
  98707. /**
  98708. * Switch the panning model to Equal Power:
  98709. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  98710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98711. */
  98712. switchPanningModelToEqualPower(): void;
  98713. private _switchPanningModel;
  98714. /**
  98715. * Connect this sound to a sound track audio node like gain...
  98716. * @param soundTrackAudioNode the sound track audio node to connect to
  98717. */
  98718. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  98719. /**
  98720. * Transform this sound into a directional source
  98721. * @param coneInnerAngle Size of the inner cone in degree
  98722. * @param coneOuterAngle Size of the outer cone in degree
  98723. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  98724. */
  98725. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  98726. /**
  98727. * Gets or sets the inner angle for the directional cone.
  98728. */
  98729. /**
  98730. * Gets or sets the inner angle for the directional cone.
  98731. */
  98732. directionalConeInnerAngle: number;
  98733. /**
  98734. * Gets or sets the outer angle for the directional cone.
  98735. */
  98736. /**
  98737. * Gets or sets the outer angle for the directional cone.
  98738. */
  98739. directionalConeOuterAngle: number;
  98740. /**
  98741. * Sets the position of the emitter if spatial sound is enabled
  98742. * @param newPosition Defines the new posisiton
  98743. */
  98744. setPosition(newPosition: Vector3): void;
  98745. /**
  98746. * Sets the local direction of the emitter if spatial sound is enabled
  98747. * @param newLocalDirection Defines the new local direction
  98748. */
  98749. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  98750. private _updateDirection;
  98751. /** @hidden */
  98752. updateDistanceFromListener(): void;
  98753. /**
  98754. * Sets a new custom attenuation function for the sound.
  98755. * @param callback Defines the function used for the attenuation
  98756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98757. */
  98758. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  98759. /**
  98760. * Play the sound
  98761. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  98762. * @param offset (optional) Start the sound at a specific time in seconds
  98763. * @param length (optional) Sound duration (in seconds)
  98764. */
  98765. play(time?: number, offset?: number, length?: number): void;
  98766. private _onended;
  98767. /**
  98768. * Stop the sound
  98769. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  98770. */
  98771. stop(time?: number): void;
  98772. /**
  98773. * Put the sound in pause
  98774. */
  98775. pause(): void;
  98776. /**
  98777. * Sets a dedicated volume for this sounds
  98778. * @param newVolume Define the new volume of the sound
  98779. * @param time Define time for gradual change to new volume
  98780. */
  98781. setVolume(newVolume: number, time?: number): void;
  98782. /**
  98783. * Set the sound play back rate
  98784. * @param newPlaybackRate Define the playback rate the sound should be played at
  98785. */
  98786. setPlaybackRate(newPlaybackRate: number): void;
  98787. /**
  98788. * Gets the volume of the sound.
  98789. * @returns the volume of the sound
  98790. */
  98791. getVolume(): number;
  98792. /**
  98793. * Attach the sound to a dedicated mesh
  98794. * @param transformNode The transform node to connect the sound with
  98795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  98796. */
  98797. attachToMesh(transformNode: TransformNode): void;
  98798. /**
  98799. * Detach the sound from the previously attached mesh
  98800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  98801. */
  98802. detachFromMesh(): void;
  98803. private _onRegisterAfterWorldMatrixUpdate;
  98804. /**
  98805. * Clone the current sound in the scene.
  98806. * @returns the new sound clone
  98807. */
  98808. clone(): Nullable<Sound>;
  98809. /**
  98810. * Gets the current underlying audio buffer containing the data
  98811. * @returns the audio buffer
  98812. */
  98813. getAudioBuffer(): Nullable<AudioBuffer>;
  98814. /**
  98815. * Serializes the Sound in a JSON representation
  98816. * @returns the JSON representation of the sound
  98817. */
  98818. serialize(): any;
  98819. /**
  98820. * Parse a JSON representation of a sound to innstantiate in a given scene
  98821. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  98822. * @param scene Define the scene the new parsed sound should be created in
  98823. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  98824. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  98825. * @returns the newly parsed sound
  98826. */
  98827. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  98828. }
  98829. }
  98830. declare module BABYLON {
  98831. /**
  98832. * This defines an action helpful to play a defined sound on a triggered action.
  98833. */
  98834. export class PlaySoundAction extends Action {
  98835. private _sound;
  98836. /**
  98837. * Instantiate the action
  98838. * @param triggerOptions defines the trigger options
  98839. * @param sound defines the sound to play
  98840. * @param condition defines the trigger related conditions
  98841. */
  98842. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98843. /** @hidden */
  98844. _prepare(): void;
  98845. /**
  98846. * Execute the action and play the sound.
  98847. */
  98848. execute(): void;
  98849. /**
  98850. * Serializes the actions and its related information.
  98851. * @param parent defines the object to serialize in
  98852. * @returns the serialized object
  98853. */
  98854. serialize(parent: any): any;
  98855. }
  98856. /**
  98857. * This defines an action helpful to stop a defined sound on a triggered action.
  98858. */
  98859. export class StopSoundAction extends Action {
  98860. private _sound;
  98861. /**
  98862. * Instantiate the action
  98863. * @param triggerOptions defines the trigger options
  98864. * @param sound defines the sound to stop
  98865. * @param condition defines the trigger related conditions
  98866. */
  98867. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98868. /** @hidden */
  98869. _prepare(): void;
  98870. /**
  98871. * Execute the action and stop the sound.
  98872. */
  98873. execute(): void;
  98874. /**
  98875. * Serializes the actions and its related information.
  98876. * @param parent defines the object to serialize in
  98877. * @returns the serialized object
  98878. */
  98879. serialize(parent: any): any;
  98880. }
  98881. }
  98882. declare module BABYLON {
  98883. /**
  98884. * This defines an action responsible to change the value of a property
  98885. * by interpolating between its current value and the newly set one once triggered.
  98886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98887. */
  98888. export class InterpolateValueAction extends Action {
  98889. /**
  98890. * Defines the path of the property where the value should be interpolated
  98891. */
  98892. propertyPath: string;
  98893. /**
  98894. * Defines the target value at the end of the interpolation.
  98895. */
  98896. value: any;
  98897. /**
  98898. * Defines the time it will take for the property to interpolate to the value.
  98899. */
  98900. duration: number;
  98901. /**
  98902. * Defines if the other scene animations should be stopped when the action has been triggered
  98903. */
  98904. stopOtherAnimations?: boolean;
  98905. /**
  98906. * Defines a callback raised once the interpolation animation has been done.
  98907. */
  98908. onInterpolationDone?: () => void;
  98909. /**
  98910. * Observable triggered once the interpolation animation has been done.
  98911. */
  98912. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  98913. private _target;
  98914. private _effectiveTarget;
  98915. private _property;
  98916. /**
  98917. * Instantiate the action
  98918. * @param triggerOptions defines the trigger options
  98919. * @param target defines the object containing the value to interpolate
  98920. * @param propertyPath defines the path to the property in the target object
  98921. * @param value defines the target value at the end of the interpolation
  98922. * @param duration deines the time it will take for the property to interpolate to the value.
  98923. * @param condition defines the trigger related conditions
  98924. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  98925. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  98926. */
  98927. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  98928. /** @hidden */
  98929. _prepare(): void;
  98930. /**
  98931. * Execute the action starts the value interpolation.
  98932. */
  98933. execute(): void;
  98934. /**
  98935. * Serializes the actions and its related information.
  98936. * @param parent defines the object to serialize in
  98937. * @returns the serialized object
  98938. */
  98939. serialize(parent: any): any;
  98940. }
  98941. }
  98942. declare module BABYLON {
  98943. /**
  98944. * Options allowed during the creation of a sound track.
  98945. */
  98946. export interface ISoundTrackOptions {
  98947. /**
  98948. * The volume the sound track should take during creation
  98949. */
  98950. volume?: number;
  98951. /**
  98952. * Define if the sound track is the main sound track of the scene
  98953. */
  98954. mainTrack?: boolean;
  98955. }
  98956. /**
  98957. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  98958. * It will be also used in a future release to apply effects on a specific track.
  98959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  98960. */
  98961. export class SoundTrack {
  98962. /**
  98963. * The unique identifier of the sound track in the scene.
  98964. */
  98965. id: number;
  98966. /**
  98967. * The list of sounds included in the sound track.
  98968. */
  98969. soundCollection: Array<Sound>;
  98970. private _outputAudioNode;
  98971. private _scene;
  98972. private _isMainTrack;
  98973. private _connectedAnalyser;
  98974. private _options;
  98975. private _isInitialized;
  98976. /**
  98977. * Creates a new sound track.
  98978. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  98979. * @param scene Define the scene the sound track belongs to
  98980. * @param options
  98981. */
  98982. constructor(scene: Scene, options?: ISoundTrackOptions);
  98983. private _initializeSoundTrackAudioGraph;
  98984. /**
  98985. * Release the sound track and its associated resources
  98986. */
  98987. dispose(): void;
  98988. /**
  98989. * Adds a sound to this sound track
  98990. * @param sound define the cound to add
  98991. * @ignoreNaming
  98992. */
  98993. AddSound(sound: Sound): void;
  98994. /**
  98995. * Removes a sound to this sound track
  98996. * @param sound define the cound to remove
  98997. * @ignoreNaming
  98998. */
  98999. RemoveSound(sound: Sound): void;
  99000. /**
  99001. * Set a global volume for the full sound track.
  99002. * @param newVolume Define the new volume of the sound track
  99003. */
  99004. setVolume(newVolume: number): void;
  99005. /**
  99006. * Switch the panning model to HRTF:
  99007. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99009. */
  99010. switchPanningModelToHRTF(): void;
  99011. /**
  99012. * Switch the panning model to Equal Power:
  99013. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99015. */
  99016. switchPanningModelToEqualPower(): void;
  99017. /**
  99018. * Connect the sound track to an audio analyser allowing some amazing
  99019. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99020. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99021. * @param analyser The analyser to connect to the engine
  99022. */
  99023. connectToAnalyser(analyser: Analyser): void;
  99024. }
  99025. }
  99026. declare module BABYLON {
  99027. interface AbstractScene {
  99028. /**
  99029. * The list of sounds used in the scene.
  99030. */
  99031. sounds: Nullable<Array<Sound>>;
  99032. }
  99033. interface Scene {
  99034. /**
  99035. * @hidden
  99036. * Backing field
  99037. */
  99038. _mainSoundTrack: SoundTrack;
  99039. /**
  99040. * The main sound track played by the scene.
  99041. * It cotains your primary collection of sounds.
  99042. */
  99043. mainSoundTrack: SoundTrack;
  99044. /**
  99045. * The list of sound tracks added to the scene
  99046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99047. */
  99048. soundTracks: Nullable<Array<SoundTrack>>;
  99049. /**
  99050. * Gets a sound using a given name
  99051. * @param name defines the name to search for
  99052. * @return the found sound or null if not found at all.
  99053. */
  99054. getSoundByName(name: string): Nullable<Sound>;
  99055. /**
  99056. * Gets or sets if audio support is enabled
  99057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99058. */
  99059. audioEnabled: boolean;
  99060. /**
  99061. * Gets or sets if audio will be output to headphones
  99062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99063. */
  99064. headphone: boolean;
  99065. }
  99066. /**
  99067. * Defines the sound scene component responsible to manage any sounds
  99068. * in a given scene.
  99069. */
  99070. export class AudioSceneComponent implements ISceneSerializableComponent {
  99071. /**
  99072. * The component name helpfull to identify the component in the list of scene components.
  99073. */
  99074. readonly name: string;
  99075. /**
  99076. * The scene the component belongs to.
  99077. */
  99078. scene: Scene;
  99079. private _audioEnabled;
  99080. /**
  99081. * Gets whether audio is enabled or not.
  99082. * Please use related enable/disable method to switch state.
  99083. */
  99084. readonly audioEnabled: boolean;
  99085. private _headphone;
  99086. /**
  99087. * Gets whether audio is outputing to headphone or not.
  99088. * Please use the according Switch methods to change output.
  99089. */
  99090. readonly headphone: boolean;
  99091. /**
  99092. * Creates a new instance of the component for the given scene
  99093. * @param scene Defines the scene to register the component in
  99094. */
  99095. constructor(scene: Scene);
  99096. /**
  99097. * Registers the component in a given scene
  99098. */
  99099. register(): void;
  99100. /**
  99101. * Rebuilds the elements related to this component in case of
  99102. * context lost for instance.
  99103. */
  99104. rebuild(): void;
  99105. /**
  99106. * Serializes the component data to the specified json object
  99107. * @param serializationObject The object to serialize to
  99108. */
  99109. serialize(serializationObject: any): void;
  99110. /**
  99111. * Adds all the elements from the container to the scene
  99112. * @param container the container holding the elements
  99113. */
  99114. addFromContainer(container: AbstractScene): void;
  99115. /**
  99116. * Removes all the elements in the container from the scene
  99117. * @param container contains the elements to remove
  99118. * @param dispose if the removed element should be disposed (default: false)
  99119. */
  99120. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  99121. /**
  99122. * Disposes the component and the associated ressources.
  99123. */
  99124. dispose(): void;
  99125. /**
  99126. * Disables audio in the associated scene.
  99127. */
  99128. disableAudio(): void;
  99129. /**
  99130. * Enables audio in the associated scene.
  99131. */
  99132. enableAudio(): void;
  99133. /**
  99134. * Switch audio to headphone output.
  99135. */
  99136. switchAudioModeForHeadphones(): void;
  99137. /**
  99138. * Switch audio to normal speakers.
  99139. */
  99140. switchAudioModeForNormalSpeakers(): void;
  99141. private _afterRender;
  99142. }
  99143. }
  99144. declare module BABYLON {
  99145. /**
  99146. * Wraps one or more Sound objects and selects one with random weight for playback.
  99147. */
  99148. export class WeightedSound {
  99149. /** When true a Sound will be selected and played when the current playing Sound completes. */
  99150. loop: boolean;
  99151. private _coneInnerAngle;
  99152. private _coneOuterAngle;
  99153. private _volume;
  99154. /** A Sound is currently playing. */
  99155. isPlaying: boolean;
  99156. /** A Sound is currently paused. */
  99157. isPaused: boolean;
  99158. private _sounds;
  99159. private _weights;
  99160. private _currentIndex?;
  99161. /**
  99162. * Creates a new WeightedSound from the list of sounds given.
  99163. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  99164. * @param sounds Array of Sounds that will be selected from.
  99165. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  99166. */
  99167. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  99168. /**
  99169. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  99170. */
  99171. /**
  99172. * The size of cone in degress for a directional sound in which there will be no attenuation.
  99173. */
  99174. directionalConeInnerAngle: number;
  99175. /**
  99176. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99177. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99178. */
  99179. /**
  99180. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99181. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99182. */
  99183. directionalConeOuterAngle: number;
  99184. /**
  99185. * Playback volume.
  99186. */
  99187. /**
  99188. * Playback volume.
  99189. */
  99190. volume: number;
  99191. private _onended;
  99192. /**
  99193. * Suspend playback
  99194. */
  99195. pause(): void;
  99196. /**
  99197. * Stop playback
  99198. */
  99199. stop(): void;
  99200. /**
  99201. * Start playback.
  99202. * @param startOffset Position the clip head at a specific time in seconds.
  99203. */
  99204. play(startOffset?: number): void;
  99205. }
  99206. }
  99207. declare module BABYLON {
  99208. /**
  99209. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  99210. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99211. */
  99212. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  99213. /**
  99214. * Gets the name of the behavior.
  99215. */
  99216. readonly name: string;
  99217. /**
  99218. * The easing function used by animations
  99219. */
  99220. static EasingFunction: BackEase;
  99221. /**
  99222. * The easing mode used by animations
  99223. */
  99224. static EasingMode: number;
  99225. /**
  99226. * The duration of the animation, in milliseconds
  99227. */
  99228. transitionDuration: number;
  99229. /**
  99230. * Length of the distance animated by the transition when lower radius is reached
  99231. */
  99232. lowerRadiusTransitionRange: number;
  99233. /**
  99234. * Length of the distance animated by the transition when upper radius is reached
  99235. */
  99236. upperRadiusTransitionRange: number;
  99237. private _autoTransitionRange;
  99238. /**
  99239. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99240. */
  99241. /**
  99242. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99243. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  99244. */
  99245. autoTransitionRange: boolean;
  99246. private _attachedCamera;
  99247. private _onAfterCheckInputsObserver;
  99248. private _onMeshTargetChangedObserver;
  99249. /**
  99250. * Initializes the behavior.
  99251. */
  99252. init(): void;
  99253. /**
  99254. * Attaches the behavior to its arc rotate camera.
  99255. * @param camera Defines the camera to attach the behavior to
  99256. */
  99257. attach(camera: ArcRotateCamera): void;
  99258. /**
  99259. * Detaches the behavior from its current arc rotate camera.
  99260. */
  99261. detach(): void;
  99262. private _radiusIsAnimating;
  99263. private _radiusBounceTransition;
  99264. private _animatables;
  99265. private _cachedWheelPrecision;
  99266. /**
  99267. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  99268. * @param radiusLimit The limit to check against.
  99269. * @return Bool to indicate if at limit.
  99270. */
  99271. private _isRadiusAtLimit;
  99272. /**
  99273. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  99274. * @param radiusDelta The delta by which to animate to. Can be negative.
  99275. */
  99276. private _applyBoundRadiusAnimation;
  99277. /**
  99278. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  99279. */
  99280. protected _clearAnimationLocks(): void;
  99281. /**
  99282. * Stops and removes all animations that have been applied to the camera
  99283. */
  99284. stopAllAnimations(): void;
  99285. }
  99286. }
  99287. declare module BABYLON {
  99288. /**
  99289. * 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.
  99290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99291. */
  99292. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  99293. /**
  99294. * Gets the name of the behavior.
  99295. */
  99296. readonly name: string;
  99297. private _mode;
  99298. private _radiusScale;
  99299. private _positionScale;
  99300. private _defaultElevation;
  99301. private _elevationReturnTime;
  99302. private _elevationReturnWaitTime;
  99303. private _zoomStopsAnimation;
  99304. private _framingTime;
  99305. /**
  99306. * The easing function used by animations
  99307. */
  99308. static EasingFunction: ExponentialEase;
  99309. /**
  99310. * The easing mode used by animations
  99311. */
  99312. static EasingMode: number;
  99313. /**
  99314. * Sets the current mode used by the behavior
  99315. */
  99316. /**
  99317. * Gets current mode used by the behavior.
  99318. */
  99319. mode: number;
  99320. /**
  99321. * Sets the scale applied to the radius (1 by default)
  99322. */
  99323. /**
  99324. * Gets the scale applied to the radius
  99325. */
  99326. radiusScale: number;
  99327. /**
  99328. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99329. */
  99330. /**
  99331. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99332. */
  99333. positionScale: number;
  99334. /**
  99335. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99336. * behaviour is triggered, in radians.
  99337. */
  99338. /**
  99339. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99340. * behaviour is triggered, in radians.
  99341. */
  99342. defaultElevation: number;
  99343. /**
  99344. * Sets the time (in milliseconds) taken to return to the default beta position.
  99345. * Negative value indicates camera should not return to default.
  99346. */
  99347. /**
  99348. * Gets the time (in milliseconds) taken to return to the default beta position.
  99349. * Negative value indicates camera should not return to default.
  99350. */
  99351. elevationReturnTime: number;
  99352. /**
  99353. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99354. */
  99355. /**
  99356. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99357. */
  99358. elevationReturnWaitTime: number;
  99359. /**
  99360. * Sets the flag that indicates if user zooming should stop animation.
  99361. */
  99362. /**
  99363. * Gets the flag that indicates if user zooming should stop animation.
  99364. */
  99365. zoomStopsAnimation: boolean;
  99366. /**
  99367. * Sets the transition time when framing the mesh, in milliseconds
  99368. */
  99369. /**
  99370. * Gets the transition time when framing the mesh, in milliseconds
  99371. */
  99372. framingTime: number;
  99373. /**
  99374. * Define if the behavior should automatically change the configured
  99375. * camera limits and sensibilities.
  99376. */
  99377. autoCorrectCameraLimitsAndSensibility: boolean;
  99378. private _onPrePointerObservableObserver;
  99379. private _onAfterCheckInputsObserver;
  99380. private _onMeshTargetChangedObserver;
  99381. private _attachedCamera;
  99382. private _isPointerDown;
  99383. private _lastInteractionTime;
  99384. /**
  99385. * Initializes the behavior.
  99386. */
  99387. init(): void;
  99388. /**
  99389. * Attaches the behavior to its arc rotate camera.
  99390. * @param camera Defines the camera to attach the behavior to
  99391. */
  99392. attach(camera: ArcRotateCamera): void;
  99393. /**
  99394. * Detaches the behavior from its current arc rotate camera.
  99395. */
  99396. detach(): void;
  99397. private _animatables;
  99398. private _betaIsAnimating;
  99399. private _betaTransition;
  99400. private _radiusTransition;
  99401. private _vectorTransition;
  99402. /**
  99403. * Targets the given mesh and updates zoom level accordingly.
  99404. * @param mesh The mesh to target.
  99405. * @param radius Optional. If a cached radius position already exists, overrides default.
  99406. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99407. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99408. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99409. */
  99410. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99411. /**
  99412. * Targets the given mesh with its children and updates zoom level accordingly.
  99413. * @param mesh The mesh to target.
  99414. * @param radius Optional. If a cached radius position already exists, overrides default.
  99415. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99416. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99417. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99418. */
  99419. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99420. /**
  99421. * Targets the given meshes with their children and updates zoom level accordingly.
  99422. * @param meshes The mesh to target.
  99423. * @param radius Optional. If a cached radius position already exists, overrides default.
  99424. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99425. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99426. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99427. */
  99428. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99429. /**
  99430. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  99431. * @param minimumWorld Determines the smaller position of the bounding box extend
  99432. * @param maximumWorld Determines the bigger position of the bounding box extend
  99433. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99434. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99435. */
  99436. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99437. /**
  99438. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  99439. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  99440. * frustum width.
  99441. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  99442. * to fully enclose the mesh in the viewing frustum.
  99443. */
  99444. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  99445. /**
  99446. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  99447. * is automatically returned to its default position (expected to be above ground plane).
  99448. */
  99449. private _maintainCameraAboveGround;
  99450. /**
  99451. * Returns the frustum slope based on the canvas ratio and camera FOV
  99452. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  99453. */
  99454. private _getFrustumSlope;
  99455. /**
  99456. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  99457. */
  99458. private _clearAnimationLocks;
  99459. /**
  99460. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  99461. */
  99462. private _applyUserInteraction;
  99463. /**
  99464. * Stops and removes all animations that have been applied to the camera
  99465. */
  99466. stopAllAnimations(): void;
  99467. /**
  99468. * Gets a value indicating if the user is moving the camera
  99469. */
  99470. readonly isUserIsMoving: boolean;
  99471. /**
  99472. * The camera can move all the way towards the mesh.
  99473. */
  99474. static IgnoreBoundsSizeMode: number;
  99475. /**
  99476. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  99477. */
  99478. static FitFrustumSidesMode: number;
  99479. }
  99480. }
  99481. declare module BABYLON {
  99482. /**
  99483. * Base class for Camera Pointer Inputs.
  99484. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  99485. * for example usage.
  99486. */
  99487. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  99488. /**
  99489. * Defines the camera the input is attached to.
  99490. */
  99491. abstract camera: Camera;
  99492. /**
  99493. * Whether keyboard modifier keys are pressed at time of last mouse event.
  99494. */
  99495. protected _altKey: boolean;
  99496. protected _ctrlKey: boolean;
  99497. protected _metaKey: boolean;
  99498. protected _shiftKey: boolean;
  99499. /**
  99500. * Which mouse buttons were pressed at time of last mouse event.
  99501. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  99502. */
  99503. protected _buttonsPressed: number;
  99504. /**
  99505. * Defines the buttons associated with the input to handle camera move.
  99506. */
  99507. buttons: number[];
  99508. /**
  99509. * Attach the input controls to a specific dom element to get the input from.
  99510. * @param element Defines the element the controls should be listened from
  99511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99512. */
  99513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99514. /**
  99515. * Detach the current controls from the specified dom element.
  99516. * @param element Defines the element to stop listening the inputs from
  99517. */
  99518. detachControl(element: Nullable<HTMLElement>): void;
  99519. /**
  99520. * Gets the class name of the current input.
  99521. * @returns the class name
  99522. */
  99523. getClassName(): string;
  99524. /**
  99525. * Get the friendly name associated with the input class.
  99526. * @returns the input friendly name
  99527. */
  99528. getSimpleName(): string;
  99529. /**
  99530. * Called on pointer POINTERDOUBLETAP event.
  99531. * Override this method to provide functionality on POINTERDOUBLETAP event.
  99532. */
  99533. protected onDoubleTap(type: string): void;
  99534. /**
  99535. * Called on pointer POINTERMOVE event if only a single touch is active.
  99536. * Override this method to provide functionality.
  99537. */
  99538. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99539. /**
  99540. * Called on pointer POINTERMOVE event if multiple touches are active.
  99541. * Override this method to provide functionality.
  99542. */
  99543. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99544. /**
  99545. * Called on JS contextmenu event.
  99546. * Override this method to provide functionality.
  99547. */
  99548. protected onContextMenu(evt: PointerEvent): void;
  99549. /**
  99550. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99551. * press.
  99552. * Override this method to provide functionality.
  99553. */
  99554. protected onButtonDown(evt: PointerEvent): void;
  99555. /**
  99556. * Called each time a new POINTERUP event occurs. Ie, for each button
  99557. * release.
  99558. * Override this method to provide functionality.
  99559. */
  99560. protected onButtonUp(evt: PointerEvent): void;
  99561. /**
  99562. * Called when window becomes inactive.
  99563. * Override this method to provide functionality.
  99564. */
  99565. protected onLostFocus(): void;
  99566. private _pointerInput;
  99567. private _observer;
  99568. private _onLostFocus;
  99569. private pointA;
  99570. private pointB;
  99571. }
  99572. }
  99573. declare module BABYLON {
  99574. /**
  99575. * Manage the pointers inputs to control an arc rotate camera.
  99576. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99577. */
  99578. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  99579. /**
  99580. * Defines the camera the input is attached to.
  99581. */
  99582. camera: ArcRotateCamera;
  99583. /**
  99584. * Gets the class name of the current input.
  99585. * @returns the class name
  99586. */
  99587. getClassName(): string;
  99588. /**
  99589. * Defines the buttons associated with the input to handle camera move.
  99590. */
  99591. buttons: number[];
  99592. /**
  99593. * Defines the pointer angular sensibility along the X axis or how fast is
  99594. * the camera rotating.
  99595. */
  99596. angularSensibilityX: number;
  99597. /**
  99598. * Defines the pointer angular sensibility along the Y axis or how fast is
  99599. * the camera rotating.
  99600. */
  99601. angularSensibilityY: number;
  99602. /**
  99603. * Defines the pointer pinch precision or how fast is the camera zooming.
  99604. */
  99605. pinchPrecision: number;
  99606. /**
  99607. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99608. * from 0.
  99609. * It defines the percentage of current camera.radius to use as delta when
  99610. * pinch zoom is used.
  99611. */
  99612. pinchDeltaPercentage: number;
  99613. /**
  99614. * Defines the pointer panning sensibility or how fast is the camera moving.
  99615. */
  99616. panningSensibility: number;
  99617. /**
  99618. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  99619. */
  99620. multiTouchPanning: boolean;
  99621. /**
  99622. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  99623. * zoom (pinch) through multitouch.
  99624. */
  99625. multiTouchPanAndZoom: boolean;
  99626. /**
  99627. * Revers pinch action direction.
  99628. */
  99629. pinchInwards: boolean;
  99630. private _isPanClick;
  99631. private _twoFingerActivityCount;
  99632. private _isPinching;
  99633. /**
  99634. * Called on pointer POINTERMOVE event if only a single touch is active.
  99635. */
  99636. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99637. /**
  99638. * Called on pointer POINTERDOUBLETAP event.
  99639. */
  99640. protected onDoubleTap(type: string): void;
  99641. /**
  99642. * Called on pointer POINTERMOVE event if multiple touches are active.
  99643. */
  99644. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99645. /**
  99646. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99647. * press.
  99648. */
  99649. protected onButtonDown(evt: PointerEvent): void;
  99650. /**
  99651. * Called each time a new POINTERUP event occurs. Ie, for each button
  99652. * release.
  99653. */
  99654. protected onButtonUp(evt: PointerEvent): void;
  99655. /**
  99656. * Called when window becomes inactive.
  99657. */
  99658. protected onLostFocus(): void;
  99659. }
  99660. }
  99661. declare module BABYLON {
  99662. /**
  99663. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  99664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99665. */
  99666. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  99667. /**
  99668. * Defines the camera the input is attached to.
  99669. */
  99670. camera: ArcRotateCamera;
  99671. /**
  99672. * Defines the list of key codes associated with the up action (increase alpha)
  99673. */
  99674. keysUp: number[];
  99675. /**
  99676. * Defines the list of key codes associated with the down action (decrease alpha)
  99677. */
  99678. keysDown: number[];
  99679. /**
  99680. * Defines the list of key codes associated with the left action (increase beta)
  99681. */
  99682. keysLeft: number[];
  99683. /**
  99684. * Defines the list of key codes associated with the right action (decrease beta)
  99685. */
  99686. keysRight: number[];
  99687. /**
  99688. * Defines the list of key codes associated with the reset action.
  99689. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  99690. */
  99691. keysReset: number[];
  99692. /**
  99693. * Defines the panning sensibility of the inputs.
  99694. * (How fast is the camera paning)
  99695. */
  99696. panningSensibility: number;
  99697. /**
  99698. * Defines the zooming sensibility of the inputs.
  99699. * (How fast is the camera zooming)
  99700. */
  99701. zoomingSensibility: number;
  99702. /**
  99703. * Defines wether maintaining the alt key down switch the movement mode from
  99704. * orientation to zoom.
  99705. */
  99706. useAltToZoom: boolean;
  99707. /**
  99708. * Rotation speed of the camera
  99709. */
  99710. angularSpeed: number;
  99711. private _keys;
  99712. private _ctrlPressed;
  99713. private _altPressed;
  99714. private _onCanvasBlurObserver;
  99715. private _onKeyboardObserver;
  99716. private _engine;
  99717. private _scene;
  99718. /**
  99719. * Attach the input controls to a specific dom element to get the input from.
  99720. * @param element Defines the element the controls should be listened from
  99721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99722. */
  99723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99724. /**
  99725. * Detach the current controls from the specified dom element.
  99726. * @param element Defines the element to stop listening the inputs from
  99727. */
  99728. detachControl(element: Nullable<HTMLElement>): void;
  99729. /**
  99730. * Update the current camera state depending on the inputs that have been used this frame.
  99731. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99732. */
  99733. checkInputs(): void;
  99734. /**
  99735. * Gets the class name of the current intput.
  99736. * @returns the class name
  99737. */
  99738. getClassName(): string;
  99739. /**
  99740. * Get the friendly name associated with the input class.
  99741. * @returns the input friendly name
  99742. */
  99743. getSimpleName(): string;
  99744. }
  99745. }
  99746. declare module BABYLON {
  99747. /**
  99748. * Manage the mouse wheel inputs to control an arc rotate camera.
  99749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99750. */
  99751. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  99752. /**
  99753. * Defines the camera the input is attached to.
  99754. */
  99755. camera: ArcRotateCamera;
  99756. /**
  99757. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  99758. */
  99759. wheelPrecision: number;
  99760. /**
  99761. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99762. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99763. */
  99764. wheelDeltaPercentage: number;
  99765. private _wheel;
  99766. private _observer;
  99767. private computeDeltaFromMouseWheelLegacyEvent;
  99768. /**
  99769. * Attach the input controls to a specific dom element to get the input from.
  99770. * @param element Defines the element the controls should be listened from
  99771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99772. */
  99773. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99774. /**
  99775. * Detach the current controls from the specified dom element.
  99776. * @param element Defines the element to stop listening the inputs from
  99777. */
  99778. detachControl(element: Nullable<HTMLElement>): void;
  99779. /**
  99780. * Gets the class name of the current intput.
  99781. * @returns the class name
  99782. */
  99783. getClassName(): string;
  99784. /**
  99785. * Get the friendly name associated with the input class.
  99786. * @returns the input friendly name
  99787. */
  99788. getSimpleName(): string;
  99789. }
  99790. }
  99791. declare module BABYLON {
  99792. /**
  99793. * Default Inputs manager for the ArcRotateCamera.
  99794. * It groups all the default supported inputs for ease of use.
  99795. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99796. */
  99797. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  99798. /**
  99799. * Instantiates a new ArcRotateCameraInputsManager.
  99800. * @param camera Defines the camera the inputs belong to
  99801. */
  99802. constructor(camera: ArcRotateCamera);
  99803. /**
  99804. * Add mouse wheel input support to the input manager.
  99805. * @returns the current input manager
  99806. */
  99807. addMouseWheel(): ArcRotateCameraInputsManager;
  99808. /**
  99809. * Add pointers input support to the input manager.
  99810. * @returns the current input manager
  99811. */
  99812. addPointers(): ArcRotateCameraInputsManager;
  99813. /**
  99814. * Add keyboard input support to the input manager.
  99815. * @returns the current input manager
  99816. */
  99817. addKeyboard(): ArcRotateCameraInputsManager;
  99818. }
  99819. }
  99820. declare module BABYLON {
  99821. /**
  99822. * This represents an orbital type of camera.
  99823. *
  99824. * 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.
  99825. * 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.
  99826. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  99827. */
  99828. export class ArcRotateCamera extends TargetCamera {
  99829. /**
  99830. * Defines the rotation angle of the camera along the longitudinal axis.
  99831. */
  99832. alpha: number;
  99833. /**
  99834. * Defines the rotation angle of the camera along the latitudinal axis.
  99835. */
  99836. beta: number;
  99837. /**
  99838. * Defines the radius of the camera from it s target point.
  99839. */
  99840. radius: number;
  99841. protected _target: Vector3;
  99842. protected _targetHost: Nullable<AbstractMesh>;
  99843. /**
  99844. * Defines the target point of the camera.
  99845. * The camera looks towards it form the radius distance.
  99846. */
  99847. target: Vector3;
  99848. /**
  99849. * Define the current local position of the camera in the scene
  99850. */
  99851. position: Vector3;
  99852. protected _upVector: Vector3;
  99853. protected _upToYMatrix: Matrix;
  99854. protected _YToUpMatrix: Matrix;
  99855. /**
  99856. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  99857. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  99858. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  99859. */
  99860. upVector: Vector3;
  99861. /**
  99862. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  99863. */
  99864. setMatUp(): void;
  99865. /**
  99866. * Current inertia value on the longitudinal axis.
  99867. * The bigger this number the longer it will take for the camera to stop.
  99868. */
  99869. inertialAlphaOffset: number;
  99870. /**
  99871. * Current inertia value on the latitudinal axis.
  99872. * The bigger this number the longer it will take for the camera to stop.
  99873. */
  99874. inertialBetaOffset: number;
  99875. /**
  99876. * Current inertia value on the radius axis.
  99877. * The bigger this number the longer it will take for the camera to stop.
  99878. */
  99879. inertialRadiusOffset: number;
  99880. /**
  99881. * Minimum allowed angle on the longitudinal axis.
  99882. * This can help limiting how the Camera is able to move in the scene.
  99883. */
  99884. lowerAlphaLimit: Nullable<number>;
  99885. /**
  99886. * Maximum allowed angle on the longitudinal axis.
  99887. * This can help limiting how the Camera is able to move in the scene.
  99888. */
  99889. upperAlphaLimit: Nullable<number>;
  99890. /**
  99891. * Minimum allowed angle on the latitudinal axis.
  99892. * This can help limiting how the Camera is able to move in the scene.
  99893. */
  99894. lowerBetaLimit: number;
  99895. /**
  99896. * Maximum allowed angle on the latitudinal axis.
  99897. * This can help limiting how the Camera is able to move in the scene.
  99898. */
  99899. upperBetaLimit: number;
  99900. /**
  99901. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  99902. * This can help limiting how the Camera is able to move in the scene.
  99903. */
  99904. lowerRadiusLimit: Nullable<number>;
  99905. /**
  99906. * Maximum allowed distance of the camera to the target (The camera can not get further).
  99907. * This can help limiting how the Camera is able to move in the scene.
  99908. */
  99909. upperRadiusLimit: Nullable<number>;
  99910. /**
  99911. * Defines the current inertia value used during panning of the camera along the X axis.
  99912. */
  99913. inertialPanningX: number;
  99914. /**
  99915. * Defines the current inertia value used during panning of the camera along the Y axis.
  99916. */
  99917. inertialPanningY: number;
  99918. /**
  99919. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  99920. * Basically if your fingers moves away from more than this distance you will be considered
  99921. * in pinch mode.
  99922. */
  99923. pinchToPanMaxDistance: number;
  99924. /**
  99925. * Defines the maximum distance the camera can pan.
  99926. * This could help keeping the cammera always in your scene.
  99927. */
  99928. panningDistanceLimit: Nullable<number>;
  99929. /**
  99930. * Defines the target of the camera before paning.
  99931. */
  99932. panningOriginTarget: Vector3;
  99933. /**
  99934. * Defines the value of the inertia used during panning.
  99935. * 0 would mean stop inertia and one would mean no decelleration at all.
  99936. */
  99937. panningInertia: number;
  99938. /**
  99939. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  99940. */
  99941. angularSensibilityX: number;
  99942. /**
  99943. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  99944. */
  99945. angularSensibilityY: number;
  99946. /**
  99947. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  99948. */
  99949. pinchPrecision: number;
  99950. /**
  99951. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  99952. * It will be used instead of pinchDeltaPrecision if different from 0.
  99953. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  99954. */
  99955. pinchDeltaPercentage: number;
  99956. /**
  99957. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  99958. */
  99959. panningSensibility: number;
  99960. /**
  99961. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  99962. */
  99963. keysUp: number[];
  99964. /**
  99965. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  99966. */
  99967. keysDown: number[];
  99968. /**
  99969. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  99970. */
  99971. keysLeft: number[];
  99972. /**
  99973. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  99974. */
  99975. keysRight: number[];
  99976. /**
  99977. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  99978. */
  99979. wheelPrecision: number;
  99980. /**
  99981. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  99982. * It will be used instead of pinchDeltaPrecision if different from 0.
  99983. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  99984. */
  99985. wheelDeltaPercentage: number;
  99986. /**
  99987. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  99988. */
  99989. zoomOnFactor: number;
  99990. /**
  99991. * Defines a screen offset for the camera position.
  99992. */
  99993. targetScreenOffset: Vector2;
  99994. /**
  99995. * Allows the camera to be completely reversed.
  99996. * If false the camera can not arrive upside down.
  99997. */
  99998. allowUpsideDown: boolean;
  99999. /**
  100000. * Define if double tap/click is used to restore the previously saved state of the camera.
  100001. */
  100002. useInputToRestoreState: boolean;
  100003. /** @hidden */
  100004. _viewMatrix: Matrix;
  100005. /** @hidden */
  100006. _useCtrlForPanning: boolean;
  100007. /** @hidden */
  100008. _panningMouseButton: number;
  100009. /**
  100010. * Defines the input associated to the camera.
  100011. */
  100012. inputs: ArcRotateCameraInputsManager;
  100013. /** @hidden */
  100014. _reset: () => void;
  100015. /**
  100016. * Defines the allowed panning axis.
  100017. */
  100018. panningAxis: Vector3;
  100019. protected _localDirection: Vector3;
  100020. protected _transformedDirection: Vector3;
  100021. private _bouncingBehavior;
  100022. /**
  100023. * Gets the bouncing behavior of the camera if it has been enabled.
  100024. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100025. */
  100026. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  100027. /**
  100028. * Defines if the bouncing behavior of the camera is enabled on the camera.
  100029. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100030. */
  100031. useBouncingBehavior: boolean;
  100032. private _framingBehavior;
  100033. /**
  100034. * Gets the framing behavior of the camera if it has been enabled.
  100035. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100036. */
  100037. readonly framingBehavior: Nullable<FramingBehavior>;
  100038. /**
  100039. * Defines if the framing behavior of the camera is enabled on the camera.
  100040. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100041. */
  100042. useFramingBehavior: boolean;
  100043. private _autoRotationBehavior;
  100044. /**
  100045. * Gets the auto rotation behavior of the camera if it has been enabled.
  100046. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100047. */
  100048. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  100049. /**
  100050. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  100051. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100052. */
  100053. useAutoRotationBehavior: boolean;
  100054. /**
  100055. * Observable triggered when the mesh target has been changed on the camera.
  100056. */
  100057. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  100058. /**
  100059. * Event raised when the camera is colliding with a mesh.
  100060. */
  100061. onCollide: (collidedMesh: AbstractMesh) => void;
  100062. /**
  100063. * Defines whether the camera should check collision with the objects oh the scene.
  100064. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  100065. */
  100066. checkCollisions: boolean;
  100067. /**
  100068. * Defines the collision radius of the camera.
  100069. * This simulates a sphere around the camera.
  100070. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100071. */
  100072. collisionRadius: Vector3;
  100073. protected _collider: Collider;
  100074. protected _previousPosition: Vector3;
  100075. protected _collisionVelocity: Vector3;
  100076. protected _newPosition: Vector3;
  100077. protected _previousAlpha: number;
  100078. protected _previousBeta: number;
  100079. protected _previousRadius: number;
  100080. protected _collisionTriggered: boolean;
  100081. protected _targetBoundingCenter: Nullable<Vector3>;
  100082. private _computationVector;
  100083. /**
  100084. * Instantiates a new ArcRotateCamera in a given scene
  100085. * @param name Defines the name of the camera
  100086. * @param alpha Defines the camera rotation along the logitudinal axis
  100087. * @param beta Defines the camera rotation along the latitudinal axis
  100088. * @param radius Defines the camera distance from its target
  100089. * @param target Defines the camera target
  100090. * @param scene Defines the scene the camera belongs to
  100091. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100092. */
  100093. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100094. /** @hidden */
  100095. _initCache(): void;
  100096. /** @hidden */
  100097. _updateCache(ignoreParentClass?: boolean): void;
  100098. protected _getTargetPosition(): Vector3;
  100099. private _storedAlpha;
  100100. private _storedBeta;
  100101. private _storedRadius;
  100102. private _storedTarget;
  100103. /**
  100104. * Stores the current state of the camera (alpha, beta, radius and target)
  100105. * @returns the camera itself
  100106. */
  100107. storeState(): Camera;
  100108. /**
  100109. * @hidden
  100110. * Restored camera state. You must call storeState() first
  100111. */
  100112. _restoreStateValues(): boolean;
  100113. /** @hidden */
  100114. _isSynchronizedViewMatrix(): boolean;
  100115. /**
  100116. * Attached controls to the current camera.
  100117. * @param element Defines the element the controls should be listened from
  100118. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100119. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  100120. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  100121. */
  100122. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  100123. /**
  100124. * Detach the current controls from the camera.
  100125. * The camera will stop reacting to inputs.
  100126. * @param element Defines the element to stop listening the inputs from
  100127. */
  100128. detachControl(element: HTMLElement): void;
  100129. /** @hidden */
  100130. _checkInputs(): void;
  100131. protected _checkLimits(): void;
  100132. /**
  100133. * Rebuilds angles (alpha, beta) and radius from the give position and target
  100134. */
  100135. rebuildAnglesAndRadius(): void;
  100136. /**
  100137. * Use a position to define the current camera related information like aplha, beta and radius
  100138. * @param position Defines the position to set the camera at
  100139. */
  100140. setPosition(position: Vector3): void;
  100141. /**
  100142. * Defines the target the camera should look at.
  100143. * This will automatically adapt alpha beta and radius to fit within the new target.
  100144. * @param target Defines the new target as a Vector or a mesh
  100145. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  100146. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  100147. */
  100148. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  100149. /** @hidden */
  100150. _getViewMatrix(): Matrix;
  100151. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  100152. /**
  100153. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  100154. * @param meshes Defines the mesh to zoom on
  100155. * @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)
  100156. */
  100157. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  100158. /**
  100159. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  100160. * The target will be changed but the radius
  100161. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  100162. * @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)
  100163. */
  100164. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  100165. min: Vector3;
  100166. max: Vector3;
  100167. distance: number;
  100168. }, doNotUpdateMaxZ?: boolean): void;
  100169. /**
  100170. * @override
  100171. * Override Camera.createRigCamera
  100172. */
  100173. createRigCamera(name: string, cameraIndex: number): Camera;
  100174. /**
  100175. * @hidden
  100176. * @override
  100177. * Override Camera._updateRigCameras
  100178. */
  100179. _updateRigCameras(): void;
  100180. /**
  100181. * Destroy the camera and release the current resources hold by it.
  100182. */
  100183. dispose(): void;
  100184. /**
  100185. * Gets the current object class name.
  100186. * @return the class name
  100187. */
  100188. getClassName(): string;
  100189. }
  100190. }
  100191. declare module BABYLON {
  100192. /**
  100193. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  100194. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100195. */
  100196. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  100197. /**
  100198. * Gets the name of the behavior.
  100199. */
  100200. readonly name: string;
  100201. private _zoomStopsAnimation;
  100202. private _idleRotationSpeed;
  100203. private _idleRotationWaitTime;
  100204. private _idleRotationSpinupTime;
  100205. /**
  100206. * Sets the flag that indicates if user zooming should stop animation.
  100207. */
  100208. /**
  100209. * Gets the flag that indicates if user zooming should stop animation.
  100210. */
  100211. zoomStopsAnimation: boolean;
  100212. /**
  100213. * Sets the default speed at which the camera rotates around the model.
  100214. */
  100215. /**
  100216. * Gets the default speed at which the camera rotates around the model.
  100217. */
  100218. idleRotationSpeed: number;
  100219. /**
  100220. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  100221. */
  100222. /**
  100223. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  100224. */
  100225. idleRotationWaitTime: number;
  100226. /**
  100227. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100228. */
  100229. /**
  100230. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100231. */
  100232. idleRotationSpinupTime: number;
  100233. /**
  100234. * Gets a value indicating if the camera is currently rotating because of this behavior
  100235. */
  100236. readonly rotationInProgress: boolean;
  100237. private _onPrePointerObservableObserver;
  100238. private _onAfterCheckInputsObserver;
  100239. private _attachedCamera;
  100240. private _isPointerDown;
  100241. private _lastFrameTime;
  100242. private _lastInteractionTime;
  100243. private _cameraRotationSpeed;
  100244. /**
  100245. * Initializes the behavior.
  100246. */
  100247. init(): void;
  100248. /**
  100249. * Attaches the behavior to its arc rotate camera.
  100250. * @param camera Defines the camera to attach the behavior to
  100251. */
  100252. attach(camera: ArcRotateCamera): void;
  100253. /**
  100254. * Detaches the behavior from its current arc rotate camera.
  100255. */
  100256. detach(): void;
  100257. /**
  100258. * Returns true if user is scrolling.
  100259. * @return true if user is scrolling.
  100260. */
  100261. private _userIsZooming;
  100262. private _lastFrameRadius;
  100263. private _shouldAnimationStopForInteraction;
  100264. /**
  100265. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100266. */
  100267. private _applyUserInteraction;
  100268. private _userIsMoving;
  100269. }
  100270. }
  100271. declare module BABYLON {
  100272. /**
  100273. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  100274. */
  100275. export class AttachToBoxBehavior implements Behavior<Mesh> {
  100276. private ui;
  100277. /**
  100278. * The name of the behavior
  100279. */
  100280. name: string;
  100281. /**
  100282. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  100283. */
  100284. distanceAwayFromFace: number;
  100285. /**
  100286. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  100287. */
  100288. distanceAwayFromBottomOfFace: number;
  100289. private _faceVectors;
  100290. private _target;
  100291. private _scene;
  100292. private _onRenderObserver;
  100293. private _tmpMatrix;
  100294. private _tmpVector;
  100295. /**
  100296. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  100297. * @param ui The transform node that should be attched to the mesh
  100298. */
  100299. constructor(ui: TransformNode);
  100300. /**
  100301. * Initializes the behavior
  100302. */
  100303. init(): void;
  100304. private _closestFace;
  100305. private _zeroVector;
  100306. private _lookAtTmpMatrix;
  100307. private _lookAtToRef;
  100308. /**
  100309. * Attaches the AttachToBoxBehavior to the passed in mesh
  100310. * @param target The mesh that the specified node will be attached to
  100311. */
  100312. attach(target: Mesh): void;
  100313. /**
  100314. * Detaches the behavior from the mesh
  100315. */
  100316. detach(): void;
  100317. }
  100318. }
  100319. declare module BABYLON {
  100320. /**
  100321. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  100322. */
  100323. export class FadeInOutBehavior implements Behavior<Mesh> {
  100324. /**
  100325. * Time in milliseconds to delay before fading in (Default: 0)
  100326. */
  100327. delay: number;
  100328. /**
  100329. * Time in milliseconds for the mesh to fade in (Default: 300)
  100330. */
  100331. fadeInTime: number;
  100332. private _millisecondsPerFrame;
  100333. private _hovered;
  100334. private _hoverValue;
  100335. private _ownerNode;
  100336. /**
  100337. * Instatiates the FadeInOutBehavior
  100338. */
  100339. constructor();
  100340. /**
  100341. * The name of the behavior
  100342. */
  100343. readonly name: string;
  100344. /**
  100345. * Initializes the behavior
  100346. */
  100347. init(): void;
  100348. /**
  100349. * Attaches the fade behavior on the passed in mesh
  100350. * @param ownerNode The mesh that will be faded in/out once attached
  100351. */
  100352. attach(ownerNode: Mesh): void;
  100353. /**
  100354. * Detaches the behavior from the mesh
  100355. */
  100356. detach(): void;
  100357. /**
  100358. * Triggers the mesh to begin fading in or out
  100359. * @param value if the object should fade in or out (true to fade in)
  100360. */
  100361. fadeIn(value: boolean): void;
  100362. private _update;
  100363. private _setAllVisibility;
  100364. }
  100365. }
  100366. declare module BABYLON {
  100367. /**
  100368. * Class containing a set of static utilities functions for managing Pivots
  100369. * @hidden
  100370. */
  100371. export class PivotTools {
  100372. private static _PivotCached;
  100373. private static _OldPivotPoint;
  100374. private static _PivotTranslation;
  100375. private static _PivotTmpVector;
  100376. /** @hidden */
  100377. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  100378. /** @hidden */
  100379. static _RestorePivotPoint(mesh: AbstractMesh): void;
  100380. }
  100381. }
  100382. declare module BABYLON {
  100383. /**
  100384. * Class containing static functions to help procedurally build meshes
  100385. */
  100386. export class PlaneBuilder {
  100387. /**
  100388. * Creates a plane mesh
  100389. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  100390. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  100391. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  100392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100395. * @param name defines the name of the mesh
  100396. * @param options defines the options used to create the mesh
  100397. * @param scene defines the hosting scene
  100398. * @returns the plane mesh
  100399. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  100400. */
  100401. static CreatePlane(name: string, options: {
  100402. size?: number;
  100403. width?: number;
  100404. height?: number;
  100405. sideOrientation?: number;
  100406. frontUVs?: Vector4;
  100407. backUVs?: Vector4;
  100408. updatable?: boolean;
  100409. sourcePlane?: Plane;
  100410. }, scene?: Nullable<Scene>): Mesh;
  100411. }
  100412. }
  100413. declare module BABYLON {
  100414. /**
  100415. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  100416. */
  100417. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  100418. private static _AnyMouseID;
  100419. /**
  100420. * Abstract mesh the behavior is set on
  100421. */
  100422. attachedNode: AbstractMesh;
  100423. private _dragPlane;
  100424. private _scene;
  100425. private _pointerObserver;
  100426. private _beforeRenderObserver;
  100427. private static _planeScene;
  100428. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  100429. /**
  100430. * 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)
  100431. */
  100432. maxDragAngle: number;
  100433. /**
  100434. * @hidden
  100435. */
  100436. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  100437. /**
  100438. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100439. */
  100440. currentDraggingPointerID: number;
  100441. /**
  100442. * The last position where the pointer hit the drag plane in world space
  100443. */
  100444. lastDragPosition: Vector3;
  100445. /**
  100446. * If the behavior is currently in a dragging state
  100447. */
  100448. dragging: boolean;
  100449. /**
  100450. * 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)
  100451. */
  100452. dragDeltaRatio: number;
  100453. /**
  100454. * If the drag plane orientation should be updated during the dragging (Default: true)
  100455. */
  100456. updateDragPlane: boolean;
  100457. private _debugMode;
  100458. private _moving;
  100459. /**
  100460. * Fires each time the attached mesh is dragged with the pointer
  100461. * * delta between last drag position and current drag position in world space
  100462. * * dragDistance along the drag axis
  100463. * * dragPlaneNormal normal of the current drag plane used during the drag
  100464. * * dragPlanePoint in world space where the drag intersects the drag plane
  100465. */
  100466. onDragObservable: Observable<{
  100467. delta: Vector3;
  100468. dragPlanePoint: Vector3;
  100469. dragPlaneNormal: Vector3;
  100470. dragDistance: number;
  100471. pointerId: number;
  100472. }>;
  100473. /**
  100474. * Fires each time a drag begins (eg. mouse down on mesh)
  100475. */
  100476. onDragStartObservable: Observable<{
  100477. dragPlanePoint: Vector3;
  100478. pointerId: number;
  100479. }>;
  100480. /**
  100481. * Fires each time a drag ends (eg. mouse release after drag)
  100482. */
  100483. onDragEndObservable: Observable<{
  100484. dragPlanePoint: Vector3;
  100485. pointerId: number;
  100486. }>;
  100487. /**
  100488. * If the attached mesh should be moved when dragged
  100489. */
  100490. moveAttached: boolean;
  100491. /**
  100492. * If the drag behavior will react to drag events (Default: true)
  100493. */
  100494. enabled: boolean;
  100495. /**
  100496. * If pointer events should start and release the drag (Default: true)
  100497. */
  100498. startAndReleaseDragOnPointerEvents: boolean;
  100499. /**
  100500. * If camera controls should be detached during the drag
  100501. */
  100502. detachCameraControls: boolean;
  100503. /**
  100504. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  100505. */
  100506. useObjectOrienationForDragging: boolean;
  100507. private _options;
  100508. /**
  100509. * Creates a pointer drag behavior that can be attached to a mesh
  100510. * @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)
  100511. */
  100512. constructor(options?: {
  100513. dragAxis?: Vector3;
  100514. dragPlaneNormal?: Vector3;
  100515. });
  100516. /**
  100517. * Predicate to determine if it is valid to move the object to a new position when it is moved
  100518. */
  100519. validateDrag: (targetPosition: Vector3) => boolean;
  100520. /**
  100521. * The name of the behavior
  100522. */
  100523. readonly name: string;
  100524. /**
  100525. * Initializes the behavior
  100526. */
  100527. init(): void;
  100528. private _tmpVector;
  100529. private _alternatePickedPoint;
  100530. private _worldDragAxis;
  100531. private _targetPosition;
  100532. private _attachedElement;
  100533. /**
  100534. * Attaches the drag behavior the passed in mesh
  100535. * @param ownerNode The mesh that will be dragged around once attached
  100536. */
  100537. attach(ownerNode: AbstractMesh): void;
  100538. /**
  100539. * Force relase the drag action by code.
  100540. */
  100541. releaseDrag(): void;
  100542. private _startDragRay;
  100543. private _lastPointerRay;
  100544. /**
  100545. * Simulates the start of a pointer drag event on the behavior
  100546. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  100547. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  100548. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  100549. */
  100550. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  100551. private _startDrag;
  100552. private _dragDelta;
  100553. private _moveDrag;
  100554. private _pickWithRayOnDragPlane;
  100555. private _pointA;
  100556. private _pointB;
  100557. private _pointC;
  100558. private _lineA;
  100559. private _lineB;
  100560. private _localAxis;
  100561. private _lookAt;
  100562. private _updateDragPlanePosition;
  100563. /**
  100564. * Detaches the behavior from the mesh
  100565. */
  100566. detach(): void;
  100567. }
  100568. }
  100569. declare module BABYLON {
  100570. /**
  100571. * A behavior that when attached to a mesh will allow the mesh to be scaled
  100572. */
  100573. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  100574. private _dragBehaviorA;
  100575. private _dragBehaviorB;
  100576. private _startDistance;
  100577. private _initialScale;
  100578. private _targetScale;
  100579. private _ownerNode;
  100580. private _sceneRenderObserver;
  100581. /**
  100582. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  100583. */
  100584. constructor();
  100585. /**
  100586. * The name of the behavior
  100587. */
  100588. readonly name: string;
  100589. /**
  100590. * Initializes the behavior
  100591. */
  100592. init(): void;
  100593. private _getCurrentDistance;
  100594. /**
  100595. * Attaches the scale behavior the passed in mesh
  100596. * @param ownerNode The mesh that will be scaled around once attached
  100597. */
  100598. attach(ownerNode: Mesh): void;
  100599. /**
  100600. * Detaches the behavior from the mesh
  100601. */
  100602. detach(): void;
  100603. }
  100604. }
  100605. declare module BABYLON {
  100606. /**
  100607. * 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
  100608. */
  100609. export class SixDofDragBehavior implements Behavior<Mesh> {
  100610. private static _virtualScene;
  100611. private _ownerNode;
  100612. private _sceneRenderObserver;
  100613. private _scene;
  100614. private _targetPosition;
  100615. private _virtualOriginMesh;
  100616. private _virtualDragMesh;
  100617. private _pointerObserver;
  100618. private _moving;
  100619. private _startingOrientation;
  100620. /**
  100621. * 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)
  100622. */
  100623. private zDragFactor;
  100624. /**
  100625. * If the object should rotate to face the drag origin
  100626. */
  100627. rotateDraggedObject: boolean;
  100628. /**
  100629. * If the behavior is currently in a dragging state
  100630. */
  100631. dragging: boolean;
  100632. /**
  100633. * 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)
  100634. */
  100635. dragDeltaRatio: number;
  100636. /**
  100637. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100638. */
  100639. currentDraggingPointerID: number;
  100640. /**
  100641. * If camera controls should be detached during the drag
  100642. */
  100643. detachCameraControls: boolean;
  100644. /**
  100645. * Fires each time a drag starts
  100646. */
  100647. onDragStartObservable: Observable<{}>;
  100648. /**
  100649. * Fires each time a drag ends (eg. mouse release after drag)
  100650. */
  100651. onDragEndObservable: Observable<{}>;
  100652. /**
  100653. * 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
  100654. */
  100655. constructor();
  100656. /**
  100657. * The name of the behavior
  100658. */
  100659. readonly name: string;
  100660. /**
  100661. * Initializes the behavior
  100662. */
  100663. init(): void;
  100664. /**
  100665. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  100666. */
  100667. private readonly _pointerCamera;
  100668. /**
  100669. * Attaches the scale behavior the passed in mesh
  100670. * @param ownerNode The mesh that will be scaled around once attached
  100671. */
  100672. attach(ownerNode: Mesh): void;
  100673. /**
  100674. * Detaches the behavior from the mesh
  100675. */
  100676. detach(): void;
  100677. }
  100678. }
  100679. declare module BABYLON {
  100680. /**
  100681. * Class used to apply inverse kinematics to bones
  100682. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  100683. */
  100684. export class BoneIKController {
  100685. private static _tmpVecs;
  100686. private static _tmpQuat;
  100687. private static _tmpMats;
  100688. /**
  100689. * Gets or sets the target mesh
  100690. */
  100691. targetMesh: AbstractMesh;
  100692. /** Gets or sets the mesh used as pole */
  100693. poleTargetMesh: AbstractMesh;
  100694. /**
  100695. * Gets or sets the bone used as pole
  100696. */
  100697. poleTargetBone: Nullable<Bone>;
  100698. /**
  100699. * Gets or sets the target position
  100700. */
  100701. targetPosition: Vector3;
  100702. /**
  100703. * Gets or sets the pole target position
  100704. */
  100705. poleTargetPosition: Vector3;
  100706. /**
  100707. * Gets or sets the pole target local offset
  100708. */
  100709. poleTargetLocalOffset: Vector3;
  100710. /**
  100711. * Gets or sets the pole angle
  100712. */
  100713. poleAngle: number;
  100714. /**
  100715. * Gets or sets the mesh associated with the controller
  100716. */
  100717. mesh: AbstractMesh;
  100718. /**
  100719. * 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)
  100720. */
  100721. slerpAmount: number;
  100722. private _bone1Quat;
  100723. private _bone1Mat;
  100724. private _bone2Ang;
  100725. private _bone1;
  100726. private _bone2;
  100727. private _bone1Length;
  100728. private _bone2Length;
  100729. private _maxAngle;
  100730. private _maxReach;
  100731. private _rightHandedSystem;
  100732. private _bendAxis;
  100733. private _slerping;
  100734. private _adjustRoll;
  100735. /**
  100736. * Gets or sets maximum allowed angle
  100737. */
  100738. maxAngle: number;
  100739. /**
  100740. * Creates a new BoneIKController
  100741. * @param mesh defines the mesh to control
  100742. * @param bone defines the bone to control
  100743. * @param options defines options to set up the controller
  100744. */
  100745. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  100746. targetMesh?: AbstractMesh;
  100747. poleTargetMesh?: AbstractMesh;
  100748. poleTargetBone?: Bone;
  100749. poleTargetLocalOffset?: Vector3;
  100750. poleAngle?: number;
  100751. bendAxis?: Vector3;
  100752. maxAngle?: number;
  100753. slerpAmount?: number;
  100754. });
  100755. private _setMaxAngle;
  100756. /**
  100757. * Force the controller to update the bones
  100758. */
  100759. update(): void;
  100760. }
  100761. }
  100762. declare module BABYLON {
  100763. /**
  100764. * Class used to make a bone look toward a point in space
  100765. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  100766. */
  100767. export class BoneLookController {
  100768. private static _tmpVecs;
  100769. private static _tmpQuat;
  100770. private static _tmpMats;
  100771. /**
  100772. * The target Vector3 that the bone will look at
  100773. */
  100774. target: Vector3;
  100775. /**
  100776. * The mesh that the bone is attached to
  100777. */
  100778. mesh: AbstractMesh;
  100779. /**
  100780. * The bone that will be looking to the target
  100781. */
  100782. bone: Bone;
  100783. /**
  100784. * The up axis of the coordinate system that is used when the bone is rotated
  100785. */
  100786. upAxis: Vector3;
  100787. /**
  100788. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  100789. */
  100790. upAxisSpace: Space;
  100791. /**
  100792. * Used to make an adjustment to the yaw of the bone
  100793. */
  100794. adjustYaw: number;
  100795. /**
  100796. * Used to make an adjustment to the pitch of the bone
  100797. */
  100798. adjustPitch: number;
  100799. /**
  100800. * Used to make an adjustment to the roll of the bone
  100801. */
  100802. adjustRoll: number;
  100803. /**
  100804. * 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)
  100805. */
  100806. slerpAmount: number;
  100807. private _minYaw;
  100808. private _maxYaw;
  100809. private _minPitch;
  100810. private _maxPitch;
  100811. private _minYawSin;
  100812. private _minYawCos;
  100813. private _maxYawSin;
  100814. private _maxYawCos;
  100815. private _midYawConstraint;
  100816. private _minPitchTan;
  100817. private _maxPitchTan;
  100818. private _boneQuat;
  100819. private _slerping;
  100820. private _transformYawPitch;
  100821. private _transformYawPitchInv;
  100822. private _firstFrameSkipped;
  100823. private _yawRange;
  100824. private _fowardAxis;
  100825. /**
  100826. * Gets or sets the minimum yaw angle that the bone can look to
  100827. */
  100828. minYaw: number;
  100829. /**
  100830. * Gets or sets the maximum yaw angle that the bone can look to
  100831. */
  100832. maxYaw: number;
  100833. /**
  100834. * Gets or sets the minimum pitch angle that the bone can look to
  100835. */
  100836. minPitch: number;
  100837. /**
  100838. * Gets or sets the maximum pitch angle that the bone can look to
  100839. */
  100840. maxPitch: number;
  100841. /**
  100842. * Create a BoneLookController
  100843. * @param mesh the mesh that the bone belongs to
  100844. * @param bone the bone that will be looking to the target
  100845. * @param target the target Vector3 to look at
  100846. * @param options optional settings:
  100847. * * maxYaw: the maximum angle the bone will yaw to
  100848. * * minYaw: the minimum angle the bone will yaw to
  100849. * * maxPitch: the maximum angle the bone will pitch to
  100850. * * minPitch: the minimum angle the bone will yaw to
  100851. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  100852. * * upAxis: the up axis of the coordinate system
  100853. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  100854. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  100855. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  100856. * * adjustYaw: used to make an adjustment to the yaw of the bone
  100857. * * adjustPitch: used to make an adjustment to the pitch of the bone
  100858. * * adjustRoll: used to make an adjustment to the roll of the bone
  100859. **/
  100860. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  100861. maxYaw?: number;
  100862. minYaw?: number;
  100863. maxPitch?: number;
  100864. minPitch?: number;
  100865. slerpAmount?: number;
  100866. upAxis?: Vector3;
  100867. upAxisSpace?: Space;
  100868. yawAxis?: Vector3;
  100869. pitchAxis?: Vector3;
  100870. adjustYaw?: number;
  100871. adjustPitch?: number;
  100872. adjustRoll?: number;
  100873. });
  100874. /**
  100875. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  100876. */
  100877. update(): void;
  100878. private _getAngleDiff;
  100879. private _getAngleBetween;
  100880. private _isAngleBetween;
  100881. }
  100882. }
  100883. declare module BABYLON {
  100884. /**
  100885. * Manage the gamepad inputs to control an arc rotate camera.
  100886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100887. */
  100888. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  100889. /**
  100890. * Defines the camera the input is attached to.
  100891. */
  100892. camera: ArcRotateCamera;
  100893. /**
  100894. * Defines the gamepad the input is gathering event from.
  100895. */
  100896. gamepad: Nullable<Gamepad>;
  100897. /**
  100898. * Defines the gamepad rotation sensiblity.
  100899. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100900. */
  100901. gamepadRotationSensibility: number;
  100902. /**
  100903. * Defines the gamepad move sensiblity.
  100904. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100905. */
  100906. gamepadMoveSensibility: number;
  100907. private _onGamepadConnectedObserver;
  100908. private _onGamepadDisconnectedObserver;
  100909. /**
  100910. * Attach the input controls to a specific dom element to get the input from.
  100911. * @param element Defines the element the controls should be listened from
  100912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100913. */
  100914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100915. /**
  100916. * Detach the current controls from the specified dom element.
  100917. * @param element Defines the element to stop listening the inputs from
  100918. */
  100919. detachControl(element: Nullable<HTMLElement>): void;
  100920. /**
  100921. * Update the current camera state depending on the inputs that have been used this frame.
  100922. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100923. */
  100924. checkInputs(): void;
  100925. /**
  100926. * Gets the class name of the current intput.
  100927. * @returns the class name
  100928. */
  100929. getClassName(): string;
  100930. /**
  100931. * Get the friendly name associated with the input class.
  100932. * @returns the input friendly name
  100933. */
  100934. getSimpleName(): string;
  100935. }
  100936. }
  100937. declare module BABYLON {
  100938. interface ArcRotateCameraInputsManager {
  100939. /**
  100940. * Add orientation input support to the input manager.
  100941. * @returns the current input manager
  100942. */
  100943. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  100944. }
  100945. /**
  100946. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  100947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100948. */
  100949. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  100950. /**
  100951. * Defines the camera the input is attached to.
  100952. */
  100953. camera: ArcRotateCamera;
  100954. /**
  100955. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  100956. */
  100957. alphaCorrection: number;
  100958. /**
  100959. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  100960. */
  100961. gammaCorrection: number;
  100962. private _alpha;
  100963. private _gamma;
  100964. private _dirty;
  100965. private _deviceOrientationHandler;
  100966. /**
  100967. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  100968. */
  100969. constructor();
  100970. /**
  100971. * Attach the input controls to a specific dom element to get the input from.
  100972. * @param element Defines the element the controls should be listened from
  100973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100974. */
  100975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100976. /** @hidden */
  100977. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  100978. /**
  100979. * Update the current camera state depending on the inputs that have been used this frame.
  100980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100981. */
  100982. checkInputs(): void;
  100983. /**
  100984. * Detach the current controls from the specified dom element.
  100985. * @param element Defines the element to stop listening the inputs from
  100986. */
  100987. detachControl(element: Nullable<HTMLElement>): void;
  100988. /**
  100989. * Gets the class name of the current intput.
  100990. * @returns the class name
  100991. */
  100992. getClassName(): string;
  100993. /**
  100994. * Get the friendly name associated with the input class.
  100995. * @returns the input friendly name
  100996. */
  100997. getSimpleName(): string;
  100998. }
  100999. }
  101000. declare module BABYLON {
  101001. /**
  101002. * Listen to mouse events to control the camera.
  101003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101004. */
  101005. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  101006. /**
  101007. * Defines the camera the input is attached to.
  101008. */
  101009. camera: FlyCamera;
  101010. /**
  101011. * Defines if touch is enabled. (Default is true.)
  101012. */
  101013. touchEnabled: boolean;
  101014. /**
  101015. * Defines the buttons associated with the input to handle camera rotation.
  101016. */
  101017. buttons: number[];
  101018. /**
  101019. * Assign buttons for Yaw control.
  101020. */
  101021. buttonsYaw: number[];
  101022. /**
  101023. * Assign buttons for Pitch control.
  101024. */
  101025. buttonsPitch: number[];
  101026. /**
  101027. * Assign buttons for Roll control.
  101028. */
  101029. buttonsRoll: number[];
  101030. /**
  101031. * Detect if any button is being pressed while mouse is moved.
  101032. * -1 = Mouse locked.
  101033. * 0 = Left button.
  101034. * 1 = Middle Button.
  101035. * 2 = Right Button.
  101036. */
  101037. activeButton: number;
  101038. /**
  101039. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  101040. * Higher values reduce its sensitivity.
  101041. */
  101042. angularSensibility: number;
  101043. private _mousemoveCallback;
  101044. private _observer;
  101045. private _rollObserver;
  101046. private previousPosition;
  101047. private noPreventDefault;
  101048. private element;
  101049. /**
  101050. * Listen to mouse events to control the camera.
  101051. * @param touchEnabled Define if touch is enabled. (Default is true.)
  101052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101053. */
  101054. constructor(touchEnabled?: boolean);
  101055. /**
  101056. * Attach the mouse control to the HTML DOM element.
  101057. * @param element Defines the element that listens to the input events.
  101058. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  101059. */
  101060. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101061. /**
  101062. * Detach the current controls from the specified dom element.
  101063. * @param element Defines the element to stop listening the inputs from
  101064. */
  101065. detachControl(element: Nullable<HTMLElement>): void;
  101066. /**
  101067. * Gets the class name of the current input.
  101068. * @returns the class name.
  101069. */
  101070. getClassName(): string;
  101071. /**
  101072. * Get the friendly name associated with the input class.
  101073. * @returns the input's friendly name.
  101074. */
  101075. getSimpleName(): string;
  101076. private _pointerInput;
  101077. private _onMouseMove;
  101078. /**
  101079. * Rotate camera by mouse offset.
  101080. */
  101081. private rotateCamera;
  101082. }
  101083. }
  101084. declare module BABYLON {
  101085. /**
  101086. * Default Inputs manager for the FlyCamera.
  101087. * It groups all the default supported inputs for ease of use.
  101088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101089. */
  101090. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  101091. /**
  101092. * Instantiates a new FlyCameraInputsManager.
  101093. * @param camera Defines the camera the inputs belong to.
  101094. */
  101095. constructor(camera: FlyCamera);
  101096. /**
  101097. * Add keyboard input support to the input manager.
  101098. * @returns the new FlyCameraKeyboardMoveInput().
  101099. */
  101100. addKeyboard(): FlyCameraInputsManager;
  101101. /**
  101102. * Add mouse input support to the input manager.
  101103. * @param touchEnabled Enable touch screen support.
  101104. * @returns the new FlyCameraMouseInput().
  101105. */
  101106. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  101107. }
  101108. }
  101109. declare module BABYLON {
  101110. /**
  101111. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101112. * such as in a 3D Space Shooter or a Flight Simulator.
  101113. */
  101114. export class FlyCamera extends TargetCamera {
  101115. /**
  101116. * Define the collision ellipsoid of the camera.
  101117. * This is helpful for simulating a camera body, like a player's body.
  101118. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101119. */
  101120. ellipsoid: Vector3;
  101121. /**
  101122. * Define an offset for the position of the ellipsoid around the camera.
  101123. * This can be helpful if the camera is attached away from the player's body center,
  101124. * such as at its head.
  101125. */
  101126. ellipsoidOffset: Vector3;
  101127. /**
  101128. * Enable or disable collisions of the camera with the rest of the scene objects.
  101129. */
  101130. checkCollisions: boolean;
  101131. /**
  101132. * Enable or disable gravity on the camera.
  101133. */
  101134. applyGravity: boolean;
  101135. /**
  101136. * Define the current direction the camera is moving to.
  101137. */
  101138. cameraDirection: Vector3;
  101139. /**
  101140. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  101141. * This overrides and empties cameraRotation.
  101142. */
  101143. rotationQuaternion: Quaternion;
  101144. /**
  101145. * Track Roll to maintain the wanted Rolling when looking around.
  101146. */
  101147. _trackRoll: number;
  101148. /**
  101149. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  101150. */
  101151. rollCorrect: number;
  101152. /**
  101153. * Mimic a banked turn, Rolling the camera when Yawing.
  101154. * It's recommended to use rollCorrect = 10 for faster banking correction.
  101155. */
  101156. bankedTurn: boolean;
  101157. /**
  101158. * Limit in radians for how much Roll banking will add. (Default: 90°)
  101159. */
  101160. bankedTurnLimit: number;
  101161. /**
  101162. * Value of 0 disables the banked Roll.
  101163. * Value of 1 is equal to the Yaw angle in radians.
  101164. */
  101165. bankedTurnMultiplier: number;
  101166. /**
  101167. * The inputs manager loads all the input sources, such as keyboard and mouse.
  101168. */
  101169. inputs: FlyCameraInputsManager;
  101170. /**
  101171. * Gets the input sensibility for mouse input.
  101172. * Higher values reduce sensitivity.
  101173. */
  101174. /**
  101175. * Sets the input sensibility for a mouse input.
  101176. * Higher values reduce sensitivity.
  101177. */
  101178. angularSensibility: number;
  101179. /**
  101180. * Get the keys for camera movement forward.
  101181. */
  101182. /**
  101183. * Set the keys for camera movement forward.
  101184. */
  101185. keysForward: number[];
  101186. /**
  101187. * Get the keys for camera movement backward.
  101188. */
  101189. keysBackward: number[];
  101190. /**
  101191. * Get the keys for camera movement up.
  101192. */
  101193. /**
  101194. * Set the keys for camera movement up.
  101195. */
  101196. keysUp: number[];
  101197. /**
  101198. * Get the keys for camera movement down.
  101199. */
  101200. /**
  101201. * Set the keys for camera movement down.
  101202. */
  101203. keysDown: number[];
  101204. /**
  101205. * Get the keys for camera movement left.
  101206. */
  101207. /**
  101208. * Set the keys for camera movement left.
  101209. */
  101210. keysLeft: number[];
  101211. /**
  101212. * Set the keys for camera movement right.
  101213. */
  101214. /**
  101215. * Set the keys for camera movement right.
  101216. */
  101217. keysRight: number[];
  101218. /**
  101219. * Event raised when the camera collides with a mesh in the scene.
  101220. */
  101221. onCollide: (collidedMesh: AbstractMesh) => void;
  101222. private _collider;
  101223. private _needMoveForGravity;
  101224. private _oldPosition;
  101225. private _diffPosition;
  101226. private _newPosition;
  101227. /** @hidden */
  101228. _localDirection: Vector3;
  101229. /** @hidden */
  101230. _transformedDirection: Vector3;
  101231. /**
  101232. * Instantiates a FlyCamera.
  101233. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101234. * such as in a 3D Space Shooter or a Flight Simulator.
  101235. * @param name Define the name of the camera in the scene.
  101236. * @param position Define the starting position of the camera in the scene.
  101237. * @param scene Define the scene the camera belongs to.
  101238. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  101239. */
  101240. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101241. /**
  101242. * Attach a control to the HTML DOM element.
  101243. * @param element Defines the element that listens to the input events.
  101244. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  101245. */
  101246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101247. /**
  101248. * Detach a control from the HTML DOM element.
  101249. * The camera will stop reacting to that input.
  101250. * @param element Defines the element that listens to the input events.
  101251. */
  101252. detachControl(element: HTMLElement): void;
  101253. private _collisionMask;
  101254. /**
  101255. * Get the mask that the camera ignores in collision events.
  101256. */
  101257. /**
  101258. * Set the mask that the camera ignores in collision events.
  101259. */
  101260. collisionMask: number;
  101261. /** @hidden */
  101262. _collideWithWorld(displacement: Vector3): void;
  101263. /** @hidden */
  101264. private _onCollisionPositionChange;
  101265. /** @hidden */
  101266. _checkInputs(): void;
  101267. /** @hidden */
  101268. _decideIfNeedsToMove(): boolean;
  101269. /** @hidden */
  101270. _updatePosition(): void;
  101271. /**
  101272. * Restore the Roll to its target value at the rate specified.
  101273. * @param rate - Higher means slower restoring.
  101274. * @hidden
  101275. */
  101276. restoreRoll(rate: number): void;
  101277. /**
  101278. * Destroy the camera and release the current resources held by it.
  101279. */
  101280. dispose(): void;
  101281. /**
  101282. * Get the current object class name.
  101283. * @returns the class name.
  101284. */
  101285. getClassName(): string;
  101286. }
  101287. }
  101288. declare module BABYLON {
  101289. /**
  101290. * Listen to keyboard events to control the camera.
  101291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101292. */
  101293. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  101294. /**
  101295. * Defines the camera the input is attached to.
  101296. */
  101297. camera: FlyCamera;
  101298. /**
  101299. * The list of keyboard keys used to control the forward move of the camera.
  101300. */
  101301. keysForward: number[];
  101302. /**
  101303. * The list of keyboard keys used to control the backward move of the camera.
  101304. */
  101305. keysBackward: number[];
  101306. /**
  101307. * The list of keyboard keys used to control the forward move of the camera.
  101308. */
  101309. keysUp: number[];
  101310. /**
  101311. * The list of keyboard keys used to control the backward move of the camera.
  101312. */
  101313. keysDown: number[];
  101314. /**
  101315. * The list of keyboard keys used to control the right strafe move of the camera.
  101316. */
  101317. keysRight: number[];
  101318. /**
  101319. * The list of keyboard keys used to control the left strafe move of the camera.
  101320. */
  101321. keysLeft: number[];
  101322. private _keys;
  101323. private _onCanvasBlurObserver;
  101324. private _onKeyboardObserver;
  101325. private _engine;
  101326. private _scene;
  101327. /**
  101328. * Attach the input controls to a specific dom element to get the input from.
  101329. * @param element Defines the element the controls should be listened from
  101330. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101331. */
  101332. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101333. /**
  101334. * Detach the current controls from the specified dom element.
  101335. * @param element Defines the element to stop listening the inputs from
  101336. */
  101337. detachControl(element: Nullable<HTMLElement>): void;
  101338. /**
  101339. * Gets the class name of the current intput.
  101340. * @returns the class name
  101341. */
  101342. getClassName(): string;
  101343. /** @hidden */
  101344. _onLostFocus(e: FocusEvent): void;
  101345. /**
  101346. * Get the friendly name associated with the input class.
  101347. * @returns the input friendly name
  101348. */
  101349. getSimpleName(): string;
  101350. /**
  101351. * Update the current camera state depending on the inputs that have been used this frame.
  101352. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101353. */
  101354. checkInputs(): void;
  101355. }
  101356. }
  101357. declare module BABYLON {
  101358. /**
  101359. * Manage the mouse wheel inputs to control a follow camera.
  101360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101361. */
  101362. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  101363. /**
  101364. * Defines the camera the input is attached to.
  101365. */
  101366. camera: FollowCamera;
  101367. /**
  101368. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  101369. */
  101370. axisControlRadius: boolean;
  101371. /**
  101372. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  101373. */
  101374. axisControlHeight: boolean;
  101375. /**
  101376. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  101377. */
  101378. axisControlRotation: boolean;
  101379. /**
  101380. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  101381. * relation to mouseWheel events.
  101382. */
  101383. wheelPrecision: number;
  101384. /**
  101385. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101386. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101387. */
  101388. wheelDeltaPercentage: number;
  101389. private _wheel;
  101390. private _observer;
  101391. /**
  101392. * Attach the input controls to a specific dom element to get the input from.
  101393. * @param element Defines the element the controls should be listened from
  101394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101395. */
  101396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101397. /**
  101398. * Detach the current controls from the specified dom element.
  101399. * @param element Defines the element to stop listening the inputs from
  101400. */
  101401. detachControl(element: Nullable<HTMLElement>): void;
  101402. /**
  101403. * Gets the class name of the current intput.
  101404. * @returns the class name
  101405. */
  101406. getClassName(): string;
  101407. /**
  101408. * Get the friendly name associated with the input class.
  101409. * @returns the input friendly name
  101410. */
  101411. getSimpleName(): string;
  101412. }
  101413. }
  101414. declare module BABYLON {
  101415. /**
  101416. * Manage the pointers inputs to control an follow camera.
  101417. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101418. */
  101419. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  101420. /**
  101421. * Defines the camera the input is attached to.
  101422. */
  101423. camera: FollowCamera;
  101424. /**
  101425. * Gets the class name of the current input.
  101426. * @returns the class name
  101427. */
  101428. getClassName(): string;
  101429. /**
  101430. * Defines the pointer angular sensibility along the X axis or how fast is
  101431. * the camera rotating.
  101432. * A negative number will reverse the axis direction.
  101433. */
  101434. angularSensibilityX: number;
  101435. /**
  101436. * Defines the pointer angular sensibility along the Y axis or how fast is
  101437. * the camera rotating.
  101438. * A negative number will reverse the axis direction.
  101439. */
  101440. angularSensibilityY: number;
  101441. /**
  101442. * Defines the pointer pinch precision or how fast is the camera zooming.
  101443. * A negative number will reverse the axis direction.
  101444. */
  101445. pinchPrecision: number;
  101446. /**
  101447. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101448. * from 0.
  101449. * It defines the percentage of current camera.radius to use as delta when
  101450. * pinch zoom is used.
  101451. */
  101452. pinchDeltaPercentage: number;
  101453. /**
  101454. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  101455. */
  101456. axisXControlRadius: boolean;
  101457. /**
  101458. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  101459. */
  101460. axisXControlHeight: boolean;
  101461. /**
  101462. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  101463. */
  101464. axisXControlRotation: boolean;
  101465. /**
  101466. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  101467. */
  101468. axisYControlRadius: boolean;
  101469. /**
  101470. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  101471. */
  101472. axisYControlHeight: boolean;
  101473. /**
  101474. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  101475. */
  101476. axisYControlRotation: boolean;
  101477. /**
  101478. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  101479. */
  101480. axisPinchControlRadius: boolean;
  101481. /**
  101482. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  101483. */
  101484. axisPinchControlHeight: boolean;
  101485. /**
  101486. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  101487. */
  101488. axisPinchControlRotation: boolean;
  101489. /**
  101490. * Log error messages if basic misconfiguration has occurred.
  101491. */
  101492. warningEnable: boolean;
  101493. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101494. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101495. private _warningCounter;
  101496. private _warning;
  101497. }
  101498. }
  101499. declare module BABYLON {
  101500. /**
  101501. * Default Inputs manager for the FollowCamera.
  101502. * It groups all the default supported inputs for ease of use.
  101503. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101504. */
  101505. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  101506. /**
  101507. * Instantiates a new FollowCameraInputsManager.
  101508. * @param camera Defines the camera the inputs belong to
  101509. */
  101510. constructor(camera: FollowCamera);
  101511. /**
  101512. * Add keyboard input support to the input manager.
  101513. * @returns the current input manager
  101514. */
  101515. addKeyboard(): FollowCameraInputsManager;
  101516. /**
  101517. * Add mouse wheel input support to the input manager.
  101518. * @returns the current input manager
  101519. */
  101520. addMouseWheel(): FollowCameraInputsManager;
  101521. /**
  101522. * Add pointers input support to the input manager.
  101523. * @returns the current input manager
  101524. */
  101525. addPointers(): FollowCameraInputsManager;
  101526. /**
  101527. * Add orientation input support to the input manager.
  101528. * @returns the current input manager
  101529. */
  101530. addVRDeviceOrientation(): FollowCameraInputsManager;
  101531. }
  101532. }
  101533. declare module BABYLON {
  101534. /**
  101535. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  101536. * an arc rotate version arcFollowCamera are available.
  101537. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101538. */
  101539. export class FollowCamera extends TargetCamera {
  101540. /**
  101541. * Distance the follow camera should follow an object at
  101542. */
  101543. radius: number;
  101544. /**
  101545. * Minimum allowed distance of the camera to the axis of rotation
  101546. * (The camera can not get closer).
  101547. * This can help limiting how the Camera is able to move in the scene.
  101548. */
  101549. lowerRadiusLimit: Nullable<number>;
  101550. /**
  101551. * Maximum allowed distance of the camera to the axis of rotation
  101552. * (The camera can not get further).
  101553. * This can help limiting how the Camera is able to move in the scene.
  101554. */
  101555. upperRadiusLimit: Nullable<number>;
  101556. /**
  101557. * Define a rotation offset between the camera and the object it follows
  101558. */
  101559. rotationOffset: number;
  101560. /**
  101561. * Minimum allowed angle to camera position relative to target object.
  101562. * This can help limiting how the Camera is able to move in the scene.
  101563. */
  101564. lowerRotationOffsetLimit: Nullable<number>;
  101565. /**
  101566. * Maximum allowed angle to camera position relative to target object.
  101567. * This can help limiting how the Camera is able to move in the scene.
  101568. */
  101569. upperRotationOffsetLimit: Nullable<number>;
  101570. /**
  101571. * Define a height offset between the camera and the object it follows.
  101572. * It can help following an object from the top (like a car chaing a plane)
  101573. */
  101574. heightOffset: number;
  101575. /**
  101576. * Minimum allowed height of camera position relative to target object.
  101577. * This can help limiting how the Camera is able to move in the scene.
  101578. */
  101579. lowerHeightOffsetLimit: Nullable<number>;
  101580. /**
  101581. * Maximum allowed height of camera position relative to target object.
  101582. * This can help limiting how the Camera is able to move in the scene.
  101583. */
  101584. upperHeightOffsetLimit: Nullable<number>;
  101585. /**
  101586. * Define how fast the camera can accelerate to follow it s target.
  101587. */
  101588. cameraAcceleration: number;
  101589. /**
  101590. * Define the speed limit of the camera following an object.
  101591. */
  101592. maxCameraSpeed: number;
  101593. /**
  101594. * Define the target of the camera.
  101595. */
  101596. lockedTarget: Nullable<AbstractMesh>;
  101597. /**
  101598. * Defines the input associated with the camera.
  101599. */
  101600. inputs: FollowCameraInputsManager;
  101601. /**
  101602. * Instantiates the follow camera.
  101603. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101604. * @param name Define the name of the camera in the scene
  101605. * @param position Define the position of the camera
  101606. * @param scene Define the scene the camera belong to
  101607. * @param lockedTarget Define the target of the camera
  101608. */
  101609. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  101610. private _follow;
  101611. /**
  101612. * Attached controls to the current camera.
  101613. * @param element Defines the element the controls should be listened from
  101614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101615. */
  101616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101617. /**
  101618. * Detach the current controls from the camera.
  101619. * The camera will stop reacting to inputs.
  101620. * @param element Defines the element to stop listening the inputs from
  101621. */
  101622. detachControl(element: HTMLElement): void;
  101623. /** @hidden */
  101624. _checkInputs(): void;
  101625. private _checkLimits;
  101626. /**
  101627. * Gets the camera class name.
  101628. * @returns the class name
  101629. */
  101630. getClassName(): string;
  101631. }
  101632. /**
  101633. * Arc Rotate version of the follow camera.
  101634. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  101635. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101636. */
  101637. export class ArcFollowCamera extends TargetCamera {
  101638. /** The longitudinal angle of the camera */
  101639. alpha: number;
  101640. /** The latitudinal angle of the camera */
  101641. beta: number;
  101642. /** The radius of the camera from its target */
  101643. radius: number;
  101644. /** Define the camera target (the messh it should follow) */
  101645. target: Nullable<AbstractMesh>;
  101646. private _cartesianCoordinates;
  101647. /**
  101648. * Instantiates a new ArcFollowCamera
  101649. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101650. * @param name Define the name of the camera
  101651. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  101652. * @param beta Define the rotation angle of the camera around the elevation axis
  101653. * @param radius Define the radius of the camera from its target point
  101654. * @param target Define the target of the camera
  101655. * @param scene Define the scene the camera belongs to
  101656. */
  101657. constructor(name: string,
  101658. /** The longitudinal angle of the camera */
  101659. alpha: number,
  101660. /** The latitudinal angle of the camera */
  101661. beta: number,
  101662. /** The radius of the camera from its target */
  101663. radius: number,
  101664. /** Define the camera target (the messh it should follow) */
  101665. target: Nullable<AbstractMesh>, scene: Scene);
  101666. private _follow;
  101667. /** @hidden */
  101668. _checkInputs(): void;
  101669. /**
  101670. * Returns the class name of the object.
  101671. * It is mostly used internally for serialization purposes.
  101672. */
  101673. getClassName(): string;
  101674. }
  101675. }
  101676. declare module BABYLON {
  101677. /**
  101678. * Manage the keyboard inputs to control the movement of a follow camera.
  101679. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101680. */
  101681. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  101682. /**
  101683. * Defines the camera the input is attached to.
  101684. */
  101685. camera: FollowCamera;
  101686. /**
  101687. * Defines the list of key codes associated with the up action (increase heightOffset)
  101688. */
  101689. keysHeightOffsetIncr: number[];
  101690. /**
  101691. * Defines the list of key codes associated with the down action (decrease heightOffset)
  101692. */
  101693. keysHeightOffsetDecr: number[];
  101694. /**
  101695. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  101696. */
  101697. keysHeightOffsetModifierAlt: boolean;
  101698. /**
  101699. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  101700. */
  101701. keysHeightOffsetModifierCtrl: boolean;
  101702. /**
  101703. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  101704. */
  101705. keysHeightOffsetModifierShift: boolean;
  101706. /**
  101707. * Defines the list of key codes associated with the left action (increase rotationOffset)
  101708. */
  101709. keysRotationOffsetIncr: number[];
  101710. /**
  101711. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  101712. */
  101713. keysRotationOffsetDecr: number[];
  101714. /**
  101715. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  101716. */
  101717. keysRotationOffsetModifierAlt: boolean;
  101718. /**
  101719. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  101720. */
  101721. keysRotationOffsetModifierCtrl: boolean;
  101722. /**
  101723. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  101724. */
  101725. keysRotationOffsetModifierShift: boolean;
  101726. /**
  101727. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  101728. */
  101729. keysRadiusIncr: number[];
  101730. /**
  101731. * Defines the list of key codes associated with the zoom-out action (increase radius)
  101732. */
  101733. keysRadiusDecr: number[];
  101734. /**
  101735. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  101736. */
  101737. keysRadiusModifierAlt: boolean;
  101738. /**
  101739. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  101740. */
  101741. keysRadiusModifierCtrl: boolean;
  101742. /**
  101743. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  101744. */
  101745. keysRadiusModifierShift: boolean;
  101746. /**
  101747. * Defines the rate of change of heightOffset.
  101748. */
  101749. heightSensibility: number;
  101750. /**
  101751. * Defines the rate of change of rotationOffset.
  101752. */
  101753. rotationSensibility: number;
  101754. /**
  101755. * Defines the rate of change of radius.
  101756. */
  101757. radiusSensibility: number;
  101758. private _keys;
  101759. private _ctrlPressed;
  101760. private _altPressed;
  101761. private _shiftPressed;
  101762. private _onCanvasBlurObserver;
  101763. private _onKeyboardObserver;
  101764. private _engine;
  101765. private _scene;
  101766. /**
  101767. * Attach the input controls to a specific dom element to get the input from.
  101768. * @param element Defines the element the controls should be listened from
  101769. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101770. */
  101771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101772. /**
  101773. * Detach the current controls from the specified dom element.
  101774. * @param element Defines the element to stop listening the inputs from
  101775. */
  101776. detachControl(element: Nullable<HTMLElement>): void;
  101777. /**
  101778. * Update the current camera state depending on the inputs that have been used this frame.
  101779. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101780. */
  101781. checkInputs(): void;
  101782. /**
  101783. * Gets the class name of the current input.
  101784. * @returns the class name
  101785. */
  101786. getClassName(): string;
  101787. /**
  101788. * Get the friendly name associated with the input class.
  101789. * @returns the input friendly name
  101790. */
  101791. getSimpleName(): string;
  101792. /**
  101793. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101794. * allow modification of the heightOffset value.
  101795. */
  101796. private _modifierHeightOffset;
  101797. /**
  101798. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101799. * allow modification of the rotationOffset value.
  101800. */
  101801. private _modifierRotationOffset;
  101802. /**
  101803. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101804. * allow modification of the radius value.
  101805. */
  101806. private _modifierRadius;
  101807. }
  101808. }
  101809. declare module BABYLON {
  101810. interface FreeCameraInputsManager {
  101811. /**
  101812. * @hidden
  101813. */
  101814. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  101815. /**
  101816. * Add orientation input support to the input manager.
  101817. * @returns the current input manager
  101818. */
  101819. addDeviceOrientation(): FreeCameraInputsManager;
  101820. }
  101821. /**
  101822. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  101823. * Screen rotation is taken into account.
  101824. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101825. */
  101826. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  101827. private _camera;
  101828. private _screenOrientationAngle;
  101829. private _constantTranform;
  101830. private _screenQuaternion;
  101831. private _alpha;
  101832. private _beta;
  101833. private _gamma;
  101834. /**
  101835. * Can be used to detect if a device orientation sensor is availible on a device
  101836. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  101837. * @returns a promise that will resolve on orientation change
  101838. */
  101839. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  101840. /**
  101841. * @hidden
  101842. */
  101843. _onDeviceOrientationChangedObservable: Observable<void>;
  101844. /**
  101845. * Instantiates a new input
  101846. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101847. */
  101848. constructor();
  101849. /**
  101850. * Define the camera controlled by the input.
  101851. */
  101852. camera: FreeCamera;
  101853. /**
  101854. * Attach the input controls to a specific dom element to get the input from.
  101855. * @param element Defines the element the controls should be listened from
  101856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101857. */
  101858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101859. private _orientationChanged;
  101860. private _deviceOrientation;
  101861. /**
  101862. * Detach the current controls from the specified dom element.
  101863. * @param element Defines the element to stop listening the inputs from
  101864. */
  101865. detachControl(element: Nullable<HTMLElement>): void;
  101866. /**
  101867. * Update the current camera state depending on the inputs that have been used this frame.
  101868. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101869. */
  101870. checkInputs(): void;
  101871. /**
  101872. * Gets the class name of the current intput.
  101873. * @returns the class name
  101874. */
  101875. getClassName(): string;
  101876. /**
  101877. * Get the friendly name associated with the input class.
  101878. * @returns the input friendly name
  101879. */
  101880. getSimpleName(): string;
  101881. }
  101882. }
  101883. declare module BABYLON {
  101884. /**
  101885. * Manage the gamepad inputs to control a free camera.
  101886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101887. */
  101888. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  101889. /**
  101890. * Define the camera the input is attached to.
  101891. */
  101892. camera: FreeCamera;
  101893. /**
  101894. * Define the Gamepad controlling the input
  101895. */
  101896. gamepad: Nullable<Gamepad>;
  101897. /**
  101898. * Defines the gamepad rotation sensiblity.
  101899. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101900. */
  101901. gamepadAngularSensibility: number;
  101902. /**
  101903. * Defines the gamepad move sensiblity.
  101904. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101905. */
  101906. gamepadMoveSensibility: number;
  101907. private _onGamepadConnectedObserver;
  101908. private _onGamepadDisconnectedObserver;
  101909. private _cameraTransform;
  101910. private _deltaTransform;
  101911. private _vector3;
  101912. private _vector2;
  101913. /**
  101914. * Attach the input controls to a specific dom element to get the input from.
  101915. * @param element Defines the element the controls should be listened from
  101916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101917. */
  101918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101919. /**
  101920. * Detach the current controls from the specified dom element.
  101921. * @param element Defines the element to stop listening the inputs from
  101922. */
  101923. detachControl(element: Nullable<HTMLElement>): void;
  101924. /**
  101925. * Update the current camera state depending on the inputs that have been used this frame.
  101926. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101927. */
  101928. checkInputs(): void;
  101929. /**
  101930. * Gets the class name of the current intput.
  101931. * @returns the class name
  101932. */
  101933. getClassName(): string;
  101934. /**
  101935. * Get the friendly name associated with the input class.
  101936. * @returns the input friendly name
  101937. */
  101938. getSimpleName(): string;
  101939. }
  101940. }
  101941. declare module BABYLON {
  101942. /**
  101943. * Defines the potential axis of a Joystick
  101944. */
  101945. export enum JoystickAxis {
  101946. /** X axis */
  101947. X = 0,
  101948. /** Y axis */
  101949. Y = 1,
  101950. /** Z axis */
  101951. Z = 2
  101952. }
  101953. /**
  101954. * Class used to define virtual joystick (used in touch mode)
  101955. */
  101956. export class VirtualJoystick {
  101957. /**
  101958. * Gets or sets a boolean indicating that left and right values must be inverted
  101959. */
  101960. reverseLeftRight: boolean;
  101961. /**
  101962. * Gets or sets a boolean indicating that up and down values must be inverted
  101963. */
  101964. reverseUpDown: boolean;
  101965. /**
  101966. * Gets the offset value for the position (ie. the change of the position value)
  101967. */
  101968. deltaPosition: Vector3;
  101969. /**
  101970. * Gets a boolean indicating if the virtual joystick was pressed
  101971. */
  101972. pressed: boolean;
  101973. /**
  101974. * Canvas the virtual joystick will render onto, default z-index of this is 5
  101975. */
  101976. static Canvas: Nullable<HTMLCanvasElement>;
  101977. private static _globalJoystickIndex;
  101978. private static vjCanvasContext;
  101979. private static vjCanvasWidth;
  101980. private static vjCanvasHeight;
  101981. private static halfWidth;
  101982. private _action;
  101983. private _axisTargetedByLeftAndRight;
  101984. private _axisTargetedByUpAndDown;
  101985. private _joystickSensibility;
  101986. private _inversedSensibility;
  101987. private _joystickPointerID;
  101988. private _joystickColor;
  101989. private _joystickPointerPos;
  101990. private _joystickPreviousPointerPos;
  101991. private _joystickPointerStartPos;
  101992. private _deltaJoystickVector;
  101993. private _leftJoystick;
  101994. private _touches;
  101995. private _onPointerDownHandlerRef;
  101996. private _onPointerMoveHandlerRef;
  101997. private _onPointerUpHandlerRef;
  101998. private _onResize;
  101999. /**
  102000. * Creates a new virtual joystick
  102001. * @param leftJoystick defines that the joystick is for left hand (false by default)
  102002. */
  102003. constructor(leftJoystick?: boolean);
  102004. /**
  102005. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  102006. * @param newJoystickSensibility defines the new sensibility
  102007. */
  102008. setJoystickSensibility(newJoystickSensibility: number): void;
  102009. private _onPointerDown;
  102010. private _onPointerMove;
  102011. private _onPointerUp;
  102012. /**
  102013. * Change the color of the virtual joystick
  102014. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  102015. */
  102016. setJoystickColor(newColor: string): void;
  102017. /**
  102018. * Defines a callback to call when the joystick is touched
  102019. * @param action defines the callback
  102020. */
  102021. setActionOnTouch(action: () => any): void;
  102022. /**
  102023. * Defines which axis you'd like to control for left & right
  102024. * @param axis defines the axis to use
  102025. */
  102026. setAxisForLeftRight(axis: JoystickAxis): void;
  102027. /**
  102028. * Defines which axis you'd like to control for up & down
  102029. * @param axis defines the axis to use
  102030. */
  102031. setAxisForUpDown(axis: JoystickAxis): void;
  102032. private _drawVirtualJoystick;
  102033. /**
  102034. * Release internal HTML canvas
  102035. */
  102036. releaseCanvas(): void;
  102037. }
  102038. }
  102039. declare module BABYLON {
  102040. interface FreeCameraInputsManager {
  102041. /**
  102042. * Add virtual joystick input support to the input manager.
  102043. * @returns the current input manager
  102044. */
  102045. addVirtualJoystick(): FreeCameraInputsManager;
  102046. }
  102047. /**
  102048. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  102049. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102050. */
  102051. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  102052. /**
  102053. * Defines the camera the input is attached to.
  102054. */
  102055. camera: FreeCamera;
  102056. private _leftjoystick;
  102057. private _rightjoystick;
  102058. /**
  102059. * Gets the left stick of the virtual joystick.
  102060. * @returns The virtual Joystick
  102061. */
  102062. getLeftJoystick(): VirtualJoystick;
  102063. /**
  102064. * Gets the right stick of the virtual joystick.
  102065. * @returns The virtual Joystick
  102066. */
  102067. getRightJoystick(): VirtualJoystick;
  102068. /**
  102069. * Update the current camera state depending on the inputs that have been used this frame.
  102070. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102071. */
  102072. checkInputs(): void;
  102073. /**
  102074. * Attach the input controls to a specific dom element to get the input from.
  102075. * @param element Defines the element the controls should be listened from
  102076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102077. */
  102078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102079. /**
  102080. * Detach the current controls from the specified dom element.
  102081. * @param element Defines the element to stop listening the inputs from
  102082. */
  102083. detachControl(element: Nullable<HTMLElement>): void;
  102084. /**
  102085. * Gets the class name of the current intput.
  102086. * @returns the class name
  102087. */
  102088. getClassName(): string;
  102089. /**
  102090. * Get the friendly name associated with the input class.
  102091. * @returns the input friendly name
  102092. */
  102093. getSimpleName(): string;
  102094. }
  102095. }
  102096. declare module BABYLON {
  102097. /**
  102098. * This represents a FPS type of camera controlled by touch.
  102099. * This is like a universal camera minus the Gamepad controls.
  102100. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102101. */
  102102. export class TouchCamera extends FreeCamera {
  102103. /**
  102104. * Defines the touch sensibility for rotation.
  102105. * The higher the faster.
  102106. */
  102107. touchAngularSensibility: number;
  102108. /**
  102109. * Defines the touch sensibility for move.
  102110. * The higher the faster.
  102111. */
  102112. touchMoveSensibility: number;
  102113. /**
  102114. * Instantiates a new touch camera.
  102115. * This represents a FPS type of camera controlled by touch.
  102116. * This is like a universal camera minus the Gamepad controls.
  102117. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102118. * @param name Define the name of the camera in the scene
  102119. * @param position Define the start position of the camera in the scene
  102120. * @param scene Define the scene the camera belongs to
  102121. */
  102122. constructor(name: string, position: Vector3, scene: Scene);
  102123. /**
  102124. * Gets the current object class name.
  102125. * @return the class name
  102126. */
  102127. getClassName(): string;
  102128. /** @hidden */
  102129. _setupInputs(): void;
  102130. }
  102131. }
  102132. declare module BABYLON {
  102133. /**
  102134. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  102135. * being tilted forward or back and left or right.
  102136. */
  102137. export class DeviceOrientationCamera extends FreeCamera {
  102138. private _initialQuaternion;
  102139. private _quaternionCache;
  102140. private _tmpDragQuaternion;
  102141. /**
  102142. * Creates a new device orientation camera
  102143. * @param name The name of the camera
  102144. * @param position The start position camera
  102145. * @param scene The scene the camera belongs to
  102146. */
  102147. constructor(name: string, position: Vector3, scene: Scene);
  102148. /**
  102149. * @hidden
  102150. * Disabled pointer input on first orientation sensor update (Default: true)
  102151. */
  102152. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  102153. private _dragFactor;
  102154. /**
  102155. * Enabled turning on the y axis when the orientation sensor is active
  102156. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  102157. */
  102158. enableHorizontalDragging(dragFactor?: number): void;
  102159. /**
  102160. * Gets the current instance class name ("DeviceOrientationCamera").
  102161. * This helps avoiding instanceof at run time.
  102162. * @returns the class name
  102163. */
  102164. getClassName(): string;
  102165. /**
  102166. * @hidden
  102167. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  102168. */
  102169. _checkInputs(): void;
  102170. /**
  102171. * Reset the camera to its default orientation on the specified axis only.
  102172. * @param axis The axis to reset
  102173. */
  102174. resetToCurrentRotation(axis?: Axis): void;
  102175. }
  102176. }
  102177. declare module BABYLON {
  102178. /**
  102179. * Defines supported buttons for XBox360 compatible gamepads
  102180. */
  102181. export enum Xbox360Button {
  102182. /** A */
  102183. A = 0,
  102184. /** B */
  102185. B = 1,
  102186. /** X */
  102187. X = 2,
  102188. /** Y */
  102189. Y = 3,
  102190. /** Start */
  102191. Start = 4,
  102192. /** Back */
  102193. Back = 5,
  102194. /** Left button */
  102195. LB = 6,
  102196. /** Right button */
  102197. RB = 7,
  102198. /** Left stick */
  102199. LeftStick = 8,
  102200. /** Right stick */
  102201. RightStick = 9
  102202. }
  102203. /** Defines values for XBox360 DPad */
  102204. export enum Xbox360Dpad {
  102205. /** Up */
  102206. Up = 0,
  102207. /** Down */
  102208. Down = 1,
  102209. /** Left */
  102210. Left = 2,
  102211. /** Right */
  102212. Right = 3
  102213. }
  102214. /**
  102215. * Defines a XBox360 gamepad
  102216. */
  102217. export class Xbox360Pad extends Gamepad {
  102218. private _leftTrigger;
  102219. private _rightTrigger;
  102220. private _onlefttriggerchanged;
  102221. private _onrighttriggerchanged;
  102222. private _onbuttondown;
  102223. private _onbuttonup;
  102224. private _ondpaddown;
  102225. private _ondpadup;
  102226. /** Observable raised when a button is pressed */
  102227. onButtonDownObservable: Observable<Xbox360Button>;
  102228. /** Observable raised when a button is released */
  102229. onButtonUpObservable: Observable<Xbox360Button>;
  102230. /** Observable raised when a pad is pressed */
  102231. onPadDownObservable: Observable<Xbox360Dpad>;
  102232. /** Observable raised when a pad is released */
  102233. onPadUpObservable: Observable<Xbox360Dpad>;
  102234. private _buttonA;
  102235. private _buttonB;
  102236. private _buttonX;
  102237. private _buttonY;
  102238. private _buttonBack;
  102239. private _buttonStart;
  102240. private _buttonLB;
  102241. private _buttonRB;
  102242. private _buttonLeftStick;
  102243. private _buttonRightStick;
  102244. private _dPadUp;
  102245. private _dPadDown;
  102246. private _dPadLeft;
  102247. private _dPadRight;
  102248. private _isXboxOnePad;
  102249. /**
  102250. * Creates a new XBox360 gamepad object
  102251. * @param id defines the id of this gamepad
  102252. * @param index defines its index
  102253. * @param gamepad defines the internal HTML gamepad object
  102254. * @param xboxOne defines if it is a XBox One gamepad
  102255. */
  102256. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  102257. /**
  102258. * Defines the callback to call when left trigger is pressed
  102259. * @param callback defines the callback to use
  102260. */
  102261. onlefttriggerchanged(callback: (value: number) => void): void;
  102262. /**
  102263. * Defines the callback to call when right trigger is pressed
  102264. * @param callback defines the callback to use
  102265. */
  102266. onrighttriggerchanged(callback: (value: number) => void): void;
  102267. /**
  102268. * Gets the left trigger value
  102269. */
  102270. /**
  102271. * Sets the left trigger value
  102272. */
  102273. leftTrigger: number;
  102274. /**
  102275. * Gets the right trigger value
  102276. */
  102277. /**
  102278. * Sets the right trigger value
  102279. */
  102280. rightTrigger: number;
  102281. /**
  102282. * Defines the callback to call when a button is pressed
  102283. * @param callback defines the callback to use
  102284. */
  102285. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  102286. /**
  102287. * Defines the callback to call when a button is released
  102288. * @param callback defines the callback to use
  102289. */
  102290. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  102291. /**
  102292. * Defines the callback to call when a pad is pressed
  102293. * @param callback defines the callback to use
  102294. */
  102295. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  102296. /**
  102297. * Defines the callback to call when a pad is released
  102298. * @param callback defines the callback to use
  102299. */
  102300. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  102301. private _setButtonValue;
  102302. private _setDPadValue;
  102303. /**
  102304. * Gets the value of the `A` button
  102305. */
  102306. /**
  102307. * Sets the value of the `A` button
  102308. */
  102309. buttonA: number;
  102310. /**
  102311. * Gets the value of the `B` button
  102312. */
  102313. /**
  102314. * Sets the value of the `B` button
  102315. */
  102316. buttonB: number;
  102317. /**
  102318. * Gets the value of the `X` button
  102319. */
  102320. /**
  102321. * Sets the value of the `X` button
  102322. */
  102323. buttonX: number;
  102324. /**
  102325. * Gets the value of the `Y` button
  102326. */
  102327. /**
  102328. * Sets the value of the `Y` button
  102329. */
  102330. buttonY: number;
  102331. /**
  102332. * Gets the value of the `Start` button
  102333. */
  102334. /**
  102335. * Sets the value of the `Start` button
  102336. */
  102337. buttonStart: number;
  102338. /**
  102339. * Gets the value of the `Back` button
  102340. */
  102341. /**
  102342. * Sets the value of the `Back` button
  102343. */
  102344. buttonBack: number;
  102345. /**
  102346. * Gets the value of the `Left` button
  102347. */
  102348. /**
  102349. * Sets the value of the `Left` button
  102350. */
  102351. buttonLB: number;
  102352. /**
  102353. * Gets the value of the `Right` button
  102354. */
  102355. /**
  102356. * Sets the value of the `Right` button
  102357. */
  102358. buttonRB: number;
  102359. /**
  102360. * Gets the value of the Left joystick
  102361. */
  102362. /**
  102363. * Sets the value of the Left joystick
  102364. */
  102365. buttonLeftStick: number;
  102366. /**
  102367. * Gets the value of the Right joystick
  102368. */
  102369. /**
  102370. * Sets the value of the Right joystick
  102371. */
  102372. buttonRightStick: number;
  102373. /**
  102374. * Gets the value of D-pad up
  102375. */
  102376. /**
  102377. * Sets the value of D-pad up
  102378. */
  102379. dPadUp: number;
  102380. /**
  102381. * Gets the value of D-pad down
  102382. */
  102383. /**
  102384. * Sets the value of D-pad down
  102385. */
  102386. dPadDown: number;
  102387. /**
  102388. * Gets the value of D-pad left
  102389. */
  102390. /**
  102391. * Sets the value of D-pad left
  102392. */
  102393. dPadLeft: number;
  102394. /**
  102395. * Gets the value of D-pad right
  102396. */
  102397. /**
  102398. * Sets the value of D-pad right
  102399. */
  102400. dPadRight: number;
  102401. /**
  102402. * Force the gamepad to synchronize with device values
  102403. */
  102404. update(): void;
  102405. /**
  102406. * Disposes the gamepad
  102407. */
  102408. dispose(): void;
  102409. }
  102410. }
  102411. declare module BABYLON {
  102412. /**
  102413. * Manager for handling gamepads
  102414. */
  102415. export class GamepadManager {
  102416. private _scene?;
  102417. private _babylonGamepads;
  102418. private _oneGamepadConnected;
  102419. /** @hidden */
  102420. _isMonitoring: boolean;
  102421. private _gamepadEventSupported;
  102422. private _gamepadSupport;
  102423. /**
  102424. * observable to be triggered when the gamepad controller has been connected
  102425. */
  102426. onGamepadConnectedObservable: Observable<Gamepad>;
  102427. /**
  102428. * observable to be triggered when the gamepad controller has been disconnected
  102429. */
  102430. onGamepadDisconnectedObservable: Observable<Gamepad>;
  102431. private _onGamepadConnectedEvent;
  102432. private _onGamepadDisconnectedEvent;
  102433. /**
  102434. * Initializes the gamepad manager
  102435. * @param _scene BabylonJS scene
  102436. */
  102437. constructor(_scene?: Scene | undefined);
  102438. /**
  102439. * The gamepads in the game pad manager
  102440. */
  102441. readonly gamepads: Gamepad[];
  102442. /**
  102443. * Get the gamepad controllers based on type
  102444. * @param type The type of gamepad controller
  102445. * @returns Nullable gamepad
  102446. */
  102447. getGamepadByType(type?: number): Nullable<Gamepad>;
  102448. /**
  102449. * Disposes the gamepad manager
  102450. */
  102451. dispose(): void;
  102452. private _addNewGamepad;
  102453. private _startMonitoringGamepads;
  102454. private _stopMonitoringGamepads;
  102455. /** @hidden */
  102456. _checkGamepadsStatus(): void;
  102457. private _updateGamepadObjects;
  102458. }
  102459. }
  102460. declare module BABYLON {
  102461. interface Scene {
  102462. /** @hidden */
  102463. _gamepadManager: Nullable<GamepadManager>;
  102464. /**
  102465. * Gets the gamepad manager associated with the scene
  102466. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  102467. */
  102468. gamepadManager: GamepadManager;
  102469. }
  102470. /**
  102471. * Interface representing a free camera inputs manager
  102472. */
  102473. interface FreeCameraInputsManager {
  102474. /**
  102475. * Adds gamepad input support to the FreeCameraInputsManager.
  102476. * @returns the FreeCameraInputsManager
  102477. */
  102478. addGamepad(): FreeCameraInputsManager;
  102479. }
  102480. /**
  102481. * Interface representing an arc rotate camera inputs manager
  102482. */
  102483. interface ArcRotateCameraInputsManager {
  102484. /**
  102485. * Adds gamepad input support to the ArcRotateCamera InputManager.
  102486. * @returns the camera inputs manager
  102487. */
  102488. addGamepad(): ArcRotateCameraInputsManager;
  102489. }
  102490. /**
  102491. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  102492. */
  102493. export class GamepadSystemSceneComponent implements ISceneComponent {
  102494. /**
  102495. * The component name helpfull to identify the component in the list of scene components.
  102496. */
  102497. readonly name: string;
  102498. /**
  102499. * The scene the component belongs to.
  102500. */
  102501. scene: Scene;
  102502. /**
  102503. * Creates a new instance of the component for the given scene
  102504. * @param scene Defines the scene to register the component in
  102505. */
  102506. constructor(scene: Scene);
  102507. /**
  102508. * Registers the component in a given scene
  102509. */
  102510. register(): void;
  102511. /**
  102512. * Rebuilds the elements related to this component in case of
  102513. * context lost for instance.
  102514. */
  102515. rebuild(): void;
  102516. /**
  102517. * Disposes the component and the associated ressources
  102518. */
  102519. dispose(): void;
  102520. private _beforeCameraUpdate;
  102521. }
  102522. }
  102523. declare module BABYLON {
  102524. /**
  102525. * 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,
  102526. * which still works and will still be found in many Playgrounds.
  102527. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102528. */
  102529. export class UniversalCamera extends TouchCamera {
  102530. /**
  102531. * Defines the gamepad rotation sensiblity.
  102532. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102533. */
  102534. gamepadAngularSensibility: number;
  102535. /**
  102536. * Defines the gamepad move sensiblity.
  102537. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102538. */
  102539. gamepadMoveSensibility: number;
  102540. /**
  102541. * 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,
  102542. * which still works and will still be found in many Playgrounds.
  102543. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102544. * @param name Define the name of the camera in the scene
  102545. * @param position Define the start position of the camera in the scene
  102546. * @param scene Define the scene the camera belongs to
  102547. */
  102548. constructor(name: string, position: Vector3, scene: Scene);
  102549. /**
  102550. * Gets the current object class name.
  102551. * @return the class name
  102552. */
  102553. getClassName(): string;
  102554. }
  102555. }
  102556. declare module BABYLON {
  102557. /**
  102558. * This represents a FPS type of camera. This is only here for back compat purpose.
  102559. * Please use the UniversalCamera instead as both are identical.
  102560. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102561. */
  102562. export class GamepadCamera extends UniversalCamera {
  102563. /**
  102564. * Instantiates a new Gamepad Camera
  102565. * This represents a FPS type of camera. This is only here for back compat purpose.
  102566. * Please use the UniversalCamera instead as both are identical.
  102567. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102568. * @param name Define the name of the camera in the scene
  102569. * @param position Define the start position of the camera in the scene
  102570. * @param scene Define the scene the camera belongs to
  102571. */
  102572. constructor(name: string, position: Vector3, scene: Scene);
  102573. /**
  102574. * Gets the current object class name.
  102575. * @return the class name
  102576. */
  102577. getClassName(): string;
  102578. }
  102579. }
  102580. declare module BABYLON {
  102581. /** @hidden */
  102582. export var passPixelShader: {
  102583. name: string;
  102584. shader: string;
  102585. };
  102586. }
  102587. declare module BABYLON {
  102588. /** @hidden */
  102589. export var passCubePixelShader: {
  102590. name: string;
  102591. shader: string;
  102592. };
  102593. }
  102594. declare module BABYLON {
  102595. /**
  102596. * PassPostProcess which produces an output the same as it's input
  102597. */
  102598. export class PassPostProcess extends PostProcess {
  102599. /**
  102600. * Creates the PassPostProcess
  102601. * @param name The name of the effect.
  102602. * @param options The required width/height ratio to downsize to before computing the render pass.
  102603. * @param camera The camera to apply the render pass to.
  102604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102605. * @param engine The engine which the post process will be applied. (default: current engine)
  102606. * @param reusable If the post process can be reused on the same frame. (default: false)
  102607. * @param textureType The type of texture to be used when performing the post processing.
  102608. * @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)
  102609. */
  102610. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  102611. }
  102612. /**
  102613. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  102614. */
  102615. export class PassCubePostProcess extends PostProcess {
  102616. private _face;
  102617. /**
  102618. * Gets or sets the cube face to display.
  102619. * * 0 is +X
  102620. * * 1 is -X
  102621. * * 2 is +Y
  102622. * * 3 is -Y
  102623. * * 4 is +Z
  102624. * * 5 is -Z
  102625. */
  102626. face: number;
  102627. /**
  102628. * Creates the PassCubePostProcess
  102629. * @param name The name of the effect.
  102630. * @param options The required width/height ratio to downsize to before computing the render pass.
  102631. * @param camera The camera to apply the render pass to.
  102632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102633. * @param engine The engine which the post process will be applied. (default: current engine)
  102634. * @param reusable If the post process can be reused on the same frame. (default: false)
  102635. * @param textureType The type of texture to be used when performing the post processing.
  102636. * @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)
  102637. */
  102638. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  102639. }
  102640. }
  102641. declare module BABYLON {
  102642. /** @hidden */
  102643. export var anaglyphPixelShader: {
  102644. name: string;
  102645. shader: string;
  102646. };
  102647. }
  102648. declare module BABYLON {
  102649. /**
  102650. * Postprocess used to generate anaglyphic rendering
  102651. */
  102652. export class AnaglyphPostProcess extends PostProcess {
  102653. private _passedProcess;
  102654. /**
  102655. * Creates a new AnaglyphPostProcess
  102656. * @param name defines postprocess name
  102657. * @param options defines creation options or target ratio scale
  102658. * @param rigCameras defines cameras using this postprocess
  102659. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  102660. * @param engine defines hosting engine
  102661. * @param reusable defines if the postprocess will be reused multiple times per frame
  102662. */
  102663. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  102664. }
  102665. }
  102666. declare module BABYLON {
  102667. /**
  102668. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  102669. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102670. */
  102671. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  102672. /**
  102673. * Creates a new AnaglyphArcRotateCamera
  102674. * @param name defines camera name
  102675. * @param alpha defines alpha angle (in radians)
  102676. * @param beta defines beta angle (in radians)
  102677. * @param radius defines radius
  102678. * @param target defines camera target
  102679. * @param interaxialDistance defines distance between each color axis
  102680. * @param scene defines the hosting scene
  102681. */
  102682. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  102683. /**
  102684. * Gets camera class name
  102685. * @returns AnaglyphArcRotateCamera
  102686. */
  102687. getClassName(): string;
  102688. }
  102689. }
  102690. declare module BABYLON {
  102691. /**
  102692. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  102693. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102694. */
  102695. export class AnaglyphFreeCamera extends FreeCamera {
  102696. /**
  102697. * Creates a new AnaglyphFreeCamera
  102698. * @param name defines camera name
  102699. * @param position defines initial position
  102700. * @param interaxialDistance defines distance between each color axis
  102701. * @param scene defines the hosting scene
  102702. */
  102703. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102704. /**
  102705. * Gets camera class name
  102706. * @returns AnaglyphFreeCamera
  102707. */
  102708. getClassName(): string;
  102709. }
  102710. }
  102711. declare module BABYLON {
  102712. /**
  102713. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  102714. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102715. */
  102716. export class AnaglyphGamepadCamera extends GamepadCamera {
  102717. /**
  102718. * Creates a new AnaglyphGamepadCamera
  102719. * @param name defines camera name
  102720. * @param position defines initial position
  102721. * @param interaxialDistance defines distance between each color axis
  102722. * @param scene defines the hosting scene
  102723. */
  102724. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102725. /**
  102726. * Gets camera class name
  102727. * @returns AnaglyphGamepadCamera
  102728. */
  102729. getClassName(): string;
  102730. }
  102731. }
  102732. declare module BABYLON {
  102733. /**
  102734. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  102735. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102736. */
  102737. export class AnaglyphUniversalCamera extends UniversalCamera {
  102738. /**
  102739. * Creates a new AnaglyphUniversalCamera
  102740. * @param name defines camera name
  102741. * @param position defines initial position
  102742. * @param interaxialDistance defines distance between each color axis
  102743. * @param scene defines the hosting scene
  102744. */
  102745. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102746. /**
  102747. * Gets camera class name
  102748. * @returns AnaglyphUniversalCamera
  102749. */
  102750. getClassName(): string;
  102751. }
  102752. }
  102753. declare module BABYLON {
  102754. /** @hidden */
  102755. export var stereoscopicInterlacePixelShader: {
  102756. name: string;
  102757. shader: string;
  102758. };
  102759. }
  102760. declare module BABYLON {
  102761. /**
  102762. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  102763. */
  102764. export class StereoscopicInterlacePostProcess extends PostProcess {
  102765. private _stepSize;
  102766. private _passedProcess;
  102767. /**
  102768. * Initializes a StereoscopicInterlacePostProcess
  102769. * @param name The name of the effect.
  102770. * @param rigCameras The rig cameras to be appled to the post process
  102771. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  102772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102773. * @param engine The engine which the post process will be applied. (default: current engine)
  102774. * @param reusable If the post process can be reused on the same frame. (default: false)
  102775. */
  102776. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  102777. }
  102778. }
  102779. declare module BABYLON {
  102780. /**
  102781. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  102782. * @see http://doc.babylonjs.com/features/cameras
  102783. */
  102784. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  102785. /**
  102786. * Creates a new StereoscopicArcRotateCamera
  102787. * @param name defines camera name
  102788. * @param alpha defines alpha angle (in radians)
  102789. * @param beta defines beta angle (in radians)
  102790. * @param radius defines radius
  102791. * @param target defines camera target
  102792. * @param interaxialDistance defines distance between each color axis
  102793. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102794. * @param scene defines the hosting scene
  102795. */
  102796. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102797. /**
  102798. * Gets camera class name
  102799. * @returns StereoscopicArcRotateCamera
  102800. */
  102801. getClassName(): string;
  102802. }
  102803. }
  102804. declare module BABYLON {
  102805. /**
  102806. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  102807. * @see http://doc.babylonjs.com/features/cameras
  102808. */
  102809. export class StereoscopicFreeCamera extends FreeCamera {
  102810. /**
  102811. * Creates a new StereoscopicFreeCamera
  102812. * @param name defines camera name
  102813. * @param position defines initial position
  102814. * @param interaxialDistance defines distance between each color axis
  102815. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102816. * @param scene defines the hosting scene
  102817. */
  102818. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102819. /**
  102820. * Gets camera class name
  102821. * @returns StereoscopicFreeCamera
  102822. */
  102823. getClassName(): string;
  102824. }
  102825. }
  102826. declare module BABYLON {
  102827. /**
  102828. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  102829. * @see http://doc.babylonjs.com/features/cameras
  102830. */
  102831. export class StereoscopicGamepadCamera extends GamepadCamera {
  102832. /**
  102833. * Creates a new StereoscopicGamepadCamera
  102834. * @param name defines camera name
  102835. * @param position defines initial position
  102836. * @param interaxialDistance defines distance between each color axis
  102837. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102838. * @param scene defines the hosting scene
  102839. */
  102840. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102841. /**
  102842. * Gets camera class name
  102843. * @returns StereoscopicGamepadCamera
  102844. */
  102845. getClassName(): string;
  102846. }
  102847. }
  102848. declare module BABYLON {
  102849. /**
  102850. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  102851. * @see http://doc.babylonjs.com/features/cameras
  102852. */
  102853. export class StereoscopicUniversalCamera extends UniversalCamera {
  102854. /**
  102855. * Creates a new StereoscopicUniversalCamera
  102856. * @param name defines camera name
  102857. * @param position defines initial position
  102858. * @param interaxialDistance defines distance between each color axis
  102859. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102860. * @param scene defines the hosting scene
  102861. */
  102862. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102863. /**
  102864. * Gets camera class name
  102865. * @returns StereoscopicUniversalCamera
  102866. */
  102867. getClassName(): string;
  102868. }
  102869. }
  102870. declare module BABYLON {
  102871. /**
  102872. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  102873. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102874. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102875. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102876. */
  102877. export class VirtualJoysticksCamera extends FreeCamera {
  102878. /**
  102879. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  102880. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102881. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102882. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102883. * @param name Define the name of the camera in the scene
  102884. * @param position Define the start position of the camera in the scene
  102885. * @param scene Define the scene the camera belongs to
  102886. */
  102887. constructor(name: string, position: Vector3, scene: Scene);
  102888. /**
  102889. * Gets the current object class name.
  102890. * @return the class name
  102891. */
  102892. getClassName(): string;
  102893. }
  102894. }
  102895. declare module BABYLON {
  102896. /**
  102897. * This represents all the required metrics to create a VR camera.
  102898. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  102899. */
  102900. export class VRCameraMetrics {
  102901. /**
  102902. * Define the horizontal resolution off the screen.
  102903. */
  102904. hResolution: number;
  102905. /**
  102906. * Define the vertical resolution off the screen.
  102907. */
  102908. vResolution: number;
  102909. /**
  102910. * Define the horizontal screen size.
  102911. */
  102912. hScreenSize: number;
  102913. /**
  102914. * Define the vertical screen size.
  102915. */
  102916. vScreenSize: number;
  102917. /**
  102918. * Define the vertical screen center position.
  102919. */
  102920. vScreenCenter: number;
  102921. /**
  102922. * Define the distance of the eyes to the screen.
  102923. */
  102924. eyeToScreenDistance: number;
  102925. /**
  102926. * Define the distance between both lenses
  102927. */
  102928. lensSeparationDistance: number;
  102929. /**
  102930. * Define the distance between both viewer's eyes.
  102931. */
  102932. interpupillaryDistance: number;
  102933. /**
  102934. * Define the distortion factor of the VR postprocess.
  102935. * Please, touch with care.
  102936. */
  102937. distortionK: number[];
  102938. /**
  102939. * Define the chromatic aberration correction factors for the VR post process.
  102940. */
  102941. chromaAbCorrection: number[];
  102942. /**
  102943. * Define the scale factor of the post process.
  102944. * The smaller the better but the slower.
  102945. */
  102946. postProcessScaleFactor: number;
  102947. /**
  102948. * Define an offset for the lens center.
  102949. */
  102950. lensCenterOffset: number;
  102951. /**
  102952. * Define if the current vr camera should compensate the distortion of the lense or not.
  102953. */
  102954. compensateDistortion: boolean;
  102955. /**
  102956. * Defines if multiview should be enabled when rendering (Default: false)
  102957. */
  102958. multiviewEnabled: boolean;
  102959. /**
  102960. * Gets the rendering aspect ratio based on the provided resolutions.
  102961. */
  102962. readonly aspectRatio: number;
  102963. /**
  102964. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  102965. */
  102966. readonly aspectRatioFov: number;
  102967. /**
  102968. * @hidden
  102969. */
  102970. readonly leftHMatrix: Matrix;
  102971. /**
  102972. * @hidden
  102973. */
  102974. readonly rightHMatrix: Matrix;
  102975. /**
  102976. * @hidden
  102977. */
  102978. readonly leftPreViewMatrix: Matrix;
  102979. /**
  102980. * @hidden
  102981. */
  102982. readonly rightPreViewMatrix: Matrix;
  102983. /**
  102984. * Get the default VRMetrics based on the most generic setup.
  102985. * @returns the default vr metrics
  102986. */
  102987. static GetDefault(): VRCameraMetrics;
  102988. }
  102989. }
  102990. declare module BABYLON {
  102991. /** @hidden */
  102992. export var vrDistortionCorrectionPixelShader: {
  102993. name: string;
  102994. shader: string;
  102995. };
  102996. }
  102997. declare module BABYLON {
  102998. /**
  102999. * VRDistortionCorrectionPostProcess used for mobile VR
  103000. */
  103001. export class VRDistortionCorrectionPostProcess extends PostProcess {
  103002. private _isRightEye;
  103003. private _distortionFactors;
  103004. private _postProcessScaleFactor;
  103005. private _lensCenterOffset;
  103006. private _scaleIn;
  103007. private _scaleFactor;
  103008. private _lensCenter;
  103009. /**
  103010. * Initializes the VRDistortionCorrectionPostProcess
  103011. * @param name The name of the effect.
  103012. * @param camera The camera to apply the render pass to.
  103013. * @param isRightEye If this is for the right eye distortion
  103014. * @param vrMetrics All the required metrics for the VR camera
  103015. */
  103016. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  103017. }
  103018. }
  103019. declare module BABYLON {
  103020. /**
  103021. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  103022. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103023. */
  103024. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  103025. /**
  103026. * Creates a new VRDeviceOrientationArcRotateCamera
  103027. * @param name defines camera name
  103028. * @param alpha defines the camera rotation along the logitudinal axis
  103029. * @param beta defines the camera rotation along the latitudinal axis
  103030. * @param radius defines the camera distance from its target
  103031. * @param target defines the camera target
  103032. * @param scene defines the scene the camera belongs to
  103033. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103034. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103035. */
  103036. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103037. /**
  103038. * Gets camera class name
  103039. * @returns VRDeviceOrientationArcRotateCamera
  103040. */
  103041. getClassName(): string;
  103042. }
  103043. }
  103044. declare module BABYLON {
  103045. /**
  103046. * Camera used to simulate VR rendering (based on FreeCamera)
  103047. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103048. */
  103049. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  103050. /**
  103051. * Creates a new VRDeviceOrientationFreeCamera
  103052. * @param name defines camera name
  103053. * @param position defines the start position of the camera
  103054. * @param scene defines the scene the camera belongs to
  103055. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103056. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103057. */
  103058. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103059. /**
  103060. * Gets camera class name
  103061. * @returns VRDeviceOrientationFreeCamera
  103062. */
  103063. getClassName(): string;
  103064. }
  103065. }
  103066. declare module BABYLON {
  103067. /**
  103068. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  103069. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103070. */
  103071. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  103072. /**
  103073. * Creates a new VRDeviceOrientationGamepadCamera
  103074. * @param name defines camera name
  103075. * @param position defines the start position of the camera
  103076. * @param scene defines the scene the camera belongs to
  103077. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103078. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103079. */
  103080. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103081. /**
  103082. * Gets camera class name
  103083. * @returns VRDeviceOrientationGamepadCamera
  103084. */
  103085. getClassName(): string;
  103086. }
  103087. }
  103088. declare module BABYLON {
  103089. /**
  103090. * Base class of materials working in push mode in babylon JS
  103091. * @hidden
  103092. */
  103093. export class PushMaterial extends Material {
  103094. protected _activeEffect: Effect;
  103095. protected _normalMatrix: Matrix;
  103096. /**
  103097. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  103098. * This means that the material can keep using a previous shader while a new one is being compiled.
  103099. * This is mostly used when shader parallel compilation is supported (true by default)
  103100. */
  103101. allowShaderHotSwapping: boolean;
  103102. constructor(name: string, scene: Scene);
  103103. getEffect(): Effect;
  103104. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103105. /**
  103106. * Binds the given world matrix to the active effect
  103107. *
  103108. * @param world the matrix to bind
  103109. */
  103110. bindOnlyWorldMatrix(world: Matrix): void;
  103111. /**
  103112. * Binds the given normal matrix to the active effect
  103113. *
  103114. * @param normalMatrix the matrix to bind
  103115. */
  103116. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  103117. bind(world: Matrix, mesh?: Mesh): void;
  103118. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  103119. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  103120. }
  103121. }
  103122. declare module BABYLON {
  103123. /**
  103124. * This groups all the flags used to control the materials channel.
  103125. */
  103126. export class MaterialFlags {
  103127. private static _DiffuseTextureEnabled;
  103128. /**
  103129. * Are diffuse textures enabled in the application.
  103130. */
  103131. static DiffuseTextureEnabled: boolean;
  103132. private static _AmbientTextureEnabled;
  103133. /**
  103134. * Are ambient textures enabled in the application.
  103135. */
  103136. static AmbientTextureEnabled: boolean;
  103137. private static _OpacityTextureEnabled;
  103138. /**
  103139. * Are opacity textures enabled in the application.
  103140. */
  103141. static OpacityTextureEnabled: boolean;
  103142. private static _ReflectionTextureEnabled;
  103143. /**
  103144. * Are reflection textures enabled in the application.
  103145. */
  103146. static ReflectionTextureEnabled: boolean;
  103147. private static _EmissiveTextureEnabled;
  103148. /**
  103149. * Are emissive textures enabled in the application.
  103150. */
  103151. static EmissiveTextureEnabled: boolean;
  103152. private static _SpecularTextureEnabled;
  103153. /**
  103154. * Are specular textures enabled in the application.
  103155. */
  103156. static SpecularTextureEnabled: boolean;
  103157. private static _BumpTextureEnabled;
  103158. /**
  103159. * Are bump textures enabled in the application.
  103160. */
  103161. static BumpTextureEnabled: boolean;
  103162. private static _LightmapTextureEnabled;
  103163. /**
  103164. * Are lightmap textures enabled in the application.
  103165. */
  103166. static LightmapTextureEnabled: boolean;
  103167. private static _RefractionTextureEnabled;
  103168. /**
  103169. * Are refraction textures enabled in the application.
  103170. */
  103171. static RefractionTextureEnabled: boolean;
  103172. private static _ColorGradingTextureEnabled;
  103173. /**
  103174. * Are color grading textures enabled in the application.
  103175. */
  103176. static ColorGradingTextureEnabled: boolean;
  103177. private static _FresnelEnabled;
  103178. /**
  103179. * Are fresnels enabled in the application.
  103180. */
  103181. static FresnelEnabled: boolean;
  103182. private static _ClearCoatTextureEnabled;
  103183. /**
  103184. * Are clear coat textures enabled in the application.
  103185. */
  103186. static ClearCoatTextureEnabled: boolean;
  103187. private static _ClearCoatBumpTextureEnabled;
  103188. /**
  103189. * Are clear coat bump textures enabled in the application.
  103190. */
  103191. static ClearCoatBumpTextureEnabled: boolean;
  103192. private static _ClearCoatTintTextureEnabled;
  103193. /**
  103194. * Are clear coat tint textures enabled in the application.
  103195. */
  103196. static ClearCoatTintTextureEnabled: boolean;
  103197. private static _SheenTextureEnabled;
  103198. /**
  103199. * Are sheen textures enabled in the application.
  103200. */
  103201. static SheenTextureEnabled: boolean;
  103202. private static _AnisotropicTextureEnabled;
  103203. /**
  103204. * Are anisotropic textures enabled in the application.
  103205. */
  103206. static AnisotropicTextureEnabled: boolean;
  103207. private static _ThicknessTextureEnabled;
  103208. /**
  103209. * Are thickness textures enabled in the application.
  103210. */
  103211. static ThicknessTextureEnabled: boolean;
  103212. }
  103213. }
  103214. declare module BABYLON {
  103215. /** @hidden */
  103216. export var defaultFragmentDeclaration: {
  103217. name: string;
  103218. shader: string;
  103219. };
  103220. }
  103221. declare module BABYLON {
  103222. /** @hidden */
  103223. export var defaultUboDeclaration: {
  103224. name: string;
  103225. shader: string;
  103226. };
  103227. }
  103228. declare module BABYLON {
  103229. /** @hidden */
  103230. export var lightFragmentDeclaration: {
  103231. name: string;
  103232. shader: string;
  103233. };
  103234. }
  103235. declare module BABYLON {
  103236. /** @hidden */
  103237. export var lightUboDeclaration: {
  103238. name: string;
  103239. shader: string;
  103240. };
  103241. }
  103242. declare module BABYLON {
  103243. /** @hidden */
  103244. export var lightsFragmentFunctions: {
  103245. name: string;
  103246. shader: string;
  103247. };
  103248. }
  103249. declare module BABYLON {
  103250. /** @hidden */
  103251. export var shadowsFragmentFunctions: {
  103252. name: string;
  103253. shader: string;
  103254. };
  103255. }
  103256. declare module BABYLON {
  103257. /** @hidden */
  103258. export var fresnelFunction: {
  103259. name: string;
  103260. shader: string;
  103261. };
  103262. }
  103263. declare module BABYLON {
  103264. /** @hidden */
  103265. export var reflectionFunction: {
  103266. name: string;
  103267. shader: string;
  103268. };
  103269. }
  103270. declare module BABYLON {
  103271. /** @hidden */
  103272. export var bumpFragmentFunctions: {
  103273. name: string;
  103274. shader: string;
  103275. };
  103276. }
  103277. declare module BABYLON {
  103278. /** @hidden */
  103279. export var logDepthDeclaration: {
  103280. name: string;
  103281. shader: string;
  103282. };
  103283. }
  103284. declare module BABYLON {
  103285. /** @hidden */
  103286. export var bumpFragment: {
  103287. name: string;
  103288. shader: string;
  103289. };
  103290. }
  103291. declare module BABYLON {
  103292. /** @hidden */
  103293. export var depthPrePass: {
  103294. name: string;
  103295. shader: string;
  103296. };
  103297. }
  103298. declare module BABYLON {
  103299. /** @hidden */
  103300. export var lightFragment: {
  103301. name: string;
  103302. shader: string;
  103303. };
  103304. }
  103305. declare module BABYLON {
  103306. /** @hidden */
  103307. export var logDepthFragment: {
  103308. name: string;
  103309. shader: string;
  103310. };
  103311. }
  103312. declare module BABYLON {
  103313. /** @hidden */
  103314. export var defaultPixelShader: {
  103315. name: string;
  103316. shader: string;
  103317. };
  103318. }
  103319. declare module BABYLON {
  103320. /** @hidden */
  103321. export var defaultVertexDeclaration: {
  103322. name: string;
  103323. shader: string;
  103324. };
  103325. }
  103326. declare module BABYLON {
  103327. /** @hidden */
  103328. export var bumpVertexDeclaration: {
  103329. name: string;
  103330. shader: string;
  103331. };
  103332. }
  103333. declare module BABYLON {
  103334. /** @hidden */
  103335. export var bumpVertex: {
  103336. name: string;
  103337. shader: string;
  103338. };
  103339. }
  103340. declare module BABYLON {
  103341. /** @hidden */
  103342. export var fogVertex: {
  103343. name: string;
  103344. shader: string;
  103345. };
  103346. }
  103347. declare module BABYLON {
  103348. /** @hidden */
  103349. export var shadowsVertex: {
  103350. name: string;
  103351. shader: string;
  103352. };
  103353. }
  103354. declare module BABYLON {
  103355. /** @hidden */
  103356. export var pointCloudVertex: {
  103357. name: string;
  103358. shader: string;
  103359. };
  103360. }
  103361. declare module BABYLON {
  103362. /** @hidden */
  103363. export var logDepthVertex: {
  103364. name: string;
  103365. shader: string;
  103366. };
  103367. }
  103368. declare module BABYLON {
  103369. /** @hidden */
  103370. export var defaultVertexShader: {
  103371. name: string;
  103372. shader: string;
  103373. };
  103374. }
  103375. declare module BABYLON {
  103376. /** @hidden */
  103377. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103378. MAINUV1: boolean;
  103379. MAINUV2: boolean;
  103380. DIFFUSE: boolean;
  103381. DIFFUSEDIRECTUV: number;
  103382. AMBIENT: boolean;
  103383. AMBIENTDIRECTUV: number;
  103384. OPACITY: boolean;
  103385. OPACITYDIRECTUV: number;
  103386. OPACITYRGB: boolean;
  103387. REFLECTION: boolean;
  103388. EMISSIVE: boolean;
  103389. EMISSIVEDIRECTUV: number;
  103390. SPECULAR: boolean;
  103391. SPECULARDIRECTUV: number;
  103392. BUMP: boolean;
  103393. BUMPDIRECTUV: number;
  103394. PARALLAX: boolean;
  103395. PARALLAXOCCLUSION: boolean;
  103396. SPECULAROVERALPHA: boolean;
  103397. CLIPPLANE: boolean;
  103398. CLIPPLANE2: boolean;
  103399. CLIPPLANE3: boolean;
  103400. CLIPPLANE4: boolean;
  103401. ALPHATEST: boolean;
  103402. DEPTHPREPASS: boolean;
  103403. ALPHAFROMDIFFUSE: boolean;
  103404. POINTSIZE: boolean;
  103405. FOG: boolean;
  103406. SPECULARTERM: boolean;
  103407. DIFFUSEFRESNEL: boolean;
  103408. OPACITYFRESNEL: boolean;
  103409. REFLECTIONFRESNEL: boolean;
  103410. REFRACTIONFRESNEL: boolean;
  103411. EMISSIVEFRESNEL: boolean;
  103412. FRESNEL: boolean;
  103413. NORMAL: boolean;
  103414. UV1: boolean;
  103415. UV2: boolean;
  103416. VERTEXCOLOR: boolean;
  103417. VERTEXALPHA: boolean;
  103418. NUM_BONE_INFLUENCERS: number;
  103419. BonesPerMesh: number;
  103420. BONETEXTURE: boolean;
  103421. INSTANCES: boolean;
  103422. GLOSSINESS: boolean;
  103423. ROUGHNESS: boolean;
  103424. EMISSIVEASILLUMINATION: boolean;
  103425. LINKEMISSIVEWITHDIFFUSE: boolean;
  103426. REFLECTIONFRESNELFROMSPECULAR: boolean;
  103427. LIGHTMAP: boolean;
  103428. LIGHTMAPDIRECTUV: number;
  103429. OBJECTSPACE_NORMALMAP: boolean;
  103430. USELIGHTMAPASSHADOWMAP: boolean;
  103431. REFLECTIONMAP_3D: boolean;
  103432. REFLECTIONMAP_SPHERICAL: boolean;
  103433. REFLECTIONMAP_PLANAR: boolean;
  103434. REFLECTIONMAP_CUBIC: boolean;
  103435. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103436. REFLECTIONMAP_PROJECTION: boolean;
  103437. REFLECTIONMAP_SKYBOX: boolean;
  103438. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103439. REFLECTIONMAP_EXPLICIT: boolean;
  103440. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103441. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103442. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103443. INVERTCUBICMAP: boolean;
  103444. LOGARITHMICDEPTH: boolean;
  103445. REFRACTION: boolean;
  103446. REFRACTIONMAP_3D: boolean;
  103447. REFLECTIONOVERALPHA: boolean;
  103448. TWOSIDEDLIGHTING: boolean;
  103449. SHADOWFLOAT: boolean;
  103450. MORPHTARGETS: boolean;
  103451. MORPHTARGETS_NORMAL: boolean;
  103452. MORPHTARGETS_TANGENT: boolean;
  103453. MORPHTARGETS_UV: boolean;
  103454. NUM_MORPH_INFLUENCERS: number;
  103455. NONUNIFORMSCALING: boolean;
  103456. PREMULTIPLYALPHA: boolean;
  103457. IMAGEPROCESSING: boolean;
  103458. VIGNETTE: boolean;
  103459. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103460. VIGNETTEBLENDMODEOPAQUE: boolean;
  103461. TONEMAPPING: boolean;
  103462. TONEMAPPING_ACES: boolean;
  103463. CONTRAST: boolean;
  103464. COLORCURVES: boolean;
  103465. COLORGRADING: boolean;
  103466. COLORGRADING3D: boolean;
  103467. SAMPLER3DGREENDEPTH: boolean;
  103468. SAMPLER3DBGRMAP: boolean;
  103469. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103470. MULTIVIEW: boolean;
  103471. /**
  103472. * If the reflection texture on this material is in linear color space
  103473. * @hidden
  103474. */
  103475. IS_REFLECTION_LINEAR: boolean;
  103476. /**
  103477. * If the refraction texture on this material is in linear color space
  103478. * @hidden
  103479. */
  103480. IS_REFRACTION_LINEAR: boolean;
  103481. EXPOSURE: boolean;
  103482. constructor();
  103483. setReflectionMode(modeToEnable: string): void;
  103484. }
  103485. /**
  103486. * This is the default material used in Babylon. It is the best trade off between quality
  103487. * and performances.
  103488. * @see http://doc.babylonjs.com/babylon101/materials
  103489. */
  103490. export class StandardMaterial extends PushMaterial {
  103491. private _diffuseTexture;
  103492. /**
  103493. * The basic texture of the material as viewed under a light.
  103494. */
  103495. diffuseTexture: Nullable<BaseTexture>;
  103496. private _ambientTexture;
  103497. /**
  103498. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  103499. */
  103500. ambientTexture: Nullable<BaseTexture>;
  103501. private _opacityTexture;
  103502. /**
  103503. * Define the transparency of the material from a texture.
  103504. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  103505. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  103506. */
  103507. opacityTexture: Nullable<BaseTexture>;
  103508. private _reflectionTexture;
  103509. /**
  103510. * Define the texture used to display the reflection.
  103511. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103512. */
  103513. reflectionTexture: Nullable<BaseTexture>;
  103514. private _emissiveTexture;
  103515. /**
  103516. * Define texture of the material as if self lit.
  103517. * This will be mixed in the final result even in the absence of light.
  103518. */
  103519. emissiveTexture: Nullable<BaseTexture>;
  103520. private _specularTexture;
  103521. /**
  103522. * Define how the color and intensity of the highlight given by the light in the material.
  103523. */
  103524. specularTexture: Nullable<BaseTexture>;
  103525. private _bumpTexture;
  103526. /**
  103527. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  103528. * 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.
  103529. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  103530. */
  103531. bumpTexture: Nullable<BaseTexture>;
  103532. private _lightmapTexture;
  103533. /**
  103534. * Complex lighting can be computationally expensive to compute at runtime.
  103535. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  103536. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  103537. */
  103538. lightmapTexture: Nullable<BaseTexture>;
  103539. private _refractionTexture;
  103540. /**
  103541. * Define the texture used to display the refraction.
  103542. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103543. */
  103544. refractionTexture: Nullable<BaseTexture>;
  103545. /**
  103546. * The color of the material lit by the environmental background lighting.
  103547. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  103548. */
  103549. ambientColor: Color3;
  103550. /**
  103551. * The basic color of the material as viewed under a light.
  103552. */
  103553. diffuseColor: Color3;
  103554. /**
  103555. * Define how the color and intensity of the highlight given by the light in the material.
  103556. */
  103557. specularColor: Color3;
  103558. /**
  103559. * Define the color of the material as if self lit.
  103560. * This will be mixed in the final result even in the absence of light.
  103561. */
  103562. emissiveColor: Color3;
  103563. /**
  103564. * Defines how sharp are the highlights in the material.
  103565. * The bigger the value the sharper giving a more glossy feeling to the result.
  103566. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  103567. */
  103568. specularPower: number;
  103569. private _useAlphaFromDiffuseTexture;
  103570. /**
  103571. * Does the transparency come from the diffuse texture alpha channel.
  103572. */
  103573. useAlphaFromDiffuseTexture: boolean;
  103574. private _useEmissiveAsIllumination;
  103575. /**
  103576. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  103577. */
  103578. useEmissiveAsIllumination: boolean;
  103579. private _linkEmissiveWithDiffuse;
  103580. /**
  103581. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  103582. * the emissive level when the final color is close to one.
  103583. */
  103584. linkEmissiveWithDiffuse: boolean;
  103585. private _useSpecularOverAlpha;
  103586. /**
  103587. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103588. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103589. */
  103590. useSpecularOverAlpha: boolean;
  103591. private _useReflectionOverAlpha;
  103592. /**
  103593. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103594. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103595. */
  103596. useReflectionOverAlpha: boolean;
  103597. private _disableLighting;
  103598. /**
  103599. * Does lights from the scene impacts this material.
  103600. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  103601. */
  103602. disableLighting: boolean;
  103603. private _useObjectSpaceNormalMap;
  103604. /**
  103605. * Allows using an object space normal map (instead of tangent space).
  103606. */
  103607. useObjectSpaceNormalMap: boolean;
  103608. private _useParallax;
  103609. /**
  103610. * Is parallax enabled or not.
  103611. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103612. */
  103613. useParallax: boolean;
  103614. private _useParallaxOcclusion;
  103615. /**
  103616. * Is parallax occlusion enabled or not.
  103617. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  103618. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103619. */
  103620. useParallaxOcclusion: boolean;
  103621. /**
  103622. * 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.
  103623. */
  103624. parallaxScaleBias: number;
  103625. private _roughness;
  103626. /**
  103627. * Helps to define how blurry the reflections should appears in the material.
  103628. */
  103629. roughness: number;
  103630. /**
  103631. * In case of refraction, define the value of the index of refraction.
  103632. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103633. */
  103634. indexOfRefraction: number;
  103635. /**
  103636. * Invert the refraction texture alongside the y axis.
  103637. * It can be useful with procedural textures or probe for instance.
  103638. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103639. */
  103640. invertRefractionY: boolean;
  103641. /**
  103642. * Defines the alpha limits in alpha test mode.
  103643. */
  103644. alphaCutOff: number;
  103645. private _useLightmapAsShadowmap;
  103646. /**
  103647. * In case of light mapping, define whether the map contains light or shadow informations.
  103648. */
  103649. useLightmapAsShadowmap: boolean;
  103650. private _diffuseFresnelParameters;
  103651. /**
  103652. * Define the diffuse fresnel parameters of the material.
  103653. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103654. */
  103655. diffuseFresnelParameters: FresnelParameters;
  103656. private _opacityFresnelParameters;
  103657. /**
  103658. * Define the opacity fresnel parameters of the material.
  103659. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103660. */
  103661. opacityFresnelParameters: FresnelParameters;
  103662. private _reflectionFresnelParameters;
  103663. /**
  103664. * Define the reflection fresnel parameters of the material.
  103665. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103666. */
  103667. reflectionFresnelParameters: FresnelParameters;
  103668. private _refractionFresnelParameters;
  103669. /**
  103670. * Define the refraction fresnel parameters of the material.
  103671. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103672. */
  103673. refractionFresnelParameters: FresnelParameters;
  103674. private _emissiveFresnelParameters;
  103675. /**
  103676. * Define the emissive fresnel parameters of the material.
  103677. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103678. */
  103679. emissiveFresnelParameters: FresnelParameters;
  103680. private _useReflectionFresnelFromSpecular;
  103681. /**
  103682. * If true automatically deducts the fresnels values from the material specularity.
  103683. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103684. */
  103685. useReflectionFresnelFromSpecular: boolean;
  103686. private _useGlossinessFromSpecularMapAlpha;
  103687. /**
  103688. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  103689. */
  103690. useGlossinessFromSpecularMapAlpha: boolean;
  103691. private _maxSimultaneousLights;
  103692. /**
  103693. * Defines the maximum number of lights that can be used in the material
  103694. */
  103695. maxSimultaneousLights: number;
  103696. private _invertNormalMapX;
  103697. /**
  103698. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103699. */
  103700. invertNormalMapX: boolean;
  103701. private _invertNormalMapY;
  103702. /**
  103703. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103704. */
  103705. invertNormalMapY: boolean;
  103706. private _twoSidedLighting;
  103707. /**
  103708. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103709. */
  103710. twoSidedLighting: boolean;
  103711. /**
  103712. * Default configuration related to image processing available in the standard Material.
  103713. */
  103714. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103715. /**
  103716. * Gets the image processing configuration used either in this material.
  103717. */
  103718. /**
  103719. * Sets the Default image processing configuration used either in the this material.
  103720. *
  103721. * If sets to null, the scene one is in use.
  103722. */
  103723. imageProcessingConfiguration: ImageProcessingConfiguration;
  103724. /**
  103725. * Keep track of the image processing observer to allow dispose and replace.
  103726. */
  103727. private _imageProcessingObserver;
  103728. /**
  103729. * Attaches a new image processing configuration to the Standard Material.
  103730. * @param configuration
  103731. */
  103732. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103733. /**
  103734. * Gets wether the color curves effect is enabled.
  103735. */
  103736. /**
  103737. * Sets wether the color curves effect is enabled.
  103738. */
  103739. cameraColorCurvesEnabled: boolean;
  103740. /**
  103741. * Gets wether the color grading effect is enabled.
  103742. */
  103743. /**
  103744. * Gets wether the color grading effect is enabled.
  103745. */
  103746. cameraColorGradingEnabled: boolean;
  103747. /**
  103748. * Gets wether tonemapping is enabled or not.
  103749. */
  103750. /**
  103751. * Sets wether tonemapping is enabled or not
  103752. */
  103753. cameraToneMappingEnabled: boolean;
  103754. /**
  103755. * The camera exposure used on this material.
  103756. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103757. * This corresponds to a photographic exposure.
  103758. */
  103759. /**
  103760. * The camera exposure used on this material.
  103761. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103762. * This corresponds to a photographic exposure.
  103763. */
  103764. cameraExposure: number;
  103765. /**
  103766. * Gets The camera contrast used on this material.
  103767. */
  103768. /**
  103769. * Sets The camera contrast used on this material.
  103770. */
  103771. cameraContrast: number;
  103772. /**
  103773. * Gets the Color Grading 2D Lookup Texture.
  103774. */
  103775. /**
  103776. * Sets the Color Grading 2D Lookup Texture.
  103777. */
  103778. cameraColorGradingTexture: Nullable<BaseTexture>;
  103779. /**
  103780. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103781. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103782. * 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;
  103783. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103784. */
  103785. /**
  103786. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103787. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103788. * 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;
  103789. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103790. */
  103791. cameraColorCurves: Nullable<ColorCurves>;
  103792. /**
  103793. * Custom callback helping to override the default shader used in the material.
  103794. */
  103795. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  103796. protected _renderTargets: SmartArray<RenderTargetTexture>;
  103797. protected _worldViewProjectionMatrix: Matrix;
  103798. protected _globalAmbientColor: Color3;
  103799. protected _useLogarithmicDepth: boolean;
  103800. /**
  103801. * Instantiates a new standard material.
  103802. * This is the default material used in Babylon. It is the best trade off between quality
  103803. * and performances.
  103804. * @see http://doc.babylonjs.com/babylon101/materials
  103805. * @param name Define the name of the material in the scene
  103806. * @param scene Define the scene the material belong to
  103807. */
  103808. constructor(name: string, scene: Scene);
  103809. /**
  103810. * Gets a boolean indicating that current material needs to register RTT
  103811. */
  103812. readonly hasRenderTargetTextures: boolean;
  103813. /**
  103814. * Gets the current class name of the material e.g. "StandardMaterial"
  103815. * Mainly use in serialization.
  103816. * @returns the class name
  103817. */
  103818. getClassName(): string;
  103819. /**
  103820. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  103821. * You can try switching to logarithmic depth.
  103822. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  103823. */
  103824. useLogarithmicDepth: boolean;
  103825. /**
  103826. * Specifies if the material will require alpha blending
  103827. * @returns a boolean specifying if alpha blending is needed
  103828. */
  103829. needAlphaBlending(): boolean;
  103830. /**
  103831. * Specifies if this material should be rendered in alpha test mode
  103832. * @returns a boolean specifying if an alpha test is needed.
  103833. */
  103834. needAlphaTesting(): boolean;
  103835. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  103836. /**
  103837. * Get the texture used for alpha test purpose.
  103838. * @returns the diffuse texture in case of the standard material.
  103839. */
  103840. getAlphaTestTexture(): Nullable<BaseTexture>;
  103841. /**
  103842. * Get if the submesh is ready to be used and all its information available.
  103843. * Child classes can use it to update shaders
  103844. * @param mesh defines the mesh to check
  103845. * @param subMesh defines which submesh to check
  103846. * @param useInstances specifies that instances should be used
  103847. * @returns a boolean indicating that the submesh is ready or not
  103848. */
  103849. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103850. /**
  103851. * Builds the material UBO layouts.
  103852. * Used internally during the effect preparation.
  103853. */
  103854. buildUniformLayout(): void;
  103855. /**
  103856. * Unbinds the material from the mesh
  103857. */
  103858. unbind(): void;
  103859. /**
  103860. * Binds the submesh to this material by preparing the effect and shader to draw
  103861. * @param world defines the world transformation matrix
  103862. * @param mesh defines the mesh containing the submesh
  103863. * @param subMesh defines the submesh to bind the material to
  103864. */
  103865. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103866. /**
  103867. * Get the list of animatables in the material.
  103868. * @returns the list of animatables object used in the material
  103869. */
  103870. getAnimatables(): IAnimatable[];
  103871. /**
  103872. * Gets the active textures from the material
  103873. * @returns an array of textures
  103874. */
  103875. getActiveTextures(): BaseTexture[];
  103876. /**
  103877. * Specifies if the material uses a texture
  103878. * @param texture defines the texture to check against the material
  103879. * @returns a boolean specifying if the material uses the texture
  103880. */
  103881. hasTexture(texture: BaseTexture): boolean;
  103882. /**
  103883. * Disposes the material
  103884. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103885. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103886. */
  103887. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103888. /**
  103889. * Makes a duplicate of the material, and gives it a new name
  103890. * @param name defines the new name for the duplicated material
  103891. * @returns the cloned material
  103892. */
  103893. clone(name: string): StandardMaterial;
  103894. /**
  103895. * Serializes this material in a JSON representation
  103896. * @returns the serialized material object
  103897. */
  103898. serialize(): any;
  103899. /**
  103900. * Creates a standard material from parsed material data
  103901. * @param source defines the JSON representation of the material
  103902. * @param scene defines the hosting scene
  103903. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103904. * @returns a new standard material
  103905. */
  103906. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  103907. /**
  103908. * Are diffuse textures enabled in the application.
  103909. */
  103910. static DiffuseTextureEnabled: boolean;
  103911. /**
  103912. * Are ambient textures enabled in the application.
  103913. */
  103914. static AmbientTextureEnabled: boolean;
  103915. /**
  103916. * Are opacity textures enabled in the application.
  103917. */
  103918. static OpacityTextureEnabled: boolean;
  103919. /**
  103920. * Are reflection textures enabled in the application.
  103921. */
  103922. static ReflectionTextureEnabled: boolean;
  103923. /**
  103924. * Are emissive textures enabled in the application.
  103925. */
  103926. static EmissiveTextureEnabled: boolean;
  103927. /**
  103928. * Are specular textures enabled in the application.
  103929. */
  103930. static SpecularTextureEnabled: boolean;
  103931. /**
  103932. * Are bump textures enabled in the application.
  103933. */
  103934. static BumpTextureEnabled: boolean;
  103935. /**
  103936. * Are lightmap textures enabled in the application.
  103937. */
  103938. static LightmapTextureEnabled: boolean;
  103939. /**
  103940. * Are refraction textures enabled in the application.
  103941. */
  103942. static RefractionTextureEnabled: boolean;
  103943. /**
  103944. * Are color grading textures enabled in the application.
  103945. */
  103946. static ColorGradingTextureEnabled: boolean;
  103947. /**
  103948. * Are fresnels enabled in the application.
  103949. */
  103950. static FresnelEnabled: boolean;
  103951. }
  103952. }
  103953. declare module BABYLON {
  103954. /**
  103955. * A class extending Texture allowing drawing on a texture
  103956. * @see http://doc.babylonjs.com/how_to/dynamictexture
  103957. */
  103958. export class DynamicTexture extends Texture {
  103959. private _generateMipMaps;
  103960. private _canvas;
  103961. private _context;
  103962. private _engine;
  103963. /**
  103964. * Creates a DynamicTexture
  103965. * @param name defines the name of the texture
  103966. * @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
  103967. * @param scene defines the scene where you want the texture
  103968. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  103969. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  103970. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  103971. */
  103972. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  103973. /**
  103974. * Get the current class name of the texture useful for serialization or dynamic coding.
  103975. * @returns "DynamicTexture"
  103976. */
  103977. getClassName(): string;
  103978. /**
  103979. * Gets the current state of canRescale
  103980. */
  103981. readonly canRescale: boolean;
  103982. private _recreate;
  103983. /**
  103984. * Scales the texture
  103985. * @param ratio the scale factor to apply to both width and height
  103986. */
  103987. scale(ratio: number): void;
  103988. /**
  103989. * Resizes the texture
  103990. * @param width the new width
  103991. * @param height the new height
  103992. */
  103993. scaleTo(width: number, height: number): void;
  103994. /**
  103995. * Gets the context of the canvas used by the texture
  103996. * @returns the canvas context of the dynamic texture
  103997. */
  103998. getContext(): CanvasRenderingContext2D;
  103999. /**
  104000. * Clears the texture
  104001. */
  104002. clear(): void;
  104003. /**
  104004. * Updates the texture
  104005. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104006. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  104007. */
  104008. update(invertY?: boolean, premulAlpha?: boolean): void;
  104009. /**
  104010. * Draws text onto the texture
  104011. * @param text defines the text to be drawn
  104012. * @param x defines the placement of the text from the left
  104013. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  104014. * @param font defines the font to be used with font-style, font-size, font-name
  104015. * @param color defines the color used for the text
  104016. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  104017. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104018. * @param update defines whether texture is immediately update (default is true)
  104019. */
  104020. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  104021. /**
  104022. * Clones the texture
  104023. * @returns the clone of the texture.
  104024. */
  104025. clone(): DynamicTexture;
  104026. /**
  104027. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  104028. * @returns a serialized dynamic texture object
  104029. */
  104030. serialize(): any;
  104031. /** @hidden */
  104032. _rebuild(): void;
  104033. }
  104034. }
  104035. declare module BABYLON {
  104036. /** @hidden */
  104037. export var imageProcessingPixelShader: {
  104038. name: string;
  104039. shader: string;
  104040. };
  104041. }
  104042. declare module BABYLON {
  104043. /**
  104044. * ImageProcessingPostProcess
  104045. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104046. */
  104047. export class ImageProcessingPostProcess extends PostProcess {
  104048. /**
  104049. * Default configuration related to image processing available in the PBR Material.
  104050. */
  104051. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104052. /**
  104053. * Gets the image processing configuration used either in this material.
  104054. */
  104055. /**
  104056. * Sets the Default image processing configuration used either in the this material.
  104057. *
  104058. * If sets to null, the scene one is in use.
  104059. */
  104060. imageProcessingConfiguration: ImageProcessingConfiguration;
  104061. /**
  104062. * Keep track of the image processing observer to allow dispose and replace.
  104063. */
  104064. private _imageProcessingObserver;
  104065. /**
  104066. * Attaches a new image processing configuration to the PBR Material.
  104067. * @param configuration
  104068. */
  104069. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104070. /**
  104071. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104072. */
  104073. /**
  104074. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104075. */
  104076. colorCurves: Nullable<ColorCurves>;
  104077. /**
  104078. * Gets wether the color curves effect is enabled.
  104079. */
  104080. /**
  104081. * Sets wether the color curves effect is enabled.
  104082. */
  104083. colorCurvesEnabled: boolean;
  104084. /**
  104085. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104086. */
  104087. /**
  104088. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104089. */
  104090. colorGradingTexture: Nullable<BaseTexture>;
  104091. /**
  104092. * Gets wether the color grading effect is enabled.
  104093. */
  104094. /**
  104095. * Gets wether the color grading effect is enabled.
  104096. */
  104097. colorGradingEnabled: boolean;
  104098. /**
  104099. * Gets exposure used in the effect.
  104100. */
  104101. /**
  104102. * Sets exposure used in the effect.
  104103. */
  104104. exposure: number;
  104105. /**
  104106. * Gets wether tonemapping is enabled or not.
  104107. */
  104108. /**
  104109. * Sets wether tonemapping is enabled or not
  104110. */
  104111. toneMappingEnabled: boolean;
  104112. /**
  104113. * Gets the type of tone mapping effect.
  104114. */
  104115. /**
  104116. * Sets the type of tone mapping effect.
  104117. */
  104118. toneMappingType: number;
  104119. /**
  104120. * Gets contrast used in the effect.
  104121. */
  104122. /**
  104123. * Sets contrast used in the effect.
  104124. */
  104125. contrast: number;
  104126. /**
  104127. * Gets Vignette stretch size.
  104128. */
  104129. /**
  104130. * Sets Vignette stretch size.
  104131. */
  104132. vignetteStretch: number;
  104133. /**
  104134. * Gets Vignette centre X Offset.
  104135. */
  104136. /**
  104137. * Sets Vignette centre X Offset.
  104138. */
  104139. vignetteCentreX: number;
  104140. /**
  104141. * Gets Vignette centre Y Offset.
  104142. */
  104143. /**
  104144. * Sets Vignette centre Y Offset.
  104145. */
  104146. vignetteCentreY: number;
  104147. /**
  104148. * Gets Vignette weight or intensity of the vignette effect.
  104149. */
  104150. /**
  104151. * Sets Vignette weight or intensity of the vignette effect.
  104152. */
  104153. vignetteWeight: number;
  104154. /**
  104155. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104156. * if vignetteEnabled is set to true.
  104157. */
  104158. /**
  104159. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104160. * if vignetteEnabled is set to true.
  104161. */
  104162. vignetteColor: Color4;
  104163. /**
  104164. * Gets Camera field of view used by the Vignette effect.
  104165. */
  104166. /**
  104167. * Sets Camera field of view used by the Vignette effect.
  104168. */
  104169. vignetteCameraFov: number;
  104170. /**
  104171. * Gets the vignette blend mode allowing different kind of effect.
  104172. */
  104173. /**
  104174. * Sets the vignette blend mode allowing different kind of effect.
  104175. */
  104176. vignetteBlendMode: number;
  104177. /**
  104178. * Gets wether the vignette effect is enabled.
  104179. */
  104180. /**
  104181. * Sets wether the vignette effect is enabled.
  104182. */
  104183. vignetteEnabled: boolean;
  104184. private _fromLinearSpace;
  104185. /**
  104186. * Gets wether the input of the processing is in Gamma or Linear Space.
  104187. */
  104188. /**
  104189. * Sets wether the input of the processing is in Gamma or Linear Space.
  104190. */
  104191. fromLinearSpace: boolean;
  104192. /**
  104193. * Defines cache preventing GC.
  104194. */
  104195. private _defines;
  104196. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104197. /**
  104198. * "ImageProcessingPostProcess"
  104199. * @returns "ImageProcessingPostProcess"
  104200. */
  104201. getClassName(): string;
  104202. protected _updateParameters(): void;
  104203. dispose(camera?: Camera): void;
  104204. }
  104205. }
  104206. declare module BABYLON {
  104207. /**
  104208. * Class containing static functions to help procedurally build meshes
  104209. */
  104210. export class GroundBuilder {
  104211. /**
  104212. * Creates a ground mesh
  104213. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  104214. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  104215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104216. * @param name defines the name of the mesh
  104217. * @param options defines the options used to create the mesh
  104218. * @param scene defines the hosting scene
  104219. * @returns the ground mesh
  104220. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104221. */
  104222. static CreateGround(name: string, options: {
  104223. width?: number;
  104224. height?: number;
  104225. subdivisions?: number;
  104226. subdivisionsX?: number;
  104227. subdivisionsY?: number;
  104228. updatable?: boolean;
  104229. }, scene: any): Mesh;
  104230. /**
  104231. * Creates a tiled ground mesh
  104232. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104233. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104234. * * 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
  104235. * * 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
  104236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104237. * @param name defines the name of the mesh
  104238. * @param options defines the options used to create the mesh
  104239. * @param scene defines the hosting scene
  104240. * @returns the tiled ground mesh
  104241. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104242. */
  104243. static CreateTiledGround(name: string, options: {
  104244. xmin: number;
  104245. zmin: number;
  104246. xmax: number;
  104247. zmax: number;
  104248. subdivisions?: {
  104249. w: number;
  104250. h: number;
  104251. };
  104252. precision?: {
  104253. w: number;
  104254. h: number;
  104255. };
  104256. updatable?: boolean;
  104257. }, scene?: Nullable<Scene>): Mesh;
  104258. /**
  104259. * Creates a ground mesh from a height map
  104260. * * The parameter `url` sets the URL of the height map image resource.
  104261. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104262. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104263. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104264. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104265. * * 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.
  104266. * * 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).
  104267. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104269. * @param name defines the name of the mesh
  104270. * @param url defines the url to the height map
  104271. * @param options defines the options used to create the mesh
  104272. * @param scene defines the hosting scene
  104273. * @returns the ground mesh
  104274. * @see https://doc.babylonjs.com/babylon101/height_map
  104275. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104276. */
  104277. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104278. width?: number;
  104279. height?: number;
  104280. subdivisions?: number;
  104281. minHeight?: number;
  104282. maxHeight?: number;
  104283. colorFilter?: Color3;
  104284. alphaFilter?: number;
  104285. updatable?: boolean;
  104286. onReady?: (mesh: GroundMesh) => void;
  104287. }, scene?: Nullable<Scene>): GroundMesh;
  104288. }
  104289. }
  104290. declare module BABYLON {
  104291. /**
  104292. * Class containing static functions to help procedurally build meshes
  104293. */
  104294. export class TorusBuilder {
  104295. /**
  104296. * Creates a torus mesh
  104297. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  104298. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  104299. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  104300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104303. * @param name defines the name of the mesh
  104304. * @param options defines the options used to create the mesh
  104305. * @param scene defines the hosting scene
  104306. * @returns the torus mesh
  104307. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  104308. */
  104309. static CreateTorus(name: string, options: {
  104310. diameter?: number;
  104311. thickness?: number;
  104312. tessellation?: number;
  104313. updatable?: boolean;
  104314. sideOrientation?: number;
  104315. frontUVs?: Vector4;
  104316. backUVs?: Vector4;
  104317. }, scene: any): Mesh;
  104318. }
  104319. }
  104320. declare module BABYLON {
  104321. /**
  104322. * Class containing static functions to help procedurally build meshes
  104323. */
  104324. export class CylinderBuilder {
  104325. /**
  104326. * Creates a cylinder or a cone mesh
  104327. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  104328. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  104329. * * 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.
  104330. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  104331. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  104332. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  104333. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  104334. * * 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).
  104335. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  104336. * * 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).
  104337. * * 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
  104338. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  104339. * * 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
  104340. * * 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.
  104341. * * If `enclose` is false, a ring surface is one element.
  104342. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  104343. * * 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
  104344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104347. * @param name defines the name of the mesh
  104348. * @param options defines the options used to create the mesh
  104349. * @param scene defines the hosting scene
  104350. * @returns the cylinder mesh
  104351. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  104352. */
  104353. static CreateCylinder(name: string, options: {
  104354. height?: number;
  104355. diameterTop?: number;
  104356. diameterBottom?: number;
  104357. diameter?: number;
  104358. tessellation?: number;
  104359. subdivisions?: number;
  104360. arc?: number;
  104361. faceColors?: Color4[];
  104362. faceUV?: Vector4[];
  104363. updatable?: boolean;
  104364. hasRings?: boolean;
  104365. enclose?: boolean;
  104366. cap?: number;
  104367. sideOrientation?: number;
  104368. frontUVs?: Vector4;
  104369. backUVs?: Vector4;
  104370. }, scene: any): Mesh;
  104371. }
  104372. }
  104373. declare module BABYLON {
  104374. /**
  104375. * Options to modify the vr teleportation behavior.
  104376. */
  104377. export interface VRTeleportationOptions {
  104378. /**
  104379. * The name of the mesh which should be used as the teleportation floor. (default: null)
  104380. */
  104381. floorMeshName?: string;
  104382. /**
  104383. * A list of meshes to be used as the teleportation floor. (default: empty)
  104384. */
  104385. floorMeshes?: Mesh[];
  104386. }
  104387. /**
  104388. * Options to modify the vr experience helper's behavior.
  104389. */
  104390. export interface VRExperienceHelperOptions extends WebVROptions {
  104391. /**
  104392. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  104393. */
  104394. createDeviceOrientationCamera?: boolean;
  104395. /**
  104396. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  104397. */
  104398. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  104399. /**
  104400. * Uses the main button on the controller to toggle the laser casted. (default: true)
  104401. */
  104402. laserToggle?: boolean;
  104403. /**
  104404. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  104405. */
  104406. floorMeshes?: Mesh[];
  104407. /**
  104408. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  104409. */
  104410. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  104411. }
  104412. /**
  104413. * Event containing information after VR has been entered
  104414. */
  104415. export class OnAfterEnteringVRObservableEvent {
  104416. /**
  104417. * If entering vr was successful
  104418. */
  104419. success: boolean;
  104420. }
  104421. /**
  104422. * Helps to quickly add VR support to an existing scene.
  104423. * See http://doc.babylonjs.com/how_to/webvr_helper
  104424. */
  104425. export class VRExperienceHelper {
  104426. /** Options to modify the vr experience helper's behavior. */
  104427. webVROptions: VRExperienceHelperOptions;
  104428. private _scene;
  104429. private _position;
  104430. private _btnVR;
  104431. private _btnVRDisplayed;
  104432. private _webVRsupported;
  104433. private _webVRready;
  104434. private _webVRrequesting;
  104435. private _webVRpresenting;
  104436. private _hasEnteredVR;
  104437. private _fullscreenVRpresenting;
  104438. private _canvas;
  104439. private _webVRCamera;
  104440. private _vrDeviceOrientationCamera;
  104441. private _deviceOrientationCamera;
  104442. private _existingCamera;
  104443. private _onKeyDown;
  104444. private _onVrDisplayPresentChange;
  104445. private _onVRDisplayChanged;
  104446. private _onVRRequestPresentStart;
  104447. private _onVRRequestPresentComplete;
  104448. /**
  104449. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  104450. */
  104451. enableGazeEvenWhenNoPointerLock: boolean;
  104452. /**
  104453. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  104454. */
  104455. exitVROnDoubleTap: boolean;
  104456. /**
  104457. * Observable raised right before entering VR.
  104458. */
  104459. onEnteringVRObservable: Observable<VRExperienceHelper>;
  104460. /**
  104461. * Observable raised when entering VR has completed.
  104462. */
  104463. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  104464. /**
  104465. * Observable raised when exiting VR.
  104466. */
  104467. onExitingVRObservable: Observable<VRExperienceHelper>;
  104468. /**
  104469. * Observable raised when controller mesh is loaded.
  104470. */
  104471. onControllerMeshLoadedObservable: Observable<WebVRController>;
  104472. /** Return this.onEnteringVRObservable
  104473. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  104474. */
  104475. readonly onEnteringVR: Observable<VRExperienceHelper>;
  104476. /** Return this.onExitingVRObservable
  104477. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  104478. */
  104479. readonly onExitingVR: Observable<VRExperienceHelper>;
  104480. /** Return this.onControllerMeshLoadedObservable
  104481. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  104482. */
  104483. readonly onControllerMeshLoaded: Observable<WebVRController>;
  104484. private _rayLength;
  104485. private _useCustomVRButton;
  104486. private _teleportationRequested;
  104487. private _teleportActive;
  104488. private _floorMeshName;
  104489. private _floorMeshesCollection;
  104490. private _rotationAllowed;
  104491. private _teleportBackwardsVector;
  104492. private _teleportationTarget;
  104493. private _isDefaultTeleportationTarget;
  104494. private _postProcessMove;
  104495. private _teleportationFillColor;
  104496. private _teleportationBorderColor;
  104497. private _rotationAngle;
  104498. private _haloCenter;
  104499. private _cameraGazer;
  104500. private _padSensibilityUp;
  104501. private _padSensibilityDown;
  104502. private _leftController;
  104503. private _rightController;
  104504. /**
  104505. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  104506. */
  104507. onNewMeshSelected: Observable<AbstractMesh>;
  104508. /**
  104509. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  104510. */
  104511. onNewMeshPicked: Observable<PickingInfo>;
  104512. private _circleEase;
  104513. /**
  104514. * Observable raised before camera teleportation
  104515. */
  104516. onBeforeCameraTeleport: Observable<Vector3>;
  104517. /**
  104518. * Observable raised after camera teleportation
  104519. */
  104520. onAfterCameraTeleport: Observable<Vector3>;
  104521. /**
  104522. * Observable raised when current selected mesh gets unselected
  104523. */
  104524. onSelectedMeshUnselected: Observable<AbstractMesh>;
  104525. private _raySelectionPredicate;
  104526. /**
  104527. * To be optionaly changed by user to define custom ray selection
  104528. */
  104529. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  104530. /**
  104531. * To be optionaly changed by user to define custom selection logic (after ray selection)
  104532. */
  104533. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  104534. /**
  104535. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  104536. */
  104537. teleportationEnabled: boolean;
  104538. private _defaultHeight;
  104539. private _teleportationInitialized;
  104540. private _interactionsEnabled;
  104541. private _interactionsRequested;
  104542. private _displayGaze;
  104543. private _displayLaserPointer;
  104544. /**
  104545. * The mesh used to display where the user is going to teleport.
  104546. */
  104547. /**
  104548. * Sets the mesh to be used to display where the user is going to teleport.
  104549. */
  104550. teleportationTarget: Mesh;
  104551. /**
  104552. * 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
  104553. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  104554. * See http://doc.babylonjs.com/resources/baking_transformations
  104555. */
  104556. gazeTrackerMesh: Mesh;
  104557. /**
  104558. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  104559. */
  104560. updateGazeTrackerScale: boolean;
  104561. /**
  104562. * If the gaze trackers color should be updated when selecting meshes
  104563. */
  104564. updateGazeTrackerColor: boolean;
  104565. /**
  104566. * The gaze tracking mesh corresponding to the left controller
  104567. */
  104568. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  104569. /**
  104570. * The gaze tracking mesh corresponding to the right controller
  104571. */
  104572. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  104573. /**
  104574. * If the ray of the gaze should be displayed.
  104575. */
  104576. /**
  104577. * Sets if the ray of the gaze should be displayed.
  104578. */
  104579. displayGaze: boolean;
  104580. /**
  104581. * If the ray of the LaserPointer should be displayed.
  104582. */
  104583. /**
  104584. * Sets if the ray of the LaserPointer should be displayed.
  104585. */
  104586. displayLaserPointer: boolean;
  104587. /**
  104588. * The deviceOrientationCamera used as the camera when not in VR.
  104589. */
  104590. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  104591. /**
  104592. * Based on the current WebVR support, returns the current VR camera used.
  104593. */
  104594. readonly currentVRCamera: Nullable<Camera>;
  104595. /**
  104596. * The webVRCamera which is used when in VR.
  104597. */
  104598. readonly webVRCamera: WebVRFreeCamera;
  104599. /**
  104600. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  104601. */
  104602. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  104603. /**
  104604. * The html button that is used to trigger entering into VR.
  104605. */
  104606. readonly vrButton: Nullable<HTMLButtonElement>;
  104607. private readonly _teleportationRequestInitiated;
  104608. /**
  104609. * Defines wether or not Pointer lock should be requested when switching to
  104610. * full screen.
  104611. */
  104612. requestPointerLockOnFullScreen: boolean;
  104613. /**
  104614. * Instantiates a VRExperienceHelper.
  104615. * Helps to quickly add VR support to an existing scene.
  104616. * @param scene The scene the VRExperienceHelper belongs to.
  104617. * @param webVROptions Options to modify the vr experience helper's behavior.
  104618. */
  104619. constructor(scene: Scene,
  104620. /** Options to modify the vr experience helper's behavior. */
  104621. webVROptions?: VRExperienceHelperOptions);
  104622. private _onDefaultMeshLoaded;
  104623. private _onResize;
  104624. private _onFullscreenChange;
  104625. /**
  104626. * Gets a value indicating if we are currently in VR mode.
  104627. */
  104628. readonly isInVRMode: boolean;
  104629. private onVrDisplayPresentChange;
  104630. private onVRDisplayChanged;
  104631. private moveButtonToBottomRight;
  104632. private displayVRButton;
  104633. private updateButtonVisibility;
  104634. private _cachedAngularSensibility;
  104635. /**
  104636. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  104637. * Otherwise, will use the fullscreen API.
  104638. */
  104639. enterVR(): void;
  104640. /**
  104641. * Attempt to exit VR, or fullscreen.
  104642. */
  104643. exitVR(): void;
  104644. /**
  104645. * The position of the vr experience helper.
  104646. */
  104647. /**
  104648. * Sets the position of the vr experience helper.
  104649. */
  104650. position: Vector3;
  104651. /**
  104652. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  104653. */
  104654. enableInteractions(): void;
  104655. private readonly _noControllerIsActive;
  104656. private beforeRender;
  104657. private _isTeleportationFloor;
  104658. /**
  104659. * Adds a floor mesh to be used for teleportation.
  104660. * @param floorMesh the mesh to be used for teleportation.
  104661. */
  104662. addFloorMesh(floorMesh: Mesh): void;
  104663. /**
  104664. * Removes a floor mesh from being used for teleportation.
  104665. * @param floorMesh the mesh to be removed.
  104666. */
  104667. removeFloorMesh(floorMesh: Mesh): void;
  104668. /**
  104669. * Enables interactions and teleportation using the VR controllers and gaze.
  104670. * @param vrTeleportationOptions options to modify teleportation behavior.
  104671. */
  104672. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  104673. private _onNewGamepadConnected;
  104674. private _tryEnableInteractionOnController;
  104675. private _onNewGamepadDisconnected;
  104676. private _enableInteractionOnController;
  104677. private _checkTeleportWithRay;
  104678. private _checkRotate;
  104679. private _checkTeleportBackwards;
  104680. private _enableTeleportationOnController;
  104681. private _createTeleportationCircles;
  104682. private _displayTeleportationTarget;
  104683. private _hideTeleportationTarget;
  104684. private _rotateCamera;
  104685. private _moveTeleportationSelectorTo;
  104686. private _workingVector;
  104687. private _workingQuaternion;
  104688. private _workingMatrix;
  104689. /**
  104690. * Teleports the users feet to the desired location
  104691. * @param location The location where the user's feet should be placed
  104692. */
  104693. teleportCamera(location: Vector3): void;
  104694. private _convertNormalToDirectionOfRay;
  104695. private _castRayAndSelectObject;
  104696. private _notifySelectedMeshUnselected;
  104697. /**
  104698. * Sets the color of the laser ray from the vr controllers.
  104699. * @param color new color for the ray.
  104700. */
  104701. changeLaserColor(color: Color3): void;
  104702. /**
  104703. * Sets the color of the ray from the vr headsets gaze.
  104704. * @param color new color for the ray.
  104705. */
  104706. changeGazeColor(color: Color3): void;
  104707. /**
  104708. * Exits VR and disposes of the vr experience helper
  104709. */
  104710. dispose(): void;
  104711. /**
  104712. * Gets the name of the VRExperienceHelper class
  104713. * @returns "VRExperienceHelper"
  104714. */
  104715. getClassName(): string;
  104716. }
  104717. }
  104718. declare module BABYLON {
  104719. /**
  104720. * Manages an XRSession to work with Babylon's engine
  104721. * @see https://doc.babylonjs.com/how_to/webxr
  104722. */
  104723. export class WebXRSessionManager implements IDisposable {
  104724. private scene;
  104725. /**
  104726. * Fires every time a new xrFrame arrives which can be used to update the camera
  104727. */
  104728. onXRFrameObservable: Observable<any>;
  104729. /**
  104730. * Fires when the xr session is ended either by the device or manually done
  104731. */
  104732. onXRSessionEnded: Observable<any>;
  104733. /**
  104734. * Underlying xr session
  104735. */
  104736. session: XRSession;
  104737. /**
  104738. * Type of reference space used when creating the session
  104739. */
  104740. referenceSpace: XRReferenceSpace;
  104741. /** @hidden */
  104742. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  104743. /**
  104744. * Current XR frame
  104745. */
  104746. currentFrame: Nullable<XRFrame>;
  104747. private _xrNavigator;
  104748. private baseLayer;
  104749. /**
  104750. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  104751. * @param scene The scene which the session should be created for
  104752. */
  104753. constructor(scene: Scene);
  104754. /**
  104755. * Initializes the manager
  104756. * After initialization enterXR can be called to start an XR session
  104757. * @returns Promise which resolves after it is initialized
  104758. */
  104759. initializeAsync(): Promise<void>;
  104760. /**
  104761. * Initializes an xr session
  104762. * @param xrSessionMode mode to initialize
  104763. * @returns a promise which will resolve once the session has been initialized
  104764. */
  104765. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  104766. /**
  104767. * Sets the reference space on the xr session
  104768. * @param referenceSpace space to set
  104769. * @returns a promise that will resolve once the reference space has been set
  104770. */
  104771. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  104772. /**
  104773. * Updates the render state of the session
  104774. * @param state state to set
  104775. * @returns a promise that resolves once the render state has been updated
  104776. */
  104777. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  104778. /**
  104779. * Starts rendering to the xr layer
  104780. * @returns a promise that will resolve once rendering has started
  104781. */
  104782. startRenderingToXRAsync(): Promise<void>;
  104783. /**
  104784. * Stops the xrSession and restores the renderloop
  104785. * @returns Promise which resolves after it exits XR
  104786. */
  104787. exitXRAsync(): Promise<unknown>;
  104788. /**
  104789. * Checks if a session would be supported for the creation options specified
  104790. * @param sessionMode session mode to check if supported eg. immersive-vr
  104791. * @returns true if supported
  104792. */
  104793. supportsSessionAsync(sessionMode: XRSessionMode): any;
  104794. /**
  104795. * @hidden
  104796. * Converts the render layer of xrSession to a render target
  104797. * @param session session to create render target for
  104798. * @param scene scene the new render target should be created for
  104799. */
  104800. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  104801. /**
  104802. * Disposes of the session manager
  104803. */
  104804. dispose(): void;
  104805. }
  104806. }
  104807. declare module BABYLON {
  104808. /**
  104809. * WebXR Camera which holds the views for the xrSession
  104810. * @see https://doc.babylonjs.com/how_to/webxr
  104811. */
  104812. export class WebXRCamera extends FreeCamera {
  104813. private static _TmpMatrix;
  104814. /**
  104815. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  104816. * @param name the name of the camera
  104817. * @param scene the scene to add the camera to
  104818. */
  104819. constructor(name: string, scene: Scene);
  104820. private _updateNumberOfRigCameras;
  104821. /** @hidden */
  104822. _updateForDualEyeDebugging(pupilDistance?: number): void;
  104823. /**
  104824. * Updates the cameras position from the current pose information of the XR session
  104825. * @param xrSessionManager the session containing pose information
  104826. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  104827. */
  104828. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  104829. }
  104830. }
  104831. declare module BABYLON {
  104832. /**
  104833. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  104834. */
  104835. export class WebXRManagedOutputCanvas implements IDisposable {
  104836. private helper;
  104837. private _canvas;
  104838. /**
  104839. * xrpresent context of the canvas which can be used to display/mirror xr content
  104840. */
  104841. canvasContext: WebGLRenderingContext;
  104842. /**
  104843. * xr layer for the canvas
  104844. */
  104845. xrLayer: Nullable<XRWebGLLayer>;
  104846. /**
  104847. * Initializes the xr layer for the session
  104848. * @param xrSession xr session
  104849. * @returns a promise that will resolve once the XR Layer has been created
  104850. */
  104851. initializeXRLayerAsync(xrSession: any): any;
  104852. /**
  104853. * Initializes the canvas to be added/removed upon entering/exiting xr
  104854. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  104855. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  104856. */
  104857. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  104858. /**
  104859. * Disposes of the object
  104860. */
  104861. dispose(): void;
  104862. private _setManagedOutputCanvas;
  104863. private _addCanvas;
  104864. private _removeCanvas;
  104865. }
  104866. }
  104867. declare module BABYLON {
  104868. /**
  104869. * States of the webXR experience
  104870. */
  104871. export enum WebXRState {
  104872. /**
  104873. * Transitioning to being in XR mode
  104874. */
  104875. ENTERING_XR = 0,
  104876. /**
  104877. * Transitioning to non XR mode
  104878. */
  104879. EXITING_XR = 1,
  104880. /**
  104881. * In XR mode and presenting
  104882. */
  104883. IN_XR = 2,
  104884. /**
  104885. * Not entered XR mode
  104886. */
  104887. NOT_IN_XR = 3
  104888. }
  104889. /**
  104890. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  104891. * @see https://doc.babylonjs.com/how_to/webxr
  104892. */
  104893. export class WebXRExperienceHelper implements IDisposable {
  104894. private scene;
  104895. /**
  104896. * 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
  104897. */
  104898. container: AbstractMesh;
  104899. /**
  104900. * Camera used to render xr content
  104901. */
  104902. camera: WebXRCamera;
  104903. /**
  104904. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  104905. */
  104906. state: WebXRState;
  104907. private _setState;
  104908. private static _TmpVector;
  104909. /**
  104910. * Fires when the state of the experience helper has changed
  104911. */
  104912. onStateChangedObservable: Observable<WebXRState>;
  104913. /** Session manager used to keep track of xr session */
  104914. sessionManager: WebXRSessionManager;
  104915. private _nonVRCamera;
  104916. private _originalSceneAutoClear;
  104917. private _supported;
  104918. /**
  104919. * Creates the experience helper
  104920. * @param scene the scene to attach the experience helper to
  104921. * @returns a promise for the experience helper
  104922. */
  104923. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  104924. /**
  104925. * Creates a WebXRExperienceHelper
  104926. * @param scene The scene the helper should be created in
  104927. */
  104928. private constructor();
  104929. /**
  104930. * Exits XR mode and returns the scene to its original state
  104931. * @returns promise that resolves after xr mode has exited
  104932. */
  104933. exitXRAsync(): Promise<unknown>;
  104934. /**
  104935. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  104936. * @param sessionCreationOptions options for the XR session
  104937. * @param referenceSpaceType frame of reference of the XR session
  104938. * @param outputCanvas the output canvas that will be used to enter XR mode
  104939. * @returns promise that resolves after xr mode has entered
  104940. */
  104941. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  104942. /**
  104943. * Updates the global position of the camera by moving the camera's container
  104944. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  104945. * @param position The desired global position of the camera
  104946. */
  104947. setPositionOfCameraUsingContainer(position: Vector3): void;
  104948. /**
  104949. * Rotates the xr camera by rotating the camera's container around the camera's position
  104950. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  104951. * @param rotation the desired quaternion rotation to apply to the camera
  104952. */
  104953. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  104954. /**
  104955. * Disposes of the experience helper
  104956. */
  104957. dispose(): void;
  104958. }
  104959. }
  104960. declare module BABYLON {
  104961. /**
  104962. * Button which can be used to enter a different mode of XR
  104963. */
  104964. export class WebXREnterExitUIButton {
  104965. /** button element */
  104966. element: HTMLElement;
  104967. /** XR initialization options for the button */
  104968. sessionMode: XRSessionMode;
  104969. /** Reference space type */
  104970. referenceSpaceType: XRReferenceSpaceType;
  104971. /**
  104972. * Creates a WebXREnterExitUIButton
  104973. * @param element button element
  104974. * @param sessionMode XR initialization session mode
  104975. * @param referenceSpaceType the type of reference space to be used
  104976. */
  104977. constructor(
  104978. /** button element */
  104979. element: HTMLElement,
  104980. /** XR initialization options for the button */
  104981. sessionMode: XRSessionMode,
  104982. /** Reference space type */
  104983. referenceSpaceType: XRReferenceSpaceType);
  104984. /**
  104985. * Overwritable function which can be used to update the button's visuals when the state changes
  104986. * @param activeButton the current active button in the UI
  104987. */
  104988. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  104989. }
  104990. /**
  104991. * Options to create the webXR UI
  104992. */
  104993. export class WebXREnterExitUIOptions {
  104994. /**
  104995. * Context to enter xr with
  104996. */
  104997. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  104998. /**
  104999. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  105000. */
  105001. customButtons?: Array<WebXREnterExitUIButton>;
  105002. }
  105003. /**
  105004. * UI to allow the user to enter/exit XR mode
  105005. */
  105006. export class WebXREnterExitUI implements IDisposable {
  105007. private scene;
  105008. private _overlay;
  105009. private _buttons;
  105010. private _activeButton;
  105011. /**
  105012. * Fired every time the active button is changed.
  105013. *
  105014. * When xr is entered via a button that launches xr that button will be the callback parameter
  105015. *
  105016. * When exiting xr the callback parameter will be null)
  105017. */
  105018. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  105019. /**
  105020. * Creates UI to allow the user to enter/exit XR mode
  105021. * @param scene the scene to add the ui to
  105022. * @param helper the xr experience helper to enter/exit xr with
  105023. * @param options options to configure the UI
  105024. * @returns the created ui
  105025. */
  105026. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  105027. private constructor();
  105028. private _updateButtons;
  105029. /**
  105030. * Disposes of the object
  105031. */
  105032. dispose(): void;
  105033. }
  105034. }
  105035. declare module BABYLON {
  105036. /**
  105037. * Represents an XR input
  105038. */
  105039. export class WebXRController {
  105040. private scene;
  105041. /** The underlying input source for the controller */
  105042. inputSource: XRInputSource;
  105043. private parentContainer;
  105044. /**
  105045. * 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
  105046. */
  105047. grip?: AbstractMesh;
  105048. /**
  105049. * Pointer which can be used to select objects or attach a visible laser to
  105050. */
  105051. pointer: AbstractMesh;
  105052. /**
  105053. * Event that fires when the controller is removed/disposed
  105054. */
  105055. onDisposeObservable: Observable<{}>;
  105056. private _tmpMatrix;
  105057. private _tmpQuaternion;
  105058. private _tmpVector;
  105059. /**
  105060. * Creates the controller
  105061. * @see https://doc.babylonjs.com/how_to/webxr
  105062. * @param scene the scene which the controller should be associated to
  105063. * @param inputSource the underlying input source for the controller
  105064. * @param parentContainer parent that the controller meshes should be children of
  105065. */
  105066. constructor(scene: Scene,
  105067. /** The underlying input source for the controller */
  105068. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  105069. /**
  105070. * Updates the controller pose based on the given XRFrame
  105071. * @param xrFrame xr frame to update the pose with
  105072. * @param referenceSpace reference space to use
  105073. */
  105074. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  105075. /**
  105076. * Gets a world space ray coming from the controller
  105077. * @param result the resulting ray
  105078. */
  105079. getWorldPointerRayToRef(result: Ray): void;
  105080. /**
  105081. * Disposes of the object
  105082. */
  105083. dispose(): void;
  105084. }
  105085. }
  105086. declare module BABYLON {
  105087. /**
  105088. * XR input used to track XR inputs such as controllers/rays
  105089. */
  105090. export class WebXRInput implements IDisposable {
  105091. /**
  105092. * Base experience the input listens to
  105093. */
  105094. baseExperience: WebXRExperienceHelper;
  105095. /**
  105096. * XR controllers being tracked
  105097. */
  105098. controllers: Array<WebXRController>;
  105099. private _frameObserver;
  105100. private _stateObserver;
  105101. /**
  105102. * Event when a controller has been connected/added
  105103. */
  105104. onControllerAddedObservable: Observable<WebXRController>;
  105105. /**
  105106. * Event when a controller has been removed/disconnected
  105107. */
  105108. onControllerRemovedObservable: Observable<WebXRController>;
  105109. /**
  105110. * Initializes the WebXRInput
  105111. * @param baseExperience experience helper which the input should be created for
  105112. */
  105113. constructor(
  105114. /**
  105115. * Base experience the input listens to
  105116. */
  105117. baseExperience: WebXRExperienceHelper);
  105118. private _onInputSourcesChange;
  105119. private _addAndRemoveControllers;
  105120. /**
  105121. * Disposes of the object
  105122. */
  105123. dispose(): void;
  105124. }
  105125. }
  105126. declare module BABYLON {
  105127. /**
  105128. * Enables teleportation
  105129. */
  105130. export class WebXRControllerTeleportation {
  105131. private _teleportationFillColor;
  105132. private _teleportationBorderColor;
  105133. private _tmpRay;
  105134. private _tmpVector;
  105135. /**
  105136. * Creates a WebXRControllerTeleportation
  105137. * @param input input manager to add teleportation to
  105138. * @param floorMeshes floormeshes which can be teleported to
  105139. */
  105140. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  105141. }
  105142. }
  105143. declare module BABYLON {
  105144. /**
  105145. * Handles pointer input automatically for the pointer of XR controllers
  105146. */
  105147. export class WebXRControllerPointerSelection {
  105148. private static _idCounter;
  105149. private _tmpRay;
  105150. /**
  105151. * Creates a WebXRControllerPointerSelection
  105152. * @param input input manager to setup pointer selection
  105153. */
  105154. constructor(input: WebXRInput);
  105155. private _convertNormalToDirectionOfRay;
  105156. private _updatePointerDistance;
  105157. }
  105158. }
  105159. declare module BABYLON {
  105160. /**
  105161. * Class used to represent data loading progression
  105162. */
  105163. export class SceneLoaderProgressEvent {
  105164. /** defines if data length to load can be evaluated */
  105165. readonly lengthComputable: boolean;
  105166. /** defines the loaded data length */
  105167. readonly loaded: number;
  105168. /** defines the data length to load */
  105169. readonly total: number;
  105170. /**
  105171. * Create a new progress event
  105172. * @param lengthComputable defines if data length to load can be evaluated
  105173. * @param loaded defines the loaded data length
  105174. * @param total defines the data length to load
  105175. */
  105176. constructor(
  105177. /** defines if data length to load can be evaluated */
  105178. lengthComputable: boolean,
  105179. /** defines the loaded data length */
  105180. loaded: number,
  105181. /** defines the data length to load */
  105182. total: number);
  105183. /**
  105184. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105185. * @param event defines the source event
  105186. * @returns a new SceneLoaderProgressEvent
  105187. */
  105188. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105189. }
  105190. /**
  105191. * Interface used by SceneLoader plugins to define supported file extensions
  105192. */
  105193. export interface ISceneLoaderPluginExtensions {
  105194. /**
  105195. * Defines the list of supported extensions
  105196. */
  105197. [extension: string]: {
  105198. isBinary: boolean;
  105199. };
  105200. }
  105201. /**
  105202. * Interface used by SceneLoader plugin factory
  105203. */
  105204. export interface ISceneLoaderPluginFactory {
  105205. /**
  105206. * Defines the name of the factory
  105207. */
  105208. name: string;
  105209. /**
  105210. * Function called to create a new plugin
  105211. * @return the new plugin
  105212. */
  105213. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105214. /**
  105215. * Boolean indicating if the plugin can direct load specific data
  105216. */
  105217. canDirectLoad?: (data: string) => boolean;
  105218. }
  105219. /**
  105220. * Interface used to define a SceneLoader plugin
  105221. */
  105222. export interface ISceneLoaderPlugin {
  105223. /**
  105224. * The friendly name of this plugin.
  105225. */
  105226. name: string;
  105227. /**
  105228. * The file extensions supported by this plugin.
  105229. */
  105230. extensions: string | ISceneLoaderPluginExtensions;
  105231. /**
  105232. * Import meshes into a scene.
  105233. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105234. * @param scene The scene to import into
  105235. * @param data The data to import
  105236. * @param rootUrl The root url for scene and resources
  105237. * @param meshes The meshes array to import into
  105238. * @param particleSystems The particle systems array to import into
  105239. * @param skeletons The skeletons array to import into
  105240. * @param onError The callback when import fails
  105241. * @returns True if successful or false otherwise
  105242. */
  105243. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105244. /**
  105245. * Load into a scene.
  105246. * @param scene The scene to load into
  105247. * @param data The data to import
  105248. * @param rootUrl The root url for scene and resources
  105249. * @param onError The callback when import fails
  105250. * @returns true if successful or false otherwise
  105251. */
  105252. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105253. /**
  105254. * The callback that returns true if the data can be directly loaded.
  105255. */
  105256. canDirectLoad?: (data: string) => boolean;
  105257. /**
  105258. * The callback that allows custom handling of the root url based on the response url.
  105259. */
  105260. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105261. /**
  105262. * Load into an asset container.
  105263. * @param scene The scene to load into
  105264. * @param data The data to import
  105265. * @param rootUrl The root url for scene and resources
  105266. * @param onError The callback when import fails
  105267. * @returns The loaded asset container
  105268. */
  105269. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105270. }
  105271. /**
  105272. * Interface used to define an async SceneLoader plugin
  105273. */
  105274. export interface ISceneLoaderPluginAsync {
  105275. /**
  105276. * The friendly name of this plugin.
  105277. */
  105278. name: string;
  105279. /**
  105280. * The file extensions supported by this plugin.
  105281. */
  105282. extensions: string | ISceneLoaderPluginExtensions;
  105283. /**
  105284. * Import meshes into a scene.
  105285. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105286. * @param scene The scene to import into
  105287. * @param data The data to import
  105288. * @param rootUrl The root url for scene and resources
  105289. * @param onProgress The callback when the load progresses
  105290. * @param fileName Defines the name of the file to load
  105291. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105292. */
  105293. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105294. meshes: AbstractMesh[];
  105295. particleSystems: IParticleSystem[];
  105296. skeletons: Skeleton[];
  105297. animationGroups: AnimationGroup[];
  105298. }>;
  105299. /**
  105300. * Load into a scene.
  105301. * @param scene The scene to load into
  105302. * @param data The data to import
  105303. * @param rootUrl The root url for scene and resources
  105304. * @param onProgress The callback when the load progresses
  105305. * @param fileName Defines the name of the file to load
  105306. * @returns Nothing
  105307. */
  105308. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105309. /**
  105310. * The callback that returns true if the data can be directly loaded.
  105311. */
  105312. canDirectLoad?: (data: string) => boolean;
  105313. /**
  105314. * The callback that allows custom handling of the root url based on the response url.
  105315. */
  105316. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105317. /**
  105318. * Load into an asset container.
  105319. * @param scene The scene to load into
  105320. * @param data The data to import
  105321. * @param rootUrl The root url for scene and resources
  105322. * @param onProgress The callback when the load progresses
  105323. * @param fileName Defines the name of the file to load
  105324. * @returns The loaded asset container
  105325. */
  105326. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105327. }
  105328. /**
  105329. * Class used to load scene from various file formats using registered plugins
  105330. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105331. */
  105332. export class SceneLoader {
  105333. /**
  105334. * No logging while loading
  105335. */
  105336. static readonly NO_LOGGING: number;
  105337. /**
  105338. * Minimal logging while loading
  105339. */
  105340. static readonly MINIMAL_LOGGING: number;
  105341. /**
  105342. * Summary logging while loading
  105343. */
  105344. static readonly SUMMARY_LOGGING: number;
  105345. /**
  105346. * Detailled logging while loading
  105347. */
  105348. static readonly DETAILED_LOGGING: number;
  105349. /**
  105350. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105351. */
  105352. static ForceFullSceneLoadingForIncremental: boolean;
  105353. /**
  105354. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105355. */
  105356. static ShowLoadingScreen: boolean;
  105357. /**
  105358. * Defines the current logging level (while loading the scene)
  105359. * @ignorenaming
  105360. */
  105361. static loggingLevel: number;
  105362. /**
  105363. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105364. */
  105365. static CleanBoneMatrixWeights: boolean;
  105366. /**
  105367. * Event raised when a plugin is used to load a scene
  105368. */
  105369. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105370. private static _registeredPlugins;
  105371. private static _getDefaultPlugin;
  105372. private static _getPluginForExtension;
  105373. private static _getPluginForDirectLoad;
  105374. private static _getPluginForFilename;
  105375. private static _getDirectLoad;
  105376. private static _loadData;
  105377. private static _getFileInfo;
  105378. /**
  105379. * Gets a plugin that can load the given extension
  105380. * @param extension defines the extension to load
  105381. * @returns a plugin or null if none works
  105382. */
  105383. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105384. /**
  105385. * Gets a boolean indicating that the given extension can be loaded
  105386. * @param extension defines the extension to load
  105387. * @returns true if the extension is supported
  105388. */
  105389. static IsPluginForExtensionAvailable(extension: string): boolean;
  105390. /**
  105391. * Adds a new plugin to the list of registered plugins
  105392. * @param plugin defines the plugin to add
  105393. */
  105394. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105395. /**
  105396. * Import meshes into a scene
  105397. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105398. * @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)
  105399. * @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)
  105400. * @param scene the instance of BABYLON.Scene to append to
  105401. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105402. * @param onProgress a callback with a progress event for each file being loaded
  105403. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105404. * @param pluginExtension the extension used to determine the plugin
  105405. * @returns The loaded plugin
  105406. */
  105407. 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>;
  105408. /**
  105409. * Import meshes into a scene
  105410. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105411. * @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)
  105412. * @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)
  105413. * @param scene the instance of BABYLON.Scene to append to
  105414. * @param onProgress a callback with a progress event for each file being loaded
  105415. * @param pluginExtension the extension used to determine the plugin
  105416. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105417. */
  105418. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105419. meshes: AbstractMesh[];
  105420. particleSystems: IParticleSystem[];
  105421. skeletons: Skeleton[];
  105422. animationGroups: AnimationGroup[];
  105423. }>;
  105424. /**
  105425. * Load a scene
  105426. * @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)
  105427. * @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)
  105428. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105429. * @param onSuccess a callback with the scene when import succeeds
  105430. * @param onProgress a callback with a progress event for each file being loaded
  105431. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105432. * @param pluginExtension the extension used to determine the plugin
  105433. * @returns The loaded plugin
  105434. */
  105435. 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>;
  105436. /**
  105437. * Load a scene
  105438. * @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)
  105439. * @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)
  105440. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105441. * @param onProgress a callback with a progress event for each file being loaded
  105442. * @param pluginExtension the extension used to determine the plugin
  105443. * @returns The loaded scene
  105444. */
  105445. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105446. /**
  105447. * Append a scene
  105448. * @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)
  105449. * @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)
  105450. * @param scene is the instance of BABYLON.Scene to append to
  105451. * @param onSuccess a callback with the scene when import succeeds
  105452. * @param onProgress a callback with a progress event for each file being loaded
  105453. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105454. * @param pluginExtension the extension used to determine the plugin
  105455. * @returns The loaded plugin
  105456. */
  105457. 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>;
  105458. /**
  105459. * Append a scene
  105460. * @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)
  105461. * @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)
  105462. * @param scene is the instance of BABYLON.Scene to append to
  105463. * @param onProgress a callback with a progress event for each file being loaded
  105464. * @param pluginExtension the extension used to determine the plugin
  105465. * @returns The given scene
  105466. */
  105467. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105468. /**
  105469. * Load a scene into an asset container
  105470. * @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)
  105471. * @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)
  105472. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105473. * @param onSuccess a callback with the scene when import succeeds
  105474. * @param onProgress a callback with a progress event for each file being loaded
  105475. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105476. * @param pluginExtension the extension used to determine the plugin
  105477. * @returns The loaded plugin
  105478. */
  105479. 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>;
  105480. /**
  105481. * Load a scene into an asset container
  105482. * @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)
  105483. * @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)
  105484. * @param scene is the instance of Scene to append to
  105485. * @param onProgress a callback with a progress event for each file being loaded
  105486. * @param pluginExtension the extension used to determine the plugin
  105487. * @returns The loaded asset container
  105488. */
  105489. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105490. }
  105491. }
  105492. declare module BABYLON {
  105493. /**
  105494. * Generic Controller
  105495. */
  105496. export class GenericController extends WebVRController {
  105497. /**
  105498. * Base Url for the controller model.
  105499. */
  105500. static readonly MODEL_BASE_URL: string;
  105501. /**
  105502. * File name for the controller model.
  105503. */
  105504. static readonly MODEL_FILENAME: string;
  105505. /**
  105506. * Creates a new GenericController from a gamepad
  105507. * @param vrGamepad the gamepad that the controller should be created from
  105508. */
  105509. constructor(vrGamepad: any);
  105510. /**
  105511. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105512. * @param scene scene in which to add meshes
  105513. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105514. */
  105515. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105516. /**
  105517. * Called once for each button that changed state since the last frame
  105518. * @param buttonIdx Which button index changed
  105519. * @param state New state of the button
  105520. * @param changes Which properties on the state changed since last frame
  105521. */
  105522. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105523. }
  105524. }
  105525. declare module BABYLON {
  105526. /**
  105527. * Defines the WindowsMotionController object that the state of the windows motion controller
  105528. */
  105529. export class WindowsMotionController extends WebVRController {
  105530. /**
  105531. * The base url used to load the left and right controller models
  105532. */
  105533. static MODEL_BASE_URL: string;
  105534. /**
  105535. * The name of the left controller model file
  105536. */
  105537. static MODEL_LEFT_FILENAME: string;
  105538. /**
  105539. * The name of the right controller model file
  105540. */
  105541. static MODEL_RIGHT_FILENAME: string;
  105542. /**
  105543. * The controller name prefix for this controller type
  105544. */
  105545. static readonly GAMEPAD_ID_PREFIX: string;
  105546. /**
  105547. * The controller id pattern for this controller type
  105548. */
  105549. private static readonly GAMEPAD_ID_PATTERN;
  105550. private _loadedMeshInfo;
  105551. private readonly _mapping;
  105552. /**
  105553. * Fired when the trackpad on this controller is clicked
  105554. */
  105555. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105556. /**
  105557. * Fired when the trackpad on this controller is modified
  105558. */
  105559. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105560. /**
  105561. * The current x and y values of this controller's trackpad
  105562. */
  105563. trackpad: StickValues;
  105564. /**
  105565. * Creates a new WindowsMotionController from a gamepad
  105566. * @param vrGamepad the gamepad that the controller should be created from
  105567. */
  105568. constructor(vrGamepad: any);
  105569. /**
  105570. * Fired when the trigger on this controller is modified
  105571. */
  105572. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105573. /**
  105574. * Fired when the menu button on this controller is modified
  105575. */
  105576. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105577. /**
  105578. * Fired when the grip button on this controller is modified
  105579. */
  105580. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105581. /**
  105582. * Fired when the thumbstick button on this controller is modified
  105583. */
  105584. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105585. /**
  105586. * Fired when the touchpad button on this controller is modified
  105587. */
  105588. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105589. /**
  105590. * Fired when the touchpad values on this controller are modified
  105591. */
  105592. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105593. private _updateTrackpad;
  105594. /**
  105595. * Called once per frame by the engine.
  105596. */
  105597. update(): void;
  105598. /**
  105599. * Called once for each button that changed state since the last frame
  105600. * @param buttonIdx Which button index changed
  105601. * @param state New state of the button
  105602. * @param changes Which properties on the state changed since last frame
  105603. */
  105604. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105605. /**
  105606. * Moves the buttons on the controller mesh based on their current state
  105607. * @param buttonName the name of the button to move
  105608. * @param buttonValue the value of the button which determines the buttons new position
  105609. */
  105610. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105611. /**
  105612. * Moves the axis on the controller mesh based on its current state
  105613. * @param axis the index of the axis
  105614. * @param axisValue the value of the axis which determines the meshes new position
  105615. * @hidden
  105616. */
  105617. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105618. /**
  105619. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105620. * @param scene scene in which to add meshes
  105621. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105622. */
  105623. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105624. /**
  105625. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105626. * can be transformed by button presses and axes values, based on this._mapping.
  105627. *
  105628. * @param scene scene in which the meshes exist
  105629. * @param meshes list of meshes that make up the controller model to process
  105630. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105631. */
  105632. private processModel;
  105633. private createMeshInfo;
  105634. /**
  105635. * Gets the ray of the controller in the direction the controller is pointing
  105636. * @param length the length the resulting ray should be
  105637. * @returns a ray in the direction the controller is pointing
  105638. */
  105639. getForwardRay(length?: number): Ray;
  105640. /**
  105641. * Disposes of the controller
  105642. */
  105643. dispose(): void;
  105644. }
  105645. }
  105646. declare module BABYLON {
  105647. /**
  105648. * Oculus Touch Controller
  105649. */
  105650. export class OculusTouchController extends WebVRController {
  105651. /**
  105652. * Base Url for the controller model.
  105653. */
  105654. static MODEL_BASE_URL: string;
  105655. /**
  105656. * File name for the left controller model.
  105657. */
  105658. static MODEL_LEFT_FILENAME: string;
  105659. /**
  105660. * File name for the right controller model.
  105661. */
  105662. static MODEL_RIGHT_FILENAME: string;
  105663. /**
  105664. * Base Url for the Quest controller model.
  105665. */
  105666. static QUEST_MODEL_BASE_URL: string;
  105667. /**
  105668. * @hidden
  105669. * If the controllers are running on a device that needs the updated Quest controller models
  105670. */
  105671. static _IsQuest: boolean;
  105672. /**
  105673. * Fired when the secondary trigger on this controller is modified
  105674. */
  105675. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105676. /**
  105677. * Fired when the thumb rest on this controller is modified
  105678. */
  105679. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105680. /**
  105681. * Creates a new OculusTouchController from a gamepad
  105682. * @param vrGamepad the gamepad that the controller should be created from
  105683. */
  105684. constructor(vrGamepad: any);
  105685. /**
  105686. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105687. * @param scene scene in which to add meshes
  105688. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105689. */
  105690. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105691. /**
  105692. * Fired when the A button on this controller is modified
  105693. */
  105694. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105695. /**
  105696. * Fired when the B button on this controller is modified
  105697. */
  105698. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105699. /**
  105700. * Fired when the X button on this controller is modified
  105701. */
  105702. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105703. /**
  105704. * Fired when the Y button on this controller is modified
  105705. */
  105706. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105707. /**
  105708. * Called once for each button that changed state since the last frame
  105709. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105710. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105711. * 2) secondary trigger (same)
  105712. * 3) A (right) X (left), touch, pressed = value
  105713. * 4) B / Y
  105714. * 5) thumb rest
  105715. * @param buttonIdx Which button index changed
  105716. * @param state New state of the button
  105717. * @param changes Which properties on the state changed since last frame
  105718. */
  105719. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105720. }
  105721. }
  105722. declare module BABYLON {
  105723. /**
  105724. * Vive Controller
  105725. */
  105726. export class ViveController extends WebVRController {
  105727. /**
  105728. * Base Url for the controller model.
  105729. */
  105730. static MODEL_BASE_URL: string;
  105731. /**
  105732. * File name for the controller model.
  105733. */
  105734. static MODEL_FILENAME: string;
  105735. /**
  105736. * Creates a new ViveController from a gamepad
  105737. * @param vrGamepad the gamepad that the controller should be created from
  105738. */
  105739. constructor(vrGamepad: any);
  105740. /**
  105741. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105742. * @param scene scene in which to add meshes
  105743. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105744. */
  105745. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105746. /**
  105747. * Fired when the left button on this controller is modified
  105748. */
  105749. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105750. /**
  105751. * Fired when the right button on this controller is modified
  105752. */
  105753. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105754. /**
  105755. * Fired when the menu button on this controller is modified
  105756. */
  105757. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105758. /**
  105759. * Called once for each button that changed state since the last frame
  105760. * Vive mapping:
  105761. * 0: touchpad
  105762. * 1: trigger
  105763. * 2: left AND right buttons
  105764. * 3: menu button
  105765. * @param buttonIdx Which button index changed
  105766. * @param state New state of the button
  105767. * @param changes Which properties on the state changed since last frame
  105768. */
  105769. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105770. }
  105771. }
  105772. declare module BABYLON {
  105773. /**
  105774. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  105775. */
  105776. export class WebXRControllerModelLoader {
  105777. /**
  105778. * Creates the WebXRControllerModelLoader
  105779. * @param input xr input that creates the controllers
  105780. */
  105781. constructor(input: WebXRInput);
  105782. }
  105783. }
  105784. declare module BABYLON {
  105785. /**
  105786. * Contains an array of blocks representing the octree
  105787. */
  105788. export interface IOctreeContainer<T> {
  105789. /**
  105790. * Blocks within the octree
  105791. */
  105792. blocks: Array<OctreeBlock<T>>;
  105793. }
  105794. /**
  105795. * Class used to store a cell in an octree
  105796. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105797. */
  105798. export class OctreeBlock<T> {
  105799. /**
  105800. * Gets the content of the current block
  105801. */
  105802. entries: T[];
  105803. /**
  105804. * Gets the list of block children
  105805. */
  105806. blocks: Array<OctreeBlock<T>>;
  105807. private _depth;
  105808. private _maxDepth;
  105809. private _capacity;
  105810. private _minPoint;
  105811. private _maxPoint;
  105812. private _boundingVectors;
  105813. private _creationFunc;
  105814. /**
  105815. * Creates a new block
  105816. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  105817. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  105818. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  105819. * @param depth defines the current depth of this block in the octree
  105820. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  105821. * @param creationFunc defines a callback to call when an element is added to the block
  105822. */
  105823. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  105824. /**
  105825. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  105826. */
  105827. readonly capacity: number;
  105828. /**
  105829. * Gets the minimum vector (in world space) of the block's bounding box
  105830. */
  105831. readonly minPoint: Vector3;
  105832. /**
  105833. * Gets the maximum vector (in world space) of the block's bounding box
  105834. */
  105835. readonly maxPoint: Vector3;
  105836. /**
  105837. * Add a new element to this block
  105838. * @param entry defines the element to add
  105839. */
  105840. addEntry(entry: T): void;
  105841. /**
  105842. * Remove an element from this block
  105843. * @param entry defines the element to remove
  105844. */
  105845. removeEntry(entry: T): void;
  105846. /**
  105847. * Add an array of elements to this block
  105848. * @param entries defines the array of elements to add
  105849. */
  105850. addEntries(entries: T[]): void;
  105851. /**
  105852. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  105853. * @param frustumPlanes defines the frustum planes to test
  105854. * @param selection defines the array to store current content if selection is positive
  105855. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105856. */
  105857. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105858. /**
  105859. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  105860. * @param sphereCenter defines the bounding sphere center
  105861. * @param sphereRadius defines the bounding sphere radius
  105862. * @param selection defines the array to store current content if selection is positive
  105863. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105864. */
  105865. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105866. /**
  105867. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  105868. * @param ray defines the ray to test with
  105869. * @param selection defines the array to store current content if selection is positive
  105870. */
  105871. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  105872. /**
  105873. * Subdivide the content into child blocks (this block will then be empty)
  105874. */
  105875. createInnerBlocks(): void;
  105876. /**
  105877. * @hidden
  105878. */
  105879. 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;
  105880. }
  105881. }
  105882. declare module BABYLON {
  105883. /**
  105884. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  105885. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105886. */
  105887. export class Octree<T> {
  105888. /** 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.) */
  105889. maxDepth: number;
  105890. /**
  105891. * Blocks within the octree containing objects
  105892. */
  105893. blocks: Array<OctreeBlock<T>>;
  105894. /**
  105895. * Content stored in the octree
  105896. */
  105897. dynamicContent: T[];
  105898. private _maxBlockCapacity;
  105899. private _selectionContent;
  105900. private _creationFunc;
  105901. /**
  105902. * Creates a octree
  105903. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105904. * @param creationFunc function to be used to instatiate the octree
  105905. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  105906. * @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.)
  105907. */
  105908. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  105909. /** 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.) */
  105910. maxDepth?: number);
  105911. /**
  105912. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  105913. * @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);
  105914. * @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);
  105915. * @param entries meshes to be added to the octree blocks
  105916. */
  105917. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  105918. /**
  105919. * Adds a mesh to the octree
  105920. * @param entry Mesh to add to the octree
  105921. */
  105922. addMesh(entry: T): void;
  105923. /**
  105924. * Remove an element from the octree
  105925. * @param entry defines the element to remove
  105926. */
  105927. removeMesh(entry: T): void;
  105928. /**
  105929. * Selects an array of meshes within the frustum
  105930. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  105931. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  105932. * @returns array of meshes within the frustum
  105933. */
  105934. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  105935. /**
  105936. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  105937. * @param sphereCenter defines the bounding sphere center
  105938. * @param sphereRadius defines the bounding sphere radius
  105939. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105940. * @returns an array of objects that intersect the sphere
  105941. */
  105942. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  105943. /**
  105944. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  105945. * @param ray defines the ray to test with
  105946. * @returns array of intersected objects
  105947. */
  105948. intersectsRay(ray: Ray): SmartArray<T>;
  105949. /**
  105950. * Adds a mesh into the octree block if it intersects the block
  105951. */
  105952. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  105953. /**
  105954. * Adds a submesh into the octree block if it intersects the block
  105955. */
  105956. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  105957. }
  105958. }
  105959. declare module BABYLON {
  105960. interface Scene {
  105961. /**
  105962. * @hidden
  105963. * Backing Filed
  105964. */
  105965. _selectionOctree: Octree<AbstractMesh>;
  105966. /**
  105967. * Gets the octree used to boost mesh selection (picking)
  105968. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105969. */
  105970. selectionOctree: Octree<AbstractMesh>;
  105971. /**
  105972. * Creates or updates the octree used to boost selection (picking)
  105973. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105974. * @param maxCapacity defines the maximum capacity per leaf
  105975. * @param maxDepth defines the maximum depth of the octree
  105976. * @returns an octree of AbstractMesh
  105977. */
  105978. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  105979. }
  105980. interface AbstractMesh {
  105981. /**
  105982. * @hidden
  105983. * Backing Field
  105984. */
  105985. _submeshesOctree: Octree<SubMesh>;
  105986. /**
  105987. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  105988. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105989. * @param maxCapacity defines the maximum size of each block (64 by default)
  105990. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  105991. * @returns the new octree
  105992. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  105993. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105994. */
  105995. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  105996. }
  105997. /**
  105998. * Defines the octree scene component responsible to manage any octrees
  105999. * in a given scene.
  106000. */
  106001. export class OctreeSceneComponent {
  106002. /**
  106003. * The component name help to identify the component in the list of scene components.
  106004. */
  106005. readonly name: string;
  106006. /**
  106007. * The scene the component belongs to.
  106008. */
  106009. scene: Scene;
  106010. /**
  106011. * Indicates if the meshes have been checked to make sure they are isEnabled()
  106012. */
  106013. readonly checksIsEnabled: boolean;
  106014. /**
  106015. * Creates a new instance of the component for the given scene
  106016. * @param scene Defines the scene to register the component in
  106017. */
  106018. constructor(scene: Scene);
  106019. /**
  106020. * Registers the component in a given scene
  106021. */
  106022. register(): void;
  106023. /**
  106024. * Return the list of active meshes
  106025. * @returns the list of active meshes
  106026. */
  106027. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106028. /**
  106029. * Return the list of active sub meshes
  106030. * @param mesh The mesh to get the candidates sub meshes from
  106031. * @returns the list of active sub meshes
  106032. */
  106033. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106034. private _tempRay;
  106035. /**
  106036. * Return the list of sub meshes intersecting with a given local ray
  106037. * @param mesh defines the mesh to find the submesh for
  106038. * @param localRay defines the ray in local space
  106039. * @returns the list of intersecting sub meshes
  106040. */
  106041. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  106042. /**
  106043. * Return the list of sub meshes colliding with a collider
  106044. * @param mesh defines the mesh to find the submesh for
  106045. * @param collider defines the collider to evaluate the collision against
  106046. * @returns the list of colliding sub meshes
  106047. */
  106048. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  106049. /**
  106050. * Rebuilds the elements related to this component in case of
  106051. * context lost for instance.
  106052. */
  106053. rebuild(): void;
  106054. /**
  106055. * Disposes the component and the associated ressources.
  106056. */
  106057. dispose(): void;
  106058. }
  106059. }
  106060. declare module BABYLON {
  106061. /**
  106062. * Renders a layer on top of an existing scene
  106063. */
  106064. export class UtilityLayerRenderer implements IDisposable {
  106065. /** the original scene that will be rendered on top of */
  106066. originalScene: Scene;
  106067. private _pointerCaptures;
  106068. private _lastPointerEvents;
  106069. private static _DefaultUtilityLayer;
  106070. private static _DefaultKeepDepthUtilityLayer;
  106071. private _sharedGizmoLight;
  106072. private _renderCamera;
  106073. /**
  106074. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  106075. * @returns the camera that is used when rendering the utility layer
  106076. */
  106077. getRenderCamera(): Nullable<Camera>;
  106078. /**
  106079. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  106080. * @param cam the camera that should be used when rendering the utility layer
  106081. */
  106082. setRenderCamera(cam: Nullable<Camera>): void;
  106083. /**
  106084. * @hidden
  106085. * Light which used by gizmos to get light shading
  106086. */
  106087. _getSharedGizmoLight(): HemisphericLight;
  106088. /**
  106089. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  106090. */
  106091. pickUtilitySceneFirst: boolean;
  106092. /**
  106093. * 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)
  106094. */
  106095. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  106096. /**
  106097. * 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)
  106098. */
  106099. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  106100. /**
  106101. * The scene that is rendered on top of the original scene
  106102. */
  106103. utilityLayerScene: Scene;
  106104. /**
  106105. * If the utility layer should automatically be rendered on top of existing scene
  106106. */
  106107. shouldRender: boolean;
  106108. /**
  106109. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  106110. */
  106111. onlyCheckPointerDownEvents: boolean;
  106112. /**
  106113. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  106114. */
  106115. processAllEvents: boolean;
  106116. /**
  106117. * Observable raised when the pointer move from the utility layer scene to the main scene
  106118. */
  106119. onPointerOutObservable: Observable<number>;
  106120. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  106121. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  106122. private _afterRenderObserver;
  106123. private _sceneDisposeObserver;
  106124. private _originalPointerObserver;
  106125. /**
  106126. * Instantiates a UtilityLayerRenderer
  106127. * @param originalScene the original scene that will be rendered on top of
  106128. * @param handleEvents boolean indicating if the utility layer should handle events
  106129. */
  106130. constructor(
  106131. /** the original scene that will be rendered on top of */
  106132. originalScene: Scene, handleEvents?: boolean);
  106133. private _notifyObservers;
  106134. /**
  106135. * Renders the utility layers scene on top of the original scene
  106136. */
  106137. render(): void;
  106138. /**
  106139. * Disposes of the renderer
  106140. */
  106141. dispose(): void;
  106142. private _updateCamera;
  106143. }
  106144. }
  106145. declare module BABYLON {
  106146. /**
  106147. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  106148. */
  106149. export class Gizmo implements IDisposable {
  106150. /** The utility layer the gizmo will be added to */
  106151. gizmoLayer: UtilityLayerRenderer;
  106152. /**
  106153. * The root mesh of the gizmo
  106154. */
  106155. _rootMesh: Mesh;
  106156. private _attachedMesh;
  106157. /**
  106158. * Ratio for the scale of the gizmo (Default: 1)
  106159. */
  106160. scaleRatio: number;
  106161. /**
  106162. * If a custom mesh has been set (Default: false)
  106163. */
  106164. protected _customMeshSet: boolean;
  106165. /**
  106166. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  106167. * * When set, interactions will be enabled
  106168. */
  106169. attachedMesh: Nullable<AbstractMesh>;
  106170. /**
  106171. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106172. * @param mesh The mesh to replace the default mesh of the gizmo
  106173. */
  106174. setCustomMesh(mesh: Mesh): void;
  106175. /**
  106176. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  106177. */
  106178. updateGizmoRotationToMatchAttachedMesh: boolean;
  106179. /**
  106180. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  106181. */
  106182. updateGizmoPositionToMatchAttachedMesh: boolean;
  106183. /**
  106184. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  106185. */
  106186. updateScale: boolean;
  106187. protected _interactionsEnabled: boolean;
  106188. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106189. private _beforeRenderObserver;
  106190. private _tempVector;
  106191. /**
  106192. * Creates a gizmo
  106193. * @param gizmoLayer The utility layer the gizmo will be added to
  106194. */
  106195. constructor(
  106196. /** The utility layer the gizmo will be added to */
  106197. gizmoLayer?: UtilityLayerRenderer);
  106198. /**
  106199. * Updates the gizmo to match the attached mesh's position/rotation
  106200. */
  106201. protected _update(): void;
  106202. /**
  106203. * Disposes of the gizmo
  106204. */
  106205. dispose(): void;
  106206. }
  106207. }
  106208. declare module BABYLON {
  106209. /**
  106210. * Single plane drag gizmo
  106211. */
  106212. export class PlaneDragGizmo extends Gizmo {
  106213. /**
  106214. * Drag behavior responsible for the gizmos dragging interactions
  106215. */
  106216. dragBehavior: PointerDragBehavior;
  106217. private _pointerObserver;
  106218. /**
  106219. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106220. */
  106221. snapDistance: number;
  106222. /**
  106223. * Event that fires each time the gizmo snaps to a new location.
  106224. * * snapDistance is the the change in distance
  106225. */
  106226. onSnapObservable: Observable<{
  106227. snapDistance: number;
  106228. }>;
  106229. private _plane;
  106230. private _coloredMaterial;
  106231. private _hoverMaterial;
  106232. private _isEnabled;
  106233. private _parent;
  106234. /** @hidden */
  106235. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  106236. /** @hidden */
  106237. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106238. /**
  106239. * Creates a PlaneDragGizmo
  106240. * @param gizmoLayer The utility layer the gizmo will be added to
  106241. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  106242. * @param color The color of the gizmo
  106243. */
  106244. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106245. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106246. /**
  106247. * If the gizmo is enabled
  106248. */
  106249. isEnabled: boolean;
  106250. /**
  106251. * Disposes of the gizmo
  106252. */
  106253. dispose(): void;
  106254. }
  106255. }
  106256. declare module BABYLON {
  106257. /**
  106258. * Gizmo that enables dragging a mesh along 3 axis
  106259. */
  106260. export class PositionGizmo extends Gizmo {
  106261. /**
  106262. * Internal gizmo used for interactions on the x axis
  106263. */
  106264. xGizmo: AxisDragGizmo;
  106265. /**
  106266. * Internal gizmo used for interactions on the y axis
  106267. */
  106268. yGizmo: AxisDragGizmo;
  106269. /**
  106270. * Internal gizmo used for interactions on the z axis
  106271. */
  106272. zGizmo: AxisDragGizmo;
  106273. /**
  106274. * Internal gizmo used for interactions on the yz plane
  106275. */
  106276. xPlaneGizmo: PlaneDragGizmo;
  106277. /**
  106278. * Internal gizmo used for interactions on the xz plane
  106279. */
  106280. yPlaneGizmo: PlaneDragGizmo;
  106281. /**
  106282. * Internal gizmo used for interactions on the xy plane
  106283. */
  106284. zPlaneGizmo: PlaneDragGizmo;
  106285. /**
  106286. * private variables
  106287. */
  106288. private _meshAttached;
  106289. private _updateGizmoRotationToMatchAttachedMesh;
  106290. private _snapDistance;
  106291. private _scaleRatio;
  106292. /** Fires an event when any of it's sub gizmos are dragged */
  106293. onDragStartObservable: Observable<unknown>;
  106294. /** Fires an event when any of it's sub gizmos are released from dragging */
  106295. onDragEndObservable: Observable<unknown>;
  106296. /**
  106297. * If set to true, planar drag is enabled
  106298. */
  106299. private _planarGizmoEnabled;
  106300. attachedMesh: Nullable<AbstractMesh>;
  106301. /**
  106302. * Creates a PositionGizmo
  106303. * @param gizmoLayer The utility layer the gizmo will be added to
  106304. */
  106305. constructor(gizmoLayer?: UtilityLayerRenderer);
  106306. /**
  106307. * If the planar drag gizmo is enabled
  106308. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  106309. */
  106310. planarGizmoEnabled: boolean;
  106311. updateGizmoRotationToMatchAttachedMesh: boolean;
  106312. /**
  106313. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106314. */
  106315. snapDistance: number;
  106316. /**
  106317. * Ratio for the scale of the gizmo (Default: 1)
  106318. */
  106319. scaleRatio: number;
  106320. /**
  106321. * Disposes of the gizmo
  106322. */
  106323. dispose(): void;
  106324. /**
  106325. * CustomMeshes are not supported by this gizmo
  106326. * @param mesh The mesh to replace the default mesh of the gizmo
  106327. */
  106328. setCustomMesh(mesh: Mesh): void;
  106329. }
  106330. }
  106331. declare module BABYLON {
  106332. /**
  106333. * Single axis drag gizmo
  106334. */
  106335. export class AxisDragGizmo extends Gizmo {
  106336. /**
  106337. * Drag behavior responsible for the gizmos dragging interactions
  106338. */
  106339. dragBehavior: PointerDragBehavior;
  106340. private _pointerObserver;
  106341. /**
  106342. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106343. */
  106344. snapDistance: number;
  106345. /**
  106346. * Event that fires each time the gizmo snaps to a new location.
  106347. * * snapDistance is the the change in distance
  106348. */
  106349. onSnapObservable: Observable<{
  106350. snapDistance: number;
  106351. }>;
  106352. private _isEnabled;
  106353. private _parent;
  106354. private _arrow;
  106355. private _coloredMaterial;
  106356. private _hoverMaterial;
  106357. /** @hidden */
  106358. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  106359. /** @hidden */
  106360. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106361. /**
  106362. * Creates an AxisDragGizmo
  106363. * @param gizmoLayer The utility layer the gizmo will be added to
  106364. * @param dragAxis The axis which the gizmo will be able to drag on
  106365. * @param color The color of the gizmo
  106366. */
  106367. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106368. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106369. /**
  106370. * If the gizmo is enabled
  106371. */
  106372. isEnabled: boolean;
  106373. /**
  106374. * Disposes of the gizmo
  106375. */
  106376. dispose(): void;
  106377. }
  106378. }
  106379. declare module BABYLON.Debug {
  106380. /**
  106381. * The Axes viewer will show 3 axes in a specific point in space
  106382. */
  106383. export class AxesViewer {
  106384. private _xAxis;
  106385. private _yAxis;
  106386. private _zAxis;
  106387. private _scaleLinesFactor;
  106388. private _instanced;
  106389. /**
  106390. * Gets the hosting scene
  106391. */
  106392. scene: Scene;
  106393. /**
  106394. * Gets or sets a number used to scale line length
  106395. */
  106396. scaleLines: number;
  106397. /** Gets the node hierarchy used to render x-axis */
  106398. readonly xAxis: TransformNode;
  106399. /** Gets the node hierarchy used to render y-axis */
  106400. readonly yAxis: TransformNode;
  106401. /** Gets the node hierarchy used to render z-axis */
  106402. readonly zAxis: TransformNode;
  106403. /**
  106404. * Creates a new AxesViewer
  106405. * @param scene defines the hosting scene
  106406. * @param scaleLines defines a number used to scale line length (1 by default)
  106407. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  106408. * @param xAxis defines the node hierarchy used to render the x-axis
  106409. * @param yAxis defines the node hierarchy used to render the y-axis
  106410. * @param zAxis defines the node hierarchy used to render the z-axis
  106411. */
  106412. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  106413. /**
  106414. * Force the viewer to update
  106415. * @param position defines the position of the viewer
  106416. * @param xaxis defines the x axis of the viewer
  106417. * @param yaxis defines the y axis of the viewer
  106418. * @param zaxis defines the z axis of the viewer
  106419. */
  106420. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  106421. /**
  106422. * Creates an instance of this axes viewer.
  106423. * @returns a new axes viewer with instanced meshes
  106424. */
  106425. createInstance(): AxesViewer;
  106426. /** Releases resources */
  106427. dispose(): void;
  106428. private static _SetRenderingGroupId;
  106429. }
  106430. }
  106431. declare module BABYLON.Debug {
  106432. /**
  106433. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  106434. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  106435. */
  106436. export class BoneAxesViewer extends AxesViewer {
  106437. /**
  106438. * Gets or sets the target mesh where to display the axes viewer
  106439. */
  106440. mesh: Nullable<Mesh>;
  106441. /**
  106442. * Gets or sets the target bone where to display the axes viewer
  106443. */
  106444. bone: Nullable<Bone>;
  106445. /** Gets current position */
  106446. pos: Vector3;
  106447. /** Gets direction of X axis */
  106448. xaxis: Vector3;
  106449. /** Gets direction of Y axis */
  106450. yaxis: Vector3;
  106451. /** Gets direction of Z axis */
  106452. zaxis: Vector3;
  106453. /**
  106454. * Creates a new BoneAxesViewer
  106455. * @param scene defines the hosting scene
  106456. * @param bone defines the target bone
  106457. * @param mesh defines the target mesh
  106458. * @param scaleLines defines a scaling factor for line length (1 by default)
  106459. */
  106460. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  106461. /**
  106462. * Force the viewer to update
  106463. */
  106464. update(): void;
  106465. /** Releases resources */
  106466. dispose(): void;
  106467. }
  106468. }
  106469. declare module BABYLON {
  106470. /**
  106471. * Interface used to define scene explorer extensibility option
  106472. */
  106473. export interface IExplorerExtensibilityOption {
  106474. /**
  106475. * Define the option label
  106476. */
  106477. label: string;
  106478. /**
  106479. * Defines the action to execute on click
  106480. */
  106481. action: (entity: any) => void;
  106482. }
  106483. /**
  106484. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  106485. */
  106486. export interface IExplorerExtensibilityGroup {
  106487. /**
  106488. * Defines a predicate to test if a given type mut be extended
  106489. */
  106490. predicate: (entity: any) => boolean;
  106491. /**
  106492. * Gets the list of options added to a type
  106493. */
  106494. entries: IExplorerExtensibilityOption[];
  106495. }
  106496. /**
  106497. * Interface used to define the options to use to create the Inspector
  106498. */
  106499. export interface IInspectorOptions {
  106500. /**
  106501. * Display in overlay mode (default: false)
  106502. */
  106503. overlay?: boolean;
  106504. /**
  106505. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  106506. */
  106507. globalRoot?: HTMLElement;
  106508. /**
  106509. * Display the Scene explorer
  106510. */
  106511. showExplorer?: boolean;
  106512. /**
  106513. * Display the property inspector
  106514. */
  106515. showInspector?: boolean;
  106516. /**
  106517. * Display in embed mode (both panes on the right)
  106518. */
  106519. embedMode?: boolean;
  106520. /**
  106521. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  106522. */
  106523. handleResize?: boolean;
  106524. /**
  106525. * Allow the panes to popup (default: true)
  106526. */
  106527. enablePopup?: boolean;
  106528. /**
  106529. * Allow the panes to be closed by users (default: true)
  106530. */
  106531. enableClose?: boolean;
  106532. /**
  106533. * Optional list of extensibility entries
  106534. */
  106535. explorerExtensibility?: IExplorerExtensibilityGroup[];
  106536. /**
  106537. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  106538. */
  106539. inspectorURL?: string;
  106540. }
  106541. interface Scene {
  106542. /**
  106543. * @hidden
  106544. * Backing field
  106545. */
  106546. _debugLayer: DebugLayer;
  106547. /**
  106548. * Gets the debug layer (aka Inspector) associated with the scene
  106549. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106550. */
  106551. debugLayer: DebugLayer;
  106552. }
  106553. /**
  106554. * The debug layer (aka Inspector) is the go to tool in order to better understand
  106555. * what is happening in your scene
  106556. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106557. */
  106558. export class DebugLayer {
  106559. /**
  106560. * Define the url to get the inspector script from.
  106561. * By default it uses the babylonjs CDN.
  106562. * @ignoreNaming
  106563. */
  106564. static InspectorURL: string;
  106565. private _scene;
  106566. private BJSINSPECTOR;
  106567. private _onPropertyChangedObservable?;
  106568. /**
  106569. * Observable triggered when a property is changed through the inspector.
  106570. */
  106571. readonly onPropertyChangedObservable: any;
  106572. /**
  106573. * Instantiates a new debug layer.
  106574. * The debug layer (aka Inspector) is the go to tool in order to better understand
  106575. * what is happening in your scene
  106576. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106577. * @param scene Defines the scene to inspect
  106578. */
  106579. constructor(scene: Scene);
  106580. /** Creates the inspector window. */
  106581. private _createInspector;
  106582. /**
  106583. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  106584. * @param entity defines the entity to select
  106585. * @param lineContainerTitle defines the specific block to highlight
  106586. */
  106587. select(entity: any, lineContainerTitle?: string): void;
  106588. /** Get the inspector from bundle or global */
  106589. private _getGlobalInspector;
  106590. /**
  106591. * Get if the inspector is visible or not.
  106592. * @returns true if visible otherwise, false
  106593. */
  106594. isVisible(): boolean;
  106595. /**
  106596. * Hide the inspector and close its window.
  106597. */
  106598. hide(): void;
  106599. /**
  106600. * Launch the debugLayer.
  106601. * @param config Define the configuration of the inspector
  106602. * @return a promise fulfilled when the debug layer is visible
  106603. */
  106604. show(config?: IInspectorOptions): Promise<DebugLayer>;
  106605. }
  106606. }
  106607. declare module BABYLON {
  106608. /**
  106609. * Class containing static functions to help procedurally build meshes
  106610. */
  106611. export class BoxBuilder {
  106612. /**
  106613. * Creates a box mesh
  106614. * * The parameter `size` sets the size (float) of each box side (default 1)
  106615. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  106616. * * 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)
  106617. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106621. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  106622. * @param name defines the name of the mesh
  106623. * @param options defines the options used to create the mesh
  106624. * @param scene defines the hosting scene
  106625. * @returns the box mesh
  106626. */
  106627. static CreateBox(name: string, options: {
  106628. size?: number;
  106629. width?: number;
  106630. height?: number;
  106631. depth?: number;
  106632. faceUV?: Vector4[];
  106633. faceColors?: Color4[];
  106634. sideOrientation?: number;
  106635. frontUVs?: Vector4;
  106636. backUVs?: Vector4;
  106637. wrap?: boolean;
  106638. topBaseAt?: number;
  106639. bottomBaseAt?: number;
  106640. updatable?: boolean;
  106641. }, scene?: Nullable<Scene>): Mesh;
  106642. }
  106643. }
  106644. declare module BABYLON {
  106645. /**
  106646. * Class containing static functions to help procedurally build meshes
  106647. */
  106648. export class SphereBuilder {
  106649. /**
  106650. * Creates a sphere mesh
  106651. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  106652. * * 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`)
  106653. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  106654. * * 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
  106655. * * 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)
  106656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106659. * @param name defines the name of the mesh
  106660. * @param options defines the options used to create the mesh
  106661. * @param scene defines the hosting scene
  106662. * @returns the sphere mesh
  106663. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  106664. */
  106665. static CreateSphere(name: string, options: {
  106666. segments?: number;
  106667. diameter?: number;
  106668. diameterX?: number;
  106669. diameterY?: number;
  106670. diameterZ?: number;
  106671. arc?: number;
  106672. slice?: number;
  106673. sideOrientation?: number;
  106674. frontUVs?: Vector4;
  106675. backUVs?: Vector4;
  106676. updatable?: boolean;
  106677. }, scene: any): Mesh;
  106678. }
  106679. }
  106680. declare module BABYLON.Debug {
  106681. /**
  106682. * Used to show the physics impostor around the specific mesh
  106683. */
  106684. export class PhysicsViewer {
  106685. /** @hidden */
  106686. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  106687. /** @hidden */
  106688. protected _meshes: Array<Nullable<AbstractMesh>>;
  106689. /** @hidden */
  106690. protected _scene: Nullable<Scene>;
  106691. /** @hidden */
  106692. protected _numMeshes: number;
  106693. /** @hidden */
  106694. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  106695. private _renderFunction;
  106696. private _utilityLayer;
  106697. private _debugBoxMesh;
  106698. private _debugSphereMesh;
  106699. private _debugCylinderMesh;
  106700. private _debugMaterial;
  106701. private _debugMeshMeshes;
  106702. /**
  106703. * Creates a new PhysicsViewer
  106704. * @param scene defines the hosting scene
  106705. */
  106706. constructor(scene: Scene);
  106707. /** @hidden */
  106708. protected _updateDebugMeshes(): void;
  106709. /**
  106710. * Renders a specified physic impostor
  106711. * @param impostor defines the impostor to render
  106712. * @param targetMesh defines the mesh represented by the impostor
  106713. * @returns the new debug mesh used to render the impostor
  106714. */
  106715. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  106716. /**
  106717. * Hides a specified physic impostor
  106718. * @param impostor defines the impostor to hide
  106719. */
  106720. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  106721. private _getDebugMaterial;
  106722. private _getDebugBoxMesh;
  106723. private _getDebugSphereMesh;
  106724. private _getDebugCylinderMesh;
  106725. private _getDebugMeshMesh;
  106726. private _getDebugMesh;
  106727. /** Releases all resources */
  106728. dispose(): void;
  106729. }
  106730. }
  106731. declare module BABYLON {
  106732. /**
  106733. * Class containing static functions to help procedurally build meshes
  106734. */
  106735. export class LinesBuilder {
  106736. /**
  106737. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106738. * * 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
  106739. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106740. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106741. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106742. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106743. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106744. * * 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
  106745. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106747. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106748. * @param name defines the name of the new line system
  106749. * @param options defines the options used to create the line system
  106750. * @param scene defines the hosting scene
  106751. * @returns a new line system mesh
  106752. */
  106753. static CreateLineSystem(name: string, options: {
  106754. lines: Vector3[][];
  106755. updatable?: boolean;
  106756. instance?: Nullable<LinesMesh>;
  106757. colors?: Nullable<Color4[][]>;
  106758. useVertexAlpha?: boolean;
  106759. }, scene: Nullable<Scene>): LinesMesh;
  106760. /**
  106761. * Creates a line mesh
  106762. * 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
  106763. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106764. * * The parameter `points` is an array successive Vector3
  106765. * * 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
  106766. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106767. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106768. * * When updating an instance, remember that only point positions can change, not the number of points
  106769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106770. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106771. * @param name defines the name of the new line system
  106772. * @param options defines the options used to create the line system
  106773. * @param scene defines the hosting scene
  106774. * @returns a new line mesh
  106775. */
  106776. static CreateLines(name: string, options: {
  106777. points: Vector3[];
  106778. updatable?: boolean;
  106779. instance?: Nullable<LinesMesh>;
  106780. colors?: Color4[];
  106781. useVertexAlpha?: boolean;
  106782. }, scene?: Nullable<Scene>): LinesMesh;
  106783. /**
  106784. * Creates a dashed line mesh
  106785. * * 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
  106786. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106787. * * The parameter `points` is an array successive Vector3
  106788. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106789. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106790. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106791. * * 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
  106792. * * When updating an instance, remember that only point positions can change, not the number of points
  106793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106794. * @param name defines the name of the mesh
  106795. * @param options defines the options used to create the mesh
  106796. * @param scene defines the hosting scene
  106797. * @returns the dashed line mesh
  106798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106799. */
  106800. static CreateDashedLines(name: string, options: {
  106801. points: Vector3[];
  106802. dashSize?: number;
  106803. gapSize?: number;
  106804. dashNb?: number;
  106805. updatable?: boolean;
  106806. instance?: LinesMesh;
  106807. }, scene?: Nullable<Scene>): LinesMesh;
  106808. }
  106809. }
  106810. declare module BABYLON {
  106811. /**
  106812. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  106813. * in order to better appreciate the issue one might have.
  106814. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  106815. */
  106816. export class RayHelper {
  106817. /**
  106818. * Defines the ray we are currently tryin to visualize.
  106819. */
  106820. ray: Nullable<Ray>;
  106821. private _renderPoints;
  106822. private _renderLine;
  106823. private _renderFunction;
  106824. private _scene;
  106825. private _updateToMeshFunction;
  106826. private _attachedToMesh;
  106827. private _meshSpaceDirection;
  106828. private _meshSpaceOrigin;
  106829. /**
  106830. * Helper function to create a colored helper in a scene in one line.
  106831. * @param ray Defines the ray we are currently tryin to visualize
  106832. * @param scene Defines the scene the ray is used in
  106833. * @param color Defines the color we want to see the ray in
  106834. * @returns The newly created ray helper.
  106835. */
  106836. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  106837. /**
  106838. * Instantiate a new ray helper.
  106839. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  106840. * in order to better appreciate the issue one might have.
  106841. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  106842. * @param ray Defines the ray we are currently tryin to visualize
  106843. */
  106844. constructor(ray: Ray);
  106845. /**
  106846. * Shows the ray we are willing to debug.
  106847. * @param scene Defines the scene the ray needs to be rendered in
  106848. * @param color Defines the color the ray needs to be rendered in
  106849. */
  106850. show(scene: Scene, color?: Color3): void;
  106851. /**
  106852. * Hides the ray we are debugging.
  106853. */
  106854. hide(): void;
  106855. private _render;
  106856. /**
  106857. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  106858. * @param mesh Defines the mesh we want the helper attached to
  106859. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  106860. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  106861. * @param length Defines the length of the ray
  106862. */
  106863. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  106864. /**
  106865. * Detach the ray helper from the mesh it has previously been attached to.
  106866. */
  106867. detachFromMesh(): void;
  106868. private _updateToMesh;
  106869. /**
  106870. * Dispose the helper and release its associated resources.
  106871. */
  106872. dispose(): void;
  106873. }
  106874. }
  106875. declare module BABYLON.Debug {
  106876. /**
  106877. * Class used to render a debug view of a given skeleton
  106878. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  106879. */
  106880. export class SkeletonViewer {
  106881. /** defines the skeleton to render */
  106882. skeleton: Skeleton;
  106883. /** defines the mesh attached to the skeleton */
  106884. mesh: AbstractMesh;
  106885. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106886. autoUpdateBonesMatrices: boolean;
  106887. /** defines the rendering group id to use with the viewer */
  106888. renderingGroupId: number;
  106889. /** Gets or sets the color used to render the skeleton */
  106890. color: Color3;
  106891. private _scene;
  106892. private _debugLines;
  106893. private _debugMesh;
  106894. private _isEnabled;
  106895. private _renderFunction;
  106896. private _utilityLayer;
  106897. /**
  106898. * Returns the mesh used to render the bones
  106899. */
  106900. readonly debugMesh: Nullable<LinesMesh>;
  106901. /**
  106902. * Creates a new SkeletonViewer
  106903. * @param skeleton defines the skeleton to render
  106904. * @param mesh defines the mesh attached to the skeleton
  106905. * @param scene defines the hosting scene
  106906. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  106907. * @param renderingGroupId defines the rendering group id to use with the viewer
  106908. */
  106909. constructor(
  106910. /** defines the skeleton to render */
  106911. skeleton: Skeleton,
  106912. /** defines the mesh attached to the skeleton */
  106913. mesh: AbstractMesh, scene: Scene,
  106914. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106915. autoUpdateBonesMatrices?: boolean,
  106916. /** defines the rendering group id to use with the viewer */
  106917. renderingGroupId?: number);
  106918. /** Gets or sets a boolean indicating if the viewer is enabled */
  106919. isEnabled: boolean;
  106920. private _getBonePosition;
  106921. private _getLinesForBonesWithLength;
  106922. private _getLinesForBonesNoLength;
  106923. /** Update the viewer to sync with current skeleton state */
  106924. update(): void;
  106925. /** Release associated resources */
  106926. dispose(): void;
  106927. }
  106928. }
  106929. declare module BABYLON {
  106930. /**
  106931. * Options to create the null engine
  106932. */
  106933. export class NullEngineOptions {
  106934. /**
  106935. * Render width (Default: 512)
  106936. */
  106937. renderWidth: number;
  106938. /**
  106939. * Render height (Default: 256)
  106940. */
  106941. renderHeight: number;
  106942. /**
  106943. * Texture size (Default: 512)
  106944. */
  106945. textureSize: number;
  106946. /**
  106947. * If delta time between frames should be constant
  106948. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106949. */
  106950. deterministicLockstep: boolean;
  106951. /**
  106952. * Maximum about of steps between frames (Default: 4)
  106953. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106954. */
  106955. lockstepMaxSteps: number;
  106956. }
  106957. /**
  106958. * The null engine class provides support for headless version of babylon.js.
  106959. * This can be used in server side scenario or for testing purposes
  106960. */
  106961. export class NullEngine extends Engine {
  106962. private _options;
  106963. /**
  106964. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106965. */
  106966. isDeterministicLockStep(): boolean;
  106967. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  106968. getLockstepMaxSteps(): number;
  106969. /**
  106970. * Sets hardware scaling, used to save performance if needed
  106971. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  106972. */
  106973. getHardwareScalingLevel(): number;
  106974. constructor(options?: NullEngineOptions);
  106975. createVertexBuffer(vertices: FloatArray): DataBuffer;
  106976. createIndexBuffer(indices: IndicesArray): DataBuffer;
  106977. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  106978. getRenderWidth(useScreen?: boolean): number;
  106979. getRenderHeight(useScreen?: boolean): number;
  106980. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  106981. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  106982. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  106983. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  106984. bindSamplers(effect: Effect): void;
  106985. enableEffect(effect: Effect): void;
  106986. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106987. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  106988. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  106989. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  106990. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  106991. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  106992. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  106993. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  106994. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  106995. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  106996. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  106997. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  106998. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  106999. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  107000. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107001. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107002. setFloat(uniform: WebGLUniformLocation, value: number): void;
  107003. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  107004. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  107005. setBool(uniform: WebGLUniformLocation, bool: number): void;
  107006. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  107007. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107008. bindBuffers(vertexBuffers: {
  107009. [key: string]: VertexBuffer;
  107010. }, indexBuffer: DataBuffer, effect: Effect): void;
  107011. wipeCaches(bruteForce?: boolean): void;
  107012. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  107013. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  107014. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107015. /** @hidden */
  107016. _createTexture(): WebGLTexture;
  107017. /** @hidden */
  107018. _releaseTexture(texture: InternalTexture): void;
  107019. 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;
  107020. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  107021. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  107022. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  107023. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  107024. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  107025. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  107026. areAllEffectsReady(): boolean;
  107027. /**
  107028. * @hidden
  107029. * Get the current error code of the webGL context
  107030. * @returns the error code
  107031. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  107032. */
  107033. getError(): number;
  107034. /** @hidden */
  107035. _getUnpackAlignement(): number;
  107036. /** @hidden */
  107037. _unpackFlipY(value: boolean): void;
  107038. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  107039. /**
  107040. * Updates a dynamic vertex buffer.
  107041. * @param vertexBuffer the vertex buffer to update
  107042. * @param data the data used to update the vertex buffer
  107043. * @param byteOffset the byte offset of the data (optional)
  107044. * @param byteLength the byte length of the data (optional)
  107045. */
  107046. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  107047. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  107048. /** @hidden */
  107049. _bindTexture(channel: number, texture: InternalTexture): void;
  107050. /** @hidden */
  107051. _releaseBuffer(buffer: DataBuffer): boolean;
  107052. releaseEffects(): void;
  107053. displayLoadingUI(): void;
  107054. hideLoadingUI(): void;
  107055. /** @hidden */
  107056. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107057. /** @hidden */
  107058. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107059. /** @hidden */
  107060. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107061. /** @hidden */
  107062. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  107063. }
  107064. }
  107065. declare module BABYLON {
  107066. /** @hidden */
  107067. export class _OcclusionDataStorage {
  107068. /** @hidden */
  107069. occlusionInternalRetryCounter: number;
  107070. /** @hidden */
  107071. isOcclusionQueryInProgress: boolean;
  107072. /** @hidden */
  107073. isOccluded: boolean;
  107074. /** @hidden */
  107075. occlusionRetryCount: number;
  107076. /** @hidden */
  107077. occlusionType: number;
  107078. /** @hidden */
  107079. occlusionQueryAlgorithmType: number;
  107080. }
  107081. interface Engine {
  107082. /**
  107083. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  107084. * @return the new query
  107085. */
  107086. createQuery(): WebGLQuery;
  107087. /**
  107088. * Delete and release a webGL query
  107089. * @param query defines the query to delete
  107090. * @return the current engine
  107091. */
  107092. deleteQuery(query: WebGLQuery): Engine;
  107093. /**
  107094. * Check if a given query has resolved and got its value
  107095. * @param query defines the query to check
  107096. * @returns true if the query got its value
  107097. */
  107098. isQueryResultAvailable(query: WebGLQuery): boolean;
  107099. /**
  107100. * Gets the value of a given query
  107101. * @param query defines the query to check
  107102. * @returns the value of the query
  107103. */
  107104. getQueryResult(query: WebGLQuery): number;
  107105. /**
  107106. * Initiates an occlusion query
  107107. * @param algorithmType defines the algorithm to use
  107108. * @param query defines the query to use
  107109. * @returns the current engine
  107110. * @see http://doc.babylonjs.com/features/occlusionquery
  107111. */
  107112. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  107113. /**
  107114. * Ends an occlusion query
  107115. * @see http://doc.babylonjs.com/features/occlusionquery
  107116. * @param algorithmType defines the algorithm to use
  107117. * @returns the current engine
  107118. */
  107119. endOcclusionQuery(algorithmType: number): Engine;
  107120. /**
  107121. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  107122. * Please note that only one query can be issued at a time
  107123. * @returns a time token used to track the time span
  107124. */
  107125. startTimeQuery(): Nullable<_TimeToken>;
  107126. /**
  107127. * Ends a time query
  107128. * @param token defines the token used to measure the time span
  107129. * @returns the time spent (in ns)
  107130. */
  107131. endTimeQuery(token: _TimeToken): int;
  107132. /** @hidden */
  107133. _currentNonTimestampToken: Nullable<_TimeToken>;
  107134. /** @hidden */
  107135. _createTimeQuery(): WebGLQuery;
  107136. /** @hidden */
  107137. _deleteTimeQuery(query: WebGLQuery): void;
  107138. /** @hidden */
  107139. _getGlAlgorithmType(algorithmType: number): number;
  107140. /** @hidden */
  107141. _getTimeQueryResult(query: WebGLQuery): any;
  107142. /** @hidden */
  107143. _getTimeQueryAvailability(query: WebGLQuery): any;
  107144. }
  107145. interface AbstractMesh {
  107146. /**
  107147. * Backing filed
  107148. * @hidden
  107149. */
  107150. __occlusionDataStorage: _OcclusionDataStorage;
  107151. /**
  107152. * Access property
  107153. * @hidden
  107154. */
  107155. _occlusionDataStorage: _OcclusionDataStorage;
  107156. /**
  107157. * 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.
  107158. * The default value is -1 which means don't break the query and wait till the result
  107159. * @see http://doc.babylonjs.com/features/occlusionquery
  107160. */
  107161. occlusionRetryCount: number;
  107162. /**
  107163. * 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:
  107164. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  107165. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  107166. * * 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.
  107167. * @see http://doc.babylonjs.com/features/occlusionquery
  107168. */
  107169. occlusionType: number;
  107170. /**
  107171. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  107172. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  107173. * * 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.
  107174. * @see http://doc.babylonjs.com/features/occlusionquery
  107175. */
  107176. occlusionQueryAlgorithmType: number;
  107177. /**
  107178. * 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
  107179. * @see http://doc.babylonjs.com/features/occlusionquery
  107180. */
  107181. isOccluded: boolean;
  107182. /**
  107183. * Flag to check the progress status of the query
  107184. * @see http://doc.babylonjs.com/features/occlusionquery
  107185. */
  107186. isOcclusionQueryInProgress: boolean;
  107187. }
  107188. }
  107189. declare module BABYLON {
  107190. /** @hidden */
  107191. export var _forceTransformFeedbackToBundle: boolean;
  107192. interface Engine {
  107193. /**
  107194. * Creates a webGL transform feedback object
  107195. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  107196. * @returns the webGL transform feedback object
  107197. */
  107198. createTransformFeedback(): WebGLTransformFeedback;
  107199. /**
  107200. * Delete a webGL transform feedback object
  107201. * @param value defines the webGL transform feedback object to delete
  107202. */
  107203. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  107204. /**
  107205. * Bind a webGL transform feedback object to the webgl context
  107206. * @param value defines the webGL transform feedback object to bind
  107207. */
  107208. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  107209. /**
  107210. * Begins a transform feedback operation
  107211. * @param usePoints defines if points or triangles must be used
  107212. */
  107213. beginTransformFeedback(usePoints: boolean): void;
  107214. /**
  107215. * Ends a transform feedback operation
  107216. */
  107217. endTransformFeedback(): void;
  107218. /**
  107219. * Specify the varyings to use with transform feedback
  107220. * @param program defines the associated webGL program
  107221. * @param value defines the list of strings representing the varying names
  107222. */
  107223. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  107224. /**
  107225. * Bind a webGL buffer for a transform feedback operation
  107226. * @param value defines the webGL buffer to bind
  107227. */
  107228. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  107229. }
  107230. }
  107231. declare module BABYLON {
  107232. /**
  107233. * Creation options of the multi render target texture.
  107234. */
  107235. export interface IMultiRenderTargetOptions {
  107236. /**
  107237. * Define if the texture needs to create mip maps after render.
  107238. */
  107239. generateMipMaps?: boolean;
  107240. /**
  107241. * Define the types of all the draw buffers we want to create
  107242. */
  107243. types?: number[];
  107244. /**
  107245. * Define the sampling modes of all the draw buffers we want to create
  107246. */
  107247. samplingModes?: number[];
  107248. /**
  107249. * Define if a depth buffer is required
  107250. */
  107251. generateDepthBuffer?: boolean;
  107252. /**
  107253. * Define if a stencil buffer is required
  107254. */
  107255. generateStencilBuffer?: boolean;
  107256. /**
  107257. * Define if a depth texture is required instead of a depth buffer
  107258. */
  107259. generateDepthTexture?: boolean;
  107260. /**
  107261. * Define the number of desired draw buffers
  107262. */
  107263. textureCount?: number;
  107264. /**
  107265. * Define if aspect ratio should be adapted to the texture or stay the scene one
  107266. */
  107267. doNotChangeAspectRatio?: boolean;
  107268. /**
  107269. * Define the default type of the buffers we are creating
  107270. */
  107271. defaultType?: number;
  107272. }
  107273. /**
  107274. * A multi render target, like a render target provides the ability to render to a texture.
  107275. * Unlike the render target, it can render to several draw buffers in one draw.
  107276. * This is specially interesting in deferred rendering or for any effects requiring more than
  107277. * just one color from a single pass.
  107278. */
  107279. export class MultiRenderTarget extends RenderTargetTexture {
  107280. private _internalTextures;
  107281. private _textures;
  107282. private _multiRenderTargetOptions;
  107283. /**
  107284. * Get if draw buffers are currently supported by the used hardware and browser.
  107285. */
  107286. readonly isSupported: boolean;
  107287. /**
  107288. * Get the list of textures generated by the multi render target.
  107289. */
  107290. readonly textures: Texture[];
  107291. /**
  107292. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  107293. */
  107294. readonly depthTexture: Texture;
  107295. /**
  107296. * Set the wrapping mode on U of all the textures we are rendering to.
  107297. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107298. */
  107299. wrapU: number;
  107300. /**
  107301. * Set the wrapping mode on V of all the textures we are rendering to.
  107302. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107303. */
  107304. wrapV: number;
  107305. /**
  107306. * Instantiate a new multi render target texture.
  107307. * A multi render target, like a render target provides the ability to render to a texture.
  107308. * Unlike the render target, it can render to several draw buffers in one draw.
  107309. * This is specially interesting in deferred rendering or for any effects requiring more than
  107310. * just one color from a single pass.
  107311. * @param name Define the name of the texture
  107312. * @param size Define the size of the buffers to render to
  107313. * @param count Define the number of target we are rendering into
  107314. * @param scene Define the scene the texture belongs to
  107315. * @param options Define the options used to create the multi render target
  107316. */
  107317. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  107318. /** @hidden */
  107319. _rebuild(): void;
  107320. private _createInternalTextures;
  107321. private _createTextures;
  107322. /**
  107323. * Define the number of samples used if MSAA is enabled.
  107324. */
  107325. samples: number;
  107326. /**
  107327. * Resize all the textures in the multi render target.
  107328. * Be carrefull as it will recreate all the data in the new texture.
  107329. * @param size Define the new size
  107330. */
  107331. resize(size: any): void;
  107332. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  107333. /**
  107334. * Dispose the render targets and their associated resources
  107335. */
  107336. dispose(): void;
  107337. /**
  107338. * Release all the underlying texture used as draw buffers.
  107339. */
  107340. releaseInternalTextures(): void;
  107341. }
  107342. }
  107343. declare module BABYLON {
  107344. interface Engine {
  107345. /**
  107346. * Unbind a list of render target textures from the webGL context
  107347. * This is used only when drawBuffer extension or webGL2 are active
  107348. * @param textures defines the render target textures to unbind
  107349. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  107350. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  107351. */
  107352. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  107353. /**
  107354. * Create a multi render target texture
  107355. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  107356. * @param size defines the size of the texture
  107357. * @param options defines the creation options
  107358. * @returns the cube texture as an InternalTexture
  107359. */
  107360. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  107361. /**
  107362. * Update the sample count for a given multiple render target texture
  107363. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107364. * @param textures defines the textures to update
  107365. * @param samples defines the sample count to set
  107366. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107367. */
  107368. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  107369. }
  107370. }
  107371. declare module BABYLON {
  107372. /**
  107373. * Gather the list of clipboard event types as constants.
  107374. */
  107375. export class ClipboardEventTypes {
  107376. /**
  107377. * The clipboard event is fired when a copy command is active (pressed).
  107378. */
  107379. static readonly COPY: number;
  107380. /**
  107381. * The clipboard event is fired when a cut command is active (pressed).
  107382. */
  107383. static readonly CUT: number;
  107384. /**
  107385. * The clipboard event is fired when a paste command is active (pressed).
  107386. */
  107387. static readonly PASTE: number;
  107388. }
  107389. /**
  107390. * This class is used to store clipboard related info for the onClipboardObservable event.
  107391. */
  107392. export class ClipboardInfo {
  107393. /**
  107394. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107395. */
  107396. type: number;
  107397. /**
  107398. * Defines the related dom event
  107399. */
  107400. event: ClipboardEvent;
  107401. /**
  107402. *Creates an instance of ClipboardInfo.
  107403. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  107404. * @param event Defines the related dom event
  107405. */
  107406. constructor(
  107407. /**
  107408. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107409. */
  107410. type: number,
  107411. /**
  107412. * Defines the related dom event
  107413. */
  107414. event: ClipboardEvent);
  107415. /**
  107416. * Get the clipboard event's type from the keycode.
  107417. * @param keyCode Defines the keyCode for the current keyboard event.
  107418. * @return {number}
  107419. */
  107420. static GetTypeFromCharacter(keyCode: number): number;
  107421. }
  107422. }
  107423. declare module BABYLON {
  107424. /**
  107425. * Google Daydream controller
  107426. */
  107427. export class DaydreamController extends WebVRController {
  107428. /**
  107429. * Base Url for the controller model.
  107430. */
  107431. static MODEL_BASE_URL: string;
  107432. /**
  107433. * File name for the controller model.
  107434. */
  107435. static MODEL_FILENAME: string;
  107436. /**
  107437. * Gamepad Id prefix used to identify Daydream Controller.
  107438. */
  107439. static readonly GAMEPAD_ID_PREFIX: string;
  107440. /**
  107441. * Creates a new DaydreamController from a gamepad
  107442. * @param vrGamepad the gamepad that the controller should be created from
  107443. */
  107444. constructor(vrGamepad: any);
  107445. /**
  107446. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107447. * @param scene scene in which to add meshes
  107448. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107449. */
  107450. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107451. /**
  107452. * Called once for each button that changed state since the last frame
  107453. * @param buttonIdx Which button index changed
  107454. * @param state New state of the button
  107455. * @param changes Which properties on the state changed since last frame
  107456. */
  107457. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107458. }
  107459. }
  107460. declare module BABYLON {
  107461. /**
  107462. * Gear VR Controller
  107463. */
  107464. export class GearVRController extends WebVRController {
  107465. /**
  107466. * Base Url for the controller model.
  107467. */
  107468. static MODEL_BASE_URL: string;
  107469. /**
  107470. * File name for the controller model.
  107471. */
  107472. static MODEL_FILENAME: string;
  107473. /**
  107474. * Gamepad Id prefix used to identify this controller.
  107475. */
  107476. static readonly GAMEPAD_ID_PREFIX: string;
  107477. private readonly _buttonIndexToObservableNameMap;
  107478. /**
  107479. * Creates a new GearVRController from a gamepad
  107480. * @param vrGamepad the gamepad that the controller should be created from
  107481. */
  107482. constructor(vrGamepad: any);
  107483. /**
  107484. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107485. * @param scene scene in which to add meshes
  107486. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107487. */
  107488. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107489. /**
  107490. * Called once for each button that changed state since the last frame
  107491. * @param buttonIdx Which button index changed
  107492. * @param state New state of the button
  107493. * @param changes Which properties on the state changed since last frame
  107494. */
  107495. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107496. }
  107497. }
  107498. declare module BABYLON {
  107499. /**
  107500. * Class containing static functions to help procedurally build meshes
  107501. */
  107502. export class PolyhedronBuilder {
  107503. /**
  107504. * Creates a polyhedron mesh
  107505. * * 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
  107506. * * The parameter `size` (positive float, default 1) sets the polygon size
  107507. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107508. * * 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`
  107509. * * 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
  107510. * * 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)`)
  107511. * * 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
  107512. * * 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
  107513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107516. * @param name defines the name of the mesh
  107517. * @param options defines the options used to create the mesh
  107518. * @param scene defines the hosting scene
  107519. * @returns the polyhedron mesh
  107520. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  107521. */
  107522. static CreatePolyhedron(name: string, options: {
  107523. type?: number;
  107524. size?: number;
  107525. sizeX?: number;
  107526. sizeY?: number;
  107527. sizeZ?: number;
  107528. custom?: any;
  107529. faceUV?: Vector4[];
  107530. faceColors?: Color4[];
  107531. flat?: boolean;
  107532. updatable?: boolean;
  107533. sideOrientation?: number;
  107534. frontUVs?: Vector4;
  107535. backUVs?: Vector4;
  107536. }, scene?: Nullable<Scene>): Mesh;
  107537. }
  107538. }
  107539. declare module BABYLON {
  107540. /**
  107541. * Gizmo that enables scaling a mesh along 3 axis
  107542. */
  107543. export class ScaleGizmo extends Gizmo {
  107544. /**
  107545. * Internal gizmo used for interactions on the x axis
  107546. */
  107547. xGizmo: AxisScaleGizmo;
  107548. /**
  107549. * Internal gizmo used for interactions on the y axis
  107550. */
  107551. yGizmo: AxisScaleGizmo;
  107552. /**
  107553. * Internal gizmo used for interactions on the z axis
  107554. */
  107555. zGizmo: AxisScaleGizmo;
  107556. /**
  107557. * Internal gizmo used to scale all axis equally
  107558. */
  107559. uniformScaleGizmo: AxisScaleGizmo;
  107560. private _meshAttached;
  107561. private _updateGizmoRotationToMatchAttachedMesh;
  107562. private _snapDistance;
  107563. private _scaleRatio;
  107564. private _uniformScalingMesh;
  107565. private _octahedron;
  107566. /** Fires an event when any of it's sub gizmos are dragged */
  107567. onDragStartObservable: Observable<unknown>;
  107568. /** Fires an event when any of it's sub gizmos are released from dragging */
  107569. onDragEndObservable: Observable<unknown>;
  107570. attachedMesh: Nullable<AbstractMesh>;
  107571. /**
  107572. * Creates a ScaleGizmo
  107573. * @param gizmoLayer The utility layer the gizmo will be added to
  107574. */
  107575. constructor(gizmoLayer?: UtilityLayerRenderer);
  107576. updateGizmoRotationToMatchAttachedMesh: boolean;
  107577. /**
  107578. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107579. */
  107580. snapDistance: number;
  107581. /**
  107582. * Ratio for the scale of the gizmo (Default: 1)
  107583. */
  107584. scaleRatio: number;
  107585. /**
  107586. * Disposes of the gizmo
  107587. */
  107588. dispose(): void;
  107589. }
  107590. }
  107591. declare module BABYLON {
  107592. /**
  107593. * Single axis scale gizmo
  107594. */
  107595. export class AxisScaleGizmo extends Gizmo {
  107596. /**
  107597. * Drag behavior responsible for the gizmos dragging interactions
  107598. */
  107599. dragBehavior: PointerDragBehavior;
  107600. private _pointerObserver;
  107601. /**
  107602. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107603. */
  107604. snapDistance: number;
  107605. /**
  107606. * Event that fires each time the gizmo snaps to a new location.
  107607. * * snapDistance is the the change in distance
  107608. */
  107609. onSnapObservable: Observable<{
  107610. snapDistance: number;
  107611. }>;
  107612. /**
  107613. * If the scaling operation should be done on all axis (default: false)
  107614. */
  107615. uniformScaling: boolean;
  107616. private _isEnabled;
  107617. private _parent;
  107618. private _arrow;
  107619. private _coloredMaterial;
  107620. private _hoverMaterial;
  107621. /**
  107622. * Creates an AxisScaleGizmo
  107623. * @param gizmoLayer The utility layer the gizmo will be added to
  107624. * @param dragAxis The axis which the gizmo will be able to scale on
  107625. * @param color The color of the gizmo
  107626. */
  107627. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  107628. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107629. /**
  107630. * If the gizmo is enabled
  107631. */
  107632. isEnabled: boolean;
  107633. /**
  107634. * Disposes of the gizmo
  107635. */
  107636. dispose(): void;
  107637. /**
  107638. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  107639. * @param mesh The mesh to replace the default mesh of the gizmo
  107640. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  107641. */
  107642. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  107643. }
  107644. }
  107645. declare module BABYLON {
  107646. /**
  107647. * Bounding box gizmo
  107648. */
  107649. export class BoundingBoxGizmo extends Gizmo {
  107650. private _lineBoundingBox;
  107651. private _rotateSpheresParent;
  107652. private _scaleBoxesParent;
  107653. private _boundingDimensions;
  107654. private _renderObserver;
  107655. private _pointerObserver;
  107656. private _scaleDragSpeed;
  107657. private _tmpQuaternion;
  107658. private _tmpVector;
  107659. private _tmpRotationMatrix;
  107660. /**
  107661. * 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)
  107662. */
  107663. ignoreChildren: boolean;
  107664. /**
  107665. * 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)
  107666. */
  107667. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  107668. /**
  107669. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  107670. */
  107671. rotationSphereSize: number;
  107672. /**
  107673. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  107674. */
  107675. scaleBoxSize: number;
  107676. /**
  107677. * 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)
  107678. */
  107679. fixedDragMeshScreenSize: boolean;
  107680. /**
  107681. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  107682. */
  107683. fixedDragMeshScreenSizeDistanceFactor: number;
  107684. /**
  107685. * Fired when a rotation sphere or scale box is dragged
  107686. */
  107687. onDragStartObservable: Observable<{}>;
  107688. /**
  107689. * Fired when a scale box is dragged
  107690. */
  107691. onScaleBoxDragObservable: Observable<{}>;
  107692. /**
  107693. * Fired when a scale box drag is ended
  107694. */
  107695. onScaleBoxDragEndObservable: Observable<{}>;
  107696. /**
  107697. * Fired when a rotation sphere is dragged
  107698. */
  107699. onRotationSphereDragObservable: Observable<{}>;
  107700. /**
  107701. * Fired when a rotation sphere drag is ended
  107702. */
  107703. onRotationSphereDragEndObservable: Observable<{}>;
  107704. /**
  107705. * 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)
  107706. */
  107707. scalePivot: Nullable<Vector3>;
  107708. /**
  107709. * Mesh used as a pivot to rotate the attached mesh
  107710. */
  107711. private _anchorMesh;
  107712. private _existingMeshScale;
  107713. private _dragMesh;
  107714. private pointerDragBehavior;
  107715. private coloredMaterial;
  107716. private hoverColoredMaterial;
  107717. /**
  107718. * Sets the color of the bounding box gizmo
  107719. * @param color the color to set
  107720. */
  107721. setColor(color: Color3): void;
  107722. /**
  107723. * Creates an BoundingBoxGizmo
  107724. * @param gizmoLayer The utility layer the gizmo will be added to
  107725. * @param color The color of the gizmo
  107726. */
  107727. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  107728. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107729. private _selectNode;
  107730. /**
  107731. * Updates the bounding box information for the Gizmo
  107732. */
  107733. updateBoundingBox(): void;
  107734. private _updateRotationSpheres;
  107735. private _updateScaleBoxes;
  107736. /**
  107737. * Enables rotation on the specified axis and disables rotation on the others
  107738. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  107739. */
  107740. setEnabledRotationAxis(axis: string): void;
  107741. /**
  107742. * Enables/disables scaling
  107743. * @param enable if scaling should be enabled
  107744. */
  107745. setEnabledScaling(enable: boolean): void;
  107746. private _updateDummy;
  107747. /**
  107748. * Enables a pointer drag behavior on the bounding box of the gizmo
  107749. */
  107750. enableDragBehavior(): void;
  107751. /**
  107752. * Disposes of the gizmo
  107753. */
  107754. dispose(): void;
  107755. /**
  107756. * 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)
  107757. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  107758. * @returns the bounding box mesh with the passed in mesh as a child
  107759. */
  107760. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  107761. /**
  107762. * CustomMeshes are not supported by this gizmo
  107763. * @param mesh The mesh to replace the default mesh of the gizmo
  107764. */
  107765. setCustomMesh(mesh: Mesh): void;
  107766. }
  107767. }
  107768. declare module BABYLON {
  107769. /**
  107770. * Single plane rotation gizmo
  107771. */
  107772. export class PlaneRotationGizmo extends Gizmo {
  107773. /**
  107774. * Drag behavior responsible for the gizmos dragging interactions
  107775. */
  107776. dragBehavior: PointerDragBehavior;
  107777. private _pointerObserver;
  107778. /**
  107779. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  107780. */
  107781. snapDistance: number;
  107782. /**
  107783. * Event that fires each time the gizmo snaps to a new location.
  107784. * * snapDistance is the the change in distance
  107785. */
  107786. onSnapObservable: Observable<{
  107787. snapDistance: number;
  107788. }>;
  107789. private _isEnabled;
  107790. private _parent;
  107791. /**
  107792. * Creates a PlaneRotationGizmo
  107793. * @param gizmoLayer The utility layer the gizmo will be added to
  107794. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  107795. * @param color The color of the gizmo
  107796. * @param tessellation Amount of tessellation to be used when creating rotation circles
  107797. */
  107798. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  107799. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107800. /**
  107801. * If the gizmo is enabled
  107802. */
  107803. isEnabled: boolean;
  107804. /**
  107805. * Disposes of the gizmo
  107806. */
  107807. dispose(): void;
  107808. }
  107809. }
  107810. declare module BABYLON {
  107811. /**
  107812. * Gizmo that enables rotating a mesh along 3 axis
  107813. */
  107814. export class RotationGizmo extends Gizmo {
  107815. /**
  107816. * Internal gizmo used for interactions on the x axis
  107817. */
  107818. xGizmo: PlaneRotationGizmo;
  107819. /**
  107820. * Internal gizmo used for interactions on the y axis
  107821. */
  107822. yGizmo: PlaneRotationGizmo;
  107823. /**
  107824. * Internal gizmo used for interactions on the z axis
  107825. */
  107826. zGizmo: PlaneRotationGizmo;
  107827. /** Fires an event when any of it's sub gizmos are dragged */
  107828. onDragStartObservable: Observable<unknown>;
  107829. /** Fires an event when any of it's sub gizmos are released from dragging */
  107830. onDragEndObservable: Observable<unknown>;
  107831. private _meshAttached;
  107832. attachedMesh: Nullable<AbstractMesh>;
  107833. /**
  107834. * Creates a RotationGizmo
  107835. * @param gizmoLayer The utility layer the gizmo will be added to
  107836. * @param tessellation Amount of tessellation to be used when creating rotation circles
  107837. */
  107838. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  107839. updateGizmoRotationToMatchAttachedMesh: boolean;
  107840. /**
  107841. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107842. */
  107843. snapDistance: number;
  107844. /**
  107845. * Ratio for the scale of the gizmo (Default: 1)
  107846. */
  107847. scaleRatio: number;
  107848. /**
  107849. * Disposes of the gizmo
  107850. */
  107851. dispose(): void;
  107852. /**
  107853. * CustomMeshes are not supported by this gizmo
  107854. * @param mesh The mesh to replace the default mesh of the gizmo
  107855. */
  107856. setCustomMesh(mesh: Mesh): void;
  107857. }
  107858. }
  107859. declare module BABYLON {
  107860. /**
  107861. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  107862. */
  107863. export class GizmoManager implements IDisposable {
  107864. private scene;
  107865. /**
  107866. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  107867. */
  107868. gizmos: {
  107869. positionGizmo: Nullable<PositionGizmo>;
  107870. rotationGizmo: Nullable<RotationGizmo>;
  107871. scaleGizmo: Nullable<ScaleGizmo>;
  107872. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  107873. };
  107874. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  107875. clearGizmoOnEmptyPointerEvent: boolean;
  107876. /** Fires an event when the manager is attached to a mesh */
  107877. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  107878. private _gizmosEnabled;
  107879. private _pointerObserver;
  107880. private _attachedMesh;
  107881. private _boundingBoxColor;
  107882. private _defaultUtilityLayer;
  107883. private _defaultKeepDepthUtilityLayer;
  107884. /**
  107885. * When bounding box gizmo is enabled, this can be used to track drag/end events
  107886. */
  107887. boundingBoxDragBehavior: SixDofDragBehavior;
  107888. /**
  107889. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  107890. */
  107891. attachableMeshes: Nullable<Array<AbstractMesh>>;
  107892. /**
  107893. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  107894. */
  107895. usePointerToAttachGizmos: boolean;
  107896. /**
  107897. * Utility layer that the bounding box gizmo belongs to
  107898. */
  107899. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  107900. /**
  107901. * Utility layer that all gizmos besides bounding box belong to
  107902. */
  107903. readonly utilityLayer: UtilityLayerRenderer;
  107904. /**
  107905. * Instatiates a gizmo manager
  107906. * @param scene the scene to overlay the gizmos on top of
  107907. */
  107908. constructor(scene: Scene);
  107909. /**
  107910. * Attaches a set of gizmos to the specified mesh
  107911. * @param mesh The mesh the gizmo's should be attached to
  107912. */
  107913. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107914. /**
  107915. * If the position gizmo is enabled
  107916. */
  107917. positionGizmoEnabled: boolean;
  107918. /**
  107919. * If the rotation gizmo is enabled
  107920. */
  107921. rotationGizmoEnabled: boolean;
  107922. /**
  107923. * If the scale gizmo is enabled
  107924. */
  107925. scaleGizmoEnabled: boolean;
  107926. /**
  107927. * If the boundingBox gizmo is enabled
  107928. */
  107929. boundingBoxGizmoEnabled: boolean;
  107930. /**
  107931. * Disposes of the gizmo manager
  107932. */
  107933. dispose(): void;
  107934. }
  107935. }
  107936. declare module BABYLON {
  107937. /**
  107938. * A directional light is defined by a direction (what a surprise!).
  107939. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  107940. * 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.
  107941. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107942. */
  107943. export class DirectionalLight extends ShadowLight {
  107944. private _shadowFrustumSize;
  107945. /**
  107946. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  107947. */
  107948. /**
  107949. * Specifies a fix frustum size for the shadow generation.
  107950. */
  107951. shadowFrustumSize: number;
  107952. private _shadowOrthoScale;
  107953. /**
  107954. * Gets the shadow projection scale against the optimal computed one.
  107955. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  107956. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  107957. */
  107958. /**
  107959. * Sets the shadow projection scale against the optimal computed one.
  107960. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  107961. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  107962. */
  107963. shadowOrthoScale: number;
  107964. /**
  107965. * Automatically compute the projection matrix to best fit (including all the casters)
  107966. * on each frame.
  107967. */
  107968. autoUpdateExtends: boolean;
  107969. private _orthoLeft;
  107970. private _orthoRight;
  107971. private _orthoTop;
  107972. private _orthoBottom;
  107973. /**
  107974. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  107975. * The directional light is emitted from everywhere in the given direction.
  107976. * It can cast shadows.
  107977. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107978. * @param name The friendly name of the light
  107979. * @param direction The direction of the light
  107980. * @param scene The scene the light belongs to
  107981. */
  107982. constructor(name: string, direction: Vector3, scene: Scene);
  107983. /**
  107984. * Returns the string "DirectionalLight".
  107985. * @return The class name
  107986. */
  107987. getClassName(): string;
  107988. /**
  107989. * Returns the integer 1.
  107990. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107991. */
  107992. getTypeID(): number;
  107993. /**
  107994. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  107995. * Returns the DirectionalLight Shadow projection matrix.
  107996. */
  107997. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107998. /**
  107999. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  108000. * Returns the DirectionalLight Shadow projection matrix.
  108001. */
  108002. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  108003. /**
  108004. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  108005. * Returns the DirectionalLight Shadow projection matrix.
  108006. */
  108007. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108008. protected _buildUniformLayout(): void;
  108009. /**
  108010. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  108011. * @param effect The effect to update
  108012. * @param lightIndex The index of the light in the effect to update
  108013. * @returns The directional light
  108014. */
  108015. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  108016. /**
  108017. * Gets the minZ used for shadow according to both the scene and the light.
  108018. *
  108019. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108020. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108021. * @param activeCamera The camera we are returning the min for
  108022. * @returns the depth min z
  108023. */
  108024. getDepthMinZ(activeCamera: Camera): number;
  108025. /**
  108026. * Gets the maxZ used for shadow according to both the scene and the light.
  108027. *
  108028. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108029. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108030. * @param activeCamera The camera we are returning the max for
  108031. * @returns the depth max z
  108032. */
  108033. getDepthMaxZ(activeCamera: Camera): number;
  108034. /**
  108035. * Prepares the list of defines specific to the light type.
  108036. * @param defines the list of defines
  108037. * @param lightIndex defines the index of the light for the effect
  108038. */
  108039. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108040. }
  108041. }
  108042. declare module BABYLON {
  108043. /**
  108044. * Class containing static functions to help procedurally build meshes
  108045. */
  108046. export class HemisphereBuilder {
  108047. /**
  108048. * Creates a hemisphere mesh
  108049. * @param name defines the name of the mesh
  108050. * @param options defines the options used to create the mesh
  108051. * @param scene defines the hosting scene
  108052. * @returns the hemisphere mesh
  108053. */
  108054. static CreateHemisphere(name: string, options: {
  108055. segments?: number;
  108056. diameter?: number;
  108057. sideOrientation?: number;
  108058. }, scene: any): Mesh;
  108059. }
  108060. }
  108061. declare module BABYLON {
  108062. /**
  108063. * A spot light is defined by a position, a direction, an angle, and an exponent.
  108064. * These values define a cone of light starting from the position, emitting toward the direction.
  108065. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  108066. * and the exponent defines the speed of the decay of the light with distance (reach).
  108067. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108068. */
  108069. export class SpotLight extends ShadowLight {
  108070. private _angle;
  108071. private _innerAngle;
  108072. private _cosHalfAngle;
  108073. private _lightAngleScale;
  108074. private _lightAngleOffset;
  108075. /**
  108076. * Gets the cone angle of the spot light in Radians.
  108077. */
  108078. /**
  108079. * Sets the cone angle of the spot light in Radians.
  108080. */
  108081. angle: number;
  108082. /**
  108083. * Only used in gltf falloff mode, this defines the angle where
  108084. * the directional falloff will start before cutting at angle which could be seen
  108085. * as outer angle.
  108086. */
  108087. /**
  108088. * Only used in gltf falloff mode, this defines the angle where
  108089. * the directional falloff will start before cutting at angle which could be seen
  108090. * as outer angle.
  108091. */
  108092. innerAngle: number;
  108093. private _shadowAngleScale;
  108094. /**
  108095. * Allows scaling the angle of the light for shadow generation only.
  108096. */
  108097. /**
  108098. * Allows scaling the angle of the light for shadow generation only.
  108099. */
  108100. shadowAngleScale: number;
  108101. /**
  108102. * The light decay speed with the distance from the emission spot.
  108103. */
  108104. exponent: number;
  108105. private _projectionTextureMatrix;
  108106. /**
  108107. * Allows reading the projecton texture
  108108. */
  108109. readonly projectionTextureMatrix: Matrix;
  108110. protected _projectionTextureLightNear: number;
  108111. /**
  108112. * Gets the near clip of the Spotlight for texture projection.
  108113. */
  108114. /**
  108115. * Sets the near clip of the Spotlight for texture projection.
  108116. */
  108117. projectionTextureLightNear: number;
  108118. protected _projectionTextureLightFar: number;
  108119. /**
  108120. * Gets the far clip of the Spotlight for texture projection.
  108121. */
  108122. /**
  108123. * Sets the far clip of the Spotlight for texture projection.
  108124. */
  108125. projectionTextureLightFar: number;
  108126. protected _projectionTextureUpDirection: Vector3;
  108127. /**
  108128. * Gets the Up vector of the Spotlight for texture projection.
  108129. */
  108130. /**
  108131. * Sets the Up vector of the Spotlight for texture projection.
  108132. */
  108133. projectionTextureUpDirection: Vector3;
  108134. private _projectionTexture;
  108135. /**
  108136. * Gets the projection texture of the light.
  108137. */
  108138. /**
  108139. * Sets the projection texture of the light.
  108140. */
  108141. projectionTexture: Nullable<BaseTexture>;
  108142. private _projectionTextureViewLightDirty;
  108143. private _projectionTextureProjectionLightDirty;
  108144. private _projectionTextureDirty;
  108145. private _projectionTextureViewTargetVector;
  108146. private _projectionTextureViewLightMatrix;
  108147. private _projectionTextureProjectionLightMatrix;
  108148. private _projectionTextureScalingMatrix;
  108149. /**
  108150. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  108151. * It can cast shadows.
  108152. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108153. * @param name The light friendly name
  108154. * @param position The position of the spot light in the scene
  108155. * @param direction The direction of the light in the scene
  108156. * @param angle The cone angle of the light in Radians
  108157. * @param exponent The light decay speed with the distance from the emission spot
  108158. * @param scene The scene the lights belongs to
  108159. */
  108160. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  108161. /**
  108162. * Returns the string "SpotLight".
  108163. * @returns the class name
  108164. */
  108165. getClassName(): string;
  108166. /**
  108167. * Returns the integer 2.
  108168. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108169. */
  108170. getTypeID(): number;
  108171. /**
  108172. * Overrides the direction setter to recompute the projection texture view light Matrix.
  108173. */
  108174. protected _setDirection(value: Vector3): void;
  108175. /**
  108176. * Overrides the position setter to recompute the projection texture view light Matrix.
  108177. */
  108178. protected _setPosition(value: Vector3): void;
  108179. /**
  108180. * 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.
  108181. * Returns the SpotLight.
  108182. */
  108183. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108184. protected _computeProjectionTextureViewLightMatrix(): void;
  108185. protected _computeProjectionTextureProjectionLightMatrix(): void;
  108186. /**
  108187. * Main function for light texture projection matrix computing.
  108188. */
  108189. protected _computeProjectionTextureMatrix(): void;
  108190. protected _buildUniformLayout(): void;
  108191. private _computeAngleValues;
  108192. /**
  108193. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  108194. * @param effect The effect to update
  108195. * @param lightIndex The index of the light in the effect to update
  108196. * @returns The spot light
  108197. */
  108198. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  108199. /**
  108200. * Disposes the light and the associated resources.
  108201. */
  108202. dispose(): void;
  108203. /**
  108204. * Prepares the list of defines specific to the light type.
  108205. * @param defines the list of defines
  108206. * @param lightIndex defines the index of the light for the effect
  108207. */
  108208. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108209. }
  108210. }
  108211. declare module BABYLON {
  108212. /**
  108213. * Gizmo that enables viewing a light
  108214. */
  108215. export class LightGizmo extends Gizmo {
  108216. private _lightMesh;
  108217. private _material;
  108218. private cachedPosition;
  108219. private cachedForward;
  108220. /**
  108221. * Creates a LightGizmo
  108222. * @param gizmoLayer The utility layer the gizmo will be added to
  108223. */
  108224. constructor(gizmoLayer?: UtilityLayerRenderer);
  108225. private _light;
  108226. /**
  108227. * The light that the gizmo is attached to
  108228. */
  108229. light: Nullable<Light>;
  108230. /**
  108231. * @hidden
  108232. * Updates the gizmo to match the attached mesh's position/rotation
  108233. */
  108234. protected _update(): void;
  108235. private static _Scale;
  108236. /**
  108237. * Creates the lines for a light mesh
  108238. */
  108239. private static _createLightLines;
  108240. /**
  108241. * Disposes of the light gizmo
  108242. */
  108243. dispose(): void;
  108244. private static _CreateHemisphericLightMesh;
  108245. private static _CreatePointLightMesh;
  108246. private static _CreateSpotLightMesh;
  108247. private static _CreateDirectionalLightMesh;
  108248. }
  108249. }
  108250. declare module BABYLON {
  108251. /** @hidden */
  108252. export var backgroundFragmentDeclaration: {
  108253. name: string;
  108254. shader: string;
  108255. };
  108256. }
  108257. declare module BABYLON {
  108258. /** @hidden */
  108259. export var backgroundUboDeclaration: {
  108260. name: string;
  108261. shader: string;
  108262. };
  108263. }
  108264. declare module BABYLON {
  108265. /** @hidden */
  108266. export var backgroundPixelShader: {
  108267. name: string;
  108268. shader: string;
  108269. };
  108270. }
  108271. declare module BABYLON {
  108272. /** @hidden */
  108273. export var backgroundVertexDeclaration: {
  108274. name: string;
  108275. shader: string;
  108276. };
  108277. }
  108278. declare module BABYLON {
  108279. /** @hidden */
  108280. export var backgroundVertexShader: {
  108281. name: string;
  108282. shader: string;
  108283. };
  108284. }
  108285. declare module BABYLON {
  108286. /**
  108287. * Background material used to create an efficient environement around your scene.
  108288. */
  108289. export class BackgroundMaterial extends PushMaterial {
  108290. /**
  108291. * Standard reflectance value at parallel view angle.
  108292. */
  108293. static StandardReflectance0: number;
  108294. /**
  108295. * Standard reflectance value at grazing angle.
  108296. */
  108297. static StandardReflectance90: number;
  108298. protected _primaryColor: Color3;
  108299. /**
  108300. * Key light Color (multiply against the environement texture)
  108301. */
  108302. primaryColor: Color3;
  108303. protected __perceptualColor: Nullable<Color3>;
  108304. /**
  108305. * Experimental Internal Use Only.
  108306. *
  108307. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  108308. * This acts as a helper to set the primary color to a more "human friendly" value.
  108309. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  108310. * output color as close as possible from the chosen value.
  108311. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  108312. * part of lighting setup.)
  108313. */
  108314. _perceptualColor: Nullable<Color3>;
  108315. protected _primaryColorShadowLevel: float;
  108316. /**
  108317. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  108318. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  108319. */
  108320. primaryColorShadowLevel: float;
  108321. protected _primaryColorHighlightLevel: float;
  108322. /**
  108323. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  108324. * The primary color is used at the level chosen to define what the white area would look.
  108325. */
  108326. primaryColorHighlightLevel: float;
  108327. protected _reflectionTexture: Nullable<BaseTexture>;
  108328. /**
  108329. * Reflection Texture used in the material.
  108330. * Should be author in a specific way for the best result (refer to the documentation).
  108331. */
  108332. reflectionTexture: Nullable<BaseTexture>;
  108333. protected _reflectionBlur: float;
  108334. /**
  108335. * Reflection Texture level of blur.
  108336. *
  108337. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  108338. * texture twice.
  108339. */
  108340. reflectionBlur: float;
  108341. protected _diffuseTexture: Nullable<BaseTexture>;
  108342. /**
  108343. * Diffuse Texture used in the material.
  108344. * Should be author in a specific way for the best result (refer to the documentation).
  108345. */
  108346. diffuseTexture: Nullable<BaseTexture>;
  108347. protected _shadowLights: Nullable<IShadowLight[]>;
  108348. /**
  108349. * Specify the list of lights casting shadow on the material.
  108350. * All scene shadow lights will be included if null.
  108351. */
  108352. shadowLights: Nullable<IShadowLight[]>;
  108353. protected _shadowLevel: float;
  108354. /**
  108355. * Helps adjusting the shadow to a softer level if required.
  108356. * 0 means black shadows and 1 means no shadows.
  108357. */
  108358. shadowLevel: float;
  108359. protected _sceneCenter: Vector3;
  108360. /**
  108361. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  108362. * It is usually zero but might be interesting to modify according to your setup.
  108363. */
  108364. sceneCenter: Vector3;
  108365. protected _opacityFresnel: boolean;
  108366. /**
  108367. * This helps specifying that the material is falling off to the sky box at grazing angle.
  108368. * This helps ensuring a nice transition when the camera goes under the ground.
  108369. */
  108370. opacityFresnel: boolean;
  108371. protected _reflectionFresnel: boolean;
  108372. /**
  108373. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  108374. * This helps adding a mirror texture on the ground.
  108375. */
  108376. reflectionFresnel: boolean;
  108377. protected _reflectionFalloffDistance: number;
  108378. /**
  108379. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  108380. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  108381. */
  108382. reflectionFalloffDistance: number;
  108383. protected _reflectionAmount: number;
  108384. /**
  108385. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  108386. */
  108387. reflectionAmount: number;
  108388. protected _reflectionReflectance0: number;
  108389. /**
  108390. * This specifies the weight of the reflection at grazing angle.
  108391. */
  108392. reflectionReflectance0: number;
  108393. protected _reflectionReflectance90: number;
  108394. /**
  108395. * This specifies the weight of the reflection at a perpendicular point of view.
  108396. */
  108397. reflectionReflectance90: number;
  108398. /**
  108399. * Sets the reflection reflectance fresnel values according to the default standard
  108400. * empirically know to work well :-)
  108401. */
  108402. reflectionStandardFresnelWeight: number;
  108403. protected _useRGBColor: boolean;
  108404. /**
  108405. * Helps to directly use the maps channels instead of their level.
  108406. */
  108407. useRGBColor: boolean;
  108408. protected _enableNoise: boolean;
  108409. /**
  108410. * This helps reducing the banding effect that could occur on the background.
  108411. */
  108412. enableNoise: boolean;
  108413. /**
  108414. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108415. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  108416. * Recommended to be keep at 1.0 except for special cases.
  108417. */
  108418. fovMultiplier: number;
  108419. private _fovMultiplier;
  108420. /**
  108421. * Enable the FOV adjustment feature controlled by fovMultiplier.
  108422. */
  108423. useEquirectangularFOV: boolean;
  108424. private _maxSimultaneousLights;
  108425. /**
  108426. * Number of Simultaneous lights allowed on the material.
  108427. */
  108428. maxSimultaneousLights: int;
  108429. /**
  108430. * Default configuration related to image processing available in the Background Material.
  108431. */
  108432. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108433. /**
  108434. * Keep track of the image processing observer to allow dispose and replace.
  108435. */
  108436. private _imageProcessingObserver;
  108437. /**
  108438. * Attaches a new image processing configuration to the PBR Material.
  108439. * @param configuration (if null the scene configuration will be use)
  108440. */
  108441. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108442. /**
  108443. * Gets the image processing configuration used either in this material.
  108444. */
  108445. /**
  108446. * Sets the Default image processing configuration used either in the this material.
  108447. *
  108448. * If sets to null, the scene one is in use.
  108449. */
  108450. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  108451. /**
  108452. * Gets wether the color curves effect is enabled.
  108453. */
  108454. /**
  108455. * Sets wether the color curves effect is enabled.
  108456. */
  108457. cameraColorCurvesEnabled: boolean;
  108458. /**
  108459. * Gets wether the color grading effect is enabled.
  108460. */
  108461. /**
  108462. * Gets wether the color grading effect is enabled.
  108463. */
  108464. cameraColorGradingEnabled: boolean;
  108465. /**
  108466. * Gets wether tonemapping is enabled or not.
  108467. */
  108468. /**
  108469. * Sets wether tonemapping is enabled or not
  108470. */
  108471. cameraToneMappingEnabled: boolean;
  108472. /**
  108473. * The camera exposure used on this material.
  108474. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108475. * This corresponds to a photographic exposure.
  108476. */
  108477. /**
  108478. * The camera exposure used on this material.
  108479. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108480. * This corresponds to a photographic exposure.
  108481. */
  108482. cameraExposure: float;
  108483. /**
  108484. * Gets The camera contrast used on this material.
  108485. */
  108486. /**
  108487. * Sets The camera contrast used on this material.
  108488. */
  108489. cameraContrast: float;
  108490. /**
  108491. * Gets the Color Grading 2D Lookup Texture.
  108492. */
  108493. /**
  108494. * Sets the Color Grading 2D Lookup Texture.
  108495. */
  108496. cameraColorGradingTexture: Nullable<BaseTexture>;
  108497. /**
  108498. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108499. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108500. * 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;
  108501. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108502. */
  108503. /**
  108504. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108505. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108506. * 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;
  108507. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108508. */
  108509. cameraColorCurves: Nullable<ColorCurves>;
  108510. /**
  108511. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  108512. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  108513. */
  108514. switchToBGR: boolean;
  108515. private _renderTargets;
  108516. private _reflectionControls;
  108517. private _white;
  108518. private _primaryShadowColor;
  108519. private _primaryHighlightColor;
  108520. /**
  108521. * Instantiates a Background Material in the given scene
  108522. * @param name The friendly name of the material
  108523. * @param scene The scene to add the material to
  108524. */
  108525. constructor(name: string, scene: Scene);
  108526. /**
  108527. * Gets a boolean indicating that current material needs to register RTT
  108528. */
  108529. readonly hasRenderTargetTextures: boolean;
  108530. /**
  108531. * The entire material has been created in order to prevent overdraw.
  108532. * @returns false
  108533. */
  108534. needAlphaTesting(): boolean;
  108535. /**
  108536. * The entire material has been created in order to prevent overdraw.
  108537. * @returns true if blending is enable
  108538. */
  108539. needAlphaBlending(): boolean;
  108540. /**
  108541. * Checks wether the material is ready to be rendered for a given mesh.
  108542. * @param mesh The mesh to render
  108543. * @param subMesh The submesh to check against
  108544. * @param useInstances Specify wether or not the material is used with instances
  108545. * @returns true if all the dependencies are ready (Textures, Effects...)
  108546. */
  108547. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108548. /**
  108549. * Compute the primary color according to the chosen perceptual color.
  108550. */
  108551. private _computePrimaryColorFromPerceptualColor;
  108552. /**
  108553. * Compute the highlights and shadow colors according to their chosen levels.
  108554. */
  108555. private _computePrimaryColors;
  108556. /**
  108557. * Build the uniform buffer used in the material.
  108558. */
  108559. buildUniformLayout(): void;
  108560. /**
  108561. * Unbind the material.
  108562. */
  108563. unbind(): void;
  108564. /**
  108565. * Bind only the world matrix to the material.
  108566. * @param world The world matrix to bind.
  108567. */
  108568. bindOnlyWorldMatrix(world: Matrix): void;
  108569. /**
  108570. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  108571. * @param world The world matrix to bind.
  108572. * @param subMesh The submesh to bind for.
  108573. */
  108574. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108575. /**
  108576. * Dispose the material.
  108577. * @param forceDisposeEffect Force disposal of the associated effect.
  108578. * @param forceDisposeTextures Force disposal of the associated textures.
  108579. */
  108580. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108581. /**
  108582. * Clones the material.
  108583. * @param name The cloned name.
  108584. * @returns The cloned material.
  108585. */
  108586. clone(name: string): BackgroundMaterial;
  108587. /**
  108588. * Serializes the current material to its JSON representation.
  108589. * @returns The JSON representation.
  108590. */
  108591. serialize(): any;
  108592. /**
  108593. * Gets the class name of the material
  108594. * @returns "BackgroundMaterial"
  108595. */
  108596. getClassName(): string;
  108597. /**
  108598. * Parse a JSON input to create back a background material.
  108599. * @param source The JSON data to parse
  108600. * @param scene The scene to create the parsed material in
  108601. * @param rootUrl The root url of the assets the material depends upon
  108602. * @returns the instantiated BackgroundMaterial.
  108603. */
  108604. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  108605. }
  108606. }
  108607. declare module BABYLON {
  108608. /**
  108609. * Represents the different options available during the creation of
  108610. * a Environment helper.
  108611. *
  108612. * This can control the default ground, skybox and image processing setup of your scene.
  108613. */
  108614. export interface IEnvironmentHelperOptions {
  108615. /**
  108616. * Specifies wether or not to create a ground.
  108617. * True by default.
  108618. */
  108619. createGround: boolean;
  108620. /**
  108621. * Specifies the ground size.
  108622. * 15 by default.
  108623. */
  108624. groundSize: number;
  108625. /**
  108626. * The texture used on the ground for the main color.
  108627. * Comes from the BabylonJS CDN by default.
  108628. *
  108629. * Remarks: Can be either a texture or a url.
  108630. */
  108631. groundTexture: string | BaseTexture;
  108632. /**
  108633. * The color mixed in the ground texture by default.
  108634. * BabylonJS clearColor by default.
  108635. */
  108636. groundColor: Color3;
  108637. /**
  108638. * Specifies the ground opacity.
  108639. * 1 by default.
  108640. */
  108641. groundOpacity: number;
  108642. /**
  108643. * Enables the ground to receive shadows.
  108644. * True by default.
  108645. */
  108646. enableGroundShadow: boolean;
  108647. /**
  108648. * Helps preventing the shadow to be fully black on the ground.
  108649. * 0.5 by default.
  108650. */
  108651. groundShadowLevel: number;
  108652. /**
  108653. * Creates a mirror texture attach to the ground.
  108654. * false by default.
  108655. */
  108656. enableGroundMirror: boolean;
  108657. /**
  108658. * Specifies the ground mirror size ratio.
  108659. * 0.3 by default as the default kernel is 64.
  108660. */
  108661. groundMirrorSizeRatio: number;
  108662. /**
  108663. * Specifies the ground mirror blur kernel size.
  108664. * 64 by default.
  108665. */
  108666. groundMirrorBlurKernel: number;
  108667. /**
  108668. * Specifies the ground mirror visibility amount.
  108669. * 1 by default
  108670. */
  108671. groundMirrorAmount: number;
  108672. /**
  108673. * Specifies the ground mirror reflectance weight.
  108674. * This uses the standard weight of the background material to setup the fresnel effect
  108675. * of the mirror.
  108676. * 1 by default.
  108677. */
  108678. groundMirrorFresnelWeight: number;
  108679. /**
  108680. * Specifies the ground mirror Falloff distance.
  108681. * This can helps reducing the size of the reflection.
  108682. * 0 by Default.
  108683. */
  108684. groundMirrorFallOffDistance: number;
  108685. /**
  108686. * Specifies the ground mirror texture type.
  108687. * Unsigned Int by Default.
  108688. */
  108689. groundMirrorTextureType: number;
  108690. /**
  108691. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  108692. * the shown objects.
  108693. */
  108694. groundYBias: number;
  108695. /**
  108696. * Specifies wether or not to create a skybox.
  108697. * True by default.
  108698. */
  108699. createSkybox: boolean;
  108700. /**
  108701. * Specifies the skybox size.
  108702. * 20 by default.
  108703. */
  108704. skyboxSize: number;
  108705. /**
  108706. * The texture used on the skybox for the main color.
  108707. * Comes from the BabylonJS CDN by default.
  108708. *
  108709. * Remarks: Can be either a texture or a url.
  108710. */
  108711. skyboxTexture: string | BaseTexture;
  108712. /**
  108713. * The color mixed in the skybox texture by default.
  108714. * BabylonJS clearColor by default.
  108715. */
  108716. skyboxColor: Color3;
  108717. /**
  108718. * The background rotation around the Y axis of the scene.
  108719. * This helps aligning the key lights of your scene with the background.
  108720. * 0 by default.
  108721. */
  108722. backgroundYRotation: number;
  108723. /**
  108724. * Compute automatically the size of the elements to best fit with the scene.
  108725. */
  108726. sizeAuto: boolean;
  108727. /**
  108728. * Default position of the rootMesh if autoSize is not true.
  108729. */
  108730. rootPosition: Vector3;
  108731. /**
  108732. * Sets up the image processing in the scene.
  108733. * true by default.
  108734. */
  108735. setupImageProcessing: boolean;
  108736. /**
  108737. * The texture used as your environment texture in the scene.
  108738. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  108739. *
  108740. * Remarks: Can be either a texture or a url.
  108741. */
  108742. environmentTexture: string | BaseTexture;
  108743. /**
  108744. * The value of the exposure to apply to the scene.
  108745. * 0.6 by default if setupImageProcessing is true.
  108746. */
  108747. cameraExposure: number;
  108748. /**
  108749. * The value of the contrast to apply to the scene.
  108750. * 1.6 by default if setupImageProcessing is true.
  108751. */
  108752. cameraContrast: number;
  108753. /**
  108754. * Specifies wether or not tonemapping should be enabled in the scene.
  108755. * true by default if setupImageProcessing is true.
  108756. */
  108757. toneMappingEnabled: boolean;
  108758. }
  108759. /**
  108760. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  108761. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  108762. * It also helps with the default setup of your imageProcessing configuration.
  108763. */
  108764. export class EnvironmentHelper {
  108765. /**
  108766. * Default ground texture URL.
  108767. */
  108768. private static _groundTextureCDNUrl;
  108769. /**
  108770. * Default skybox texture URL.
  108771. */
  108772. private static _skyboxTextureCDNUrl;
  108773. /**
  108774. * Default environment texture URL.
  108775. */
  108776. private static _environmentTextureCDNUrl;
  108777. /**
  108778. * Creates the default options for the helper.
  108779. */
  108780. private static _getDefaultOptions;
  108781. private _rootMesh;
  108782. /**
  108783. * Gets the root mesh created by the helper.
  108784. */
  108785. readonly rootMesh: Mesh;
  108786. private _skybox;
  108787. /**
  108788. * Gets the skybox created by the helper.
  108789. */
  108790. readonly skybox: Nullable<Mesh>;
  108791. private _skyboxTexture;
  108792. /**
  108793. * Gets the skybox texture created by the helper.
  108794. */
  108795. readonly skyboxTexture: Nullable<BaseTexture>;
  108796. private _skyboxMaterial;
  108797. /**
  108798. * Gets the skybox material created by the helper.
  108799. */
  108800. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  108801. private _ground;
  108802. /**
  108803. * Gets the ground mesh created by the helper.
  108804. */
  108805. readonly ground: Nullable<Mesh>;
  108806. private _groundTexture;
  108807. /**
  108808. * Gets the ground texture created by the helper.
  108809. */
  108810. readonly groundTexture: Nullable<BaseTexture>;
  108811. private _groundMirror;
  108812. /**
  108813. * Gets the ground mirror created by the helper.
  108814. */
  108815. readonly groundMirror: Nullable<MirrorTexture>;
  108816. /**
  108817. * Gets the ground mirror render list to helps pushing the meshes
  108818. * you wish in the ground reflection.
  108819. */
  108820. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  108821. private _groundMaterial;
  108822. /**
  108823. * Gets the ground material created by the helper.
  108824. */
  108825. readonly groundMaterial: Nullable<BackgroundMaterial>;
  108826. /**
  108827. * Stores the creation options.
  108828. */
  108829. private readonly _scene;
  108830. private _options;
  108831. /**
  108832. * This observable will be notified with any error during the creation of the environment,
  108833. * mainly texture creation errors.
  108834. */
  108835. onErrorObservable: Observable<{
  108836. message?: string;
  108837. exception?: any;
  108838. }>;
  108839. /**
  108840. * constructor
  108841. * @param options Defines the options we want to customize the helper
  108842. * @param scene The scene to add the material to
  108843. */
  108844. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  108845. /**
  108846. * Updates the background according to the new options
  108847. * @param options
  108848. */
  108849. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  108850. /**
  108851. * Sets the primary color of all the available elements.
  108852. * @param color the main color to affect to the ground and the background
  108853. */
  108854. setMainColor(color: Color3): void;
  108855. /**
  108856. * Setup the image processing according to the specified options.
  108857. */
  108858. private _setupImageProcessing;
  108859. /**
  108860. * Setup the environment texture according to the specified options.
  108861. */
  108862. private _setupEnvironmentTexture;
  108863. /**
  108864. * Setup the background according to the specified options.
  108865. */
  108866. private _setupBackground;
  108867. /**
  108868. * Get the scene sizes according to the setup.
  108869. */
  108870. private _getSceneSize;
  108871. /**
  108872. * Setup the ground according to the specified options.
  108873. */
  108874. private _setupGround;
  108875. /**
  108876. * Setup the ground material according to the specified options.
  108877. */
  108878. private _setupGroundMaterial;
  108879. /**
  108880. * Setup the ground diffuse texture according to the specified options.
  108881. */
  108882. private _setupGroundDiffuseTexture;
  108883. /**
  108884. * Setup the ground mirror texture according to the specified options.
  108885. */
  108886. private _setupGroundMirrorTexture;
  108887. /**
  108888. * Setup the ground to receive the mirror texture.
  108889. */
  108890. private _setupMirrorInGroundMaterial;
  108891. /**
  108892. * Setup the skybox according to the specified options.
  108893. */
  108894. private _setupSkybox;
  108895. /**
  108896. * Setup the skybox material according to the specified options.
  108897. */
  108898. private _setupSkyboxMaterial;
  108899. /**
  108900. * Setup the skybox reflection texture according to the specified options.
  108901. */
  108902. private _setupSkyboxReflectionTexture;
  108903. private _errorHandler;
  108904. /**
  108905. * Dispose all the elements created by the Helper.
  108906. */
  108907. dispose(): void;
  108908. }
  108909. }
  108910. declare module BABYLON {
  108911. /**
  108912. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  108913. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  108914. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  108915. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  108916. */
  108917. export class PhotoDome extends TransformNode {
  108918. /**
  108919. * Define the image as a Monoscopic panoramic 360 image.
  108920. */
  108921. static readonly MODE_MONOSCOPIC: number;
  108922. /**
  108923. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  108924. */
  108925. static readonly MODE_TOPBOTTOM: number;
  108926. /**
  108927. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  108928. */
  108929. static readonly MODE_SIDEBYSIDE: number;
  108930. private _useDirectMapping;
  108931. /**
  108932. * The texture being displayed on the sphere
  108933. */
  108934. protected _photoTexture: Texture;
  108935. /**
  108936. * Gets or sets the texture being displayed on the sphere
  108937. */
  108938. photoTexture: Texture;
  108939. /**
  108940. * Observable raised when an error occured while loading the 360 image
  108941. */
  108942. onLoadErrorObservable: Observable<string>;
  108943. /**
  108944. * The skybox material
  108945. */
  108946. protected _material: BackgroundMaterial;
  108947. /**
  108948. * The surface used for the skybox
  108949. */
  108950. protected _mesh: Mesh;
  108951. /**
  108952. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108953. * Also see the options.resolution property.
  108954. */
  108955. fovMultiplier: number;
  108956. private _imageMode;
  108957. /**
  108958. * Gets or set the current video mode for the video. It can be:
  108959. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  108960. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  108961. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  108962. */
  108963. imageMode: number;
  108964. /**
  108965. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  108966. * @param name Element's name, child elements will append suffixes for their own names.
  108967. * @param urlsOfPhoto defines the url of the photo to display
  108968. * @param options defines an object containing optional or exposed sub element properties
  108969. * @param onError defines a callback called when an error occured while loading the texture
  108970. */
  108971. constructor(name: string, urlOfPhoto: string, options: {
  108972. resolution?: number;
  108973. size?: number;
  108974. useDirectMapping?: boolean;
  108975. faceForward?: boolean;
  108976. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  108977. private _onBeforeCameraRenderObserver;
  108978. private _changeImageMode;
  108979. /**
  108980. * Releases resources associated with this node.
  108981. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108982. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108983. */
  108984. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108985. }
  108986. }
  108987. declare module BABYLON {
  108988. /** @hidden */
  108989. export var rgbdDecodePixelShader: {
  108990. name: string;
  108991. shader: string;
  108992. };
  108993. }
  108994. declare module BABYLON {
  108995. /**
  108996. * Class used to host texture specific utilities
  108997. */
  108998. export class BRDFTextureTools {
  108999. /**
  109000. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  109001. * @param texture the texture to expand.
  109002. */
  109003. private static _ExpandDefaultBRDFTexture;
  109004. /**
  109005. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  109006. * @param scene defines the hosting scene
  109007. * @returns the environment BRDF texture
  109008. */
  109009. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  109010. private static _environmentBRDFBase64Texture;
  109011. }
  109012. }
  109013. declare module BABYLON {
  109014. /**
  109015. * @hidden
  109016. */
  109017. export interface IMaterialClearCoatDefines {
  109018. CLEARCOAT: boolean;
  109019. CLEARCOAT_DEFAULTIOR: boolean;
  109020. CLEARCOAT_TEXTURE: boolean;
  109021. CLEARCOAT_TEXTUREDIRECTUV: number;
  109022. CLEARCOAT_BUMP: boolean;
  109023. CLEARCOAT_BUMPDIRECTUV: number;
  109024. CLEARCOAT_TINT: boolean;
  109025. CLEARCOAT_TINT_TEXTURE: boolean;
  109026. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  109027. /** @hidden */
  109028. _areTexturesDirty: boolean;
  109029. }
  109030. /**
  109031. * Define the code related to the clear coat parameters of the pbr material.
  109032. */
  109033. export class PBRClearCoatConfiguration {
  109034. /**
  109035. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109036. * The default fits with a polyurethane material.
  109037. */
  109038. private static readonly _DefaultIndexOfRefraction;
  109039. private _isEnabled;
  109040. /**
  109041. * Defines if the clear coat is enabled in the material.
  109042. */
  109043. isEnabled: boolean;
  109044. /**
  109045. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  109046. */
  109047. intensity: number;
  109048. /**
  109049. * Defines the clear coat layer roughness.
  109050. */
  109051. roughness: number;
  109052. private _indexOfRefraction;
  109053. /**
  109054. * Defines the index of refraction of the clear coat.
  109055. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109056. * The default fits with a polyurethane material.
  109057. * Changing the default value is more performance intensive.
  109058. */
  109059. indexOfRefraction: number;
  109060. private _texture;
  109061. /**
  109062. * Stores the clear coat values in a texture.
  109063. */
  109064. texture: Nullable<BaseTexture>;
  109065. private _bumpTexture;
  109066. /**
  109067. * Define the clear coat specific bump texture.
  109068. */
  109069. bumpTexture: Nullable<BaseTexture>;
  109070. private _isTintEnabled;
  109071. /**
  109072. * Defines if the clear coat tint is enabled in the material.
  109073. */
  109074. isTintEnabled: boolean;
  109075. /**
  109076. * Defines the clear coat tint of the material.
  109077. * This is only use if tint is enabled
  109078. */
  109079. tintColor: Color3;
  109080. /**
  109081. * Defines the distance at which the tint color should be found in the
  109082. * clear coat media.
  109083. * This is only use if tint is enabled
  109084. */
  109085. tintColorAtDistance: number;
  109086. /**
  109087. * Defines the clear coat layer thickness.
  109088. * This is only use if tint is enabled
  109089. */
  109090. tintThickness: number;
  109091. private _tintTexture;
  109092. /**
  109093. * Stores the clear tint values in a texture.
  109094. * rgb is tint
  109095. * a is a thickness factor
  109096. */
  109097. tintTexture: Nullable<BaseTexture>;
  109098. /** @hidden */
  109099. private _internalMarkAllSubMeshesAsTexturesDirty;
  109100. /** @hidden */
  109101. _markAllSubMeshesAsTexturesDirty(): void;
  109102. /**
  109103. * Instantiate a new istance of clear coat configuration.
  109104. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109105. */
  109106. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109107. /**
  109108. * Gets wehter the submesh is ready to be used or not.
  109109. * @param defines the list of "defines" to update.
  109110. * @param scene defines the scene the material belongs to.
  109111. * @param engine defines the engine the material belongs to.
  109112. * @param disableBumpMap defines wether the material disables bump or not.
  109113. * @returns - boolean indicating that the submesh is ready or not.
  109114. */
  109115. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  109116. /**
  109117. * Checks to see if a texture is used in the material.
  109118. * @param defines the list of "defines" to update.
  109119. * @param scene defines the scene to the material belongs to.
  109120. */
  109121. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  109122. /**
  109123. * Binds the material data.
  109124. * @param uniformBuffer defines the Uniform buffer to fill in.
  109125. * @param scene defines the scene the material belongs to.
  109126. * @param engine defines the engine the material belongs to.
  109127. * @param disableBumpMap defines wether the material disables bump or not.
  109128. * @param isFrozen defines wether the material is frozen or not.
  109129. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  109130. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  109131. */
  109132. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  109133. /**
  109134. * Checks to see if a texture is used in the material.
  109135. * @param texture - Base texture to use.
  109136. * @returns - Boolean specifying if a texture is used in the material.
  109137. */
  109138. hasTexture(texture: BaseTexture): boolean;
  109139. /**
  109140. * Returns an array of the actively used textures.
  109141. * @param activeTextures Array of BaseTextures
  109142. */
  109143. getActiveTextures(activeTextures: BaseTexture[]): void;
  109144. /**
  109145. * Returns the animatable textures.
  109146. * @param animatables Array of animatable textures.
  109147. */
  109148. getAnimatables(animatables: IAnimatable[]): void;
  109149. /**
  109150. * Disposes the resources of the material.
  109151. * @param forceDisposeTextures - Forces the disposal of all textures.
  109152. */
  109153. dispose(forceDisposeTextures?: boolean): void;
  109154. /**
  109155. * Get the current class name of the texture useful for serialization or dynamic coding.
  109156. * @returns "PBRClearCoatConfiguration"
  109157. */
  109158. getClassName(): string;
  109159. /**
  109160. * Add fallbacks to the effect fallbacks list.
  109161. * @param defines defines the Base texture to use.
  109162. * @param fallbacks defines the current fallback list.
  109163. * @param currentRank defines the current fallback rank.
  109164. * @returns the new fallback rank.
  109165. */
  109166. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109167. /**
  109168. * Add the required uniforms to the current list.
  109169. * @param uniforms defines the current uniform list.
  109170. */
  109171. static AddUniforms(uniforms: string[]): void;
  109172. /**
  109173. * Add the required samplers to the current list.
  109174. * @param samplers defines the current sampler list.
  109175. */
  109176. static AddSamplers(samplers: string[]): void;
  109177. /**
  109178. * Add the required uniforms to the current buffer.
  109179. * @param uniformBuffer defines the current uniform buffer.
  109180. */
  109181. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109182. /**
  109183. * Makes a duplicate of the current configuration into another one.
  109184. * @param clearCoatConfiguration define the config where to copy the info
  109185. */
  109186. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  109187. /**
  109188. * Serializes this clear coat configuration.
  109189. * @returns - An object with the serialized config.
  109190. */
  109191. serialize(): any;
  109192. /**
  109193. * Parses a anisotropy Configuration from a serialized object.
  109194. * @param source - Serialized object.
  109195. * @param scene Defines the scene we are parsing for
  109196. * @param rootUrl Defines the rootUrl to load from
  109197. */
  109198. parse(source: any, scene: Scene, rootUrl: string): void;
  109199. }
  109200. }
  109201. declare module BABYLON {
  109202. /**
  109203. * @hidden
  109204. */
  109205. export interface IMaterialAnisotropicDefines {
  109206. ANISOTROPIC: boolean;
  109207. ANISOTROPIC_TEXTURE: boolean;
  109208. ANISOTROPIC_TEXTUREDIRECTUV: number;
  109209. MAINUV1: boolean;
  109210. _areTexturesDirty: boolean;
  109211. _needUVs: boolean;
  109212. }
  109213. /**
  109214. * Define the code related to the anisotropic parameters of the pbr material.
  109215. */
  109216. export class PBRAnisotropicConfiguration {
  109217. private _isEnabled;
  109218. /**
  109219. * Defines if the anisotropy is enabled in the material.
  109220. */
  109221. isEnabled: boolean;
  109222. /**
  109223. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  109224. */
  109225. intensity: number;
  109226. /**
  109227. * Defines if the effect is along the tangents, bitangents or in between.
  109228. * By default, the effect is "strectching" the highlights along the tangents.
  109229. */
  109230. direction: Vector2;
  109231. private _texture;
  109232. /**
  109233. * Stores the anisotropy values in a texture.
  109234. * rg is direction (like normal from -1 to 1)
  109235. * b is a intensity
  109236. */
  109237. texture: Nullable<BaseTexture>;
  109238. /** @hidden */
  109239. private _internalMarkAllSubMeshesAsTexturesDirty;
  109240. /** @hidden */
  109241. _markAllSubMeshesAsTexturesDirty(): void;
  109242. /**
  109243. * Instantiate a new istance of anisotropy configuration.
  109244. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109245. */
  109246. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109247. /**
  109248. * Specifies that the submesh is ready to be used.
  109249. * @param defines the list of "defines" to update.
  109250. * @param scene defines the scene the material belongs to.
  109251. * @returns - boolean indicating that the submesh is ready or not.
  109252. */
  109253. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  109254. /**
  109255. * Checks to see if a texture is used in the material.
  109256. * @param defines the list of "defines" to update.
  109257. * @param mesh the mesh we are preparing the defines for.
  109258. * @param scene defines the scene the material belongs to.
  109259. */
  109260. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  109261. /**
  109262. * Binds the material data.
  109263. * @param uniformBuffer defines the Uniform buffer to fill in.
  109264. * @param scene defines the scene the material belongs to.
  109265. * @param isFrozen defines wether the material is frozen or not.
  109266. */
  109267. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109268. /**
  109269. * Checks to see if a texture is used in the material.
  109270. * @param texture - Base texture to use.
  109271. * @returns - Boolean specifying if a texture is used in the material.
  109272. */
  109273. hasTexture(texture: BaseTexture): boolean;
  109274. /**
  109275. * Returns an array of the actively used textures.
  109276. * @param activeTextures Array of BaseTextures
  109277. */
  109278. getActiveTextures(activeTextures: BaseTexture[]): void;
  109279. /**
  109280. * Returns the animatable textures.
  109281. * @param animatables Array of animatable textures.
  109282. */
  109283. getAnimatables(animatables: IAnimatable[]): void;
  109284. /**
  109285. * Disposes the resources of the material.
  109286. * @param forceDisposeTextures - Forces the disposal of all textures.
  109287. */
  109288. dispose(forceDisposeTextures?: boolean): void;
  109289. /**
  109290. * Get the current class name of the texture useful for serialization or dynamic coding.
  109291. * @returns "PBRAnisotropicConfiguration"
  109292. */
  109293. getClassName(): string;
  109294. /**
  109295. * Add fallbacks to the effect fallbacks list.
  109296. * @param defines defines the Base texture to use.
  109297. * @param fallbacks defines the current fallback list.
  109298. * @param currentRank defines the current fallback rank.
  109299. * @returns the new fallback rank.
  109300. */
  109301. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109302. /**
  109303. * Add the required uniforms to the current list.
  109304. * @param uniforms defines the current uniform list.
  109305. */
  109306. static AddUniforms(uniforms: string[]): void;
  109307. /**
  109308. * Add the required uniforms to the current buffer.
  109309. * @param uniformBuffer defines the current uniform buffer.
  109310. */
  109311. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109312. /**
  109313. * Add the required samplers to the current list.
  109314. * @param samplers defines the current sampler list.
  109315. */
  109316. static AddSamplers(samplers: string[]): void;
  109317. /**
  109318. * Makes a duplicate of the current configuration into another one.
  109319. * @param anisotropicConfiguration define the config where to copy the info
  109320. */
  109321. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  109322. /**
  109323. * Serializes this anisotropy configuration.
  109324. * @returns - An object with the serialized config.
  109325. */
  109326. serialize(): any;
  109327. /**
  109328. * Parses a anisotropy Configuration from a serialized object.
  109329. * @param source - Serialized object.
  109330. * @param scene Defines the scene we are parsing for
  109331. * @param rootUrl Defines the rootUrl to load from
  109332. */
  109333. parse(source: any, scene: Scene, rootUrl: string): void;
  109334. }
  109335. }
  109336. declare module BABYLON {
  109337. /**
  109338. * @hidden
  109339. */
  109340. export interface IMaterialBRDFDefines {
  109341. BRDF_V_HEIGHT_CORRELATED: boolean;
  109342. MS_BRDF_ENERGY_CONSERVATION: boolean;
  109343. SPHERICAL_HARMONICS: boolean;
  109344. /** @hidden */
  109345. _areMiscDirty: boolean;
  109346. }
  109347. /**
  109348. * Define the code related to the BRDF parameters of the pbr material.
  109349. */
  109350. export class PBRBRDFConfiguration {
  109351. /**
  109352. * Default value used for the energy conservation.
  109353. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109354. */
  109355. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  109356. /**
  109357. * Default value used for the Smith Visibility Height Correlated mode.
  109358. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109359. */
  109360. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  109361. /**
  109362. * Default value used for the IBL diffuse part.
  109363. * This can help switching back to the polynomials mode globally which is a tiny bit
  109364. * less GPU intensive at the drawback of a lower quality.
  109365. */
  109366. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  109367. private _useEnergyConservation;
  109368. /**
  109369. * Defines if the material uses energy conservation.
  109370. */
  109371. useEnergyConservation: boolean;
  109372. private _useSmithVisibilityHeightCorrelated;
  109373. /**
  109374. * LEGACY Mode set to false
  109375. * Defines if the material uses height smith correlated visibility term.
  109376. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  109377. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  109378. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  109379. * Not relying on height correlated will also disable energy conservation.
  109380. */
  109381. useSmithVisibilityHeightCorrelated: boolean;
  109382. private _useSphericalHarmonics;
  109383. /**
  109384. * LEGACY Mode set to false
  109385. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  109386. * diffuse part of the IBL.
  109387. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  109388. * to the ground truth.
  109389. */
  109390. useSphericalHarmonics: boolean;
  109391. /** @hidden */
  109392. private _internalMarkAllSubMeshesAsMiscDirty;
  109393. /** @hidden */
  109394. _markAllSubMeshesAsMiscDirty(): void;
  109395. /**
  109396. * Instantiate a new istance of clear coat configuration.
  109397. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  109398. */
  109399. constructor(markAllSubMeshesAsMiscDirty: () => void);
  109400. /**
  109401. * Checks to see if a texture is used in the material.
  109402. * @param defines the list of "defines" to update.
  109403. */
  109404. prepareDefines(defines: IMaterialBRDFDefines): void;
  109405. /**
  109406. * Get the current class name of the texture useful for serialization or dynamic coding.
  109407. * @returns "PBRClearCoatConfiguration"
  109408. */
  109409. getClassName(): string;
  109410. /**
  109411. * Makes a duplicate of the current configuration into another one.
  109412. * @param brdfConfiguration define the config where to copy the info
  109413. */
  109414. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  109415. /**
  109416. * Serializes this BRDF configuration.
  109417. * @returns - An object with the serialized config.
  109418. */
  109419. serialize(): any;
  109420. /**
  109421. * Parses a anisotropy Configuration from a serialized object.
  109422. * @param source - Serialized object.
  109423. * @param scene Defines the scene we are parsing for
  109424. * @param rootUrl Defines the rootUrl to load from
  109425. */
  109426. parse(source: any, scene: Scene, rootUrl: string): void;
  109427. }
  109428. }
  109429. declare module BABYLON {
  109430. /**
  109431. * @hidden
  109432. */
  109433. export interface IMaterialSheenDefines {
  109434. SHEEN: boolean;
  109435. SHEEN_TEXTURE: boolean;
  109436. SHEEN_TEXTUREDIRECTUV: number;
  109437. SHEEN_LINKWITHALBEDO: boolean;
  109438. /** @hidden */
  109439. _areTexturesDirty: boolean;
  109440. }
  109441. /**
  109442. * Define the code related to the Sheen parameters of the pbr material.
  109443. */
  109444. export class PBRSheenConfiguration {
  109445. private _isEnabled;
  109446. /**
  109447. * Defines if the material uses sheen.
  109448. */
  109449. isEnabled: boolean;
  109450. private _linkSheenWithAlbedo;
  109451. /**
  109452. * Defines if the sheen is linked to the sheen color.
  109453. */
  109454. linkSheenWithAlbedo: boolean;
  109455. /**
  109456. * Defines the sheen intensity.
  109457. */
  109458. intensity: number;
  109459. /**
  109460. * Defines the sheen color.
  109461. */
  109462. color: Color3;
  109463. private _texture;
  109464. /**
  109465. * Stores the sheen tint values in a texture.
  109466. * rgb is tint
  109467. * a is a intensity
  109468. */
  109469. texture: Nullable<BaseTexture>;
  109470. /** @hidden */
  109471. private _internalMarkAllSubMeshesAsTexturesDirty;
  109472. /** @hidden */
  109473. _markAllSubMeshesAsTexturesDirty(): void;
  109474. /**
  109475. * Instantiate a new istance of clear coat configuration.
  109476. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109477. */
  109478. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109479. /**
  109480. * Specifies that the submesh is ready to be used.
  109481. * @param defines the list of "defines" to update.
  109482. * @param scene defines the scene the material belongs to.
  109483. * @returns - boolean indicating that the submesh is ready or not.
  109484. */
  109485. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  109486. /**
  109487. * Checks to see if a texture is used in the material.
  109488. * @param defines the list of "defines" to update.
  109489. * @param scene defines the scene the material belongs to.
  109490. */
  109491. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  109492. /**
  109493. * Binds the material data.
  109494. * @param uniformBuffer defines the Uniform buffer to fill in.
  109495. * @param scene defines the scene the material belongs to.
  109496. * @param isFrozen defines wether the material is frozen or not.
  109497. */
  109498. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109499. /**
  109500. * Checks to see if a texture is used in the material.
  109501. * @param texture - Base texture to use.
  109502. * @returns - Boolean specifying if a texture is used in the material.
  109503. */
  109504. hasTexture(texture: BaseTexture): boolean;
  109505. /**
  109506. * Returns an array of the actively used textures.
  109507. * @param activeTextures Array of BaseTextures
  109508. */
  109509. getActiveTextures(activeTextures: BaseTexture[]): void;
  109510. /**
  109511. * Returns the animatable textures.
  109512. * @param animatables Array of animatable textures.
  109513. */
  109514. getAnimatables(animatables: IAnimatable[]): void;
  109515. /**
  109516. * Disposes the resources of the material.
  109517. * @param forceDisposeTextures - Forces the disposal of all textures.
  109518. */
  109519. dispose(forceDisposeTextures?: boolean): void;
  109520. /**
  109521. * Get the current class name of the texture useful for serialization or dynamic coding.
  109522. * @returns "PBRSheenConfiguration"
  109523. */
  109524. getClassName(): string;
  109525. /**
  109526. * Add fallbacks to the effect fallbacks list.
  109527. * @param defines defines the Base texture to use.
  109528. * @param fallbacks defines the current fallback list.
  109529. * @param currentRank defines the current fallback rank.
  109530. * @returns the new fallback rank.
  109531. */
  109532. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109533. /**
  109534. * Add the required uniforms to the current list.
  109535. * @param uniforms defines the current uniform list.
  109536. */
  109537. static AddUniforms(uniforms: string[]): void;
  109538. /**
  109539. * Add the required uniforms to the current buffer.
  109540. * @param uniformBuffer defines the current uniform buffer.
  109541. */
  109542. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109543. /**
  109544. * Add the required samplers to the current list.
  109545. * @param samplers defines the current sampler list.
  109546. */
  109547. static AddSamplers(samplers: string[]): void;
  109548. /**
  109549. * Makes a duplicate of the current configuration into another one.
  109550. * @param sheenConfiguration define the config where to copy the info
  109551. */
  109552. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  109553. /**
  109554. * Serializes this BRDF configuration.
  109555. * @returns - An object with the serialized config.
  109556. */
  109557. serialize(): any;
  109558. /**
  109559. * Parses a anisotropy Configuration from a serialized object.
  109560. * @param source - Serialized object.
  109561. * @param scene Defines the scene we are parsing for
  109562. * @param rootUrl Defines the rootUrl to load from
  109563. */
  109564. parse(source: any, scene: Scene, rootUrl: string): void;
  109565. }
  109566. }
  109567. declare module BABYLON {
  109568. /**
  109569. * @hidden
  109570. */
  109571. export interface IMaterialSubSurfaceDefines {
  109572. SUBSURFACE: boolean;
  109573. SS_REFRACTION: boolean;
  109574. SS_TRANSLUCENCY: boolean;
  109575. SS_SCATERRING: boolean;
  109576. SS_THICKNESSANDMASK_TEXTURE: boolean;
  109577. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  109578. SS_REFRACTIONMAP_3D: boolean;
  109579. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  109580. SS_LODINREFRACTIONALPHA: boolean;
  109581. SS_GAMMAREFRACTION: boolean;
  109582. SS_RGBDREFRACTION: boolean;
  109583. SS_LINEARSPECULARREFRACTION: boolean;
  109584. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  109585. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  109586. /** @hidden */
  109587. _areTexturesDirty: boolean;
  109588. }
  109589. /**
  109590. * Define the code related to the sub surface parameters of the pbr material.
  109591. */
  109592. export class PBRSubSurfaceConfiguration {
  109593. private _isRefractionEnabled;
  109594. /**
  109595. * Defines if the refraction is enabled in the material.
  109596. */
  109597. isRefractionEnabled: boolean;
  109598. private _isTranslucencyEnabled;
  109599. /**
  109600. * Defines if the translucency is enabled in the material.
  109601. */
  109602. isTranslucencyEnabled: boolean;
  109603. private _isScatteringEnabled;
  109604. /**
  109605. * Defines the refraction intensity of the material.
  109606. * The refraction when enabled replaces the Diffuse part of the material.
  109607. * The intensity helps transitionning between diffuse and refraction.
  109608. */
  109609. refractionIntensity: number;
  109610. /**
  109611. * Defines the translucency intensity of the material.
  109612. * When translucency has been enabled, this defines how much of the "translucency"
  109613. * is addded to the diffuse part of the material.
  109614. */
  109615. translucencyIntensity: number;
  109616. /**
  109617. * Defines the scattering intensity of the material.
  109618. * When scattering has been enabled, this defines how much of the "scattered light"
  109619. * is addded to the diffuse part of the material.
  109620. */
  109621. scatteringIntensity: number;
  109622. private _thicknessTexture;
  109623. /**
  109624. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  109625. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  109626. * 0 would mean minimumThickness
  109627. * 1 would mean maximumThickness
  109628. * The other channels might be use as a mask to vary the different effects intensity.
  109629. */
  109630. thicknessTexture: Nullable<BaseTexture>;
  109631. private _refractionTexture;
  109632. /**
  109633. * Defines the texture to use for refraction.
  109634. */
  109635. refractionTexture: Nullable<BaseTexture>;
  109636. private _indexOfRefraction;
  109637. /**
  109638. * Defines the index of refraction used in the material.
  109639. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  109640. */
  109641. indexOfRefraction: number;
  109642. private _invertRefractionY;
  109643. /**
  109644. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109645. */
  109646. invertRefractionY: boolean;
  109647. private _linkRefractionWithTransparency;
  109648. /**
  109649. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109650. * Materials half opaque for instance using refraction could benefit from this control.
  109651. */
  109652. linkRefractionWithTransparency: boolean;
  109653. /**
  109654. * Defines the minimum thickness stored in the thickness map.
  109655. * If no thickness map is defined, this value will be used to simulate thickness.
  109656. */
  109657. minimumThickness: number;
  109658. /**
  109659. * Defines the maximum thickness stored in the thickness map.
  109660. */
  109661. maximumThickness: number;
  109662. /**
  109663. * Defines the volume tint of the material.
  109664. * This is used for both translucency and scattering.
  109665. */
  109666. tintColor: Color3;
  109667. /**
  109668. * Defines the distance at which the tint color should be found in the media.
  109669. * This is used for refraction only.
  109670. */
  109671. tintColorAtDistance: number;
  109672. /**
  109673. * Defines how far each channel transmit through the media.
  109674. * It is defined as a color to simplify it selection.
  109675. */
  109676. diffusionDistance: Color3;
  109677. private _useMaskFromThicknessTexture;
  109678. /**
  109679. * Stores the intensity of the different subsurface effects in the thickness texture.
  109680. * * the green channel is the translucency intensity.
  109681. * * the blue channel is the scattering intensity.
  109682. * * the alpha channel is the refraction intensity.
  109683. */
  109684. useMaskFromThicknessTexture: boolean;
  109685. /** @hidden */
  109686. private _internalMarkAllSubMeshesAsTexturesDirty;
  109687. /** @hidden */
  109688. _markAllSubMeshesAsTexturesDirty(): void;
  109689. /**
  109690. * Instantiate a new istance of sub surface configuration.
  109691. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109692. */
  109693. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109694. /**
  109695. * Gets wehter the submesh is ready to be used or not.
  109696. * @param defines the list of "defines" to update.
  109697. * @param scene defines the scene the material belongs to.
  109698. * @returns - boolean indicating that the submesh is ready or not.
  109699. */
  109700. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  109701. /**
  109702. * Checks to see if a texture is used in the material.
  109703. * @param defines the list of "defines" to update.
  109704. * @param scene defines the scene to the material belongs to.
  109705. */
  109706. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  109707. /**
  109708. * Binds the material data.
  109709. * @param uniformBuffer defines the Uniform buffer to fill in.
  109710. * @param scene defines the scene the material belongs to.
  109711. * @param engine defines the engine the material belongs to.
  109712. * @param isFrozen defines wether the material is frozen or not.
  109713. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  109714. */
  109715. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  109716. /**
  109717. * Unbinds the material from the mesh.
  109718. * @param activeEffect defines the effect that should be unbound from.
  109719. * @returns true if unbound, otherwise false
  109720. */
  109721. unbind(activeEffect: Effect): boolean;
  109722. /**
  109723. * Returns the texture used for refraction or null if none is used.
  109724. * @param scene defines the scene the material belongs to.
  109725. * @returns - Refraction texture if present. If no refraction texture and refraction
  109726. * is linked with transparency, returns environment texture. Otherwise, returns null.
  109727. */
  109728. private _getRefractionTexture;
  109729. /**
  109730. * Returns true if alpha blending should be disabled.
  109731. */
  109732. readonly disableAlphaBlending: boolean;
  109733. /**
  109734. * Fills the list of render target textures.
  109735. * @param renderTargets the list of render targets to update
  109736. */
  109737. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  109738. /**
  109739. * Checks to see if a texture is used in the material.
  109740. * @param texture - Base texture to use.
  109741. * @returns - Boolean specifying if a texture is used in the material.
  109742. */
  109743. hasTexture(texture: BaseTexture): boolean;
  109744. /**
  109745. * Gets a boolean indicating that current material needs to register RTT
  109746. * @returns true if this uses a render target otherwise false.
  109747. */
  109748. hasRenderTargetTextures(): boolean;
  109749. /**
  109750. * Returns an array of the actively used textures.
  109751. * @param activeTextures Array of BaseTextures
  109752. */
  109753. getActiveTextures(activeTextures: BaseTexture[]): void;
  109754. /**
  109755. * Returns the animatable textures.
  109756. * @param animatables Array of animatable textures.
  109757. */
  109758. getAnimatables(animatables: IAnimatable[]): void;
  109759. /**
  109760. * Disposes the resources of the material.
  109761. * @param forceDisposeTextures - Forces the disposal of all textures.
  109762. */
  109763. dispose(forceDisposeTextures?: boolean): void;
  109764. /**
  109765. * Get the current class name of the texture useful for serialization or dynamic coding.
  109766. * @returns "PBRSubSurfaceConfiguration"
  109767. */
  109768. getClassName(): string;
  109769. /**
  109770. * Add fallbacks to the effect fallbacks list.
  109771. * @param defines defines the Base texture to use.
  109772. * @param fallbacks defines the current fallback list.
  109773. * @param currentRank defines the current fallback rank.
  109774. * @returns the new fallback rank.
  109775. */
  109776. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109777. /**
  109778. * Add the required uniforms to the current list.
  109779. * @param uniforms defines the current uniform list.
  109780. */
  109781. static AddUniforms(uniforms: string[]): void;
  109782. /**
  109783. * Add the required samplers to the current list.
  109784. * @param samplers defines the current sampler list.
  109785. */
  109786. static AddSamplers(samplers: string[]): void;
  109787. /**
  109788. * Add the required uniforms to the current buffer.
  109789. * @param uniformBuffer defines the current uniform buffer.
  109790. */
  109791. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109792. /**
  109793. * Makes a duplicate of the current configuration into another one.
  109794. * @param configuration define the config where to copy the info
  109795. */
  109796. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  109797. /**
  109798. * Serializes this Sub Surface configuration.
  109799. * @returns - An object with the serialized config.
  109800. */
  109801. serialize(): any;
  109802. /**
  109803. * Parses a anisotropy Configuration from a serialized object.
  109804. * @param source - Serialized object.
  109805. * @param scene Defines the scene we are parsing for
  109806. * @param rootUrl Defines the rootUrl to load from
  109807. */
  109808. parse(source: any, scene: Scene, rootUrl: string): void;
  109809. }
  109810. }
  109811. declare module BABYLON {
  109812. /** @hidden */
  109813. export var pbrFragmentDeclaration: {
  109814. name: string;
  109815. shader: string;
  109816. };
  109817. }
  109818. declare module BABYLON {
  109819. /** @hidden */
  109820. export var pbrUboDeclaration: {
  109821. name: string;
  109822. shader: string;
  109823. };
  109824. }
  109825. declare module BABYLON {
  109826. /** @hidden */
  109827. export var pbrFragmentExtraDeclaration: {
  109828. name: string;
  109829. shader: string;
  109830. };
  109831. }
  109832. declare module BABYLON {
  109833. /** @hidden */
  109834. export var pbrFragmentSamplersDeclaration: {
  109835. name: string;
  109836. shader: string;
  109837. };
  109838. }
  109839. declare module BABYLON {
  109840. /** @hidden */
  109841. export var pbrHelperFunctions: {
  109842. name: string;
  109843. shader: string;
  109844. };
  109845. }
  109846. declare module BABYLON {
  109847. /** @hidden */
  109848. export var harmonicsFunctions: {
  109849. name: string;
  109850. shader: string;
  109851. };
  109852. }
  109853. declare module BABYLON {
  109854. /** @hidden */
  109855. export var pbrDirectLightingSetupFunctions: {
  109856. name: string;
  109857. shader: string;
  109858. };
  109859. }
  109860. declare module BABYLON {
  109861. /** @hidden */
  109862. export var pbrDirectLightingFalloffFunctions: {
  109863. name: string;
  109864. shader: string;
  109865. };
  109866. }
  109867. declare module BABYLON {
  109868. /** @hidden */
  109869. export var pbrBRDFFunctions: {
  109870. name: string;
  109871. shader: string;
  109872. };
  109873. }
  109874. declare module BABYLON {
  109875. /** @hidden */
  109876. export var pbrDirectLightingFunctions: {
  109877. name: string;
  109878. shader: string;
  109879. };
  109880. }
  109881. declare module BABYLON {
  109882. /** @hidden */
  109883. export var pbrIBLFunctions: {
  109884. name: string;
  109885. shader: string;
  109886. };
  109887. }
  109888. declare module BABYLON {
  109889. /** @hidden */
  109890. export var pbrDebug: {
  109891. name: string;
  109892. shader: string;
  109893. };
  109894. }
  109895. declare module BABYLON {
  109896. /** @hidden */
  109897. export var pbrPixelShader: {
  109898. name: string;
  109899. shader: string;
  109900. };
  109901. }
  109902. declare module BABYLON {
  109903. /** @hidden */
  109904. export var pbrVertexDeclaration: {
  109905. name: string;
  109906. shader: string;
  109907. };
  109908. }
  109909. declare module BABYLON {
  109910. /** @hidden */
  109911. export var pbrVertexShader: {
  109912. name: string;
  109913. shader: string;
  109914. };
  109915. }
  109916. declare module BABYLON {
  109917. /**
  109918. * Manages the defines for the PBR Material.
  109919. * @hidden
  109920. */
  109921. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  109922. PBR: boolean;
  109923. MAINUV1: boolean;
  109924. MAINUV2: boolean;
  109925. UV1: boolean;
  109926. UV2: boolean;
  109927. ALBEDO: boolean;
  109928. ALBEDODIRECTUV: number;
  109929. VERTEXCOLOR: boolean;
  109930. AMBIENT: boolean;
  109931. AMBIENTDIRECTUV: number;
  109932. AMBIENTINGRAYSCALE: boolean;
  109933. OPACITY: boolean;
  109934. VERTEXALPHA: boolean;
  109935. OPACITYDIRECTUV: number;
  109936. OPACITYRGB: boolean;
  109937. ALPHATEST: boolean;
  109938. DEPTHPREPASS: boolean;
  109939. ALPHABLEND: boolean;
  109940. ALPHAFROMALBEDO: boolean;
  109941. ALPHATESTVALUE: string;
  109942. SPECULAROVERALPHA: boolean;
  109943. RADIANCEOVERALPHA: boolean;
  109944. ALPHAFRESNEL: boolean;
  109945. LINEARALPHAFRESNEL: boolean;
  109946. PREMULTIPLYALPHA: boolean;
  109947. EMISSIVE: boolean;
  109948. EMISSIVEDIRECTUV: number;
  109949. REFLECTIVITY: boolean;
  109950. REFLECTIVITYDIRECTUV: number;
  109951. SPECULARTERM: boolean;
  109952. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  109953. MICROSURFACEAUTOMATIC: boolean;
  109954. LODBASEDMICROSFURACE: boolean;
  109955. MICROSURFACEMAP: boolean;
  109956. MICROSURFACEMAPDIRECTUV: number;
  109957. METALLICWORKFLOW: boolean;
  109958. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  109959. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  109960. METALLNESSSTOREINMETALMAPBLUE: boolean;
  109961. AOSTOREINMETALMAPRED: boolean;
  109962. ENVIRONMENTBRDF: boolean;
  109963. ENVIRONMENTBRDF_RGBD: boolean;
  109964. NORMAL: boolean;
  109965. TANGENT: boolean;
  109966. BUMP: boolean;
  109967. BUMPDIRECTUV: number;
  109968. OBJECTSPACE_NORMALMAP: boolean;
  109969. PARALLAX: boolean;
  109970. PARALLAXOCCLUSION: boolean;
  109971. NORMALXYSCALE: boolean;
  109972. LIGHTMAP: boolean;
  109973. LIGHTMAPDIRECTUV: number;
  109974. USELIGHTMAPASSHADOWMAP: boolean;
  109975. GAMMALIGHTMAP: boolean;
  109976. REFLECTION: boolean;
  109977. REFLECTIONMAP_3D: boolean;
  109978. REFLECTIONMAP_SPHERICAL: boolean;
  109979. REFLECTIONMAP_PLANAR: boolean;
  109980. REFLECTIONMAP_CUBIC: boolean;
  109981. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109982. REFLECTIONMAP_PROJECTION: boolean;
  109983. REFLECTIONMAP_SKYBOX: boolean;
  109984. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  109985. REFLECTIONMAP_EXPLICIT: boolean;
  109986. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109987. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109988. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109989. INVERTCUBICMAP: boolean;
  109990. USESPHERICALFROMREFLECTIONMAP: boolean;
  109991. USEIRRADIANCEMAP: boolean;
  109992. SPHERICAL_HARMONICS: boolean;
  109993. USESPHERICALINVERTEX: boolean;
  109994. REFLECTIONMAP_OPPOSITEZ: boolean;
  109995. LODINREFLECTIONALPHA: boolean;
  109996. GAMMAREFLECTION: boolean;
  109997. RGBDREFLECTION: boolean;
  109998. LINEARSPECULARREFLECTION: boolean;
  109999. RADIANCEOCCLUSION: boolean;
  110000. HORIZONOCCLUSION: boolean;
  110001. INSTANCES: boolean;
  110002. NUM_BONE_INFLUENCERS: number;
  110003. BonesPerMesh: number;
  110004. BONETEXTURE: boolean;
  110005. NONUNIFORMSCALING: boolean;
  110006. MORPHTARGETS: boolean;
  110007. MORPHTARGETS_NORMAL: boolean;
  110008. MORPHTARGETS_TANGENT: boolean;
  110009. MORPHTARGETS_UV: boolean;
  110010. NUM_MORPH_INFLUENCERS: number;
  110011. IMAGEPROCESSING: boolean;
  110012. VIGNETTE: boolean;
  110013. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110014. VIGNETTEBLENDMODEOPAQUE: boolean;
  110015. TONEMAPPING: boolean;
  110016. TONEMAPPING_ACES: boolean;
  110017. CONTRAST: boolean;
  110018. COLORCURVES: boolean;
  110019. COLORGRADING: boolean;
  110020. COLORGRADING3D: boolean;
  110021. SAMPLER3DGREENDEPTH: boolean;
  110022. SAMPLER3DBGRMAP: boolean;
  110023. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110024. EXPOSURE: boolean;
  110025. MULTIVIEW: boolean;
  110026. USEPHYSICALLIGHTFALLOFF: boolean;
  110027. USEGLTFLIGHTFALLOFF: boolean;
  110028. TWOSIDEDLIGHTING: boolean;
  110029. SHADOWFLOAT: boolean;
  110030. CLIPPLANE: boolean;
  110031. CLIPPLANE2: boolean;
  110032. CLIPPLANE3: boolean;
  110033. CLIPPLANE4: boolean;
  110034. POINTSIZE: boolean;
  110035. FOG: boolean;
  110036. LOGARITHMICDEPTH: boolean;
  110037. FORCENORMALFORWARD: boolean;
  110038. SPECULARAA: boolean;
  110039. CLEARCOAT: boolean;
  110040. CLEARCOAT_DEFAULTIOR: boolean;
  110041. CLEARCOAT_TEXTURE: boolean;
  110042. CLEARCOAT_TEXTUREDIRECTUV: number;
  110043. CLEARCOAT_BUMP: boolean;
  110044. CLEARCOAT_BUMPDIRECTUV: number;
  110045. CLEARCOAT_TINT: boolean;
  110046. CLEARCOAT_TINT_TEXTURE: boolean;
  110047. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  110048. ANISOTROPIC: boolean;
  110049. ANISOTROPIC_TEXTURE: boolean;
  110050. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110051. BRDF_V_HEIGHT_CORRELATED: boolean;
  110052. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110053. SHEEN: boolean;
  110054. SHEEN_TEXTURE: boolean;
  110055. SHEEN_TEXTUREDIRECTUV: number;
  110056. SHEEN_LINKWITHALBEDO: boolean;
  110057. SUBSURFACE: boolean;
  110058. SS_REFRACTION: boolean;
  110059. SS_TRANSLUCENCY: boolean;
  110060. SS_SCATERRING: boolean;
  110061. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110062. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110063. SS_REFRACTIONMAP_3D: boolean;
  110064. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110065. SS_LODINREFRACTIONALPHA: boolean;
  110066. SS_GAMMAREFRACTION: boolean;
  110067. SS_RGBDREFRACTION: boolean;
  110068. SS_LINEARSPECULARREFRACTION: boolean;
  110069. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110070. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110071. UNLIT: boolean;
  110072. DEBUGMODE: number;
  110073. /**
  110074. * Initializes the PBR Material defines.
  110075. */
  110076. constructor();
  110077. /**
  110078. * Resets the PBR Material defines.
  110079. */
  110080. reset(): void;
  110081. }
  110082. /**
  110083. * The Physically based material base class of BJS.
  110084. *
  110085. * This offers the main features of a standard PBR material.
  110086. * For more information, please refer to the documentation :
  110087. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110088. */
  110089. export abstract class PBRBaseMaterial extends PushMaterial {
  110090. /**
  110091. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110092. */
  110093. static readonly PBRMATERIAL_OPAQUE: number;
  110094. /**
  110095. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110096. */
  110097. static readonly PBRMATERIAL_ALPHATEST: number;
  110098. /**
  110099. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110100. */
  110101. static readonly PBRMATERIAL_ALPHABLEND: number;
  110102. /**
  110103. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110104. * They are also discarded below the alpha cutoff threshold to improve performances.
  110105. */
  110106. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  110107. /**
  110108. * Defines the default value of how much AO map is occluding the analytical lights
  110109. * (point spot...).
  110110. */
  110111. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  110112. /**
  110113. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  110114. */
  110115. static readonly LIGHTFALLOFF_PHYSICAL: number;
  110116. /**
  110117. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  110118. * to enhance interoperability with other engines.
  110119. */
  110120. static readonly LIGHTFALLOFF_GLTF: number;
  110121. /**
  110122. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  110123. * to enhance interoperability with other materials.
  110124. */
  110125. static readonly LIGHTFALLOFF_STANDARD: number;
  110126. /**
  110127. * Intensity of the direct lights e.g. the four lights available in your scene.
  110128. * This impacts both the direct diffuse and specular highlights.
  110129. */
  110130. protected _directIntensity: number;
  110131. /**
  110132. * Intensity of the emissive part of the material.
  110133. * This helps controlling the emissive effect without modifying the emissive color.
  110134. */
  110135. protected _emissiveIntensity: number;
  110136. /**
  110137. * Intensity of the environment e.g. how much the environment will light the object
  110138. * either through harmonics for rough material or through the refelction for shiny ones.
  110139. */
  110140. protected _environmentIntensity: number;
  110141. /**
  110142. * This is a special control allowing the reduction of the specular highlights coming from the
  110143. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  110144. */
  110145. protected _specularIntensity: number;
  110146. /**
  110147. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  110148. */
  110149. private _lightingInfos;
  110150. /**
  110151. * Debug Control allowing disabling the bump map on this material.
  110152. */
  110153. protected _disableBumpMap: boolean;
  110154. /**
  110155. * AKA Diffuse Texture in standard nomenclature.
  110156. */
  110157. protected _albedoTexture: Nullable<BaseTexture>;
  110158. /**
  110159. * AKA Occlusion Texture in other nomenclature.
  110160. */
  110161. protected _ambientTexture: Nullable<BaseTexture>;
  110162. /**
  110163. * AKA Occlusion Texture Intensity in other nomenclature.
  110164. */
  110165. protected _ambientTextureStrength: number;
  110166. /**
  110167. * Defines how much the AO map is occluding the analytical lights (point spot...).
  110168. * 1 means it completely occludes it
  110169. * 0 mean it has no impact
  110170. */
  110171. protected _ambientTextureImpactOnAnalyticalLights: number;
  110172. /**
  110173. * Stores the alpha values in a texture.
  110174. */
  110175. protected _opacityTexture: Nullable<BaseTexture>;
  110176. /**
  110177. * Stores the reflection values in a texture.
  110178. */
  110179. protected _reflectionTexture: Nullable<BaseTexture>;
  110180. /**
  110181. * Stores the emissive values in a texture.
  110182. */
  110183. protected _emissiveTexture: Nullable<BaseTexture>;
  110184. /**
  110185. * AKA Specular texture in other nomenclature.
  110186. */
  110187. protected _reflectivityTexture: Nullable<BaseTexture>;
  110188. /**
  110189. * Used to switch from specular/glossiness to metallic/roughness workflow.
  110190. */
  110191. protected _metallicTexture: Nullable<BaseTexture>;
  110192. /**
  110193. * Specifies the metallic scalar of the metallic/roughness workflow.
  110194. * Can also be used to scale the metalness values of the metallic texture.
  110195. */
  110196. protected _metallic: Nullable<number>;
  110197. /**
  110198. * Specifies the roughness scalar of the metallic/roughness workflow.
  110199. * Can also be used to scale the roughness values of the metallic texture.
  110200. */
  110201. protected _roughness: Nullable<number>;
  110202. /**
  110203. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  110204. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  110205. */
  110206. protected _microSurfaceTexture: Nullable<BaseTexture>;
  110207. /**
  110208. * Stores surface normal data used to displace a mesh in a texture.
  110209. */
  110210. protected _bumpTexture: Nullable<BaseTexture>;
  110211. /**
  110212. * Stores the pre-calculated light information of a mesh in a texture.
  110213. */
  110214. protected _lightmapTexture: Nullable<BaseTexture>;
  110215. /**
  110216. * The color of a material in ambient lighting.
  110217. */
  110218. protected _ambientColor: Color3;
  110219. /**
  110220. * AKA Diffuse Color in other nomenclature.
  110221. */
  110222. protected _albedoColor: Color3;
  110223. /**
  110224. * AKA Specular Color in other nomenclature.
  110225. */
  110226. protected _reflectivityColor: Color3;
  110227. /**
  110228. * The color applied when light is reflected from a material.
  110229. */
  110230. protected _reflectionColor: Color3;
  110231. /**
  110232. * The color applied when light is emitted from a material.
  110233. */
  110234. protected _emissiveColor: Color3;
  110235. /**
  110236. * AKA Glossiness in other nomenclature.
  110237. */
  110238. protected _microSurface: number;
  110239. /**
  110240. * Specifies that the material will use the light map as a show map.
  110241. */
  110242. protected _useLightmapAsShadowmap: boolean;
  110243. /**
  110244. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110245. * makes the reflect vector face the model (under horizon).
  110246. */
  110247. protected _useHorizonOcclusion: boolean;
  110248. /**
  110249. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110250. * too much the area relying on ambient texture to define their ambient occlusion.
  110251. */
  110252. protected _useRadianceOcclusion: boolean;
  110253. /**
  110254. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110255. */
  110256. protected _useAlphaFromAlbedoTexture: boolean;
  110257. /**
  110258. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  110259. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110260. */
  110261. protected _useSpecularOverAlpha: boolean;
  110262. /**
  110263. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110264. */
  110265. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110266. /**
  110267. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  110268. */
  110269. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  110270. /**
  110271. * Specifies if the metallic texture contains the roughness information in its green channel.
  110272. */
  110273. protected _useRoughnessFromMetallicTextureGreen: boolean;
  110274. /**
  110275. * Specifies if the metallic texture contains the metallness information in its blue channel.
  110276. */
  110277. protected _useMetallnessFromMetallicTextureBlue: boolean;
  110278. /**
  110279. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  110280. */
  110281. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  110282. /**
  110283. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  110284. */
  110285. protected _useAmbientInGrayScale: boolean;
  110286. /**
  110287. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  110288. * The material will try to infer what glossiness each pixel should be.
  110289. */
  110290. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  110291. /**
  110292. * Defines the falloff type used in this material.
  110293. * It by default is Physical.
  110294. */
  110295. protected _lightFalloff: number;
  110296. /**
  110297. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110298. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110299. */
  110300. protected _useRadianceOverAlpha: boolean;
  110301. /**
  110302. * Allows using an object space normal map (instead of tangent space).
  110303. */
  110304. protected _useObjectSpaceNormalMap: boolean;
  110305. /**
  110306. * Allows using the bump map in parallax mode.
  110307. */
  110308. protected _useParallax: boolean;
  110309. /**
  110310. * Allows using the bump map in parallax occlusion mode.
  110311. */
  110312. protected _useParallaxOcclusion: boolean;
  110313. /**
  110314. * Controls the scale bias of the parallax mode.
  110315. */
  110316. protected _parallaxScaleBias: number;
  110317. /**
  110318. * If sets to true, disables all the lights affecting the material.
  110319. */
  110320. protected _disableLighting: boolean;
  110321. /**
  110322. * Number of Simultaneous lights allowed on the material.
  110323. */
  110324. protected _maxSimultaneousLights: number;
  110325. /**
  110326. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110327. */
  110328. protected _invertNormalMapX: boolean;
  110329. /**
  110330. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110331. */
  110332. protected _invertNormalMapY: boolean;
  110333. /**
  110334. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110335. */
  110336. protected _twoSidedLighting: boolean;
  110337. /**
  110338. * Defines the alpha limits in alpha test mode.
  110339. */
  110340. protected _alphaCutOff: number;
  110341. /**
  110342. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110343. */
  110344. protected _forceAlphaTest: boolean;
  110345. /**
  110346. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110347. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110348. */
  110349. protected _useAlphaFresnel: boolean;
  110350. /**
  110351. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110352. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110353. */
  110354. protected _useLinearAlphaFresnel: boolean;
  110355. /**
  110356. * The transparency mode of the material.
  110357. */
  110358. protected _transparencyMode: Nullable<number>;
  110359. /**
  110360. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  110361. * from cos thetav and roughness:
  110362. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  110363. */
  110364. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  110365. /**
  110366. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  110367. */
  110368. protected _forceIrradianceInFragment: boolean;
  110369. /**
  110370. * Force normal to face away from face.
  110371. */
  110372. protected _forceNormalForward: boolean;
  110373. /**
  110374. * Enables specular anti aliasing in the PBR shader.
  110375. * It will both interacts on the Geometry for analytical and IBL lighting.
  110376. * It also prefilter the roughness map based on the bump values.
  110377. */
  110378. protected _enableSpecularAntiAliasing: boolean;
  110379. /**
  110380. * Default configuration related to image processing available in the PBR Material.
  110381. */
  110382. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110383. /**
  110384. * Keep track of the image processing observer to allow dispose and replace.
  110385. */
  110386. private _imageProcessingObserver;
  110387. /**
  110388. * Attaches a new image processing configuration to the PBR Material.
  110389. * @param configuration
  110390. */
  110391. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110392. /**
  110393. * Stores the available render targets.
  110394. */
  110395. private _renderTargets;
  110396. /**
  110397. * Sets the global ambient color for the material used in lighting calculations.
  110398. */
  110399. private _globalAmbientColor;
  110400. /**
  110401. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  110402. */
  110403. private _useLogarithmicDepth;
  110404. /**
  110405. * If set to true, no lighting calculations will be applied.
  110406. */
  110407. private _unlit;
  110408. private _debugMode;
  110409. /**
  110410. * @hidden
  110411. * This is reserved for the inspector.
  110412. * Defines the material debug mode.
  110413. * It helps seeing only some components of the material while troubleshooting.
  110414. */
  110415. debugMode: number;
  110416. /**
  110417. * @hidden
  110418. * This is reserved for the inspector.
  110419. * Specify from where on screen the debug mode should start.
  110420. * The value goes from -1 (full screen) to 1 (not visible)
  110421. * It helps with side by side comparison against the final render
  110422. * This defaults to -1
  110423. */
  110424. private debugLimit;
  110425. /**
  110426. * @hidden
  110427. * This is reserved for the inspector.
  110428. * As the default viewing range might not be enough (if the ambient is really small for instance)
  110429. * You can use the factor to better multiply the final value.
  110430. */
  110431. private debugFactor;
  110432. /**
  110433. * Defines the clear coat layer parameters for the material.
  110434. */
  110435. readonly clearCoat: PBRClearCoatConfiguration;
  110436. /**
  110437. * Defines the anisotropic parameters for the material.
  110438. */
  110439. readonly anisotropy: PBRAnisotropicConfiguration;
  110440. /**
  110441. * Defines the BRDF parameters for the material.
  110442. */
  110443. readonly brdf: PBRBRDFConfiguration;
  110444. /**
  110445. * Defines the Sheen parameters for the material.
  110446. */
  110447. readonly sheen: PBRSheenConfiguration;
  110448. /**
  110449. * Defines the SubSurface parameters for the material.
  110450. */
  110451. readonly subSurface: PBRSubSurfaceConfiguration;
  110452. /**
  110453. * Custom callback helping to override the default shader used in the material.
  110454. */
  110455. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  110456. /**
  110457. * Instantiates a new PBRMaterial instance.
  110458. *
  110459. * @param name The material name
  110460. * @param scene The scene the material will be use in.
  110461. */
  110462. constructor(name: string, scene: Scene);
  110463. /**
  110464. * Gets a boolean indicating that current material needs to register RTT
  110465. */
  110466. readonly hasRenderTargetTextures: boolean;
  110467. /**
  110468. * Gets the name of the material class.
  110469. */
  110470. getClassName(): string;
  110471. /**
  110472. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  110473. */
  110474. /**
  110475. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  110476. */
  110477. useLogarithmicDepth: boolean;
  110478. /**
  110479. * Gets the current transparency mode.
  110480. */
  110481. /**
  110482. * Sets the transparency mode of the material.
  110483. *
  110484. * | Value | Type | Description |
  110485. * | ----- | ----------------------------------- | ----------- |
  110486. * | 0 | OPAQUE | |
  110487. * | 1 | ALPHATEST | |
  110488. * | 2 | ALPHABLEND | |
  110489. * | 3 | ALPHATESTANDBLEND | |
  110490. *
  110491. */
  110492. transparencyMode: Nullable<number>;
  110493. /**
  110494. * Returns true if alpha blending should be disabled.
  110495. */
  110496. private readonly _disableAlphaBlending;
  110497. /**
  110498. * Specifies whether or not this material should be rendered in alpha blend mode.
  110499. */
  110500. needAlphaBlending(): boolean;
  110501. /**
  110502. * Specifies if the mesh will require alpha blending.
  110503. * @param mesh - BJS mesh.
  110504. */
  110505. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110506. /**
  110507. * Specifies whether or not this material should be rendered in alpha test mode.
  110508. */
  110509. needAlphaTesting(): boolean;
  110510. /**
  110511. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  110512. */
  110513. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  110514. /**
  110515. * Gets the texture used for the alpha test.
  110516. */
  110517. getAlphaTestTexture(): Nullable<BaseTexture>;
  110518. /**
  110519. * Specifies that the submesh is ready to be used.
  110520. * @param mesh - BJS mesh.
  110521. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  110522. * @param useInstances - Specifies that instances should be used.
  110523. * @returns - boolean indicating that the submesh is ready or not.
  110524. */
  110525. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110526. /**
  110527. * Specifies if the material uses metallic roughness workflow.
  110528. * @returns boolean specifiying if the material uses metallic roughness workflow.
  110529. */
  110530. isMetallicWorkflow(): boolean;
  110531. private _prepareEffect;
  110532. private _prepareDefines;
  110533. /**
  110534. * Force shader compilation
  110535. */
  110536. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  110537. clipPlane: boolean;
  110538. }>): void;
  110539. /**
  110540. * Initializes the uniform buffer layout for the shader.
  110541. */
  110542. buildUniformLayout(): void;
  110543. /**
  110544. * Unbinds the material from the mesh
  110545. */
  110546. unbind(): void;
  110547. /**
  110548. * Binds the submesh data.
  110549. * @param world - The world matrix.
  110550. * @param mesh - The BJS mesh.
  110551. * @param subMesh - A submesh of the BJS mesh.
  110552. */
  110553. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110554. /**
  110555. * Returns the animatable textures.
  110556. * @returns - Array of animatable textures.
  110557. */
  110558. getAnimatables(): IAnimatable[];
  110559. /**
  110560. * Returns the texture used for reflections.
  110561. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  110562. */
  110563. private _getReflectionTexture;
  110564. /**
  110565. * Returns an array of the actively used textures.
  110566. * @returns - Array of BaseTextures
  110567. */
  110568. getActiveTextures(): BaseTexture[];
  110569. /**
  110570. * Checks to see if a texture is used in the material.
  110571. * @param texture - Base texture to use.
  110572. * @returns - Boolean specifying if a texture is used in the material.
  110573. */
  110574. hasTexture(texture: BaseTexture): boolean;
  110575. /**
  110576. * Disposes the resources of the material.
  110577. * @param forceDisposeEffect - Forces the disposal of effects.
  110578. * @param forceDisposeTextures - Forces the disposal of all textures.
  110579. */
  110580. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110581. }
  110582. }
  110583. declare module BABYLON {
  110584. /**
  110585. * The Physically based material of BJS.
  110586. *
  110587. * This offers the main features of a standard PBR material.
  110588. * For more information, please refer to the documentation :
  110589. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110590. */
  110591. export class PBRMaterial extends PBRBaseMaterial {
  110592. /**
  110593. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110594. */
  110595. static readonly PBRMATERIAL_OPAQUE: number;
  110596. /**
  110597. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110598. */
  110599. static readonly PBRMATERIAL_ALPHATEST: number;
  110600. /**
  110601. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110602. */
  110603. static readonly PBRMATERIAL_ALPHABLEND: number;
  110604. /**
  110605. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110606. * They are also discarded below the alpha cutoff threshold to improve performances.
  110607. */
  110608. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  110609. /**
  110610. * Defines the default value of how much AO map is occluding the analytical lights
  110611. * (point spot...).
  110612. */
  110613. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  110614. /**
  110615. * Intensity of the direct lights e.g. the four lights available in your scene.
  110616. * This impacts both the direct diffuse and specular highlights.
  110617. */
  110618. directIntensity: number;
  110619. /**
  110620. * Intensity of the emissive part of the material.
  110621. * This helps controlling the emissive effect without modifying the emissive color.
  110622. */
  110623. emissiveIntensity: number;
  110624. /**
  110625. * Intensity of the environment e.g. how much the environment will light the object
  110626. * either through harmonics for rough material or through the refelction for shiny ones.
  110627. */
  110628. environmentIntensity: number;
  110629. /**
  110630. * This is a special control allowing the reduction of the specular highlights coming from the
  110631. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  110632. */
  110633. specularIntensity: number;
  110634. /**
  110635. * Debug Control allowing disabling the bump map on this material.
  110636. */
  110637. disableBumpMap: boolean;
  110638. /**
  110639. * AKA Diffuse Texture in standard nomenclature.
  110640. */
  110641. albedoTexture: BaseTexture;
  110642. /**
  110643. * AKA Occlusion Texture in other nomenclature.
  110644. */
  110645. ambientTexture: BaseTexture;
  110646. /**
  110647. * AKA Occlusion Texture Intensity in other nomenclature.
  110648. */
  110649. ambientTextureStrength: number;
  110650. /**
  110651. * Defines how much the AO map is occluding the analytical lights (point spot...).
  110652. * 1 means it completely occludes it
  110653. * 0 mean it has no impact
  110654. */
  110655. ambientTextureImpactOnAnalyticalLights: number;
  110656. /**
  110657. * Stores the alpha values in a texture.
  110658. */
  110659. opacityTexture: BaseTexture;
  110660. /**
  110661. * Stores the reflection values in a texture.
  110662. */
  110663. reflectionTexture: Nullable<BaseTexture>;
  110664. /**
  110665. * Stores the emissive values in a texture.
  110666. */
  110667. emissiveTexture: BaseTexture;
  110668. /**
  110669. * AKA Specular texture in other nomenclature.
  110670. */
  110671. reflectivityTexture: BaseTexture;
  110672. /**
  110673. * Used to switch from specular/glossiness to metallic/roughness workflow.
  110674. */
  110675. metallicTexture: BaseTexture;
  110676. /**
  110677. * Specifies the metallic scalar of the metallic/roughness workflow.
  110678. * Can also be used to scale the metalness values of the metallic texture.
  110679. */
  110680. metallic: Nullable<number>;
  110681. /**
  110682. * Specifies the roughness scalar of the metallic/roughness workflow.
  110683. * Can also be used to scale the roughness values of the metallic texture.
  110684. */
  110685. roughness: Nullable<number>;
  110686. /**
  110687. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  110688. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  110689. */
  110690. microSurfaceTexture: BaseTexture;
  110691. /**
  110692. * Stores surface normal data used to displace a mesh in a texture.
  110693. */
  110694. bumpTexture: BaseTexture;
  110695. /**
  110696. * Stores the pre-calculated light information of a mesh in a texture.
  110697. */
  110698. lightmapTexture: BaseTexture;
  110699. /**
  110700. * Stores the refracted light information in a texture.
  110701. */
  110702. refractionTexture: Nullable<BaseTexture>;
  110703. /**
  110704. * The color of a material in ambient lighting.
  110705. */
  110706. ambientColor: Color3;
  110707. /**
  110708. * AKA Diffuse Color in other nomenclature.
  110709. */
  110710. albedoColor: Color3;
  110711. /**
  110712. * AKA Specular Color in other nomenclature.
  110713. */
  110714. reflectivityColor: Color3;
  110715. /**
  110716. * The color reflected from the material.
  110717. */
  110718. reflectionColor: Color3;
  110719. /**
  110720. * The color emitted from the material.
  110721. */
  110722. emissiveColor: Color3;
  110723. /**
  110724. * AKA Glossiness in other nomenclature.
  110725. */
  110726. microSurface: number;
  110727. /**
  110728. * source material index of refraction (IOR)' / 'destination material IOR.
  110729. */
  110730. indexOfRefraction: number;
  110731. /**
  110732. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  110733. */
  110734. invertRefractionY: boolean;
  110735. /**
  110736. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  110737. * Materials half opaque for instance using refraction could benefit from this control.
  110738. */
  110739. linkRefractionWithTransparency: boolean;
  110740. /**
  110741. * If true, the light map contains occlusion information instead of lighting info.
  110742. */
  110743. useLightmapAsShadowmap: boolean;
  110744. /**
  110745. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110746. */
  110747. useAlphaFromAlbedoTexture: boolean;
  110748. /**
  110749. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110750. */
  110751. forceAlphaTest: boolean;
  110752. /**
  110753. * Defines the alpha limits in alpha test mode.
  110754. */
  110755. alphaCutOff: number;
  110756. /**
  110757. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110758. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110759. */
  110760. useSpecularOverAlpha: boolean;
  110761. /**
  110762. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110763. */
  110764. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110765. /**
  110766. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  110767. */
  110768. useRoughnessFromMetallicTextureAlpha: boolean;
  110769. /**
  110770. * Specifies if the metallic texture contains the roughness information in its green channel.
  110771. */
  110772. useRoughnessFromMetallicTextureGreen: boolean;
  110773. /**
  110774. * Specifies if the metallic texture contains the metallness information in its blue channel.
  110775. */
  110776. useMetallnessFromMetallicTextureBlue: boolean;
  110777. /**
  110778. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  110779. */
  110780. useAmbientOcclusionFromMetallicTextureRed: boolean;
  110781. /**
  110782. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  110783. */
  110784. useAmbientInGrayScale: boolean;
  110785. /**
  110786. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  110787. * The material will try to infer what glossiness each pixel should be.
  110788. */
  110789. useAutoMicroSurfaceFromReflectivityMap: boolean;
  110790. /**
  110791. * BJS is using an harcoded light falloff based on a manually sets up range.
  110792. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  110793. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  110794. */
  110795. /**
  110796. * BJS is using an harcoded light falloff based on a manually sets up range.
  110797. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  110798. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  110799. */
  110800. usePhysicalLightFalloff: boolean;
  110801. /**
  110802. * In order to support the falloff compatibility with gltf, a special mode has been added
  110803. * to reproduce the gltf light falloff.
  110804. */
  110805. /**
  110806. * In order to support the falloff compatibility with gltf, a special mode has been added
  110807. * to reproduce the gltf light falloff.
  110808. */
  110809. useGLTFLightFalloff: boolean;
  110810. /**
  110811. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110812. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110813. */
  110814. useRadianceOverAlpha: boolean;
  110815. /**
  110816. * Allows using an object space normal map (instead of tangent space).
  110817. */
  110818. useObjectSpaceNormalMap: boolean;
  110819. /**
  110820. * Allows using the bump map in parallax mode.
  110821. */
  110822. useParallax: boolean;
  110823. /**
  110824. * Allows using the bump map in parallax occlusion mode.
  110825. */
  110826. useParallaxOcclusion: boolean;
  110827. /**
  110828. * Controls the scale bias of the parallax mode.
  110829. */
  110830. parallaxScaleBias: number;
  110831. /**
  110832. * If sets to true, disables all the lights affecting the material.
  110833. */
  110834. disableLighting: boolean;
  110835. /**
  110836. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  110837. */
  110838. forceIrradianceInFragment: boolean;
  110839. /**
  110840. * Number of Simultaneous lights allowed on the material.
  110841. */
  110842. maxSimultaneousLights: number;
  110843. /**
  110844. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110845. */
  110846. invertNormalMapX: boolean;
  110847. /**
  110848. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110849. */
  110850. invertNormalMapY: boolean;
  110851. /**
  110852. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110853. */
  110854. twoSidedLighting: boolean;
  110855. /**
  110856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110857. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110858. */
  110859. useAlphaFresnel: boolean;
  110860. /**
  110861. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110862. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110863. */
  110864. useLinearAlphaFresnel: boolean;
  110865. /**
  110866. * Let user defines the brdf lookup texture used for IBL.
  110867. * A default 8bit version is embedded but you could point at :
  110868. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  110869. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  110870. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  110871. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  110872. */
  110873. environmentBRDFTexture: Nullable<BaseTexture>;
  110874. /**
  110875. * Force normal to face away from face.
  110876. */
  110877. forceNormalForward: boolean;
  110878. /**
  110879. * Enables specular anti aliasing in the PBR shader.
  110880. * It will both interacts on the Geometry for analytical and IBL lighting.
  110881. * It also prefilter the roughness map based on the bump values.
  110882. */
  110883. enableSpecularAntiAliasing: boolean;
  110884. /**
  110885. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110886. * makes the reflect vector face the model (under horizon).
  110887. */
  110888. useHorizonOcclusion: boolean;
  110889. /**
  110890. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110891. * too much the area relying on ambient texture to define their ambient occlusion.
  110892. */
  110893. useRadianceOcclusion: boolean;
  110894. /**
  110895. * If set to true, no lighting calculations will be applied.
  110896. */
  110897. unlit: boolean;
  110898. /**
  110899. * Gets the image processing configuration used either in this material.
  110900. */
  110901. /**
  110902. * Sets the Default image processing configuration used either in the this material.
  110903. *
  110904. * If sets to null, the scene one is in use.
  110905. */
  110906. imageProcessingConfiguration: ImageProcessingConfiguration;
  110907. /**
  110908. * Gets wether the color curves effect is enabled.
  110909. */
  110910. /**
  110911. * Sets wether the color curves effect is enabled.
  110912. */
  110913. cameraColorCurvesEnabled: boolean;
  110914. /**
  110915. * Gets wether the color grading effect is enabled.
  110916. */
  110917. /**
  110918. * Gets wether the color grading effect is enabled.
  110919. */
  110920. cameraColorGradingEnabled: boolean;
  110921. /**
  110922. * Gets wether tonemapping is enabled or not.
  110923. */
  110924. /**
  110925. * Sets wether tonemapping is enabled or not
  110926. */
  110927. cameraToneMappingEnabled: boolean;
  110928. /**
  110929. * The camera exposure used on this material.
  110930. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110931. * This corresponds to a photographic exposure.
  110932. */
  110933. /**
  110934. * The camera exposure used on this material.
  110935. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110936. * This corresponds to a photographic exposure.
  110937. */
  110938. cameraExposure: number;
  110939. /**
  110940. * Gets The camera contrast used on this material.
  110941. */
  110942. /**
  110943. * Sets The camera contrast used on this material.
  110944. */
  110945. cameraContrast: number;
  110946. /**
  110947. * Gets the Color Grading 2D Lookup Texture.
  110948. */
  110949. /**
  110950. * Sets the Color Grading 2D Lookup Texture.
  110951. */
  110952. cameraColorGradingTexture: Nullable<BaseTexture>;
  110953. /**
  110954. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110955. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110956. * 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;
  110957. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110958. */
  110959. /**
  110960. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110961. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110962. * 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;
  110963. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110964. */
  110965. cameraColorCurves: Nullable<ColorCurves>;
  110966. /**
  110967. * Instantiates a new PBRMaterial instance.
  110968. *
  110969. * @param name The material name
  110970. * @param scene The scene the material will be use in.
  110971. */
  110972. constructor(name: string, scene: Scene);
  110973. /**
  110974. * Returns the name of this material class.
  110975. */
  110976. getClassName(): string;
  110977. /**
  110978. * Makes a duplicate of the current material.
  110979. * @param name - name to use for the new material.
  110980. */
  110981. clone(name: string): PBRMaterial;
  110982. /**
  110983. * Serializes this PBR Material.
  110984. * @returns - An object with the serialized material.
  110985. */
  110986. serialize(): any;
  110987. /**
  110988. * Parses a PBR Material from a serialized object.
  110989. * @param source - Serialized object.
  110990. * @param scene - BJS scene instance.
  110991. * @param rootUrl - url for the scene object
  110992. * @returns - PBRMaterial
  110993. */
  110994. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  110995. }
  110996. }
  110997. declare module BABYLON {
  110998. /**
  110999. * Direct draw surface info
  111000. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  111001. */
  111002. export interface DDSInfo {
  111003. /**
  111004. * Width of the texture
  111005. */
  111006. width: number;
  111007. /**
  111008. * Width of the texture
  111009. */
  111010. height: number;
  111011. /**
  111012. * Number of Mipmaps for the texture
  111013. * @see https://en.wikipedia.org/wiki/Mipmap
  111014. */
  111015. mipmapCount: number;
  111016. /**
  111017. * If the textures format is a known fourCC format
  111018. * @see https://www.fourcc.org/
  111019. */
  111020. isFourCC: boolean;
  111021. /**
  111022. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  111023. */
  111024. isRGB: boolean;
  111025. /**
  111026. * If the texture is a lumincance format
  111027. */
  111028. isLuminance: boolean;
  111029. /**
  111030. * If this is a cube texture
  111031. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  111032. */
  111033. isCube: boolean;
  111034. /**
  111035. * If the texture is a compressed format eg. FOURCC_DXT1
  111036. */
  111037. isCompressed: boolean;
  111038. /**
  111039. * The dxgiFormat of the texture
  111040. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  111041. */
  111042. dxgiFormat: number;
  111043. /**
  111044. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  111045. */
  111046. textureType: number;
  111047. /**
  111048. * Sphericle polynomial created for the dds texture
  111049. */
  111050. sphericalPolynomial?: SphericalPolynomial;
  111051. }
  111052. /**
  111053. * Class used to provide DDS decompression tools
  111054. */
  111055. export class DDSTools {
  111056. /**
  111057. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  111058. */
  111059. static StoreLODInAlphaChannel: boolean;
  111060. /**
  111061. * Gets DDS information from an array buffer
  111062. * @param arrayBuffer defines the array buffer to read data from
  111063. * @returns the DDS information
  111064. */
  111065. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  111066. private static _FloatView;
  111067. private static _Int32View;
  111068. private static _ToHalfFloat;
  111069. private static _FromHalfFloat;
  111070. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  111071. private static _GetHalfFloatRGBAArrayBuffer;
  111072. private static _GetFloatRGBAArrayBuffer;
  111073. private static _GetFloatAsUIntRGBAArrayBuffer;
  111074. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  111075. private static _GetRGBAArrayBuffer;
  111076. private static _ExtractLongWordOrder;
  111077. private static _GetRGBArrayBuffer;
  111078. private static _GetLuminanceArrayBuffer;
  111079. /**
  111080. * Uploads DDS Levels to a Babylon Texture
  111081. * @hidden
  111082. */
  111083. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  111084. }
  111085. interface Engine {
  111086. /**
  111087. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  111088. * @param rootUrl defines the url where the file to load is located
  111089. * @param scene defines the current scene
  111090. * @param lodScale defines scale to apply to the mip map selection
  111091. * @param lodOffset defines offset to apply to the mip map selection
  111092. * @param onLoad defines an optional callback raised when the texture is loaded
  111093. * @param onError defines an optional callback raised if there is an issue to load the texture
  111094. * @param format defines the format of the data
  111095. * @param forcedExtension defines the extension to use to pick the right loader
  111096. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  111097. * @returns the cube texture as an InternalTexture
  111098. */
  111099. 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;
  111100. }
  111101. }
  111102. declare module BABYLON {
  111103. /**
  111104. * Implementation of the DDS Texture Loader.
  111105. * @hidden
  111106. */
  111107. export class _DDSTextureLoader implements IInternalTextureLoader {
  111108. /**
  111109. * Defines wether the loader supports cascade loading the different faces.
  111110. */
  111111. readonly supportCascades: boolean;
  111112. /**
  111113. * This returns if the loader support the current file information.
  111114. * @param extension defines the file extension of the file being loaded
  111115. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111116. * @param fallback defines the fallback internal texture if any
  111117. * @param isBase64 defines whether the texture is encoded as a base64
  111118. * @param isBuffer defines whether the texture data are stored as a buffer
  111119. * @returns true if the loader can load the specified file
  111120. */
  111121. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111122. /**
  111123. * Transform the url before loading if required.
  111124. * @param rootUrl the url of the texture
  111125. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111126. * @returns the transformed texture
  111127. */
  111128. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111129. /**
  111130. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111131. * @param rootUrl the url of the texture
  111132. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111133. * @returns the fallback texture
  111134. */
  111135. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111136. /**
  111137. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111138. * @param data contains the texture data
  111139. * @param texture defines the BabylonJS internal texture
  111140. * @param createPolynomials will be true if polynomials have been requested
  111141. * @param onLoad defines the callback to trigger once the texture is ready
  111142. * @param onError defines the callback to trigger in case of error
  111143. */
  111144. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111145. /**
  111146. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111147. * @param data contains the texture data
  111148. * @param texture defines the BabylonJS internal texture
  111149. * @param callback defines the method to call once ready to upload
  111150. */
  111151. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111152. }
  111153. }
  111154. declare module BABYLON {
  111155. /** @hidden */
  111156. export var rgbdEncodePixelShader: {
  111157. name: string;
  111158. shader: string;
  111159. };
  111160. }
  111161. declare module BABYLON {
  111162. /**
  111163. * Raw texture data and descriptor sufficient for WebGL texture upload
  111164. */
  111165. export interface EnvironmentTextureInfo {
  111166. /**
  111167. * Version of the environment map
  111168. */
  111169. version: number;
  111170. /**
  111171. * Width of image
  111172. */
  111173. width: number;
  111174. /**
  111175. * Irradiance information stored in the file.
  111176. */
  111177. irradiance: any;
  111178. /**
  111179. * Specular information stored in the file.
  111180. */
  111181. specular: any;
  111182. }
  111183. /**
  111184. * Sets of helpers addressing the serialization and deserialization of environment texture
  111185. * stored in a BabylonJS env file.
  111186. * Those files are usually stored as .env files.
  111187. */
  111188. export class EnvironmentTextureTools {
  111189. /**
  111190. * Magic number identifying the env file.
  111191. */
  111192. private static _MagicBytes;
  111193. /**
  111194. * Gets the environment info from an env file.
  111195. * @param data The array buffer containing the .env bytes.
  111196. * @returns the environment file info (the json header) if successfully parsed.
  111197. */
  111198. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111199. /**
  111200. * Creates an environment texture from a loaded cube texture.
  111201. * @param texture defines the cube texture to convert in env file
  111202. * @return a promise containing the environment data if succesfull.
  111203. */
  111204. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111205. /**
  111206. * Creates a JSON representation of the spherical data.
  111207. * @param texture defines the texture containing the polynomials
  111208. * @return the JSON representation of the spherical info
  111209. */
  111210. private static _CreateEnvTextureIrradiance;
  111211. /**
  111212. * Uploads the texture info contained in the env file to the GPU.
  111213. * @param texture defines the internal texture to upload to
  111214. * @param arrayBuffer defines the buffer cotaining the data to load
  111215. * @param info defines the texture info retrieved through the GetEnvInfo method
  111216. * @returns a promise
  111217. */
  111218. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111219. /**
  111220. * Uploads the levels of image data to the GPU.
  111221. * @param texture defines the internal texture to upload to
  111222. * @param imageData defines the array buffer views of image data [mipmap][face]
  111223. * @returns a promise
  111224. */
  111225. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111226. /**
  111227. * Uploads spherical polynomials information to the texture.
  111228. * @param texture defines the texture we are trying to upload the information to
  111229. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111230. */
  111231. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111232. /** @hidden */
  111233. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111234. }
  111235. }
  111236. declare module BABYLON {
  111237. /**
  111238. * Implementation of the ENV Texture Loader.
  111239. * @hidden
  111240. */
  111241. export class _ENVTextureLoader implements IInternalTextureLoader {
  111242. /**
  111243. * Defines wether the loader supports cascade loading the different faces.
  111244. */
  111245. readonly supportCascades: boolean;
  111246. /**
  111247. * This returns if the loader support the current file information.
  111248. * @param extension defines the file extension of the file being loaded
  111249. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111250. * @param fallback defines the fallback internal texture if any
  111251. * @param isBase64 defines whether the texture is encoded as a base64
  111252. * @param isBuffer defines whether the texture data are stored as a buffer
  111253. * @returns true if the loader can load the specified file
  111254. */
  111255. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111256. /**
  111257. * Transform the url before loading if required.
  111258. * @param rootUrl the url of the texture
  111259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111260. * @returns the transformed texture
  111261. */
  111262. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111263. /**
  111264. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111265. * @param rootUrl the url of the texture
  111266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111267. * @returns the fallback texture
  111268. */
  111269. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111270. /**
  111271. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111272. * @param data contains the texture data
  111273. * @param texture defines the BabylonJS internal texture
  111274. * @param createPolynomials will be true if polynomials have been requested
  111275. * @param onLoad defines the callback to trigger once the texture is ready
  111276. * @param onError defines the callback to trigger in case of error
  111277. */
  111278. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111279. /**
  111280. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111281. * @param data contains the texture data
  111282. * @param texture defines the BabylonJS internal texture
  111283. * @param callback defines the method to call once ready to upload
  111284. */
  111285. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111286. }
  111287. }
  111288. declare module BABYLON {
  111289. /**
  111290. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  111291. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  111292. */
  111293. export class KhronosTextureContainer {
  111294. /** contents of the KTX container file */
  111295. arrayBuffer: any;
  111296. private static HEADER_LEN;
  111297. private static COMPRESSED_2D;
  111298. private static COMPRESSED_3D;
  111299. private static TEX_2D;
  111300. private static TEX_3D;
  111301. /**
  111302. * Gets the openGL type
  111303. */
  111304. glType: number;
  111305. /**
  111306. * Gets the openGL type size
  111307. */
  111308. glTypeSize: number;
  111309. /**
  111310. * Gets the openGL format
  111311. */
  111312. glFormat: number;
  111313. /**
  111314. * Gets the openGL internal format
  111315. */
  111316. glInternalFormat: number;
  111317. /**
  111318. * Gets the base internal format
  111319. */
  111320. glBaseInternalFormat: number;
  111321. /**
  111322. * Gets image width in pixel
  111323. */
  111324. pixelWidth: number;
  111325. /**
  111326. * Gets image height in pixel
  111327. */
  111328. pixelHeight: number;
  111329. /**
  111330. * Gets image depth in pixels
  111331. */
  111332. pixelDepth: number;
  111333. /**
  111334. * Gets the number of array elements
  111335. */
  111336. numberOfArrayElements: number;
  111337. /**
  111338. * Gets the number of faces
  111339. */
  111340. numberOfFaces: number;
  111341. /**
  111342. * Gets the number of mipmap levels
  111343. */
  111344. numberOfMipmapLevels: number;
  111345. /**
  111346. * Gets the bytes of key value data
  111347. */
  111348. bytesOfKeyValueData: number;
  111349. /**
  111350. * Gets the load type
  111351. */
  111352. loadType: number;
  111353. /**
  111354. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  111355. */
  111356. isInvalid: boolean;
  111357. /**
  111358. * Creates a new KhronosTextureContainer
  111359. * @param arrayBuffer contents of the KTX container file
  111360. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  111361. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  111362. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  111363. */
  111364. constructor(
  111365. /** contents of the KTX container file */
  111366. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  111367. /**
  111368. * Uploads KTX content to a Babylon Texture.
  111369. * It is assumed that the texture has already been created & is currently bound
  111370. * @hidden
  111371. */
  111372. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  111373. private _upload2DCompressedLevels;
  111374. }
  111375. }
  111376. declare module BABYLON {
  111377. /**
  111378. * Implementation of the KTX Texture Loader.
  111379. * @hidden
  111380. */
  111381. export class _KTXTextureLoader implements IInternalTextureLoader {
  111382. /**
  111383. * Defines wether the loader supports cascade loading the different faces.
  111384. */
  111385. readonly supportCascades: boolean;
  111386. /**
  111387. * This returns if the loader support the current file information.
  111388. * @param extension defines the file extension of the file being loaded
  111389. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111390. * @param fallback defines the fallback internal texture if any
  111391. * @param isBase64 defines whether the texture is encoded as a base64
  111392. * @param isBuffer defines whether the texture data are stored as a buffer
  111393. * @returns true if the loader can load the specified file
  111394. */
  111395. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111396. /**
  111397. * Transform the url before loading if required.
  111398. * @param rootUrl the url of the texture
  111399. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111400. * @returns the transformed texture
  111401. */
  111402. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111403. /**
  111404. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111405. * @param rootUrl the url of the texture
  111406. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111407. * @returns the fallback texture
  111408. */
  111409. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111410. /**
  111411. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111412. * @param data contains the texture data
  111413. * @param texture defines the BabylonJS internal texture
  111414. * @param createPolynomials will be true if polynomials have been requested
  111415. * @param onLoad defines the callback to trigger once the texture is ready
  111416. * @param onError defines the callback to trigger in case of error
  111417. */
  111418. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111419. /**
  111420. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111421. * @param data contains the texture data
  111422. * @param texture defines the BabylonJS internal texture
  111423. * @param callback defines the method to call once ready to upload
  111424. */
  111425. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  111426. }
  111427. }
  111428. declare module BABYLON {
  111429. /**
  111430. * Options for the default xr helper
  111431. */
  111432. export class WebXRDefaultExperienceOptions {
  111433. /**
  111434. * Floor meshes that should be used for teleporting
  111435. */
  111436. floorMeshes: Array<AbstractMesh>;
  111437. }
  111438. /**
  111439. * Default experience which provides a similar setup to the previous webVRExperience
  111440. */
  111441. export class WebXRDefaultExperience {
  111442. /**
  111443. * Base experience
  111444. */
  111445. baseExperience: WebXRExperienceHelper;
  111446. /**
  111447. * Input experience extension
  111448. */
  111449. input: WebXRInput;
  111450. /**
  111451. * Loads the controller models
  111452. */
  111453. controllerModelLoader: WebXRControllerModelLoader;
  111454. /**
  111455. * Enables laser pointer and selection
  111456. */
  111457. pointerSelection: WebXRControllerPointerSelection;
  111458. /**
  111459. * Enables teleportation
  111460. */
  111461. teleportation: WebXRControllerTeleportation;
  111462. /**
  111463. * Enables ui for enetering/exiting xr
  111464. */
  111465. enterExitUI: WebXREnterExitUI;
  111466. /**
  111467. * Default output canvas xr should render to
  111468. */
  111469. outputCanvas: WebXRManagedOutputCanvas;
  111470. /**
  111471. * Creates the default xr experience
  111472. * @param scene scene
  111473. * @param options options for basic configuration
  111474. * @returns resulting WebXRDefaultExperience
  111475. */
  111476. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111477. private constructor();
  111478. /**
  111479. * DIsposes of the experience helper
  111480. */
  111481. dispose(): void;
  111482. }
  111483. }
  111484. declare module BABYLON {
  111485. /** @hidden */
  111486. export var _forceSceneHelpersToBundle: boolean;
  111487. interface Scene {
  111488. /**
  111489. * Creates a default light for the scene.
  111490. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  111491. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  111492. */
  111493. createDefaultLight(replace?: boolean): void;
  111494. /**
  111495. * Creates a default camera for the scene.
  111496. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  111497. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  111498. * @param replace has default false, when true replaces the active camera in the scene
  111499. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  111500. */
  111501. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  111502. /**
  111503. * Creates a default camera and a default light.
  111504. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  111505. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  111506. * @param replace has the default false, when true replaces the active camera/light in the scene
  111507. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  111508. */
  111509. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  111510. /**
  111511. * Creates a new sky box
  111512. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  111513. * @param environmentTexture defines the texture to use as environment texture
  111514. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  111515. * @param scale defines the overall scale of the skybox
  111516. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  111517. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  111518. * @returns a new mesh holding the sky box
  111519. */
  111520. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  111521. /**
  111522. * Creates a new environment
  111523. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  111524. * @param options defines the options you can use to configure the environment
  111525. * @returns the new EnvironmentHelper
  111526. */
  111527. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  111528. /**
  111529. * Creates a new VREXperienceHelper
  111530. * @see http://doc.babylonjs.com/how_to/webvr_helper
  111531. * @param webVROptions defines the options used to create the new VREXperienceHelper
  111532. * @returns a new VREXperienceHelper
  111533. */
  111534. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  111535. /**
  111536. * Creates a new WebXRDefaultExperience
  111537. * @see http://doc.babylonjs.com/how_to/webxr
  111538. * @param options experience options
  111539. * @returns a promise for a new WebXRDefaultExperience
  111540. */
  111541. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111542. }
  111543. }
  111544. declare module BABYLON {
  111545. /**
  111546. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  111547. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  111548. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  111549. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111550. */
  111551. export class VideoDome extends TransformNode {
  111552. /**
  111553. * Define the video source as a Monoscopic panoramic 360 video.
  111554. */
  111555. static readonly MODE_MONOSCOPIC: number;
  111556. /**
  111557. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  111558. */
  111559. static readonly MODE_TOPBOTTOM: number;
  111560. /**
  111561. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  111562. */
  111563. static readonly MODE_SIDEBYSIDE: number;
  111564. private _useDirectMapping;
  111565. /**
  111566. * The video texture being displayed on the sphere
  111567. */
  111568. protected _videoTexture: VideoTexture;
  111569. /**
  111570. * Gets the video texture being displayed on the sphere
  111571. */
  111572. readonly videoTexture: VideoTexture;
  111573. /**
  111574. * The skybox material
  111575. */
  111576. protected _material: BackgroundMaterial;
  111577. /**
  111578. * The surface used for the skybox
  111579. */
  111580. protected _mesh: Mesh;
  111581. /**
  111582. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111583. * Also see the options.resolution property.
  111584. */
  111585. fovMultiplier: number;
  111586. private _videoMode;
  111587. /**
  111588. * Gets or set the current video mode for the video. It can be:
  111589. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  111590. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  111591. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  111592. */
  111593. videoMode: number;
  111594. /**
  111595. * Oberserver used in Stereoscopic VR Mode.
  111596. */
  111597. private _onBeforeCameraRenderObserver;
  111598. /**
  111599. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  111600. * @param name Element's name, child elements will append suffixes for their own names.
  111601. * @param urlsOrVideo defines the url(s) or the video element to use
  111602. * @param options An object containing optional or exposed sub element properties
  111603. */
  111604. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  111605. resolution?: number;
  111606. clickToPlay?: boolean;
  111607. autoPlay?: boolean;
  111608. loop?: boolean;
  111609. size?: number;
  111610. poster?: string;
  111611. faceForward?: boolean;
  111612. useDirectMapping?: boolean;
  111613. }, scene: Scene);
  111614. private _changeVideoMode;
  111615. /**
  111616. * Releases resources associated with this node.
  111617. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111618. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111619. */
  111620. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111621. }
  111622. }
  111623. declare module BABYLON {
  111624. /**
  111625. * This class can be used to get instrumentation data from a Babylon engine
  111626. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  111627. */
  111628. export class EngineInstrumentation implements IDisposable {
  111629. /**
  111630. * Define the instrumented engine.
  111631. */
  111632. engine: Engine;
  111633. private _captureGPUFrameTime;
  111634. private _gpuFrameTimeToken;
  111635. private _gpuFrameTime;
  111636. private _captureShaderCompilationTime;
  111637. private _shaderCompilationTime;
  111638. private _onBeginFrameObserver;
  111639. private _onEndFrameObserver;
  111640. private _onBeforeShaderCompilationObserver;
  111641. private _onAfterShaderCompilationObserver;
  111642. /**
  111643. * Gets the perf counter used for GPU frame time
  111644. */
  111645. readonly gpuFrameTimeCounter: PerfCounter;
  111646. /**
  111647. * Gets the GPU frame time capture status
  111648. */
  111649. /**
  111650. * Enable or disable the GPU frame time capture
  111651. */
  111652. captureGPUFrameTime: boolean;
  111653. /**
  111654. * Gets the perf counter used for shader compilation time
  111655. */
  111656. readonly shaderCompilationTimeCounter: PerfCounter;
  111657. /**
  111658. * Gets the shader compilation time capture status
  111659. */
  111660. /**
  111661. * Enable or disable the shader compilation time capture
  111662. */
  111663. captureShaderCompilationTime: boolean;
  111664. /**
  111665. * Instantiates a new engine instrumentation.
  111666. * This class can be used to get instrumentation data from a Babylon engine
  111667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  111668. * @param engine Defines the engine to instrument
  111669. */
  111670. constructor(
  111671. /**
  111672. * Define the instrumented engine.
  111673. */
  111674. engine: Engine);
  111675. /**
  111676. * Dispose and release associated resources.
  111677. */
  111678. dispose(): void;
  111679. }
  111680. }
  111681. declare module BABYLON {
  111682. /**
  111683. * This class can be used to get instrumentation data from a Babylon engine
  111684. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  111685. */
  111686. export class SceneInstrumentation implements IDisposable {
  111687. /**
  111688. * Defines the scene to instrument
  111689. */
  111690. scene: Scene;
  111691. private _captureActiveMeshesEvaluationTime;
  111692. private _activeMeshesEvaluationTime;
  111693. private _captureRenderTargetsRenderTime;
  111694. private _renderTargetsRenderTime;
  111695. private _captureFrameTime;
  111696. private _frameTime;
  111697. private _captureRenderTime;
  111698. private _renderTime;
  111699. private _captureInterFrameTime;
  111700. private _interFrameTime;
  111701. private _captureParticlesRenderTime;
  111702. private _particlesRenderTime;
  111703. private _captureSpritesRenderTime;
  111704. private _spritesRenderTime;
  111705. private _capturePhysicsTime;
  111706. private _physicsTime;
  111707. private _captureAnimationsTime;
  111708. private _animationsTime;
  111709. private _captureCameraRenderTime;
  111710. private _cameraRenderTime;
  111711. private _onBeforeActiveMeshesEvaluationObserver;
  111712. private _onAfterActiveMeshesEvaluationObserver;
  111713. private _onBeforeRenderTargetsRenderObserver;
  111714. private _onAfterRenderTargetsRenderObserver;
  111715. private _onAfterRenderObserver;
  111716. private _onBeforeDrawPhaseObserver;
  111717. private _onAfterDrawPhaseObserver;
  111718. private _onBeforeAnimationsObserver;
  111719. private _onBeforeParticlesRenderingObserver;
  111720. private _onAfterParticlesRenderingObserver;
  111721. private _onBeforeSpritesRenderingObserver;
  111722. private _onAfterSpritesRenderingObserver;
  111723. private _onBeforePhysicsObserver;
  111724. private _onAfterPhysicsObserver;
  111725. private _onAfterAnimationsObserver;
  111726. private _onBeforeCameraRenderObserver;
  111727. private _onAfterCameraRenderObserver;
  111728. /**
  111729. * Gets the perf counter used for active meshes evaluation time
  111730. */
  111731. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  111732. /**
  111733. * Gets the active meshes evaluation time capture status
  111734. */
  111735. /**
  111736. * Enable or disable the active meshes evaluation time capture
  111737. */
  111738. captureActiveMeshesEvaluationTime: boolean;
  111739. /**
  111740. * Gets the perf counter used for render targets render time
  111741. */
  111742. readonly renderTargetsRenderTimeCounter: PerfCounter;
  111743. /**
  111744. * Gets the render targets render time capture status
  111745. */
  111746. /**
  111747. * Enable or disable the render targets render time capture
  111748. */
  111749. captureRenderTargetsRenderTime: boolean;
  111750. /**
  111751. * Gets the perf counter used for particles render time
  111752. */
  111753. readonly particlesRenderTimeCounter: PerfCounter;
  111754. /**
  111755. * Gets the particles render time capture status
  111756. */
  111757. /**
  111758. * Enable or disable the particles render time capture
  111759. */
  111760. captureParticlesRenderTime: boolean;
  111761. /**
  111762. * Gets the perf counter used for sprites render time
  111763. */
  111764. readonly spritesRenderTimeCounter: PerfCounter;
  111765. /**
  111766. * Gets the sprites render time capture status
  111767. */
  111768. /**
  111769. * Enable or disable the sprites render time capture
  111770. */
  111771. captureSpritesRenderTime: boolean;
  111772. /**
  111773. * Gets the perf counter used for physics time
  111774. */
  111775. readonly physicsTimeCounter: PerfCounter;
  111776. /**
  111777. * Gets the physics time capture status
  111778. */
  111779. /**
  111780. * Enable or disable the physics time capture
  111781. */
  111782. capturePhysicsTime: boolean;
  111783. /**
  111784. * Gets the perf counter used for animations time
  111785. */
  111786. readonly animationsTimeCounter: PerfCounter;
  111787. /**
  111788. * Gets the animations time capture status
  111789. */
  111790. /**
  111791. * Enable or disable the animations time capture
  111792. */
  111793. captureAnimationsTime: boolean;
  111794. /**
  111795. * Gets the perf counter used for frame time capture
  111796. */
  111797. readonly frameTimeCounter: PerfCounter;
  111798. /**
  111799. * Gets the frame time capture status
  111800. */
  111801. /**
  111802. * Enable or disable the frame time capture
  111803. */
  111804. captureFrameTime: boolean;
  111805. /**
  111806. * Gets the perf counter used for inter-frames time capture
  111807. */
  111808. readonly interFrameTimeCounter: PerfCounter;
  111809. /**
  111810. * Gets the inter-frames time capture status
  111811. */
  111812. /**
  111813. * Enable or disable the inter-frames time capture
  111814. */
  111815. captureInterFrameTime: boolean;
  111816. /**
  111817. * Gets the perf counter used for render time capture
  111818. */
  111819. readonly renderTimeCounter: PerfCounter;
  111820. /**
  111821. * Gets the render time capture status
  111822. */
  111823. /**
  111824. * Enable or disable the render time capture
  111825. */
  111826. captureRenderTime: boolean;
  111827. /**
  111828. * Gets the perf counter used for camera render time capture
  111829. */
  111830. readonly cameraRenderTimeCounter: PerfCounter;
  111831. /**
  111832. * Gets the camera render time capture status
  111833. */
  111834. /**
  111835. * Enable or disable the camera render time capture
  111836. */
  111837. captureCameraRenderTime: boolean;
  111838. /**
  111839. * Gets the perf counter used for draw calls
  111840. */
  111841. readonly drawCallsCounter: PerfCounter;
  111842. /**
  111843. * Instantiates a new scene instrumentation.
  111844. * This class can be used to get instrumentation data from a Babylon engine
  111845. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  111846. * @param scene Defines the scene to instrument
  111847. */
  111848. constructor(
  111849. /**
  111850. * Defines the scene to instrument
  111851. */
  111852. scene: Scene);
  111853. /**
  111854. * Dispose and release associated resources.
  111855. */
  111856. dispose(): void;
  111857. }
  111858. }
  111859. declare module BABYLON {
  111860. /** @hidden */
  111861. export var glowMapGenerationPixelShader: {
  111862. name: string;
  111863. shader: string;
  111864. };
  111865. }
  111866. declare module BABYLON {
  111867. /** @hidden */
  111868. export var glowMapGenerationVertexShader: {
  111869. name: string;
  111870. shader: string;
  111871. };
  111872. }
  111873. declare module BABYLON {
  111874. /**
  111875. * Effect layer options. This helps customizing the behaviour
  111876. * of the effect layer.
  111877. */
  111878. export interface IEffectLayerOptions {
  111879. /**
  111880. * Multiplication factor apply to the canvas size to compute the render target size
  111881. * used to generated the objects (the smaller the faster).
  111882. */
  111883. mainTextureRatio: number;
  111884. /**
  111885. * Enforces a fixed size texture to ensure effect stability across devices.
  111886. */
  111887. mainTextureFixedSize?: number;
  111888. /**
  111889. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  111890. */
  111891. alphaBlendingMode: number;
  111892. /**
  111893. * The camera attached to the layer.
  111894. */
  111895. camera: Nullable<Camera>;
  111896. /**
  111897. * The rendering group to draw the layer in.
  111898. */
  111899. renderingGroupId: number;
  111900. }
  111901. /**
  111902. * The effect layer Helps adding post process effect blended with the main pass.
  111903. *
  111904. * This can be for instance use to generate glow or higlight effects on the scene.
  111905. *
  111906. * The effect layer class can not be used directly and is intented to inherited from to be
  111907. * customized per effects.
  111908. */
  111909. export abstract class EffectLayer {
  111910. private _vertexBuffers;
  111911. private _indexBuffer;
  111912. private _cachedDefines;
  111913. private _effectLayerMapGenerationEffect;
  111914. private _effectLayerOptions;
  111915. private _mergeEffect;
  111916. protected _scene: Scene;
  111917. protected _engine: Engine;
  111918. protected _maxSize: number;
  111919. protected _mainTextureDesiredSize: ISize;
  111920. protected _mainTexture: RenderTargetTexture;
  111921. protected _shouldRender: boolean;
  111922. protected _postProcesses: PostProcess[];
  111923. protected _textures: BaseTexture[];
  111924. protected _emissiveTextureAndColor: {
  111925. texture: Nullable<BaseTexture>;
  111926. color: Color4;
  111927. };
  111928. /**
  111929. * The name of the layer
  111930. */
  111931. name: string;
  111932. /**
  111933. * The clear color of the texture used to generate the glow map.
  111934. */
  111935. neutralColor: Color4;
  111936. /**
  111937. * Specifies wether the highlight layer is enabled or not.
  111938. */
  111939. isEnabled: boolean;
  111940. /**
  111941. * Gets the camera attached to the layer.
  111942. */
  111943. readonly camera: Nullable<Camera>;
  111944. /**
  111945. * Gets the rendering group id the layer should render in.
  111946. */
  111947. renderingGroupId: number;
  111948. /**
  111949. * An event triggered when the effect layer has been disposed.
  111950. */
  111951. onDisposeObservable: Observable<EffectLayer>;
  111952. /**
  111953. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  111954. */
  111955. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  111956. /**
  111957. * An event triggered when the generated texture is being merged in the scene.
  111958. */
  111959. onBeforeComposeObservable: Observable<EffectLayer>;
  111960. /**
  111961. * An event triggered when the generated texture has been merged in the scene.
  111962. */
  111963. onAfterComposeObservable: Observable<EffectLayer>;
  111964. /**
  111965. * An event triggered when the efffect layer changes its size.
  111966. */
  111967. onSizeChangedObservable: Observable<EffectLayer>;
  111968. /** @hidden */
  111969. static _SceneComponentInitialization: (scene: Scene) => void;
  111970. /**
  111971. * Instantiates a new effect Layer and references it in the scene.
  111972. * @param name The name of the layer
  111973. * @param scene The scene to use the layer in
  111974. */
  111975. constructor(
  111976. /** The Friendly of the effect in the scene */
  111977. name: string, scene: Scene);
  111978. /**
  111979. * Get the effect name of the layer.
  111980. * @return The effect name
  111981. */
  111982. abstract getEffectName(): string;
  111983. /**
  111984. * Checks for the readiness of the element composing the layer.
  111985. * @param subMesh the mesh to check for
  111986. * @param useInstances specify wether or not to use instances to render the mesh
  111987. * @return true if ready otherwise, false
  111988. */
  111989. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111990. /**
  111991. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111992. * @returns true if the effect requires stencil during the main canvas render pass.
  111993. */
  111994. abstract needStencil(): boolean;
  111995. /**
  111996. * Create the merge effect. This is the shader use to blit the information back
  111997. * to the main canvas at the end of the scene rendering.
  111998. * @returns The effect containing the shader used to merge the effect on the main canvas
  111999. */
  112000. protected abstract _createMergeEffect(): Effect;
  112001. /**
  112002. * Creates the render target textures and post processes used in the effect layer.
  112003. */
  112004. protected abstract _createTextureAndPostProcesses(): void;
  112005. /**
  112006. * Implementation specific of rendering the generating effect on the main canvas.
  112007. * @param effect The effect used to render through
  112008. */
  112009. protected abstract _internalRender(effect: Effect): void;
  112010. /**
  112011. * Sets the required values for both the emissive texture and and the main color.
  112012. */
  112013. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112014. /**
  112015. * Free any resources and references associated to a mesh.
  112016. * Internal use
  112017. * @param mesh The mesh to free.
  112018. */
  112019. abstract _disposeMesh(mesh: Mesh): void;
  112020. /**
  112021. * Serializes this layer (Glow or Highlight for example)
  112022. * @returns a serialized layer object
  112023. */
  112024. abstract serialize?(): any;
  112025. /**
  112026. * Initializes the effect layer with the required options.
  112027. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  112028. */
  112029. protected _init(options: Partial<IEffectLayerOptions>): void;
  112030. /**
  112031. * Generates the index buffer of the full screen quad blending to the main canvas.
  112032. */
  112033. private _generateIndexBuffer;
  112034. /**
  112035. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  112036. */
  112037. private _generateVertexBuffer;
  112038. /**
  112039. * Sets the main texture desired size which is the closest power of two
  112040. * of the engine canvas size.
  112041. */
  112042. private _setMainTextureSize;
  112043. /**
  112044. * Creates the main texture for the effect layer.
  112045. */
  112046. protected _createMainTexture(): void;
  112047. /**
  112048. * Adds specific effects defines.
  112049. * @param defines The defines to add specifics to.
  112050. */
  112051. protected _addCustomEffectDefines(defines: string[]): void;
  112052. /**
  112053. * Checks for the readiness of the element composing the layer.
  112054. * @param subMesh the mesh to check for
  112055. * @param useInstances specify wether or not to use instances to render the mesh
  112056. * @param emissiveTexture the associated emissive texture used to generate the glow
  112057. * @return true if ready otherwise, false
  112058. */
  112059. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  112060. /**
  112061. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  112062. */
  112063. render(): void;
  112064. /**
  112065. * Determine if a given mesh will be used in the current effect.
  112066. * @param mesh mesh to test
  112067. * @returns true if the mesh will be used
  112068. */
  112069. hasMesh(mesh: AbstractMesh): boolean;
  112070. /**
  112071. * Returns true if the layer contains information to display, otherwise false.
  112072. * @returns true if the glow layer should be rendered
  112073. */
  112074. shouldRender(): boolean;
  112075. /**
  112076. * Returns true if the mesh should render, otherwise false.
  112077. * @param mesh The mesh to render
  112078. * @returns true if it should render otherwise false
  112079. */
  112080. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  112081. /**
  112082. * Returns true if the mesh can be rendered, otherwise false.
  112083. * @param mesh The mesh to render
  112084. * @param material The material used on the mesh
  112085. * @returns true if it can be rendered otherwise false
  112086. */
  112087. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  112088. /**
  112089. * Returns true if the mesh should render, otherwise false.
  112090. * @param mesh The mesh to render
  112091. * @returns true if it should render otherwise false
  112092. */
  112093. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  112094. /**
  112095. * Renders the submesh passed in parameter to the generation map.
  112096. */
  112097. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  112098. /**
  112099. * Rebuild the required buffers.
  112100. * @hidden Internal use only.
  112101. */
  112102. _rebuild(): void;
  112103. /**
  112104. * Dispose only the render target textures and post process.
  112105. */
  112106. private _disposeTextureAndPostProcesses;
  112107. /**
  112108. * Dispose the highlight layer and free resources.
  112109. */
  112110. dispose(): void;
  112111. /**
  112112. * Gets the class name of the effect layer
  112113. * @returns the string with the class name of the effect layer
  112114. */
  112115. getClassName(): string;
  112116. /**
  112117. * Creates an effect layer from parsed effect layer data
  112118. * @param parsedEffectLayer defines effect layer data
  112119. * @param scene defines the current scene
  112120. * @param rootUrl defines the root URL containing the effect layer information
  112121. * @returns a parsed effect Layer
  112122. */
  112123. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  112124. }
  112125. }
  112126. declare module BABYLON {
  112127. interface AbstractScene {
  112128. /**
  112129. * The list of effect layers (highlights/glow) added to the scene
  112130. * @see http://doc.babylonjs.com/how_to/highlight_layer
  112131. * @see http://doc.babylonjs.com/how_to/glow_layer
  112132. */
  112133. effectLayers: Array<EffectLayer>;
  112134. /**
  112135. * Removes the given effect layer from this scene.
  112136. * @param toRemove defines the effect layer to remove
  112137. * @returns the index of the removed effect layer
  112138. */
  112139. removeEffectLayer(toRemove: EffectLayer): number;
  112140. /**
  112141. * Adds the given effect layer to this scene
  112142. * @param newEffectLayer defines the effect layer to add
  112143. */
  112144. addEffectLayer(newEffectLayer: EffectLayer): void;
  112145. }
  112146. /**
  112147. * Defines the layer scene component responsible to manage any effect layers
  112148. * in a given scene.
  112149. */
  112150. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  112151. /**
  112152. * The component name helpfull to identify the component in the list of scene components.
  112153. */
  112154. readonly name: string;
  112155. /**
  112156. * The scene the component belongs to.
  112157. */
  112158. scene: Scene;
  112159. private _engine;
  112160. private _renderEffects;
  112161. private _needStencil;
  112162. private _previousStencilState;
  112163. /**
  112164. * Creates a new instance of the component for the given scene
  112165. * @param scene Defines the scene to register the component in
  112166. */
  112167. constructor(scene: Scene);
  112168. /**
  112169. * Registers the component in a given scene
  112170. */
  112171. register(): void;
  112172. /**
  112173. * Rebuilds the elements related to this component in case of
  112174. * context lost for instance.
  112175. */
  112176. rebuild(): void;
  112177. /**
  112178. * Serializes the component data to the specified json object
  112179. * @param serializationObject The object to serialize to
  112180. */
  112181. serialize(serializationObject: any): void;
  112182. /**
  112183. * Adds all the elements from the container to the scene
  112184. * @param container the container holding the elements
  112185. */
  112186. addFromContainer(container: AbstractScene): void;
  112187. /**
  112188. * Removes all the elements in the container from the scene
  112189. * @param container contains the elements to remove
  112190. * @param dispose if the removed element should be disposed (default: false)
  112191. */
  112192. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112193. /**
  112194. * Disposes the component and the associated ressources.
  112195. */
  112196. dispose(): void;
  112197. private _isReadyForMesh;
  112198. private _renderMainTexture;
  112199. private _setStencil;
  112200. private _setStencilBack;
  112201. private _draw;
  112202. private _drawCamera;
  112203. private _drawRenderingGroup;
  112204. }
  112205. }
  112206. declare module BABYLON {
  112207. /** @hidden */
  112208. export var glowMapMergePixelShader: {
  112209. name: string;
  112210. shader: string;
  112211. };
  112212. }
  112213. declare module BABYLON {
  112214. /** @hidden */
  112215. export var glowMapMergeVertexShader: {
  112216. name: string;
  112217. shader: string;
  112218. };
  112219. }
  112220. declare module BABYLON {
  112221. interface AbstractScene {
  112222. /**
  112223. * Return a the first highlight layer of the scene with a given name.
  112224. * @param name The name of the highlight layer to look for.
  112225. * @return The highlight layer if found otherwise null.
  112226. */
  112227. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  112228. }
  112229. /**
  112230. * Glow layer options. This helps customizing the behaviour
  112231. * of the glow layer.
  112232. */
  112233. export interface IGlowLayerOptions {
  112234. /**
  112235. * Multiplication factor apply to the canvas size to compute the render target size
  112236. * used to generated the glowing objects (the smaller the faster).
  112237. */
  112238. mainTextureRatio: number;
  112239. /**
  112240. * Enforces a fixed size texture to ensure resize independant blur.
  112241. */
  112242. mainTextureFixedSize?: number;
  112243. /**
  112244. * How big is the kernel of the blur texture.
  112245. */
  112246. blurKernelSize: number;
  112247. /**
  112248. * The camera attached to the layer.
  112249. */
  112250. camera: Nullable<Camera>;
  112251. /**
  112252. * Enable MSAA by chosing the number of samples.
  112253. */
  112254. mainTextureSamples?: number;
  112255. /**
  112256. * The rendering group to draw the layer in.
  112257. */
  112258. renderingGroupId: number;
  112259. }
  112260. /**
  112261. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  112262. *
  112263. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  112264. * glowy meshes to your scene.
  112265. *
  112266. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  112267. */
  112268. export class GlowLayer extends EffectLayer {
  112269. /**
  112270. * Effect Name of the layer.
  112271. */
  112272. static readonly EffectName: string;
  112273. /**
  112274. * The default blur kernel size used for the glow.
  112275. */
  112276. static DefaultBlurKernelSize: number;
  112277. /**
  112278. * The default texture size ratio used for the glow.
  112279. */
  112280. static DefaultTextureRatio: number;
  112281. /**
  112282. * Sets the kernel size of the blur.
  112283. */
  112284. /**
  112285. * Gets the kernel size of the blur.
  112286. */
  112287. blurKernelSize: number;
  112288. /**
  112289. * Sets the glow intensity.
  112290. */
  112291. /**
  112292. * Gets the glow intensity.
  112293. */
  112294. intensity: number;
  112295. private _options;
  112296. private _intensity;
  112297. private _horizontalBlurPostprocess1;
  112298. private _verticalBlurPostprocess1;
  112299. private _horizontalBlurPostprocess2;
  112300. private _verticalBlurPostprocess2;
  112301. private _blurTexture1;
  112302. private _blurTexture2;
  112303. private _postProcesses1;
  112304. private _postProcesses2;
  112305. private _includedOnlyMeshes;
  112306. private _excludedMeshes;
  112307. /**
  112308. * Callback used to let the user override the color selection on a per mesh basis
  112309. */
  112310. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  112311. /**
  112312. * Callback used to let the user override the texture selection on a per mesh basis
  112313. */
  112314. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  112315. /**
  112316. * Instantiates a new glow Layer and references it to the scene.
  112317. * @param name The name of the layer
  112318. * @param scene The scene to use the layer in
  112319. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  112320. */
  112321. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  112322. /**
  112323. * Get the effect name of the layer.
  112324. * @return The effect name
  112325. */
  112326. getEffectName(): string;
  112327. /**
  112328. * Create the merge effect. This is the shader use to blit the information back
  112329. * to the main canvas at the end of the scene rendering.
  112330. */
  112331. protected _createMergeEffect(): Effect;
  112332. /**
  112333. * Creates the render target textures and post processes used in the glow layer.
  112334. */
  112335. protected _createTextureAndPostProcesses(): void;
  112336. /**
  112337. * Checks for the readiness of the element composing the layer.
  112338. * @param subMesh the mesh to check for
  112339. * @param useInstances specify wether or not to use instances to render the mesh
  112340. * @param emissiveTexture the associated emissive texture used to generate the glow
  112341. * @return true if ready otherwise, false
  112342. */
  112343. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112344. /**
  112345. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112346. */
  112347. needStencil(): boolean;
  112348. /**
  112349. * Returns true if the mesh can be rendered, otherwise false.
  112350. * @param mesh The mesh to render
  112351. * @param material The material used on the mesh
  112352. * @returns true if it can be rendered otherwise false
  112353. */
  112354. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  112355. /**
  112356. * Implementation specific of rendering the generating effect on the main canvas.
  112357. * @param effect The effect used to render through
  112358. */
  112359. protected _internalRender(effect: Effect): void;
  112360. /**
  112361. * Sets the required values for both the emissive texture and and the main color.
  112362. */
  112363. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112364. /**
  112365. * Returns true if the mesh should render, otherwise false.
  112366. * @param mesh The mesh to render
  112367. * @returns true if it should render otherwise false
  112368. */
  112369. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112370. /**
  112371. * Adds specific effects defines.
  112372. * @param defines The defines to add specifics to.
  112373. */
  112374. protected _addCustomEffectDefines(defines: string[]): void;
  112375. /**
  112376. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  112377. * @param mesh The mesh to exclude from the glow layer
  112378. */
  112379. addExcludedMesh(mesh: Mesh): void;
  112380. /**
  112381. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  112382. * @param mesh The mesh to remove
  112383. */
  112384. removeExcludedMesh(mesh: Mesh): void;
  112385. /**
  112386. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  112387. * @param mesh The mesh to include in the glow layer
  112388. */
  112389. addIncludedOnlyMesh(mesh: Mesh): void;
  112390. /**
  112391. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  112392. * @param mesh The mesh to remove
  112393. */
  112394. removeIncludedOnlyMesh(mesh: Mesh): void;
  112395. /**
  112396. * Determine if a given mesh will be used in the glow layer
  112397. * @param mesh The mesh to test
  112398. * @returns true if the mesh will be highlighted by the current glow layer
  112399. */
  112400. hasMesh(mesh: AbstractMesh): boolean;
  112401. /**
  112402. * Free any resources and references associated to a mesh.
  112403. * Internal use
  112404. * @param mesh The mesh to free.
  112405. * @hidden
  112406. */
  112407. _disposeMesh(mesh: Mesh): void;
  112408. /**
  112409. * Gets the class name of the effect layer
  112410. * @returns the string with the class name of the effect layer
  112411. */
  112412. getClassName(): string;
  112413. /**
  112414. * Serializes this glow layer
  112415. * @returns a serialized glow layer object
  112416. */
  112417. serialize(): any;
  112418. /**
  112419. * Creates a Glow Layer from parsed glow layer data
  112420. * @param parsedGlowLayer defines glow layer data
  112421. * @param scene defines the current scene
  112422. * @param rootUrl defines the root URL containing the glow layer information
  112423. * @returns a parsed Glow Layer
  112424. */
  112425. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  112426. }
  112427. }
  112428. declare module BABYLON {
  112429. /** @hidden */
  112430. export var glowBlurPostProcessPixelShader: {
  112431. name: string;
  112432. shader: string;
  112433. };
  112434. }
  112435. declare module BABYLON {
  112436. interface AbstractScene {
  112437. /**
  112438. * Return a the first highlight layer of the scene with a given name.
  112439. * @param name The name of the highlight layer to look for.
  112440. * @return The highlight layer if found otherwise null.
  112441. */
  112442. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  112443. }
  112444. /**
  112445. * Highlight layer options. This helps customizing the behaviour
  112446. * of the highlight layer.
  112447. */
  112448. export interface IHighlightLayerOptions {
  112449. /**
  112450. * Multiplication factor apply to the canvas size to compute the render target size
  112451. * used to generated the glowing objects (the smaller the faster).
  112452. */
  112453. mainTextureRatio: number;
  112454. /**
  112455. * Enforces a fixed size texture to ensure resize independant blur.
  112456. */
  112457. mainTextureFixedSize?: number;
  112458. /**
  112459. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  112460. * of the picture to blur (the smaller the faster).
  112461. */
  112462. blurTextureSizeRatio: number;
  112463. /**
  112464. * How big in texel of the blur texture is the vertical blur.
  112465. */
  112466. blurVerticalSize: number;
  112467. /**
  112468. * How big in texel of the blur texture is the horizontal blur.
  112469. */
  112470. blurHorizontalSize: number;
  112471. /**
  112472. * Alpha blending mode used to apply the blur. Default is combine.
  112473. */
  112474. alphaBlendingMode: number;
  112475. /**
  112476. * The camera attached to the layer.
  112477. */
  112478. camera: Nullable<Camera>;
  112479. /**
  112480. * Should we display highlight as a solid stroke?
  112481. */
  112482. isStroke?: boolean;
  112483. /**
  112484. * The rendering group to draw the layer in.
  112485. */
  112486. renderingGroupId: number;
  112487. }
  112488. /**
  112489. * The highlight layer Helps adding a glow effect around a mesh.
  112490. *
  112491. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  112492. * glowy meshes to your scene.
  112493. *
  112494. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  112495. */
  112496. export class HighlightLayer extends EffectLayer {
  112497. name: string;
  112498. /**
  112499. * Effect Name of the highlight layer.
  112500. */
  112501. static readonly EffectName: string;
  112502. /**
  112503. * The neutral color used during the preparation of the glow effect.
  112504. * This is black by default as the blend operation is a blend operation.
  112505. */
  112506. static NeutralColor: Color4;
  112507. /**
  112508. * Stencil value used for glowing meshes.
  112509. */
  112510. static GlowingMeshStencilReference: number;
  112511. /**
  112512. * Stencil value used for the other meshes in the scene.
  112513. */
  112514. static NormalMeshStencilReference: number;
  112515. /**
  112516. * Specifies whether or not the inner glow is ACTIVE in the layer.
  112517. */
  112518. innerGlow: boolean;
  112519. /**
  112520. * Specifies whether or not the outer glow is ACTIVE in the layer.
  112521. */
  112522. outerGlow: boolean;
  112523. /**
  112524. * Specifies the horizontal size of the blur.
  112525. */
  112526. /**
  112527. * Gets the horizontal size of the blur.
  112528. */
  112529. blurHorizontalSize: number;
  112530. /**
  112531. * Specifies the vertical size of the blur.
  112532. */
  112533. /**
  112534. * Gets the vertical size of the blur.
  112535. */
  112536. blurVerticalSize: number;
  112537. /**
  112538. * An event triggered when the highlight layer is being blurred.
  112539. */
  112540. onBeforeBlurObservable: Observable<HighlightLayer>;
  112541. /**
  112542. * An event triggered when the highlight layer has been blurred.
  112543. */
  112544. onAfterBlurObservable: Observable<HighlightLayer>;
  112545. private _instanceGlowingMeshStencilReference;
  112546. private _options;
  112547. private _downSamplePostprocess;
  112548. private _horizontalBlurPostprocess;
  112549. private _verticalBlurPostprocess;
  112550. private _blurTexture;
  112551. private _meshes;
  112552. private _excludedMeshes;
  112553. /**
  112554. * Instantiates a new highlight Layer and references it to the scene..
  112555. * @param name The name of the layer
  112556. * @param scene The scene to use the layer in
  112557. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  112558. */
  112559. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  112560. /**
  112561. * Get the effect name of the layer.
  112562. * @return The effect name
  112563. */
  112564. getEffectName(): string;
  112565. /**
  112566. * Create the merge effect. This is the shader use to blit the information back
  112567. * to the main canvas at the end of the scene rendering.
  112568. */
  112569. protected _createMergeEffect(): Effect;
  112570. /**
  112571. * Creates the render target textures and post processes used in the highlight layer.
  112572. */
  112573. protected _createTextureAndPostProcesses(): void;
  112574. /**
  112575. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112576. */
  112577. needStencil(): boolean;
  112578. /**
  112579. * Checks for the readiness of the element composing the layer.
  112580. * @param subMesh the mesh to check for
  112581. * @param useInstances specify wether or not to use instances to render the mesh
  112582. * @param emissiveTexture the associated emissive texture used to generate the glow
  112583. * @return true if ready otherwise, false
  112584. */
  112585. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112586. /**
  112587. * Implementation specific of rendering the generating effect on the main canvas.
  112588. * @param effect The effect used to render through
  112589. */
  112590. protected _internalRender(effect: Effect): void;
  112591. /**
  112592. * Returns true if the layer contains information to display, otherwise false.
  112593. */
  112594. shouldRender(): boolean;
  112595. /**
  112596. * Returns true if the mesh should render, otherwise false.
  112597. * @param mesh The mesh to render
  112598. * @returns true if it should render otherwise false
  112599. */
  112600. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112601. /**
  112602. * Sets the required values for both the emissive texture and and the main color.
  112603. */
  112604. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112605. /**
  112606. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  112607. * @param mesh The mesh to exclude from the highlight layer
  112608. */
  112609. addExcludedMesh(mesh: Mesh): void;
  112610. /**
  112611. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  112612. * @param mesh The mesh to highlight
  112613. */
  112614. removeExcludedMesh(mesh: Mesh): void;
  112615. /**
  112616. * Determine if a given mesh will be highlighted by the current HighlightLayer
  112617. * @param mesh mesh to test
  112618. * @returns true if the mesh will be highlighted by the current HighlightLayer
  112619. */
  112620. hasMesh(mesh: AbstractMesh): boolean;
  112621. /**
  112622. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  112623. * @param mesh The mesh to highlight
  112624. * @param color The color of the highlight
  112625. * @param glowEmissiveOnly Extract the glow from the emissive texture
  112626. */
  112627. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  112628. /**
  112629. * Remove a mesh from the highlight layer in order to make it stop glowing.
  112630. * @param mesh The mesh to highlight
  112631. */
  112632. removeMesh(mesh: Mesh): void;
  112633. /**
  112634. * Force the stencil to the normal expected value for none glowing parts
  112635. */
  112636. private _defaultStencilReference;
  112637. /**
  112638. * Free any resources and references associated to a mesh.
  112639. * Internal use
  112640. * @param mesh The mesh to free.
  112641. * @hidden
  112642. */
  112643. _disposeMesh(mesh: Mesh): void;
  112644. /**
  112645. * Dispose the highlight layer and free resources.
  112646. */
  112647. dispose(): void;
  112648. /**
  112649. * Gets the class name of the effect layer
  112650. * @returns the string with the class name of the effect layer
  112651. */
  112652. getClassName(): string;
  112653. /**
  112654. * Serializes this Highlight layer
  112655. * @returns a serialized Highlight layer object
  112656. */
  112657. serialize(): any;
  112658. /**
  112659. * Creates a Highlight layer from parsed Highlight layer data
  112660. * @param parsedHightlightLayer defines the Highlight layer data
  112661. * @param scene defines the current scene
  112662. * @param rootUrl defines the root URL containing the Highlight layer information
  112663. * @returns a parsed Highlight layer
  112664. */
  112665. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  112666. }
  112667. }
  112668. declare module BABYLON {
  112669. interface AbstractScene {
  112670. /**
  112671. * The list of layers (background and foreground) of the scene
  112672. */
  112673. layers: Array<Layer>;
  112674. }
  112675. /**
  112676. * Defines the layer scene component responsible to manage any layers
  112677. * in a given scene.
  112678. */
  112679. export class LayerSceneComponent implements ISceneComponent {
  112680. /**
  112681. * The component name helpfull to identify the component in the list of scene components.
  112682. */
  112683. readonly name: string;
  112684. /**
  112685. * The scene the component belongs to.
  112686. */
  112687. scene: Scene;
  112688. private _engine;
  112689. /**
  112690. * Creates a new instance of the component for the given scene
  112691. * @param scene Defines the scene to register the component in
  112692. */
  112693. constructor(scene: Scene);
  112694. /**
  112695. * Registers the component in a given scene
  112696. */
  112697. register(): void;
  112698. /**
  112699. * Rebuilds the elements related to this component in case of
  112700. * context lost for instance.
  112701. */
  112702. rebuild(): void;
  112703. /**
  112704. * Disposes the component and the associated ressources.
  112705. */
  112706. dispose(): void;
  112707. private _draw;
  112708. private _drawCameraPredicate;
  112709. private _drawCameraBackground;
  112710. private _drawCameraForeground;
  112711. private _drawRenderTargetPredicate;
  112712. private _drawRenderTargetBackground;
  112713. private _drawRenderTargetForeground;
  112714. /**
  112715. * Adds all the elements from the container to the scene
  112716. * @param container the container holding the elements
  112717. */
  112718. addFromContainer(container: AbstractScene): void;
  112719. /**
  112720. * Removes all the elements in the container from the scene
  112721. * @param container contains the elements to remove
  112722. * @param dispose if the removed element should be disposed (default: false)
  112723. */
  112724. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112725. }
  112726. }
  112727. declare module BABYLON {
  112728. /** @hidden */
  112729. export var layerPixelShader: {
  112730. name: string;
  112731. shader: string;
  112732. };
  112733. }
  112734. declare module BABYLON {
  112735. /** @hidden */
  112736. export var layerVertexShader: {
  112737. name: string;
  112738. shader: string;
  112739. };
  112740. }
  112741. declare module BABYLON {
  112742. /**
  112743. * This represents a full screen 2d layer.
  112744. * This can be useful to display a picture in the background of your scene for instance.
  112745. * @see https://www.babylonjs-playground.com/#08A2BS#1
  112746. */
  112747. export class Layer {
  112748. /**
  112749. * Define the name of the layer.
  112750. */
  112751. name: string;
  112752. /**
  112753. * Define the texture the layer should display.
  112754. */
  112755. texture: Nullable<Texture>;
  112756. /**
  112757. * Is the layer in background or foreground.
  112758. */
  112759. isBackground: boolean;
  112760. /**
  112761. * Define the color of the layer (instead of texture).
  112762. */
  112763. color: Color4;
  112764. /**
  112765. * Define the scale of the layer in order to zoom in out of the texture.
  112766. */
  112767. scale: Vector2;
  112768. /**
  112769. * Define an offset for the layer in order to shift the texture.
  112770. */
  112771. offset: Vector2;
  112772. /**
  112773. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  112774. */
  112775. alphaBlendingMode: number;
  112776. /**
  112777. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  112778. * Alpha test will not mix with the background color in case of transparency.
  112779. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  112780. */
  112781. alphaTest: boolean;
  112782. /**
  112783. * Define a mask to restrict the layer to only some of the scene cameras.
  112784. */
  112785. layerMask: number;
  112786. /**
  112787. * Define the list of render target the layer is visible into.
  112788. */
  112789. renderTargetTextures: RenderTargetTexture[];
  112790. /**
  112791. * Define if the layer is only used in renderTarget or if it also
  112792. * renders in the main frame buffer of the canvas.
  112793. */
  112794. renderOnlyInRenderTargetTextures: boolean;
  112795. private _scene;
  112796. private _vertexBuffers;
  112797. private _indexBuffer;
  112798. private _effect;
  112799. private _alphaTestEffect;
  112800. /**
  112801. * An event triggered when the layer is disposed.
  112802. */
  112803. onDisposeObservable: Observable<Layer>;
  112804. private _onDisposeObserver;
  112805. /**
  112806. * Back compatibility with callback before the onDisposeObservable existed.
  112807. * The set callback will be triggered when the layer has been disposed.
  112808. */
  112809. onDispose: () => void;
  112810. /**
  112811. * An event triggered before rendering the scene
  112812. */
  112813. onBeforeRenderObservable: Observable<Layer>;
  112814. private _onBeforeRenderObserver;
  112815. /**
  112816. * Back compatibility with callback before the onBeforeRenderObservable existed.
  112817. * The set callback will be triggered just before rendering the layer.
  112818. */
  112819. onBeforeRender: () => void;
  112820. /**
  112821. * An event triggered after rendering the scene
  112822. */
  112823. onAfterRenderObservable: Observable<Layer>;
  112824. private _onAfterRenderObserver;
  112825. /**
  112826. * Back compatibility with callback before the onAfterRenderObservable existed.
  112827. * The set callback will be triggered just after rendering the layer.
  112828. */
  112829. onAfterRender: () => void;
  112830. /**
  112831. * Instantiates a new layer.
  112832. * This represents a full screen 2d layer.
  112833. * This can be useful to display a picture in the background of your scene for instance.
  112834. * @see https://www.babylonjs-playground.com/#08A2BS#1
  112835. * @param name Define the name of the layer in the scene
  112836. * @param imgUrl Define the url of the texture to display in the layer
  112837. * @param scene Define the scene the layer belongs to
  112838. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  112839. * @param color Defines a color for the layer
  112840. */
  112841. constructor(
  112842. /**
  112843. * Define the name of the layer.
  112844. */
  112845. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  112846. private _createIndexBuffer;
  112847. /** @hidden */
  112848. _rebuild(): void;
  112849. /**
  112850. * Renders the layer in the scene.
  112851. */
  112852. render(): void;
  112853. /**
  112854. * Disposes and releases the associated ressources.
  112855. */
  112856. dispose(): void;
  112857. }
  112858. }
  112859. declare module BABYLON {
  112860. /** @hidden */
  112861. export var lensFlarePixelShader: {
  112862. name: string;
  112863. shader: string;
  112864. };
  112865. }
  112866. declare module BABYLON {
  112867. /** @hidden */
  112868. export var lensFlareVertexShader: {
  112869. name: string;
  112870. shader: string;
  112871. };
  112872. }
  112873. declare module BABYLON {
  112874. /**
  112875. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112876. * It is usually composed of several `lensFlare`.
  112877. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112878. */
  112879. export class LensFlareSystem {
  112880. /**
  112881. * Define the name of the lens flare system
  112882. */
  112883. name: string;
  112884. /**
  112885. * List of lens flares used in this system.
  112886. */
  112887. lensFlares: LensFlare[];
  112888. /**
  112889. * Define a limit from the border the lens flare can be visible.
  112890. */
  112891. borderLimit: number;
  112892. /**
  112893. * Define a viewport border we do not want to see the lens flare in.
  112894. */
  112895. viewportBorder: number;
  112896. /**
  112897. * Define a predicate which could limit the list of meshes able to occlude the effect.
  112898. */
  112899. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112900. /**
  112901. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  112902. */
  112903. layerMask: number;
  112904. /**
  112905. * Define the id of the lens flare system in the scene.
  112906. * (equal to name by default)
  112907. */
  112908. id: string;
  112909. private _scene;
  112910. private _emitter;
  112911. private _vertexBuffers;
  112912. private _indexBuffer;
  112913. private _effect;
  112914. private _positionX;
  112915. private _positionY;
  112916. private _isEnabled;
  112917. /** @hidden */
  112918. static _SceneComponentInitialization: (scene: Scene) => void;
  112919. /**
  112920. * Instantiates a lens flare system.
  112921. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112922. * It is usually composed of several `lensFlare`.
  112923. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112924. * @param name Define the name of the lens flare system in the scene
  112925. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  112926. * @param scene Define the scene the lens flare system belongs to
  112927. */
  112928. constructor(
  112929. /**
  112930. * Define the name of the lens flare system
  112931. */
  112932. name: string, emitter: any, scene: Scene);
  112933. /**
  112934. * Define if the lens flare system is enabled.
  112935. */
  112936. isEnabled: boolean;
  112937. /**
  112938. * Get the scene the effects belongs to.
  112939. * @returns the scene holding the lens flare system
  112940. */
  112941. getScene(): Scene;
  112942. /**
  112943. * Get the emitter of the lens flare system.
  112944. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  112945. * @returns the emitter of the lens flare system
  112946. */
  112947. getEmitter(): any;
  112948. /**
  112949. * Set the emitter of the lens flare system.
  112950. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  112951. * @param newEmitter Define the new emitter of the system
  112952. */
  112953. setEmitter(newEmitter: any): void;
  112954. /**
  112955. * Get the lens flare system emitter position.
  112956. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  112957. * @returns the position
  112958. */
  112959. getEmitterPosition(): Vector3;
  112960. /**
  112961. * @hidden
  112962. */
  112963. computeEffectivePosition(globalViewport: Viewport): boolean;
  112964. /** @hidden */
  112965. _isVisible(): boolean;
  112966. /**
  112967. * @hidden
  112968. */
  112969. render(): boolean;
  112970. /**
  112971. * Dispose and release the lens flare with its associated resources.
  112972. */
  112973. dispose(): void;
  112974. /**
  112975. * Parse a lens flare system from a JSON repressentation
  112976. * @param parsedLensFlareSystem Define the JSON to parse
  112977. * @param scene Define the scene the parsed system should be instantiated in
  112978. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  112979. * @returns the parsed system
  112980. */
  112981. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  112982. /**
  112983. * Serialize the current Lens Flare System into a JSON representation.
  112984. * @returns the serialized JSON
  112985. */
  112986. serialize(): any;
  112987. }
  112988. }
  112989. declare module BABYLON {
  112990. /**
  112991. * This represents one of the lens effect in a `lensFlareSystem`.
  112992. * It controls one of the indiviual texture used in the effect.
  112993. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112994. */
  112995. export class LensFlare {
  112996. /**
  112997. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  112998. */
  112999. size: number;
  113000. /**
  113001. * 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.
  113002. */
  113003. position: number;
  113004. /**
  113005. * Define the lens color.
  113006. */
  113007. color: Color3;
  113008. /**
  113009. * Define the lens texture.
  113010. */
  113011. texture: Nullable<Texture>;
  113012. /**
  113013. * Define the alpha mode to render this particular lens.
  113014. */
  113015. alphaMode: number;
  113016. private _system;
  113017. /**
  113018. * Creates a new Lens Flare.
  113019. * This represents one of the lens effect in a `lensFlareSystem`.
  113020. * It controls one of the indiviual texture used in the effect.
  113021. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113022. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  113023. * @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.
  113024. * @param color Define the lens color
  113025. * @param imgUrl Define the lens texture url
  113026. * @param system Define the `lensFlareSystem` this flare is part of
  113027. * @returns The newly created Lens Flare
  113028. */
  113029. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  113030. /**
  113031. * Instantiates a new Lens Flare.
  113032. * This represents one of the lens effect in a `lensFlareSystem`.
  113033. * It controls one of the indiviual texture used in the effect.
  113034. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113035. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  113036. * @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.
  113037. * @param color Define the lens color
  113038. * @param imgUrl Define the lens texture url
  113039. * @param system Define the `lensFlareSystem` this flare is part of
  113040. */
  113041. constructor(
  113042. /**
  113043. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  113044. */
  113045. size: number,
  113046. /**
  113047. * 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.
  113048. */
  113049. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  113050. /**
  113051. * Dispose and release the lens flare with its associated resources.
  113052. */
  113053. dispose(): void;
  113054. }
  113055. }
  113056. declare module BABYLON {
  113057. interface AbstractScene {
  113058. /**
  113059. * The list of lens flare system added to the scene
  113060. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113061. */
  113062. lensFlareSystems: Array<LensFlareSystem>;
  113063. /**
  113064. * Removes the given lens flare system from this scene.
  113065. * @param toRemove The lens flare system to remove
  113066. * @returns The index of the removed lens flare system
  113067. */
  113068. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  113069. /**
  113070. * Adds the given lens flare system to this scene
  113071. * @param newLensFlareSystem The lens flare system to add
  113072. */
  113073. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  113074. /**
  113075. * Gets a lens flare system using its name
  113076. * @param name defines the name to look for
  113077. * @returns the lens flare system or null if not found
  113078. */
  113079. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  113080. /**
  113081. * Gets a lens flare system using its id
  113082. * @param id defines the id to look for
  113083. * @returns the lens flare system or null if not found
  113084. */
  113085. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  113086. }
  113087. /**
  113088. * Defines the lens flare scene component responsible to manage any lens flares
  113089. * in a given scene.
  113090. */
  113091. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  113092. /**
  113093. * The component name helpfull to identify the component in the list of scene components.
  113094. */
  113095. readonly name: string;
  113096. /**
  113097. * The scene the component belongs to.
  113098. */
  113099. scene: Scene;
  113100. /**
  113101. * Creates a new instance of the component for the given scene
  113102. * @param scene Defines the scene to register the component in
  113103. */
  113104. constructor(scene: Scene);
  113105. /**
  113106. * Registers the component in a given scene
  113107. */
  113108. register(): void;
  113109. /**
  113110. * Rebuilds the elements related to this component in case of
  113111. * context lost for instance.
  113112. */
  113113. rebuild(): void;
  113114. /**
  113115. * Adds all the elements from the container to the scene
  113116. * @param container the container holding the elements
  113117. */
  113118. addFromContainer(container: AbstractScene): void;
  113119. /**
  113120. * Removes all the elements in the container from the scene
  113121. * @param container contains the elements to remove
  113122. * @param dispose if the removed element should be disposed (default: false)
  113123. */
  113124. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113125. /**
  113126. * Serializes the component data to the specified json object
  113127. * @param serializationObject The object to serialize to
  113128. */
  113129. serialize(serializationObject: any): void;
  113130. /**
  113131. * Disposes the component and the associated ressources.
  113132. */
  113133. dispose(): void;
  113134. private _draw;
  113135. }
  113136. }
  113137. declare module BABYLON {
  113138. /**
  113139. * Defines the shadow generator component responsible to manage any shadow generators
  113140. * in a given scene.
  113141. */
  113142. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  113143. /**
  113144. * The component name helpfull to identify the component in the list of scene components.
  113145. */
  113146. readonly name: string;
  113147. /**
  113148. * The scene the component belongs to.
  113149. */
  113150. scene: Scene;
  113151. /**
  113152. * Creates a new instance of the component for the given scene
  113153. * @param scene Defines the scene to register the component in
  113154. */
  113155. constructor(scene: Scene);
  113156. /**
  113157. * Registers the component in a given scene
  113158. */
  113159. register(): void;
  113160. /**
  113161. * Rebuilds the elements related to this component in case of
  113162. * context lost for instance.
  113163. */
  113164. rebuild(): void;
  113165. /**
  113166. * Serializes the component data to the specified json object
  113167. * @param serializationObject The object to serialize to
  113168. */
  113169. serialize(serializationObject: any): void;
  113170. /**
  113171. * Adds all the elements from the container to the scene
  113172. * @param container the container holding the elements
  113173. */
  113174. addFromContainer(container: AbstractScene): void;
  113175. /**
  113176. * Removes all the elements in the container from the scene
  113177. * @param container contains the elements to remove
  113178. * @param dispose if the removed element should be disposed (default: false)
  113179. */
  113180. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113181. /**
  113182. * Rebuilds the elements related to this component in case of
  113183. * context lost for instance.
  113184. */
  113185. dispose(): void;
  113186. private _gatherRenderTargets;
  113187. }
  113188. }
  113189. declare module BABYLON {
  113190. /**
  113191. * A point light is a light defined by an unique point in world space.
  113192. * The light is emitted in every direction from this point.
  113193. * A good example of a point light is a standard light bulb.
  113194. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113195. */
  113196. export class PointLight extends ShadowLight {
  113197. private _shadowAngle;
  113198. /**
  113199. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113200. * This specifies what angle the shadow will use to be created.
  113201. *
  113202. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  113203. */
  113204. /**
  113205. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113206. * This specifies what angle the shadow will use to be created.
  113207. *
  113208. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  113209. */
  113210. shadowAngle: number;
  113211. /**
  113212. * Gets the direction if it has been set.
  113213. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113214. */
  113215. /**
  113216. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113217. */
  113218. direction: Vector3;
  113219. /**
  113220. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  113221. * A PointLight emits the light in every direction.
  113222. * It can cast shadows.
  113223. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  113224. * ```javascript
  113225. * var pointLight = new PointLight("pl", camera.position, scene);
  113226. * ```
  113227. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113228. * @param name The light friendly name
  113229. * @param position The position of the point light in the scene
  113230. * @param scene The scene the lights belongs to
  113231. */
  113232. constructor(name: string, position: Vector3, scene: Scene);
  113233. /**
  113234. * Returns the string "PointLight"
  113235. * @returns the class name
  113236. */
  113237. getClassName(): string;
  113238. /**
  113239. * Returns the integer 0.
  113240. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113241. */
  113242. getTypeID(): number;
  113243. /**
  113244. * Specifies wether or not the shadowmap should be a cube texture.
  113245. * @returns true if the shadowmap needs to be a cube texture.
  113246. */
  113247. needCube(): boolean;
  113248. /**
  113249. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  113250. * @param faceIndex The index of the face we are computed the direction to generate shadow
  113251. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  113252. */
  113253. getShadowDirection(faceIndex?: number): Vector3;
  113254. /**
  113255. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  113256. * - fov = PI / 2
  113257. * - aspect ratio : 1.0
  113258. * - z-near and far equal to the active camera minZ and maxZ.
  113259. * Returns the PointLight.
  113260. */
  113261. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113262. protected _buildUniformLayout(): void;
  113263. /**
  113264. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  113265. * @param effect The effect to update
  113266. * @param lightIndex The index of the light in the effect to update
  113267. * @returns The point light
  113268. */
  113269. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  113270. /**
  113271. * Prepares the list of defines specific to the light type.
  113272. * @param defines the list of defines
  113273. * @param lightIndex defines the index of the light for the effect
  113274. */
  113275. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113276. }
  113277. }
  113278. declare module BABYLON {
  113279. /**
  113280. * Header information of HDR texture files.
  113281. */
  113282. export interface HDRInfo {
  113283. /**
  113284. * The height of the texture in pixels.
  113285. */
  113286. height: number;
  113287. /**
  113288. * The width of the texture in pixels.
  113289. */
  113290. width: number;
  113291. /**
  113292. * The index of the beginning of the data in the binary file.
  113293. */
  113294. dataPosition: number;
  113295. }
  113296. /**
  113297. * This groups tools to convert HDR texture to native colors array.
  113298. */
  113299. export class HDRTools {
  113300. private static Ldexp;
  113301. private static Rgbe2float;
  113302. private static readStringLine;
  113303. /**
  113304. * Reads header information from an RGBE texture stored in a native array.
  113305. * More information on this format are available here:
  113306. * https://en.wikipedia.org/wiki/RGBE_image_format
  113307. *
  113308. * @param uint8array The binary file stored in native array.
  113309. * @return The header information.
  113310. */
  113311. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  113312. /**
  113313. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  113314. * This RGBE texture needs to store the information as a panorama.
  113315. *
  113316. * More information on this format are available here:
  113317. * https://en.wikipedia.org/wiki/RGBE_image_format
  113318. *
  113319. * @param buffer The binary file stored in an array buffer.
  113320. * @param size The expected size of the extracted cubemap.
  113321. * @return The Cube Map information.
  113322. */
  113323. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  113324. /**
  113325. * Returns the pixels data extracted from an RGBE texture.
  113326. * This pixels will be stored left to right up to down in the R G B order in one array.
  113327. *
  113328. * More information on this format are available here:
  113329. * https://en.wikipedia.org/wiki/RGBE_image_format
  113330. *
  113331. * @param uint8array The binary file stored in an array buffer.
  113332. * @param hdrInfo The header information of the file.
  113333. * @return The pixels data in RGB right to left up to down order.
  113334. */
  113335. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  113336. private static RGBE_ReadPixels_RLE;
  113337. }
  113338. }
  113339. declare module BABYLON {
  113340. /**
  113341. * This represents a texture coming from an HDR input.
  113342. *
  113343. * The only supported format is currently panorama picture stored in RGBE format.
  113344. * Example of such files can be found on HDRLib: http://hdrlib.com/
  113345. */
  113346. export class HDRCubeTexture extends BaseTexture {
  113347. private static _facesMapping;
  113348. private _generateHarmonics;
  113349. private _noMipmap;
  113350. private _textureMatrix;
  113351. private _size;
  113352. private _onLoad;
  113353. private _onError;
  113354. /**
  113355. * The texture URL.
  113356. */
  113357. url: string;
  113358. /**
  113359. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  113360. */
  113361. coordinatesMode: number;
  113362. protected _isBlocking: boolean;
  113363. /**
  113364. * Sets wether or not the texture is blocking during loading.
  113365. */
  113366. /**
  113367. * Gets wether or not the texture is blocking during loading.
  113368. */
  113369. isBlocking: boolean;
  113370. protected _rotationY: number;
  113371. /**
  113372. * Sets texture matrix rotation angle around Y axis in radians.
  113373. */
  113374. /**
  113375. * Gets texture matrix rotation angle around Y axis radians.
  113376. */
  113377. rotationY: number;
  113378. /**
  113379. * Gets or sets the center of the bounding box associated with the cube texture
  113380. * It must define where the camera used to render the texture was set
  113381. */
  113382. boundingBoxPosition: Vector3;
  113383. private _boundingBoxSize;
  113384. /**
  113385. * Gets or sets the size of the bounding box associated with the cube texture
  113386. * When defined, the cubemap will switch to local mode
  113387. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  113388. * @example https://www.babylonjs-playground.com/#RNASML
  113389. */
  113390. boundingBoxSize: Vector3;
  113391. /**
  113392. * Instantiates an HDRTexture from the following parameters.
  113393. *
  113394. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  113395. * @param scene The scene the texture will be used in
  113396. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113397. * @param noMipmap Forces to not generate the mipmap if true
  113398. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  113399. * @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)
  113400. * @param reserved Reserved flag for internal use.
  113401. */
  113402. 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>);
  113403. /**
  113404. * Get the current class name of the texture useful for serialization or dynamic coding.
  113405. * @returns "HDRCubeTexture"
  113406. */
  113407. getClassName(): string;
  113408. /**
  113409. * Occurs when the file is raw .hdr file.
  113410. */
  113411. private loadTexture;
  113412. clone(): HDRCubeTexture;
  113413. delayLoad(): void;
  113414. /**
  113415. * Get the texture reflection matrix used to rotate/transform the reflection.
  113416. * @returns the reflection matrix
  113417. */
  113418. getReflectionTextureMatrix(): Matrix;
  113419. /**
  113420. * Set the texture reflection matrix used to rotate/transform the reflection.
  113421. * @param value Define the reflection matrix to set
  113422. */
  113423. setReflectionTextureMatrix(value: Matrix): void;
  113424. /**
  113425. * Parses a JSON representation of an HDR Texture in order to create the texture
  113426. * @param parsedTexture Define the JSON representation
  113427. * @param scene Define the scene the texture should be created in
  113428. * @param rootUrl Define the root url in case we need to load relative dependencies
  113429. * @returns the newly created texture after parsing
  113430. */
  113431. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  113432. serialize(): any;
  113433. }
  113434. }
  113435. declare module BABYLON {
  113436. /**
  113437. * Class used to control physics engine
  113438. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  113439. */
  113440. export class PhysicsEngine implements IPhysicsEngine {
  113441. private _physicsPlugin;
  113442. /**
  113443. * Global value used to control the smallest number supported by the simulation
  113444. */
  113445. static Epsilon: number;
  113446. private _impostors;
  113447. private _joints;
  113448. /**
  113449. * Gets the gravity vector used by the simulation
  113450. */
  113451. gravity: Vector3;
  113452. /**
  113453. * Factory used to create the default physics plugin.
  113454. * @returns The default physics plugin
  113455. */
  113456. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  113457. /**
  113458. * Creates a new Physics Engine
  113459. * @param gravity defines the gravity vector used by the simulation
  113460. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  113461. */
  113462. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  113463. /**
  113464. * Sets the gravity vector used by the simulation
  113465. * @param gravity defines the gravity vector to use
  113466. */
  113467. setGravity(gravity: Vector3): void;
  113468. /**
  113469. * Set the time step of the physics engine.
  113470. * Default is 1/60.
  113471. * To slow it down, enter 1/600 for example.
  113472. * To speed it up, 1/30
  113473. * @param newTimeStep defines the new timestep to apply to this world.
  113474. */
  113475. setTimeStep(newTimeStep?: number): void;
  113476. /**
  113477. * Get the time step of the physics engine.
  113478. * @returns the current time step
  113479. */
  113480. getTimeStep(): number;
  113481. /**
  113482. * Release all resources
  113483. */
  113484. dispose(): void;
  113485. /**
  113486. * Gets the name of the current physics plugin
  113487. * @returns the name of the plugin
  113488. */
  113489. getPhysicsPluginName(): string;
  113490. /**
  113491. * Adding a new impostor for the impostor tracking.
  113492. * This will be done by the impostor itself.
  113493. * @param impostor the impostor to add
  113494. */
  113495. addImpostor(impostor: PhysicsImpostor): void;
  113496. /**
  113497. * Remove an impostor from the engine.
  113498. * This impostor and its mesh will not longer be updated by the physics engine.
  113499. * @param impostor the impostor to remove
  113500. */
  113501. removeImpostor(impostor: PhysicsImpostor): void;
  113502. /**
  113503. * Add a joint to the physics engine
  113504. * @param mainImpostor defines the main impostor to which the joint is added.
  113505. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113506. * @param joint defines the joint that will connect both impostors.
  113507. */
  113508. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113509. /**
  113510. * Removes a joint from the simulation
  113511. * @param mainImpostor defines the impostor used with the joint
  113512. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113513. * @param joint defines the joint to remove
  113514. */
  113515. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113516. /**
  113517. * Called by the scene. No need to call it.
  113518. * @param delta defines the timespam between frames
  113519. */
  113520. _step(delta: number): void;
  113521. /**
  113522. * Gets the current plugin used to run the simulation
  113523. * @returns current plugin
  113524. */
  113525. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113526. /**
  113527. * Gets the list of physic impostors
  113528. * @returns an array of PhysicsImpostor
  113529. */
  113530. getImpostors(): Array<PhysicsImpostor>;
  113531. /**
  113532. * Gets the impostor for a physics enabled object
  113533. * @param object defines the object impersonated by the impostor
  113534. * @returns the PhysicsImpostor or null if not found
  113535. */
  113536. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113537. /**
  113538. * Gets the impostor for a physics body object
  113539. * @param body defines physics body used by the impostor
  113540. * @returns the PhysicsImpostor or null if not found
  113541. */
  113542. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113543. /**
  113544. * Does a raycast in the physics world
  113545. * @param from when should the ray start?
  113546. * @param to when should the ray end?
  113547. * @returns PhysicsRaycastResult
  113548. */
  113549. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113550. }
  113551. }
  113552. declare module BABYLON {
  113553. /** @hidden */
  113554. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  113555. private _useDeltaForWorldStep;
  113556. world: any;
  113557. name: string;
  113558. private _physicsMaterials;
  113559. private _fixedTimeStep;
  113560. private _cannonRaycastResult;
  113561. private _raycastResult;
  113562. private _physicsBodysToRemoveAfterStep;
  113563. BJSCANNON: any;
  113564. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  113565. setGravity(gravity: Vector3): void;
  113566. setTimeStep(timeStep: number): void;
  113567. getTimeStep(): number;
  113568. executeStep(delta: number): void;
  113569. private _removeMarkedPhysicsBodiesFromWorld;
  113570. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113571. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113572. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113573. private _processChildMeshes;
  113574. removePhysicsBody(impostor: PhysicsImpostor): void;
  113575. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113576. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113577. private _addMaterial;
  113578. private _checkWithEpsilon;
  113579. private _createShape;
  113580. private _createHeightmap;
  113581. private _minus90X;
  113582. private _plus90X;
  113583. private _tmpPosition;
  113584. private _tmpDeltaPosition;
  113585. private _tmpUnityRotation;
  113586. private _updatePhysicsBodyTransformation;
  113587. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113588. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113589. isSupported(): boolean;
  113590. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113591. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113592. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113593. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113594. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113595. getBodyMass(impostor: PhysicsImpostor): number;
  113596. getBodyFriction(impostor: PhysicsImpostor): number;
  113597. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113598. getBodyRestitution(impostor: PhysicsImpostor): number;
  113599. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113600. sleepBody(impostor: PhysicsImpostor): void;
  113601. wakeUpBody(impostor: PhysicsImpostor): void;
  113602. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  113603. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  113604. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  113605. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113606. getRadius(impostor: PhysicsImpostor): number;
  113607. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113608. dispose(): void;
  113609. private _extendNamespace;
  113610. /**
  113611. * Does a raycast in the physics world
  113612. * @param from when should the ray start?
  113613. * @param to when should the ray end?
  113614. * @returns PhysicsRaycastResult
  113615. */
  113616. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113617. }
  113618. }
  113619. declare module BABYLON {
  113620. /** @hidden */
  113621. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  113622. world: any;
  113623. name: string;
  113624. BJSOIMO: any;
  113625. private _raycastResult;
  113626. constructor(iterations?: number, oimoInjection?: any);
  113627. setGravity(gravity: Vector3): void;
  113628. setTimeStep(timeStep: number): void;
  113629. getTimeStep(): number;
  113630. private _tmpImpostorsArray;
  113631. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113632. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113633. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113634. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113635. private _tmpPositionVector;
  113636. removePhysicsBody(impostor: PhysicsImpostor): void;
  113637. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113638. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113639. isSupported(): boolean;
  113640. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113641. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113642. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113643. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113644. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113645. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113646. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113647. getBodyMass(impostor: PhysicsImpostor): number;
  113648. getBodyFriction(impostor: PhysicsImpostor): number;
  113649. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113650. getBodyRestitution(impostor: PhysicsImpostor): number;
  113651. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113652. sleepBody(impostor: PhysicsImpostor): void;
  113653. wakeUpBody(impostor: PhysicsImpostor): void;
  113654. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113655. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  113656. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  113657. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113658. getRadius(impostor: PhysicsImpostor): number;
  113659. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113660. dispose(): void;
  113661. /**
  113662. * Does a raycast in the physics world
  113663. * @param from when should the ray start?
  113664. * @param to when should the ray end?
  113665. * @returns PhysicsRaycastResult
  113666. */
  113667. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113668. }
  113669. }
  113670. declare module BABYLON {
  113671. /**
  113672. * Class containing static functions to help procedurally build meshes
  113673. */
  113674. export class RibbonBuilder {
  113675. /**
  113676. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  113677. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  113678. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  113679. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  113680. * * 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
  113681. * * 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
  113682. * * 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
  113683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113685. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113686. * * 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
  113687. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  113688. * * 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
  113689. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  113690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113691. * @param name defines the name of the mesh
  113692. * @param options defines the options used to create the mesh
  113693. * @param scene defines the hosting scene
  113694. * @returns the ribbon mesh
  113695. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  113696. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113697. */
  113698. static CreateRibbon(name: string, options: {
  113699. pathArray: Vector3[][];
  113700. closeArray?: boolean;
  113701. closePath?: boolean;
  113702. offset?: number;
  113703. updatable?: boolean;
  113704. sideOrientation?: number;
  113705. frontUVs?: Vector4;
  113706. backUVs?: Vector4;
  113707. instance?: Mesh;
  113708. invertUV?: boolean;
  113709. uvs?: Vector2[];
  113710. colors?: Color4[];
  113711. }, scene?: Nullable<Scene>): Mesh;
  113712. }
  113713. }
  113714. declare module BABYLON {
  113715. /**
  113716. * Class containing static functions to help procedurally build meshes
  113717. */
  113718. export class ShapeBuilder {
  113719. /**
  113720. * 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.
  113721. * * 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.
  113722. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  113723. * * 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.
  113724. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  113725. * * 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
  113726. * * 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
  113727. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  113728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113730. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  113731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113732. * @param name defines the name of the mesh
  113733. * @param options defines the options used to create the mesh
  113734. * @param scene defines the hosting scene
  113735. * @returns the extruded shape mesh
  113736. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113737. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113738. */
  113739. static ExtrudeShape(name: string, options: {
  113740. shape: Vector3[];
  113741. path: Vector3[];
  113742. scale?: number;
  113743. rotation?: number;
  113744. cap?: number;
  113745. updatable?: boolean;
  113746. sideOrientation?: number;
  113747. frontUVs?: Vector4;
  113748. backUVs?: Vector4;
  113749. instance?: Mesh;
  113750. invertUV?: boolean;
  113751. }, scene?: Nullable<Scene>): Mesh;
  113752. /**
  113753. * Creates an custom extruded shape mesh.
  113754. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  113755. * * 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.
  113756. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  113757. * * 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
  113758. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  113759. * * 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
  113760. * * It must returns a float value that will be the scale value applied to the shape on each path point
  113761. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  113762. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  113763. * * 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
  113764. * * 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
  113765. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  113766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113768. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113770. * @param name defines the name of the mesh
  113771. * @param options defines the options used to create the mesh
  113772. * @param scene defines the hosting scene
  113773. * @returns the custom extruded shape mesh
  113774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  113775. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113776. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113777. */
  113778. static ExtrudeShapeCustom(name: string, options: {
  113779. shape: Vector3[];
  113780. path: Vector3[];
  113781. scaleFunction?: any;
  113782. rotationFunction?: any;
  113783. ribbonCloseArray?: boolean;
  113784. ribbonClosePath?: boolean;
  113785. cap?: number;
  113786. updatable?: boolean;
  113787. sideOrientation?: number;
  113788. frontUVs?: Vector4;
  113789. backUVs?: Vector4;
  113790. instance?: Mesh;
  113791. invertUV?: boolean;
  113792. }, scene?: Nullable<Scene>): Mesh;
  113793. private static _ExtrudeShapeGeneric;
  113794. }
  113795. }
  113796. declare module BABYLON {
  113797. /**
  113798. * AmmoJS Physics plugin
  113799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113800. * @see https://github.com/kripken/ammo.js/
  113801. */
  113802. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  113803. private _useDeltaForWorldStep;
  113804. /**
  113805. * Reference to the Ammo library
  113806. */
  113807. bjsAMMO: any;
  113808. /**
  113809. * Created ammoJS world which physics bodies are added to
  113810. */
  113811. world: any;
  113812. /**
  113813. * Name of the plugin
  113814. */
  113815. name: string;
  113816. private _timeStep;
  113817. private _fixedTimeStep;
  113818. private _maxSteps;
  113819. private _tmpQuaternion;
  113820. private _tmpAmmoTransform;
  113821. private _tmpAmmoQuaternion;
  113822. private _tmpAmmoConcreteContactResultCallback;
  113823. private _collisionConfiguration;
  113824. private _dispatcher;
  113825. private _overlappingPairCache;
  113826. private _solver;
  113827. private _softBodySolver;
  113828. private _tmpAmmoVectorA;
  113829. private _tmpAmmoVectorB;
  113830. private _tmpAmmoVectorC;
  113831. private _tmpAmmoVectorD;
  113832. private _tmpContactCallbackResult;
  113833. private _tmpAmmoVectorRCA;
  113834. private _tmpAmmoVectorRCB;
  113835. private _raycastResult;
  113836. private static readonly DISABLE_COLLISION_FLAG;
  113837. private static readonly KINEMATIC_FLAG;
  113838. private static readonly DISABLE_DEACTIVATION_FLAG;
  113839. /**
  113840. * Initializes the ammoJS plugin
  113841. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  113842. * @param ammoInjection can be used to inject your own ammo reference
  113843. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  113844. */
  113845. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  113846. /**
  113847. * Sets the gravity of the physics world (m/(s^2))
  113848. * @param gravity Gravity to set
  113849. */
  113850. setGravity(gravity: Vector3): void;
  113851. /**
  113852. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  113853. * @param timeStep timestep to use in seconds
  113854. */
  113855. setTimeStep(timeStep: number): void;
  113856. /**
  113857. * 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)
  113858. * @param fixedTimeStep fixedTimeStep to use in seconds
  113859. */
  113860. setFixedTimeStep(fixedTimeStep: number): void;
  113861. /**
  113862. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  113863. * @param maxSteps the maximum number of steps by the physics engine per frame
  113864. */
  113865. setMaxSteps(maxSteps: number): void;
  113866. /**
  113867. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  113868. * @returns the current timestep in seconds
  113869. */
  113870. getTimeStep(): number;
  113871. private _isImpostorInContact;
  113872. private _isImpostorPairInContact;
  113873. private _stepSimulation;
  113874. /**
  113875. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  113876. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  113877. * After the step the babylon meshes are set to the position of the physics imposters
  113878. * @param delta amount of time to step forward
  113879. * @param impostors array of imposters to update before/after the step
  113880. */
  113881. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113882. /**
  113883. * Update babylon mesh to match physics world object
  113884. * @param impostor imposter to match
  113885. */
  113886. private _afterSoftStep;
  113887. /**
  113888. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113889. * @param impostor imposter to match
  113890. */
  113891. private _ropeStep;
  113892. /**
  113893. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113894. * @param impostor imposter to match
  113895. */
  113896. private _softbodyOrClothStep;
  113897. private _tmpVector;
  113898. private _tmpMatrix;
  113899. /**
  113900. * Applies an impulse on the imposter
  113901. * @param impostor imposter to apply impulse to
  113902. * @param force amount of force to be applied to the imposter
  113903. * @param contactPoint the location to apply the impulse on the imposter
  113904. */
  113905. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113906. /**
  113907. * Applies a force on the imposter
  113908. * @param impostor imposter to apply force
  113909. * @param force amount of force to be applied to the imposter
  113910. * @param contactPoint the location to apply the force on the imposter
  113911. */
  113912. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113913. /**
  113914. * Creates a physics body using the plugin
  113915. * @param impostor the imposter to create the physics body on
  113916. */
  113917. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113918. /**
  113919. * Removes the physics body from the imposter and disposes of the body's memory
  113920. * @param impostor imposter to remove the physics body from
  113921. */
  113922. removePhysicsBody(impostor: PhysicsImpostor): void;
  113923. /**
  113924. * Generates a joint
  113925. * @param impostorJoint the imposter joint to create the joint with
  113926. */
  113927. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113928. /**
  113929. * Removes a joint
  113930. * @param impostorJoint the imposter joint to remove the joint from
  113931. */
  113932. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113933. private _addMeshVerts;
  113934. /**
  113935. * Initialise the soft body vertices to match its object's (mesh) vertices
  113936. * Softbody vertices (nodes) are in world space and to match this
  113937. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  113938. * @param impostor to create the softbody for
  113939. */
  113940. private _softVertexData;
  113941. /**
  113942. * Create an impostor's soft body
  113943. * @param impostor to create the softbody for
  113944. */
  113945. private _createSoftbody;
  113946. /**
  113947. * Create cloth for an impostor
  113948. * @param impostor to create the softbody for
  113949. */
  113950. private _createCloth;
  113951. /**
  113952. * Create rope for an impostor
  113953. * @param impostor to create the softbody for
  113954. */
  113955. private _createRope;
  113956. private _addHullVerts;
  113957. private _createShape;
  113958. /**
  113959. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  113960. * @param impostor imposter containing the physics body and babylon object
  113961. */
  113962. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113963. /**
  113964. * Sets the babylon object's position/rotation from the physics body's position/rotation
  113965. * @param impostor imposter containing the physics body and babylon object
  113966. * @param newPosition new position
  113967. * @param newRotation new rotation
  113968. */
  113969. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113970. /**
  113971. * If this plugin is supported
  113972. * @returns true if its supported
  113973. */
  113974. isSupported(): boolean;
  113975. /**
  113976. * Sets the linear velocity of the physics body
  113977. * @param impostor imposter to set the velocity on
  113978. * @param velocity velocity to set
  113979. */
  113980. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113981. /**
  113982. * Sets the angular velocity of the physics body
  113983. * @param impostor imposter to set the velocity on
  113984. * @param velocity velocity to set
  113985. */
  113986. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113987. /**
  113988. * gets the linear velocity
  113989. * @param impostor imposter to get linear velocity from
  113990. * @returns linear velocity
  113991. */
  113992. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113993. /**
  113994. * gets the angular velocity
  113995. * @param impostor imposter to get angular velocity from
  113996. * @returns angular velocity
  113997. */
  113998. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113999. /**
  114000. * Sets the mass of physics body
  114001. * @param impostor imposter to set the mass on
  114002. * @param mass mass to set
  114003. */
  114004. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114005. /**
  114006. * Gets the mass of the physics body
  114007. * @param impostor imposter to get the mass from
  114008. * @returns mass
  114009. */
  114010. getBodyMass(impostor: PhysicsImpostor): number;
  114011. /**
  114012. * Gets friction of the impostor
  114013. * @param impostor impostor to get friction from
  114014. * @returns friction value
  114015. */
  114016. getBodyFriction(impostor: PhysicsImpostor): number;
  114017. /**
  114018. * Sets friction of the impostor
  114019. * @param impostor impostor to set friction on
  114020. * @param friction friction value
  114021. */
  114022. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114023. /**
  114024. * Gets restitution of the impostor
  114025. * @param impostor impostor to get restitution from
  114026. * @returns restitution value
  114027. */
  114028. getBodyRestitution(impostor: PhysicsImpostor): number;
  114029. /**
  114030. * Sets resitution of the impostor
  114031. * @param impostor impostor to set resitution on
  114032. * @param restitution resitution value
  114033. */
  114034. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114035. /**
  114036. * Gets pressure inside the impostor
  114037. * @param impostor impostor to get pressure from
  114038. * @returns pressure value
  114039. */
  114040. getBodyPressure(impostor: PhysicsImpostor): number;
  114041. /**
  114042. * Sets pressure inside a soft body impostor
  114043. * Cloth and rope must remain 0 pressure
  114044. * @param impostor impostor to set pressure on
  114045. * @param pressure pressure value
  114046. */
  114047. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  114048. /**
  114049. * Gets stiffness of the impostor
  114050. * @param impostor impostor to get stiffness from
  114051. * @returns pressure value
  114052. */
  114053. getBodyStiffness(impostor: PhysicsImpostor): number;
  114054. /**
  114055. * Sets stiffness of the impostor
  114056. * @param impostor impostor to set stiffness on
  114057. * @param stiffness stiffness value from 0 to 1
  114058. */
  114059. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  114060. /**
  114061. * Gets velocityIterations of the impostor
  114062. * @param impostor impostor to get velocity iterations from
  114063. * @returns velocityIterations value
  114064. */
  114065. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  114066. /**
  114067. * Sets velocityIterations of the impostor
  114068. * @param impostor impostor to set velocity iterations on
  114069. * @param velocityIterations velocityIterations value
  114070. */
  114071. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  114072. /**
  114073. * Gets positionIterations of the impostor
  114074. * @param impostor impostor to get position iterations from
  114075. * @returns positionIterations value
  114076. */
  114077. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  114078. /**
  114079. * Sets positionIterations of the impostor
  114080. * @param impostor impostor to set position on
  114081. * @param positionIterations positionIterations value
  114082. */
  114083. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  114084. /**
  114085. * Append an anchor to a cloth object
  114086. * @param impostor is the cloth impostor to add anchor to
  114087. * @param otherImpostor is the rigid impostor to anchor to
  114088. * @param width ratio across width from 0 to 1
  114089. * @param height ratio up height from 0 to 1
  114090. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  114091. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114092. */
  114093. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  114094. /**
  114095. * Append an hook to a rope object
  114096. * @param impostor is the rope impostor to add hook to
  114097. * @param otherImpostor is the rigid impostor to hook to
  114098. * @param length ratio along the rope from 0 to 1
  114099. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  114100. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114101. */
  114102. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  114103. /**
  114104. * Sleeps the physics body and stops it from being active
  114105. * @param impostor impostor to sleep
  114106. */
  114107. sleepBody(impostor: PhysicsImpostor): void;
  114108. /**
  114109. * Activates the physics body
  114110. * @param impostor impostor to activate
  114111. */
  114112. wakeUpBody(impostor: PhysicsImpostor): void;
  114113. /**
  114114. * Updates the distance parameters of the joint
  114115. * @param joint joint to update
  114116. * @param maxDistance maximum distance of the joint
  114117. * @param minDistance minimum distance of the joint
  114118. */
  114119. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  114120. /**
  114121. * Sets a motor on the joint
  114122. * @param joint joint to set motor on
  114123. * @param speed speed of the motor
  114124. * @param maxForce maximum force of the motor
  114125. * @param motorIndex index of the motor
  114126. */
  114127. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  114128. /**
  114129. * Sets the motors limit
  114130. * @param joint joint to set limit on
  114131. * @param upperLimit upper limit
  114132. * @param lowerLimit lower limit
  114133. */
  114134. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  114135. /**
  114136. * Syncs the position and rotation of a mesh with the impostor
  114137. * @param mesh mesh to sync
  114138. * @param impostor impostor to update the mesh with
  114139. */
  114140. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114141. /**
  114142. * Gets the radius of the impostor
  114143. * @param impostor impostor to get radius from
  114144. * @returns the radius
  114145. */
  114146. getRadius(impostor: PhysicsImpostor): number;
  114147. /**
  114148. * Gets the box size of the impostor
  114149. * @param impostor impostor to get box size from
  114150. * @param result the resulting box size
  114151. */
  114152. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114153. /**
  114154. * Disposes of the impostor
  114155. */
  114156. dispose(): void;
  114157. /**
  114158. * Does a raycast in the physics world
  114159. * @param from when should the ray start?
  114160. * @param to when should the ray end?
  114161. * @returns PhysicsRaycastResult
  114162. */
  114163. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114164. }
  114165. }
  114166. declare module BABYLON {
  114167. interface AbstractScene {
  114168. /**
  114169. * The list of reflection probes added to the scene
  114170. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  114171. */
  114172. reflectionProbes: Array<ReflectionProbe>;
  114173. /**
  114174. * Removes the given reflection probe from this scene.
  114175. * @param toRemove The reflection probe to remove
  114176. * @returns The index of the removed reflection probe
  114177. */
  114178. removeReflectionProbe(toRemove: ReflectionProbe): number;
  114179. /**
  114180. * Adds the given reflection probe to this scene.
  114181. * @param newReflectionProbe The reflection probe to add
  114182. */
  114183. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  114184. }
  114185. /**
  114186. * Class used to generate realtime reflection / refraction cube textures
  114187. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  114188. */
  114189. export class ReflectionProbe {
  114190. /** defines the name of the probe */
  114191. name: string;
  114192. private _scene;
  114193. private _renderTargetTexture;
  114194. private _projectionMatrix;
  114195. private _viewMatrix;
  114196. private _target;
  114197. private _add;
  114198. private _attachedMesh;
  114199. private _invertYAxis;
  114200. /** Gets or sets probe position (center of the cube map) */
  114201. position: Vector3;
  114202. /**
  114203. * Creates a new reflection probe
  114204. * @param name defines the name of the probe
  114205. * @param size defines the texture resolution (for each face)
  114206. * @param scene defines the hosting scene
  114207. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  114208. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  114209. */
  114210. constructor(
  114211. /** defines the name of the probe */
  114212. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  114213. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  114214. samples: number;
  114215. /** Gets or sets the refresh rate to use (on every frame by default) */
  114216. refreshRate: number;
  114217. /**
  114218. * Gets the hosting scene
  114219. * @returns a Scene
  114220. */
  114221. getScene(): Scene;
  114222. /** Gets the internal CubeTexture used to render to */
  114223. readonly cubeTexture: RenderTargetTexture;
  114224. /** Gets the list of meshes to render */
  114225. readonly renderList: Nullable<AbstractMesh[]>;
  114226. /**
  114227. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  114228. * @param mesh defines the mesh to attach to
  114229. */
  114230. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114231. /**
  114232. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  114233. * @param renderingGroupId The rendering group id corresponding to its index
  114234. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  114235. */
  114236. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  114237. /**
  114238. * Clean all associated resources
  114239. */
  114240. dispose(): void;
  114241. /**
  114242. * Converts the reflection probe information to a readable string for debug purpose.
  114243. * @param fullDetails Supports for multiple levels of logging within scene loading
  114244. * @returns the human readable reflection probe info
  114245. */
  114246. toString(fullDetails?: boolean): string;
  114247. /**
  114248. * Get the class name of the relfection probe.
  114249. * @returns "ReflectionProbe"
  114250. */
  114251. getClassName(): string;
  114252. /**
  114253. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  114254. * @returns The JSON representation of the texture
  114255. */
  114256. serialize(): any;
  114257. /**
  114258. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  114259. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  114260. * @param scene Define the scene the parsed reflection probe should be instantiated in
  114261. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  114262. * @returns The parsed reflection probe if successful
  114263. */
  114264. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  114265. }
  114266. }
  114267. declare module BABYLON {
  114268. /** @hidden */
  114269. export var _BabylonLoaderRegistered: boolean;
  114270. }
  114271. declare module BABYLON {
  114272. /**
  114273. * The Physically based simple base material of BJS.
  114274. *
  114275. * This enables better naming and convention enforcements on top of the pbrMaterial.
  114276. * It is used as the base class for both the specGloss and metalRough conventions.
  114277. */
  114278. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  114279. /**
  114280. * Number of Simultaneous lights allowed on the material.
  114281. */
  114282. maxSimultaneousLights: number;
  114283. /**
  114284. * If sets to true, disables all the lights affecting the material.
  114285. */
  114286. disableLighting: boolean;
  114287. /**
  114288. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  114289. */
  114290. environmentTexture: BaseTexture;
  114291. /**
  114292. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114293. */
  114294. invertNormalMapX: boolean;
  114295. /**
  114296. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114297. */
  114298. invertNormalMapY: boolean;
  114299. /**
  114300. * Normal map used in the model.
  114301. */
  114302. normalTexture: BaseTexture;
  114303. /**
  114304. * Emissivie color used to self-illuminate the model.
  114305. */
  114306. emissiveColor: Color3;
  114307. /**
  114308. * Emissivie texture used to self-illuminate the model.
  114309. */
  114310. emissiveTexture: BaseTexture;
  114311. /**
  114312. * Occlusion Channel Strenght.
  114313. */
  114314. occlusionStrength: number;
  114315. /**
  114316. * Occlusion Texture of the material (adding extra occlusion effects).
  114317. */
  114318. occlusionTexture: BaseTexture;
  114319. /**
  114320. * Defines the alpha limits in alpha test mode.
  114321. */
  114322. alphaCutOff: number;
  114323. /**
  114324. * Gets the current double sided mode.
  114325. */
  114326. /**
  114327. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114328. */
  114329. doubleSided: boolean;
  114330. /**
  114331. * Stores the pre-calculated light information of a mesh in a texture.
  114332. */
  114333. lightmapTexture: BaseTexture;
  114334. /**
  114335. * If true, the light map contains occlusion information instead of lighting info.
  114336. */
  114337. useLightmapAsShadowmap: boolean;
  114338. /**
  114339. * Instantiates a new PBRMaterial instance.
  114340. *
  114341. * @param name The material name
  114342. * @param scene The scene the material will be use in.
  114343. */
  114344. constructor(name: string, scene: Scene);
  114345. getClassName(): string;
  114346. }
  114347. }
  114348. declare module BABYLON {
  114349. /**
  114350. * The PBR material of BJS following the metal roughness convention.
  114351. *
  114352. * This fits to the PBR convention in the GLTF definition:
  114353. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  114354. */
  114355. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  114356. /**
  114357. * The base color has two different interpretations depending on the value of metalness.
  114358. * When the material is a metal, the base color is the specific measured reflectance value
  114359. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  114360. * of the material.
  114361. */
  114362. baseColor: Color3;
  114363. /**
  114364. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  114365. * well as opacity information in the alpha channel.
  114366. */
  114367. baseTexture: BaseTexture;
  114368. /**
  114369. * Specifies the metallic scalar value of the material.
  114370. * Can also be used to scale the metalness values of the metallic texture.
  114371. */
  114372. metallic: number;
  114373. /**
  114374. * Specifies the roughness scalar value of the material.
  114375. * Can also be used to scale the roughness values of the metallic texture.
  114376. */
  114377. roughness: number;
  114378. /**
  114379. * Texture containing both the metallic value in the B channel and the
  114380. * roughness value in the G channel to keep better precision.
  114381. */
  114382. metallicRoughnessTexture: BaseTexture;
  114383. /**
  114384. * Instantiates a new PBRMetalRoughnessMaterial instance.
  114385. *
  114386. * @param name The material name
  114387. * @param scene The scene the material will be use in.
  114388. */
  114389. constructor(name: string, scene: Scene);
  114390. /**
  114391. * Return the currrent class name of the material.
  114392. */
  114393. getClassName(): string;
  114394. /**
  114395. * Makes a duplicate of the current material.
  114396. * @param name - name to use for the new material.
  114397. */
  114398. clone(name: string): PBRMetallicRoughnessMaterial;
  114399. /**
  114400. * Serialize the material to a parsable JSON object.
  114401. */
  114402. serialize(): any;
  114403. /**
  114404. * Parses a JSON object correponding to the serialize function.
  114405. */
  114406. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  114407. }
  114408. }
  114409. declare module BABYLON {
  114410. /**
  114411. * The PBR material of BJS following the specular glossiness convention.
  114412. *
  114413. * This fits to the PBR convention in the GLTF definition:
  114414. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  114415. */
  114416. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  114417. /**
  114418. * Specifies the diffuse color of the material.
  114419. */
  114420. diffuseColor: Color3;
  114421. /**
  114422. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  114423. * channel.
  114424. */
  114425. diffuseTexture: BaseTexture;
  114426. /**
  114427. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  114428. */
  114429. specularColor: Color3;
  114430. /**
  114431. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  114432. */
  114433. glossiness: number;
  114434. /**
  114435. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  114436. */
  114437. specularGlossinessTexture: BaseTexture;
  114438. /**
  114439. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  114440. *
  114441. * @param name The material name
  114442. * @param scene The scene the material will be use in.
  114443. */
  114444. constructor(name: string, scene: Scene);
  114445. /**
  114446. * Return the currrent class name of the material.
  114447. */
  114448. getClassName(): string;
  114449. /**
  114450. * Makes a duplicate of the current material.
  114451. * @param name - name to use for the new material.
  114452. */
  114453. clone(name: string): PBRSpecularGlossinessMaterial;
  114454. /**
  114455. * Serialize the material to a parsable JSON object.
  114456. */
  114457. serialize(): any;
  114458. /**
  114459. * Parses a JSON object correponding to the serialize function.
  114460. */
  114461. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  114462. }
  114463. }
  114464. declare module BABYLON {
  114465. /**
  114466. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  114467. * It can help converting any input color in a desired output one. This can then be used to create effects
  114468. * from sepia, black and white to sixties or futuristic rendering...
  114469. *
  114470. * The only supported format is currently 3dl.
  114471. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  114472. */
  114473. export class ColorGradingTexture extends BaseTexture {
  114474. /**
  114475. * The current texture matrix. (will always be identity in color grading texture)
  114476. */
  114477. private _textureMatrix;
  114478. /**
  114479. * The texture URL.
  114480. */
  114481. url: string;
  114482. /**
  114483. * Empty line regex stored for GC.
  114484. */
  114485. private static _noneEmptyLineRegex;
  114486. private _engine;
  114487. /**
  114488. * Instantiates a ColorGradingTexture from the following parameters.
  114489. *
  114490. * @param url The location of the color gradind data (currently only supporting 3dl)
  114491. * @param scene The scene the texture will be used in
  114492. */
  114493. constructor(url: string, scene: Scene);
  114494. /**
  114495. * Returns the texture matrix used in most of the material.
  114496. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  114497. */
  114498. getTextureMatrix(): Matrix;
  114499. /**
  114500. * Occurs when the file being loaded is a .3dl LUT file.
  114501. */
  114502. private load3dlTexture;
  114503. /**
  114504. * Starts the loading process of the texture.
  114505. */
  114506. private loadTexture;
  114507. /**
  114508. * Clones the color gradind texture.
  114509. */
  114510. clone(): ColorGradingTexture;
  114511. /**
  114512. * Called during delayed load for textures.
  114513. */
  114514. delayLoad(): void;
  114515. /**
  114516. * Parses a color grading texture serialized by Babylon.
  114517. * @param parsedTexture The texture information being parsedTexture
  114518. * @param scene The scene to load the texture in
  114519. * @param rootUrl The root url of the data assets to load
  114520. * @return A color gradind texture
  114521. */
  114522. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  114523. /**
  114524. * Serializes the LUT texture to json format.
  114525. */
  114526. serialize(): any;
  114527. }
  114528. }
  114529. declare module BABYLON {
  114530. /**
  114531. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  114532. */
  114533. export class EquiRectangularCubeTexture extends BaseTexture {
  114534. /** The six faces of the cube. */
  114535. private static _FacesMapping;
  114536. private _noMipmap;
  114537. private _onLoad;
  114538. private _onError;
  114539. /** The size of the cubemap. */
  114540. private _size;
  114541. /** The buffer of the image. */
  114542. private _buffer;
  114543. /** The width of the input image. */
  114544. private _width;
  114545. /** The height of the input image. */
  114546. private _height;
  114547. /** The URL to the image. */
  114548. url: string;
  114549. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  114550. coordinatesMode: number;
  114551. /**
  114552. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  114553. * @param url The location of the image
  114554. * @param scene The scene the texture will be used in
  114555. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114556. * @param noMipmap Forces to not generate the mipmap if true
  114557. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114558. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114559. * @param onLoad — defines a callback called when texture is loaded
  114560. * @param onError — defines a callback called if there is an error
  114561. */
  114562. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  114563. /**
  114564. * Load the image data, by putting the image on a canvas and extracting its buffer.
  114565. */
  114566. private loadImage;
  114567. /**
  114568. * Convert the image buffer into a cubemap and create a CubeTexture.
  114569. */
  114570. private loadTexture;
  114571. /**
  114572. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  114573. * @param buffer The ArrayBuffer that should be converted.
  114574. * @returns The buffer as Float32Array.
  114575. */
  114576. private getFloat32ArrayFromArrayBuffer;
  114577. /**
  114578. * Get the current class name of the texture useful for serialization or dynamic coding.
  114579. * @returns "EquiRectangularCubeTexture"
  114580. */
  114581. getClassName(): string;
  114582. /**
  114583. * Create a clone of the current EquiRectangularCubeTexture and return it.
  114584. * @returns A clone of the current EquiRectangularCubeTexture.
  114585. */
  114586. clone(): EquiRectangularCubeTexture;
  114587. }
  114588. }
  114589. declare module BABYLON {
  114590. /**
  114591. * Based on jsTGALoader - Javascript loader for TGA file
  114592. * By Vincent Thibault
  114593. * @see http://blog.robrowser.com/javascript-tga-loader.html
  114594. */
  114595. export class TGATools {
  114596. private static _TYPE_INDEXED;
  114597. private static _TYPE_RGB;
  114598. private static _TYPE_GREY;
  114599. private static _TYPE_RLE_INDEXED;
  114600. private static _TYPE_RLE_RGB;
  114601. private static _TYPE_RLE_GREY;
  114602. private static _ORIGIN_MASK;
  114603. private static _ORIGIN_SHIFT;
  114604. private static _ORIGIN_BL;
  114605. private static _ORIGIN_BR;
  114606. private static _ORIGIN_UL;
  114607. private static _ORIGIN_UR;
  114608. /**
  114609. * Gets the header of a TGA file
  114610. * @param data defines the TGA data
  114611. * @returns the header
  114612. */
  114613. static GetTGAHeader(data: Uint8Array): any;
  114614. /**
  114615. * Uploads TGA content to a Babylon Texture
  114616. * @hidden
  114617. */
  114618. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  114619. /** @hidden */
  114620. 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;
  114621. /** @hidden */
  114622. 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;
  114623. /** @hidden */
  114624. 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;
  114625. /** @hidden */
  114626. 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;
  114627. /** @hidden */
  114628. 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;
  114629. /** @hidden */
  114630. 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;
  114631. }
  114632. }
  114633. declare module BABYLON {
  114634. /**
  114635. * Implementation of the TGA Texture Loader.
  114636. * @hidden
  114637. */
  114638. export class _TGATextureLoader implements IInternalTextureLoader {
  114639. /**
  114640. * Defines wether the loader supports cascade loading the different faces.
  114641. */
  114642. readonly supportCascades: boolean;
  114643. /**
  114644. * This returns if the loader support the current file information.
  114645. * @param extension defines the file extension of the file being loaded
  114646. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114647. * @param fallback defines the fallback internal texture if any
  114648. * @param isBase64 defines whether the texture is encoded as a base64
  114649. * @param isBuffer defines whether the texture data are stored as a buffer
  114650. * @returns true if the loader can load the specified file
  114651. */
  114652. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114653. /**
  114654. * Transform the url before loading if required.
  114655. * @param rootUrl the url of the texture
  114656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114657. * @returns the transformed texture
  114658. */
  114659. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114660. /**
  114661. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114662. * @param rootUrl the url of the texture
  114663. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114664. * @returns the fallback texture
  114665. */
  114666. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114667. /**
  114668. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114669. * @param data contains the texture data
  114670. * @param texture defines the BabylonJS internal texture
  114671. * @param createPolynomials will be true if polynomials have been requested
  114672. * @param onLoad defines the callback to trigger once the texture is ready
  114673. * @param onError defines the callback to trigger in case of error
  114674. */
  114675. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114676. /**
  114677. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114678. * @param data contains the texture data
  114679. * @param texture defines the BabylonJS internal texture
  114680. * @param callback defines the method to call once ready to upload
  114681. */
  114682. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114683. }
  114684. }
  114685. declare module BABYLON {
  114686. /**
  114687. * Info about the .basis files
  114688. */
  114689. class BasisFileInfo {
  114690. /**
  114691. * If the file has alpha
  114692. */
  114693. hasAlpha: boolean;
  114694. /**
  114695. * Info about each image of the basis file
  114696. */
  114697. images: Array<{
  114698. levels: Array<{
  114699. width: number;
  114700. height: number;
  114701. transcodedPixels: ArrayBufferView;
  114702. }>;
  114703. }>;
  114704. }
  114705. /**
  114706. * Result of transcoding a basis file
  114707. */
  114708. class TranscodeResult {
  114709. /**
  114710. * Info about the .basis file
  114711. */
  114712. fileInfo: BasisFileInfo;
  114713. /**
  114714. * Format to use when loading the file
  114715. */
  114716. format: number;
  114717. }
  114718. /**
  114719. * Configuration options for the Basis transcoder
  114720. */
  114721. export class BasisTranscodeConfiguration {
  114722. /**
  114723. * Supported compression formats used to determine the supported output format of the transcoder
  114724. */
  114725. supportedCompressionFormats?: {
  114726. /**
  114727. * etc1 compression format
  114728. */
  114729. etc1?: boolean;
  114730. /**
  114731. * s3tc compression format
  114732. */
  114733. s3tc?: boolean;
  114734. /**
  114735. * pvrtc compression format
  114736. */
  114737. pvrtc?: boolean;
  114738. /**
  114739. * etc2 compression format
  114740. */
  114741. etc2?: boolean;
  114742. };
  114743. /**
  114744. * If mipmap levels should be loaded for transcoded images (Default: true)
  114745. */
  114746. loadMipmapLevels?: boolean;
  114747. /**
  114748. * Index of a single image to load (Default: all images)
  114749. */
  114750. loadSingleImage?: number;
  114751. }
  114752. /**
  114753. * Used to load .Basis files
  114754. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  114755. */
  114756. export class BasisTools {
  114757. private static _IgnoreSupportedFormats;
  114758. /**
  114759. * URL to use when loading the basis transcoder
  114760. */
  114761. static JSModuleURL: string;
  114762. /**
  114763. * URL to use when loading the wasm module for the transcoder
  114764. */
  114765. static WasmModuleURL: string;
  114766. /**
  114767. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  114768. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  114769. * @returns internal format corresponding to the Basis format
  114770. */
  114771. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  114772. private static _WorkerPromise;
  114773. private static _Worker;
  114774. private static _actionId;
  114775. private static _CreateWorkerAsync;
  114776. /**
  114777. * Transcodes a loaded image file to compressed pixel data
  114778. * @param imageData image data to transcode
  114779. * @param config configuration options for the transcoding
  114780. * @returns a promise resulting in the transcoded image
  114781. */
  114782. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  114783. /**
  114784. * Loads a texture from the transcode result
  114785. * @param texture texture load to
  114786. * @param transcodeResult the result of transcoding the basis file to load from
  114787. */
  114788. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  114789. }
  114790. }
  114791. declare module BABYLON {
  114792. /**
  114793. * Loader for .basis file format
  114794. */
  114795. export class _BasisTextureLoader implements IInternalTextureLoader {
  114796. /**
  114797. * Defines whether the loader supports cascade loading the different faces.
  114798. */
  114799. readonly supportCascades: boolean;
  114800. /**
  114801. * This returns if the loader support the current file information.
  114802. * @param extension defines the file extension of the file being loaded
  114803. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114804. * @param fallback defines the fallback internal texture if any
  114805. * @param isBase64 defines whether the texture is encoded as a base64
  114806. * @param isBuffer defines whether the texture data are stored as a buffer
  114807. * @returns true if the loader can load the specified file
  114808. */
  114809. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114810. /**
  114811. * Transform the url before loading if required.
  114812. * @param rootUrl the url of the texture
  114813. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114814. * @returns the transformed texture
  114815. */
  114816. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114817. /**
  114818. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114819. * @param rootUrl the url of the texture
  114820. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114821. * @returns the fallback texture
  114822. */
  114823. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114824. /**
  114825. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  114826. * @param data contains the texture data
  114827. * @param texture defines the BabylonJS internal texture
  114828. * @param createPolynomials will be true if polynomials have been requested
  114829. * @param onLoad defines the callback to trigger once the texture is ready
  114830. * @param onError defines the callback to trigger in case of error
  114831. */
  114832. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114833. /**
  114834. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114835. * @param data contains the texture data
  114836. * @param texture defines the BabylonJS internal texture
  114837. * @param callback defines the method to call once ready to upload
  114838. */
  114839. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114840. }
  114841. }
  114842. declare module BABYLON {
  114843. /**
  114844. * 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.
  114845. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  114846. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  114847. */
  114848. export class CustomProceduralTexture extends ProceduralTexture {
  114849. private _animate;
  114850. private _time;
  114851. private _config;
  114852. private _texturePath;
  114853. /**
  114854. * Instantiates a new Custom Procedural Texture.
  114855. * 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.
  114856. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  114857. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  114858. * @param name Define the name of the texture
  114859. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  114860. * @param size Define the size of the texture to create
  114861. * @param scene Define the scene the texture belongs to
  114862. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  114863. * @param generateMipMaps Define if the texture should creates mip maps or not
  114864. */
  114865. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114866. private _loadJson;
  114867. /**
  114868. * Is the texture ready to be used ? (rendered at least once)
  114869. * @returns true if ready, otherwise, false.
  114870. */
  114871. isReady(): boolean;
  114872. /**
  114873. * Render the texture to its associated render target.
  114874. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  114875. */
  114876. render(useCameraPostProcess?: boolean): void;
  114877. /**
  114878. * Update the list of dependant textures samplers in the shader.
  114879. */
  114880. updateTextures(): void;
  114881. /**
  114882. * Update the uniform values of the procedural texture in the shader.
  114883. */
  114884. updateShaderUniforms(): void;
  114885. /**
  114886. * Define if the texture animates or not.
  114887. */
  114888. animate: boolean;
  114889. }
  114890. }
  114891. declare module BABYLON {
  114892. /** @hidden */
  114893. export var noisePixelShader: {
  114894. name: string;
  114895. shader: string;
  114896. };
  114897. }
  114898. declare module BABYLON {
  114899. /**
  114900. * Class used to generate noise procedural textures
  114901. */
  114902. export class NoiseProceduralTexture extends ProceduralTexture {
  114903. private _time;
  114904. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  114905. brightness: number;
  114906. /** Defines the number of octaves to process */
  114907. octaves: number;
  114908. /** Defines the level of persistence (0.8 by default) */
  114909. persistence: number;
  114910. /** Gets or sets animation speed factor (default is 1) */
  114911. animationSpeedFactor: number;
  114912. /**
  114913. * Creates a new NoiseProceduralTexture
  114914. * @param name defines the name fo the texture
  114915. * @param size defines the size of the texture (default is 256)
  114916. * @param scene defines the hosting scene
  114917. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  114918. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  114919. */
  114920. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114921. private _updateShaderUniforms;
  114922. protected _getDefines(): string;
  114923. /** Generate the current state of the procedural texture */
  114924. render(useCameraPostProcess?: boolean): void;
  114925. /**
  114926. * Serializes this noise procedural texture
  114927. * @returns a serialized noise procedural texture object
  114928. */
  114929. serialize(): any;
  114930. /**
  114931. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  114932. * @param parsedTexture defines parsed texture data
  114933. * @param scene defines the current scene
  114934. * @param rootUrl defines the root URL containing noise procedural texture information
  114935. * @returns a parsed NoiseProceduralTexture
  114936. */
  114937. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  114938. }
  114939. }
  114940. declare module BABYLON {
  114941. /**
  114942. * Raw cube texture where the raw buffers are passed in
  114943. */
  114944. export class RawCubeTexture extends CubeTexture {
  114945. /**
  114946. * Creates a cube texture where the raw buffers are passed in.
  114947. * @param scene defines the scene the texture is attached to
  114948. * @param data defines the array of data to use to create each face
  114949. * @param size defines the size of the textures
  114950. * @param format defines the format of the data
  114951. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  114952. * @param generateMipMaps defines if the engine should generate the mip levels
  114953. * @param invertY defines if data must be stored with Y axis inverted
  114954. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  114955. * @param compression defines the compression used (null by default)
  114956. */
  114957. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  114958. /**
  114959. * Updates the raw cube texture.
  114960. * @param data defines the data to store
  114961. * @param format defines the data format
  114962. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114963. * @param invertY defines if data must be stored with Y axis inverted
  114964. * @param compression defines the compression used (null by default)
  114965. * @param level defines which level of the texture to update
  114966. */
  114967. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  114968. /**
  114969. * Updates a raw cube texture with RGBD encoded data.
  114970. * @param data defines the array of data [mipmap][face] to use to create each face
  114971. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  114972. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  114973. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  114974. * @returns a promsie that resolves when the operation is complete
  114975. */
  114976. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  114977. /**
  114978. * Clones the raw cube texture.
  114979. * @return a new cube texture
  114980. */
  114981. clone(): CubeTexture;
  114982. /** @hidden */
  114983. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  114984. }
  114985. }
  114986. declare module BABYLON {
  114987. /**
  114988. * Class used to store 3D textures containing user data
  114989. */
  114990. export class RawTexture3D extends Texture {
  114991. /** Gets or sets the texture format to use */
  114992. format: number;
  114993. private _engine;
  114994. /**
  114995. * Create a new RawTexture3D
  114996. * @param data defines the data of the texture
  114997. * @param width defines the width of the texture
  114998. * @param height defines the height of the texture
  114999. * @param depth defines the depth of the texture
  115000. * @param format defines the texture format to use
  115001. * @param scene defines the hosting scene
  115002. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  115003. * @param invertY defines if texture must be stored with Y axis inverted
  115004. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115005. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  115006. */
  115007. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  115008. /** Gets or sets the texture format to use */
  115009. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  115010. /**
  115011. * Update the texture with new data
  115012. * @param data defines the data to store in the texture
  115013. */
  115014. update(data: ArrayBufferView): void;
  115015. }
  115016. }
  115017. declare module BABYLON {
  115018. /**
  115019. * Creates a refraction texture used by refraction channel of the standard material.
  115020. * It is like a mirror but to see through a material.
  115021. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115022. */
  115023. export class RefractionTexture extends RenderTargetTexture {
  115024. /**
  115025. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  115026. * 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.
  115027. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115028. */
  115029. refractionPlane: Plane;
  115030. /**
  115031. * Define how deep under the surface we should see.
  115032. */
  115033. depth: number;
  115034. /**
  115035. * Creates a refraction texture used by refraction channel of the standard material.
  115036. * It is like a mirror but to see through a material.
  115037. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115038. * @param name Define the texture name
  115039. * @param size Define the size of the underlying texture
  115040. * @param scene Define the scene the refraction belongs to
  115041. * @param generateMipMaps Define if we need to generate mips level for the refraction
  115042. */
  115043. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  115044. /**
  115045. * Clone the refraction texture.
  115046. * @returns the cloned texture
  115047. */
  115048. clone(): RefractionTexture;
  115049. /**
  115050. * Serialize the texture to a JSON representation you could use in Parse later on
  115051. * @returns the serialized JSON representation
  115052. */
  115053. serialize(): any;
  115054. }
  115055. }
  115056. declare module BABYLON {
  115057. /**
  115058. * Defines the options related to the creation of an HtmlElementTexture
  115059. */
  115060. export interface IHtmlElementTextureOptions {
  115061. /**
  115062. * Defines wether mip maps should be created or not.
  115063. */
  115064. generateMipMaps?: boolean;
  115065. /**
  115066. * Defines the sampling mode of the texture.
  115067. */
  115068. samplingMode?: number;
  115069. /**
  115070. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  115071. */
  115072. engine: Nullable<Engine>;
  115073. /**
  115074. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  115075. */
  115076. scene: Nullable<Scene>;
  115077. }
  115078. /**
  115079. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  115080. * To be as efficient as possible depending on your constraints nothing aside the first upload
  115081. * is automatically managed.
  115082. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  115083. * in your application.
  115084. *
  115085. * As the update is not automatic, you need to call them manually.
  115086. */
  115087. export class HtmlElementTexture extends BaseTexture {
  115088. /**
  115089. * The texture URL.
  115090. */
  115091. element: HTMLVideoElement | HTMLCanvasElement;
  115092. private static readonly DefaultOptions;
  115093. private _textureMatrix;
  115094. private _engine;
  115095. private _isVideo;
  115096. private _generateMipMaps;
  115097. private _samplingMode;
  115098. /**
  115099. * Instantiates a HtmlElementTexture from the following parameters.
  115100. *
  115101. * @param name Defines the name of the texture
  115102. * @param element Defines the video or canvas the texture is filled with
  115103. * @param options Defines the other none mandatory texture creation options
  115104. */
  115105. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  115106. private _createInternalTexture;
  115107. /**
  115108. * Returns the texture matrix used in most of the material.
  115109. */
  115110. getTextureMatrix(): Matrix;
  115111. /**
  115112. * Updates the content of the texture.
  115113. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  115114. */
  115115. update(invertY?: Nullable<boolean>): void;
  115116. }
  115117. }
  115118. declare module BABYLON {
  115119. /**
  115120. * Enum used to define the target of a block
  115121. */
  115122. export enum NodeMaterialBlockTargets {
  115123. /** Vertex shader */
  115124. Vertex = 1,
  115125. /** Fragment shader */
  115126. Fragment = 2,
  115127. /** Neutral */
  115128. Neutral = 4,
  115129. /** Vertex and Fragment */
  115130. VertexAndFragment = 3
  115131. }
  115132. }
  115133. declare module BABYLON {
  115134. /**
  115135. * Defines the kind of connection point for node based material
  115136. */
  115137. export enum NodeMaterialBlockConnectionPointTypes {
  115138. /** Float */
  115139. Float = 1,
  115140. /** Int */
  115141. Int = 2,
  115142. /** Vector2 */
  115143. Vector2 = 4,
  115144. /** Vector3 */
  115145. Vector3 = 8,
  115146. /** Vector4 */
  115147. Vector4 = 16,
  115148. /** Color3 */
  115149. Color3 = 32,
  115150. /** Color4 */
  115151. Color4 = 64,
  115152. /** Matrix */
  115153. Matrix = 128,
  115154. /** Detect type based on connection */
  115155. AutoDetect = 1024,
  115156. /** Output type that will be defined by input type */
  115157. BasedOnInput = 2048
  115158. }
  115159. }
  115160. declare module BABYLON {
  115161. /**
  115162. * Root class for all node material optimizers
  115163. */
  115164. export class NodeMaterialOptimizer {
  115165. /**
  115166. * Function used to optimize a NodeMaterial graph
  115167. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  115168. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  115169. */
  115170. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  115171. }
  115172. }
  115173. declare module BABYLON {
  115174. /**
  115175. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  115176. */
  115177. export class TransformBlock extends NodeMaterialBlock {
  115178. /**
  115179. * Defines the value to use to complement W value to transform it to a Vector4
  115180. */
  115181. complementW: number;
  115182. /**
  115183. * Defines the value to use to complement z value to transform it to a Vector4
  115184. */
  115185. complementZ: number;
  115186. /**
  115187. * Creates a new TransformBlock
  115188. * @param name defines the block name
  115189. */
  115190. constructor(name: string);
  115191. /**
  115192. * Gets the current class name
  115193. * @returns the class name
  115194. */
  115195. getClassName(): string;
  115196. /**
  115197. * Gets the vector input
  115198. */
  115199. readonly vector: NodeMaterialConnectionPoint;
  115200. /**
  115201. * Gets the output component
  115202. */
  115203. readonly output: NodeMaterialConnectionPoint;
  115204. /**
  115205. * Gets the matrix transform input
  115206. */
  115207. readonly transform: NodeMaterialConnectionPoint;
  115208. protected _buildBlock(state: NodeMaterialBuildState): this;
  115209. serialize(): any;
  115210. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115211. }
  115212. }
  115213. declare module BABYLON {
  115214. /**
  115215. * Block used to output the vertex position
  115216. */
  115217. export class VertexOutputBlock extends NodeMaterialBlock {
  115218. /**
  115219. * Creates a new VertexOutputBlock
  115220. * @param name defines the block name
  115221. */
  115222. constructor(name: string);
  115223. /**
  115224. * Gets the current class name
  115225. * @returns the class name
  115226. */
  115227. getClassName(): string;
  115228. /**
  115229. * Gets the vector input component
  115230. */
  115231. readonly vector: NodeMaterialConnectionPoint;
  115232. protected _buildBlock(state: NodeMaterialBuildState): this;
  115233. }
  115234. }
  115235. declare module BABYLON {
  115236. /**
  115237. * Block used to output the final color
  115238. */
  115239. export class FragmentOutputBlock extends NodeMaterialBlock {
  115240. /**
  115241. * Create a new FragmentOutputBlock
  115242. * @param name defines the block name
  115243. */
  115244. constructor(name: string);
  115245. /**
  115246. * Gets the current class name
  115247. * @returns the class name
  115248. */
  115249. getClassName(): string;
  115250. /**
  115251. * Gets the rgba input component
  115252. */
  115253. readonly rgba: NodeMaterialConnectionPoint;
  115254. /**
  115255. * Gets the rgb input component
  115256. */
  115257. readonly rgb: NodeMaterialConnectionPoint;
  115258. /**
  115259. * Gets the a input component
  115260. */
  115261. readonly a: NodeMaterialConnectionPoint;
  115262. protected _buildBlock(state: NodeMaterialBuildState): this;
  115263. }
  115264. }
  115265. declare module BABYLON {
  115266. /**
  115267. * Interface used to configure the node material editor
  115268. */
  115269. export interface INodeMaterialEditorOptions {
  115270. /** Define the URl to load node editor script */
  115271. editorURL?: string;
  115272. }
  115273. /** @hidden */
  115274. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  115275. /** BONES */
  115276. NUM_BONE_INFLUENCERS: number;
  115277. BonesPerMesh: number;
  115278. BONETEXTURE: boolean;
  115279. /** MORPH TARGETS */
  115280. MORPHTARGETS: boolean;
  115281. MORPHTARGETS_NORMAL: boolean;
  115282. MORPHTARGETS_TANGENT: boolean;
  115283. MORPHTARGETS_UV: boolean;
  115284. NUM_MORPH_INFLUENCERS: number;
  115285. /** IMAGE PROCESSING */
  115286. IMAGEPROCESSING: boolean;
  115287. VIGNETTE: boolean;
  115288. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115289. VIGNETTEBLENDMODEOPAQUE: boolean;
  115290. TONEMAPPING: boolean;
  115291. TONEMAPPING_ACES: boolean;
  115292. CONTRAST: boolean;
  115293. EXPOSURE: boolean;
  115294. COLORCURVES: boolean;
  115295. COLORGRADING: boolean;
  115296. COLORGRADING3D: boolean;
  115297. SAMPLER3DGREENDEPTH: boolean;
  115298. SAMPLER3DBGRMAP: boolean;
  115299. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115300. constructor();
  115301. setValue(name: string, value: boolean): void;
  115302. }
  115303. /**
  115304. * Class used to configure NodeMaterial
  115305. */
  115306. export interface INodeMaterialOptions {
  115307. /**
  115308. * Defines if blocks should emit comments
  115309. */
  115310. emitComments: boolean;
  115311. }
  115312. /**
  115313. * Class used to create a node based material built by assembling shader blocks
  115314. */
  115315. export class NodeMaterial extends PushMaterial {
  115316. private _options;
  115317. private _vertexCompilationState;
  115318. private _fragmentCompilationState;
  115319. private _sharedData;
  115320. private _buildId;
  115321. private _buildWasSuccessful;
  115322. private _cachedWorldViewMatrix;
  115323. private _cachedWorldViewProjectionMatrix;
  115324. private _optimizers;
  115325. /** Define the URl to load node editor script */
  115326. static EditorURL: string;
  115327. private BJSNODEMATERIALEDITOR;
  115328. /** Get the inspector from bundle or global */
  115329. private _getGlobalNodeMaterialEditor;
  115330. /**
  115331. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  115332. */
  115333. ignoreAlpha: boolean;
  115334. /**
  115335. * Defines the maximum number of lights that can be used in the material
  115336. */
  115337. maxSimultaneousLights: number;
  115338. /**
  115339. * Observable raised when the material is built
  115340. */
  115341. onBuildObservable: Observable<NodeMaterial>;
  115342. /**
  115343. * Gets or sets the root nodes of the material vertex shader
  115344. */
  115345. _vertexOutputNodes: NodeMaterialBlock[];
  115346. /**
  115347. * Gets or sets the root nodes of the material fragment (pixel) shader
  115348. */
  115349. _fragmentOutputNodes: NodeMaterialBlock[];
  115350. /** Gets or sets options to control the node material overall behavior */
  115351. options: INodeMaterialOptions;
  115352. /**
  115353. * Default configuration related to image processing available in the standard Material.
  115354. */
  115355. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115356. /**
  115357. * Gets the image processing configuration used either in this material.
  115358. */
  115359. /**
  115360. * Sets the Default image processing configuration used either in the this material.
  115361. *
  115362. * If sets to null, the scene one is in use.
  115363. */
  115364. imageProcessingConfiguration: ImageProcessingConfiguration;
  115365. /**
  115366. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  115367. */
  115368. attachedBlocks: NodeMaterialBlock[];
  115369. /**
  115370. * Create a new node based material
  115371. * @param name defines the material name
  115372. * @param scene defines the hosting scene
  115373. * @param options defines creation option
  115374. */
  115375. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  115376. /**
  115377. * Gets the current class name of the material e.g. "NodeMaterial"
  115378. * @returns the class name
  115379. */
  115380. getClassName(): string;
  115381. /**
  115382. * Keep track of the image processing observer to allow dispose and replace.
  115383. */
  115384. private _imageProcessingObserver;
  115385. /**
  115386. * Attaches a new image processing configuration to the Standard Material.
  115387. * @param configuration
  115388. */
  115389. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115390. /**
  115391. * Adds a new optimizer to the list of optimizers
  115392. * @param optimizer defines the optimizers to add
  115393. * @returns the current material
  115394. */
  115395. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115396. /**
  115397. * Remove an optimizer from the list of optimizers
  115398. * @param optimizer defines the optimizers to remove
  115399. * @returns the current material
  115400. */
  115401. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115402. /**
  115403. * Add a new block to the list of output nodes
  115404. * @param node defines the node to add
  115405. * @returns the current material
  115406. */
  115407. addOutputNode(node: NodeMaterialBlock): this;
  115408. /**
  115409. * Remove a block from the list of root nodes
  115410. * @param node defines the node to remove
  115411. * @returns the current material
  115412. */
  115413. removeOutputNode(node: NodeMaterialBlock): this;
  115414. private _addVertexOutputNode;
  115415. private _removeVertexOutputNode;
  115416. private _addFragmentOutputNode;
  115417. private _removeFragmentOutputNode;
  115418. /**
  115419. * Specifies if the material will require alpha blending
  115420. * @returns a boolean specifying if alpha blending is needed
  115421. */
  115422. needAlphaBlending(): boolean;
  115423. /**
  115424. * Specifies if this material should be rendered in alpha test mode
  115425. * @returns a boolean specifying if an alpha test is needed.
  115426. */
  115427. needAlphaTesting(): boolean;
  115428. private _initializeBlock;
  115429. private _resetDualBlocks;
  115430. /**
  115431. * Build the material and generates the inner effect
  115432. * @param verbose defines if the build should log activity
  115433. */
  115434. build(verbose?: boolean): void;
  115435. /**
  115436. * Runs an otpimization phase to try to improve the shader code
  115437. */
  115438. optimize(): void;
  115439. private _prepareDefinesForAttributes;
  115440. /**
  115441. * Get if the submesh is ready to be used and all its information available.
  115442. * Child classes can use it to update shaders
  115443. * @param mesh defines the mesh to check
  115444. * @param subMesh defines which submesh to check
  115445. * @param useInstances specifies that instances should be used
  115446. * @returns a boolean indicating that the submesh is ready or not
  115447. */
  115448. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115449. /**
  115450. * Get a string representing the shaders built by the current node graph
  115451. */
  115452. readonly compiledShaders: string;
  115453. /**
  115454. * Binds the world matrix to the material
  115455. * @param world defines the world transformation matrix
  115456. */
  115457. bindOnlyWorldMatrix(world: Matrix): void;
  115458. /**
  115459. * Binds the submesh to this material by preparing the effect and shader to draw
  115460. * @param world defines the world transformation matrix
  115461. * @param mesh defines the mesh containing the submesh
  115462. * @param subMesh defines the submesh to bind the material to
  115463. */
  115464. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115465. /**
  115466. * Gets the active textures from the material
  115467. * @returns an array of textures
  115468. */
  115469. getActiveTextures(): BaseTexture[];
  115470. /**
  115471. * Specifies if the material uses a texture
  115472. * @param texture defines the texture to check against the material
  115473. * @returns a boolean specifying if the material uses the texture
  115474. */
  115475. hasTexture(texture: BaseTexture): boolean;
  115476. /**
  115477. * Disposes the material
  115478. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  115479. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  115480. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  115481. */
  115482. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  115483. /** Creates the node editor window. */
  115484. private _createNodeEditor;
  115485. /**
  115486. * Launch the node material editor
  115487. * @param config Define the configuration of the editor
  115488. * @return a promise fulfilled when the node editor is visible
  115489. */
  115490. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  115491. /**
  115492. * Clear the current material
  115493. */
  115494. clear(): void;
  115495. /**
  115496. * Clear the current material and set it to a default state
  115497. */
  115498. setToDefault(): void;
  115499. private _gatherBlocks;
  115500. /**
  115501. * Serializes this material in a JSON representation
  115502. * @returns the serialized material object
  115503. */
  115504. serialize(): any;
  115505. /**
  115506. * Clear the current graph and load a new one from a serialization object
  115507. * @param source defines the JSON representation of the material
  115508. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  115509. */
  115510. loadFromSerialization(source: any, rootUrl?: string): void;
  115511. /**
  115512. * Creates a node material from parsed material data
  115513. * @param source defines the JSON representation of the material
  115514. * @param scene defines the hosting scene
  115515. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  115516. * @returns a new node material
  115517. */
  115518. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  115519. }
  115520. }
  115521. declare module BABYLON {
  115522. /**
  115523. * Block used to read a texture from a sampler
  115524. */
  115525. export class TextureBlock extends NodeMaterialBlock {
  115526. private _defineName;
  115527. private _samplerName;
  115528. private _transformedUVName;
  115529. private _textureTransformName;
  115530. private _textureInfoName;
  115531. private _mainUVName;
  115532. private _mainUVDefineName;
  115533. /**
  115534. * Gets or sets the texture associated with the node
  115535. */
  115536. texture: Nullable<BaseTexture>;
  115537. /**
  115538. * Create a new TextureBlock
  115539. * @param name defines the block name
  115540. */
  115541. constructor(name: string);
  115542. /**
  115543. * Gets the current class name
  115544. * @returns the class name
  115545. */
  115546. getClassName(): string;
  115547. /**
  115548. * Gets the uv input component
  115549. */
  115550. readonly uv: NodeMaterialConnectionPoint;
  115551. /**
  115552. * Gets the output component
  115553. */
  115554. readonly output: NodeMaterialConnectionPoint;
  115555. autoConfigure(): void;
  115556. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115557. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115558. isReady(): boolean;
  115559. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115560. private _injectVertexCode;
  115561. private _writeOutput;
  115562. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  115563. serialize(): any;
  115564. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115565. }
  115566. }
  115567. declare module BABYLON {
  115568. /**
  115569. * Class used to store shared data between 2 NodeMaterialBuildState
  115570. */
  115571. export class NodeMaterialBuildStateSharedData {
  115572. /**
  115573. * Gets the list of emitted varyings
  115574. */
  115575. varyings: string[];
  115576. /**
  115577. * Gets the varying declaration string
  115578. */
  115579. varyingDeclaration: string;
  115580. /**
  115581. * Input blocks
  115582. */
  115583. inputBlocks: InputBlock[];
  115584. /**
  115585. * Input blocks
  115586. */
  115587. textureBlocks: TextureBlock[];
  115588. /**
  115589. * Bindable blocks (Blocks that need to set data to the effect)
  115590. */
  115591. bindableBlocks: NodeMaterialBlock[];
  115592. /**
  115593. * List of blocks that can provide a compilation fallback
  115594. */
  115595. blocksWithFallbacks: NodeMaterialBlock[];
  115596. /**
  115597. * List of blocks that can provide a define update
  115598. */
  115599. blocksWithDefines: NodeMaterialBlock[];
  115600. /**
  115601. * List of blocks that can provide a repeatable content
  115602. */
  115603. repeatableContentBlocks: NodeMaterialBlock[];
  115604. /**
  115605. * List of blocks that can provide a dynamic list of uniforms
  115606. */
  115607. dynamicUniformBlocks: NodeMaterialBlock[];
  115608. /**
  115609. * List of blocks that can block the isReady function for the material
  115610. */
  115611. blockingBlocks: NodeMaterialBlock[];
  115612. /**
  115613. * Build Id used to avoid multiple recompilations
  115614. */
  115615. buildId: number;
  115616. /** List of emitted variables */
  115617. variableNames: {
  115618. [key: string]: number;
  115619. };
  115620. /** List of emitted defines */
  115621. defineNames: {
  115622. [key: string]: number;
  115623. };
  115624. /** Should emit comments? */
  115625. emitComments: boolean;
  115626. /** Emit build activity */
  115627. verbose: boolean;
  115628. /**
  115629. * Gets the compilation hints emitted at compilation time
  115630. */
  115631. hints: {
  115632. needWorldViewMatrix: boolean;
  115633. needWorldViewProjectionMatrix: boolean;
  115634. needAlphaBlending: boolean;
  115635. needAlphaTesting: boolean;
  115636. };
  115637. /**
  115638. * List of compilation checks
  115639. */
  115640. checks: {
  115641. emitVertex: boolean;
  115642. emitFragment: boolean;
  115643. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  115644. };
  115645. /** Creates a new shared data */
  115646. constructor();
  115647. /**
  115648. * Emits console errors and exceptions if there is a failing check
  115649. */
  115650. emitErrors(): void;
  115651. }
  115652. }
  115653. declare module BABYLON {
  115654. /**
  115655. * Class used to store node based material build state
  115656. */
  115657. export class NodeMaterialBuildState {
  115658. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  115659. supportUniformBuffers: boolean;
  115660. /**
  115661. * Gets the list of emitted attributes
  115662. */
  115663. attributes: string[];
  115664. /**
  115665. * Gets the list of emitted uniforms
  115666. */
  115667. uniforms: string[];
  115668. /**
  115669. * Gets the list of emitted uniform buffers
  115670. */
  115671. uniformBuffers: string[];
  115672. /**
  115673. * Gets the list of emitted samplers
  115674. */
  115675. samplers: string[];
  115676. /**
  115677. * Gets the list of emitted functions
  115678. */
  115679. functions: {
  115680. [key: string]: string;
  115681. };
  115682. /**
  115683. * Gets the target of the compilation state
  115684. */
  115685. target: NodeMaterialBlockTargets;
  115686. /**
  115687. * Gets the list of emitted counters
  115688. */
  115689. counters: {
  115690. [key: string]: number;
  115691. };
  115692. /**
  115693. * Shared data between multiple NodeMaterialBuildState instances
  115694. */
  115695. sharedData: NodeMaterialBuildStateSharedData;
  115696. /** @hidden */
  115697. _vertexState: NodeMaterialBuildState;
  115698. /** @hidden */
  115699. _attributeDeclaration: string;
  115700. /** @hidden */
  115701. _uniformDeclaration: string;
  115702. /** @hidden */
  115703. _samplerDeclaration: string;
  115704. /** @hidden */
  115705. _varyingTransfer: string;
  115706. private _repeatableContentAnchorIndex;
  115707. /** @hidden */
  115708. _builtCompilationString: string;
  115709. /**
  115710. * Gets the emitted compilation strings
  115711. */
  115712. compilationString: string;
  115713. /**
  115714. * Finalize the compilation strings
  115715. * @param state defines the current compilation state
  115716. */
  115717. finalize(state: NodeMaterialBuildState): void;
  115718. /** @hidden */
  115719. readonly _repeatableContentAnchor: string;
  115720. /** @hidden */
  115721. _getFreeVariableName(prefix: string): string;
  115722. /** @hidden */
  115723. _getFreeDefineName(prefix: string): string;
  115724. /** @hidden */
  115725. _excludeVariableName(name: string): void;
  115726. /** @hidden */
  115727. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  115728. /** @hidden */
  115729. _emitFunction(name: string, code: string, comments: string): void;
  115730. /** @hidden */
  115731. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  115732. replaceStrings?: {
  115733. search: RegExp;
  115734. replace: string;
  115735. }[];
  115736. repeatKey?: string;
  115737. }): string;
  115738. /** @hidden */
  115739. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  115740. repeatKey?: string;
  115741. removeAttributes?: boolean;
  115742. removeUniforms?: boolean;
  115743. removeVaryings?: boolean;
  115744. removeIfDef?: boolean;
  115745. replaceStrings?: {
  115746. search: RegExp;
  115747. replace: string;
  115748. }[];
  115749. }, storeKey?: string): void;
  115750. /** @hidden */
  115751. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  115752. /** @hidden */
  115753. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  115754. }
  115755. }
  115756. declare module BABYLON {
  115757. /**
  115758. * Defines a block that can be used inside a node based material
  115759. */
  115760. export class NodeMaterialBlock {
  115761. private _buildId;
  115762. private _buildTarget;
  115763. private _target;
  115764. private _isFinalMerger;
  115765. private _isInput;
  115766. /** @hidden */
  115767. _inputs: NodeMaterialConnectionPoint[];
  115768. /** @hidden */
  115769. _outputs: NodeMaterialConnectionPoint[];
  115770. /**
  115771. * Gets or sets the name of the block
  115772. */
  115773. name: string;
  115774. /**
  115775. * Gets or sets the unique id of the node
  115776. */
  115777. uniqueId: number;
  115778. /**
  115779. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  115780. */
  115781. readonly isFinalMerger: boolean;
  115782. /**
  115783. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  115784. */
  115785. readonly isInput: boolean;
  115786. /**
  115787. * Gets or sets the build Id
  115788. */
  115789. buildId: number;
  115790. /**
  115791. * Gets or sets the target of the block
  115792. */
  115793. target: NodeMaterialBlockTargets;
  115794. /**
  115795. * Gets the list of input points
  115796. */
  115797. readonly inputs: NodeMaterialConnectionPoint[];
  115798. /** Gets the list of output points */
  115799. readonly outputs: NodeMaterialConnectionPoint[];
  115800. /**
  115801. * Find an input by its name
  115802. * @param name defines the name of the input to look for
  115803. * @returns the input or null if not found
  115804. */
  115805. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  115806. /**
  115807. * Find an output by its name
  115808. * @param name defines the name of the outputto look for
  115809. * @returns the output or null if not found
  115810. */
  115811. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  115812. /**
  115813. * Creates a new NodeMaterialBlock
  115814. * @param name defines the block name
  115815. * @param target defines the target of that block (Vertex by default)
  115816. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  115817. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  115818. */
  115819. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  115820. /**
  115821. * Initialize the block and prepare the context for build
  115822. * @param state defines the state that will be used for the build
  115823. */
  115824. initialize(state: NodeMaterialBuildState): void;
  115825. /**
  115826. * Bind data to effect. Will only be called for blocks with isBindable === true
  115827. * @param effect defines the effect to bind data to
  115828. * @param nodeMaterial defines the hosting NodeMaterial
  115829. * @param mesh defines the mesh that will be rendered
  115830. */
  115831. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115832. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  115833. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  115834. protected _writeFloat(value: number): string;
  115835. /**
  115836. * Gets the current class name e.g. "NodeMaterialBlock"
  115837. * @returns the class name
  115838. */
  115839. getClassName(): string;
  115840. /**
  115841. * Register a new input. Must be called inside a block constructor
  115842. * @param name defines the connection point name
  115843. * @param type defines the connection point type
  115844. * @param isOptional defines a boolean indicating that this input can be omitted
  115845. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  115846. * @returns the current block
  115847. */
  115848. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  115849. /**
  115850. * Register a new output. Must be called inside a block constructor
  115851. * @param name defines the connection point name
  115852. * @param type defines the connection point type
  115853. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  115854. * @returns the current block
  115855. */
  115856. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  115857. /**
  115858. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  115859. * @param forOutput defines an optional connection point to check compatibility with
  115860. * @returns the first available input or null
  115861. */
  115862. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  115863. /**
  115864. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  115865. * @param forBlock defines an optional block to check compatibility with
  115866. * @returns the first available input or null
  115867. */
  115868. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  115869. /**
  115870. * Connect current block with another block
  115871. * @param other defines the block to connect with
  115872. * @param options define the various options to help pick the right connections
  115873. * @returns the current block
  115874. */
  115875. connectTo(other: NodeMaterialBlock, options?: {
  115876. input?: string;
  115877. output?: string;
  115878. outputSwizzle?: string;
  115879. }): this | undefined;
  115880. protected _buildBlock(state: NodeMaterialBuildState): void;
  115881. /**
  115882. * Add uniforms, samplers and uniform buffers at compilation time
  115883. * @param state defines the state to update
  115884. * @param nodeMaterial defines the node material requesting the update
  115885. * @param defines defines the material defines to update
  115886. */
  115887. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115888. /**
  115889. * Add potential fallbacks if shader compilation fails
  115890. * @param mesh defines the mesh to be rendered
  115891. * @param fallbacks defines the current prioritized list of fallbacks
  115892. */
  115893. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  115894. /**
  115895. * Update defines for shader compilation
  115896. * @param mesh defines the mesh to be rendered
  115897. * @param nodeMaterial defines the node material requesting the update
  115898. * @param defines defines the material defines to update
  115899. * @param useInstances specifies that instances should be used
  115900. */
  115901. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115902. /**
  115903. * Initialize defines for shader compilation
  115904. * @param mesh defines the mesh to be rendered
  115905. * @param nodeMaterial defines the node material requesting the update
  115906. * @param defines defines the material defines to be prepared
  115907. * @param useInstances specifies that instances should be used
  115908. */
  115909. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115910. /**
  115911. * Lets the block try to connect some inputs automatically
  115912. */
  115913. autoConfigure(): void;
  115914. /**
  115915. * Function called when a block is declared as repeatable content generator
  115916. * @param vertexShaderState defines the current compilation state for the vertex shader
  115917. * @param fragmentShaderState defines the current compilation state for the fragment shader
  115918. * @param mesh defines the mesh to be rendered
  115919. * @param defines defines the material defines to update
  115920. */
  115921. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  115922. /**
  115923. * Checks if the block is ready
  115924. * @param mesh defines the mesh to be rendered
  115925. * @param nodeMaterial defines the node material requesting the update
  115926. * @param defines defines the material defines to update
  115927. * @param useInstances specifies that instances should be used
  115928. * @returns true if the block is ready
  115929. */
  115930. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  115931. private _processBuild;
  115932. /**
  115933. * Compile the current node and generate the shader code
  115934. * @param state defines the current compilation state (uniforms, samplers, current string)
  115935. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  115936. * @returns true if already built
  115937. */
  115938. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  115939. /**
  115940. * Serializes this block in a JSON representation
  115941. * @returns the serialized block object
  115942. */
  115943. serialize(): any;
  115944. /** @hidden */
  115945. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115946. }
  115947. }
  115948. declare module BABYLON {
  115949. /**
  115950. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  115951. */
  115952. export enum NodeMaterialBlockConnectionPointMode {
  115953. /** Value is an uniform */
  115954. Uniform = 0,
  115955. /** Value is a mesh attribute */
  115956. Attribute = 1,
  115957. /** Value is a varying between vertex and fragment shaders */
  115958. Varying = 2,
  115959. /** Mode is undefined */
  115960. Undefined = 3
  115961. }
  115962. }
  115963. declare module BABYLON {
  115964. /**
  115965. * Enum used to define well known values e.g. values automatically provided by the system
  115966. */
  115967. export enum NodeMaterialWellKnownValues {
  115968. /** World */
  115969. World = 1,
  115970. /** View */
  115971. View = 2,
  115972. /** Projection */
  115973. Projection = 3,
  115974. /** ViewProjection */
  115975. ViewProjection = 4,
  115976. /** WorldView */
  115977. WorldView = 5,
  115978. /** WorldViewProjection */
  115979. WorldViewProjection = 6,
  115980. /** CameraPosition */
  115981. CameraPosition = 7,
  115982. /** Fog Color */
  115983. FogColor = 8
  115984. }
  115985. }
  115986. declare module BABYLON {
  115987. /**
  115988. * Contains position and normal vectors for a vertex
  115989. */
  115990. export class PositionNormalVertex {
  115991. /** the position of the vertex (defaut: 0,0,0) */
  115992. position: Vector3;
  115993. /** the normal of the vertex (defaut: 0,1,0) */
  115994. normal: Vector3;
  115995. /**
  115996. * Creates a PositionNormalVertex
  115997. * @param position the position of the vertex (defaut: 0,0,0)
  115998. * @param normal the normal of the vertex (defaut: 0,1,0)
  115999. */
  116000. constructor(
  116001. /** the position of the vertex (defaut: 0,0,0) */
  116002. position?: Vector3,
  116003. /** the normal of the vertex (defaut: 0,1,0) */
  116004. normal?: Vector3);
  116005. /**
  116006. * Clones the PositionNormalVertex
  116007. * @returns the cloned PositionNormalVertex
  116008. */
  116009. clone(): PositionNormalVertex;
  116010. }
  116011. /**
  116012. * Contains position, normal and uv vectors for a vertex
  116013. */
  116014. export class PositionNormalTextureVertex {
  116015. /** the position of the vertex (defaut: 0,0,0) */
  116016. position: Vector3;
  116017. /** the normal of the vertex (defaut: 0,1,0) */
  116018. normal: Vector3;
  116019. /** the uv of the vertex (default: 0,0) */
  116020. uv: Vector2;
  116021. /**
  116022. * Creates a PositionNormalTextureVertex
  116023. * @param position the position of the vertex (defaut: 0,0,0)
  116024. * @param normal the normal of the vertex (defaut: 0,1,0)
  116025. * @param uv the uv of the vertex (default: 0,0)
  116026. */
  116027. constructor(
  116028. /** the position of the vertex (defaut: 0,0,0) */
  116029. position?: Vector3,
  116030. /** the normal of the vertex (defaut: 0,1,0) */
  116031. normal?: Vector3,
  116032. /** the uv of the vertex (default: 0,0) */
  116033. uv?: Vector2);
  116034. /**
  116035. * Clones the PositionNormalTextureVertex
  116036. * @returns the cloned PositionNormalTextureVertex
  116037. */
  116038. clone(): PositionNormalTextureVertex;
  116039. }
  116040. }
  116041. declare module BABYLON {
  116042. /**
  116043. * Block used to expose an input value
  116044. */
  116045. export class InputBlock extends NodeMaterialBlock {
  116046. private _mode;
  116047. private _associatedVariableName;
  116048. private _storedValue;
  116049. private _valueCallback;
  116050. private _type;
  116051. /** @hidden */
  116052. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  116053. /**
  116054. * Gets or sets the connection point type (default is float)
  116055. */
  116056. readonly type: NodeMaterialBlockConnectionPointTypes;
  116057. /**
  116058. * Creates a new InputBlock
  116059. * @param name defines the block name
  116060. * @param target defines the target of that block (Vertex by default)
  116061. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  116062. */
  116063. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  116064. /**
  116065. * Gets the output component
  116066. */
  116067. readonly output: NodeMaterialConnectionPoint;
  116068. /**
  116069. * Set the source of this connection point to a vertex attribute
  116070. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  116071. * @returns the current connection point
  116072. */
  116073. setAsAttribute(attributeName?: string): InputBlock;
  116074. /**
  116075. * Set the source of this connection point to a well known value
  116076. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  116077. * @returns the current connection point
  116078. */
  116079. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  116080. /**
  116081. * Gets or sets the value of that point.
  116082. * Please note that this value will be ignored if valueCallback is defined
  116083. */
  116084. value: any;
  116085. /**
  116086. * Gets or sets a callback used to get the value of that point.
  116087. * Please note that setting this value will force the connection point to ignore the value property
  116088. */
  116089. valueCallback: () => any;
  116090. /**
  116091. * Gets or sets the associated variable name in the shader
  116092. */
  116093. associatedVariableName: string;
  116094. /**
  116095. * Gets a boolean indicating that this connection point not defined yet
  116096. */
  116097. readonly isUndefined: boolean;
  116098. /**
  116099. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  116100. * In this case the connection point name must be the name of the uniform to use.
  116101. * Can only be set on inputs
  116102. */
  116103. isUniform: boolean;
  116104. /**
  116105. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  116106. * In this case the connection point name must be the name of the attribute to use
  116107. * Can only be set on inputs
  116108. */
  116109. isAttribute: boolean;
  116110. /**
  116111. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  116112. * Can only be set on exit points
  116113. */
  116114. isVarying: boolean;
  116115. /**
  116116. * Gets a boolean indicating that the current connection point is a well known value
  116117. */
  116118. readonly isWellKnownValue: boolean;
  116119. /**
  116120. * Gets or sets the current well known value or null if not defined as well know value
  116121. */
  116122. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  116123. /**
  116124. * Gets the current class name
  116125. * @returns the class name
  116126. */
  116127. getClassName(): string;
  116128. private _emitDefine;
  116129. /**
  116130. * Set the input block to its default value (based on its type)
  116131. */
  116132. setDefaultValue(): void;
  116133. private _emit;
  116134. /** @hidden */
  116135. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  116136. /** @hidden */
  116137. _transmit(effect: Effect, scene: Scene): void;
  116138. protected _buildBlock(state: NodeMaterialBuildState): void;
  116139. serialize(): any;
  116140. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116141. }
  116142. }
  116143. declare module BABYLON {
  116144. /**
  116145. * Defines a connection point for a block
  116146. */
  116147. export class NodeMaterialConnectionPoint {
  116148. /** @hidden */
  116149. _ownerBlock: NodeMaterialBlock;
  116150. /** @hidden */
  116151. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  116152. private _endpoints;
  116153. private _associatedVariableName;
  116154. /** @hidden */
  116155. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  116156. private _type;
  116157. /** @hidden */
  116158. _enforceAssociatedVariableName: boolean;
  116159. /**
  116160. * Gets or sets the additional types supported byt this connection point
  116161. */
  116162. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  116163. /**
  116164. * Gets or sets the associated variable name in the shader
  116165. */
  116166. associatedVariableName: string;
  116167. /**
  116168. * Gets or sets the connection point type (default is float)
  116169. */
  116170. type: NodeMaterialBlockConnectionPointTypes;
  116171. /**
  116172. * Gets or sets the connection point name
  116173. */
  116174. name: string;
  116175. /**
  116176. * Gets or sets a boolean indicating that this connection point can be omitted
  116177. */
  116178. isOptional: boolean;
  116179. /**
  116180. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  116181. */
  116182. define: string;
  116183. /** Gets or sets the target of that connection point */
  116184. target: NodeMaterialBlockTargets;
  116185. /**
  116186. * Gets a boolean indicating that the current point is connected
  116187. */
  116188. readonly isConnected: boolean;
  116189. /**
  116190. * Gets a boolean indicating that the current point is connected to an input block
  116191. */
  116192. readonly isConnectedToInput: boolean;
  116193. /**
  116194. * Gets a the connected input block (if any)
  116195. */
  116196. readonly connectInputBlock: Nullable<InputBlock>;
  116197. /** Get the other side of the connection (if any) */
  116198. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  116199. /** Get the block that owns this connection point */
  116200. readonly ownerBlock: NodeMaterialBlock;
  116201. /** Get the block connected on the other side of this connection (if any) */
  116202. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  116203. /** Get the block connected on the endpoints of this connection (if any) */
  116204. readonly connectedBlocks: Array<NodeMaterialBlock>;
  116205. /** Gets the list of connected endpoints */
  116206. readonly endpoints: NodeMaterialConnectionPoint[];
  116207. /**
  116208. * Creates a new connection point
  116209. * @param name defines the connection point name
  116210. * @param ownerBlock defines the block hosting this connection point
  116211. */
  116212. constructor(name: string, ownerBlock: NodeMaterialBlock);
  116213. /**
  116214. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  116215. * @returns the class name
  116216. */
  116217. getClassName(): string;
  116218. /**
  116219. * Gets an boolean indicating if the current point can be connected to another point
  116220. * @param connectionPoint defines the other connection point
  116221. * @returns true if the connection is possible
  116222. */
  116223. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  116224. /**
  116225. * Connect this point to another connection point
  116226. * @param connectionPoint defines the other connection point
  116227. * @returns the current connection point
  116228. */
  116229. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116230. /**
  116231. * Disconnect this point from one of his endpoint
  116232. * @param endpoint defines the other connection point
  116233. * @returns the current connection point
  116234. */
  116235. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116236. /**
  116237. * Serializes this point in a JSON representation
  116238. * @returns the serialized point object
  116239. */
  116240. serialize(): any;
  116241. }
  116242. }
  116243. declare module BABYLON {
  116244. /**
  116245. * Block used to add support for vertex skinning (bones)
  116246. */
  116247. export class BonesBlock extends NodeMaterialBlock {
  116248. /**
  116249. * Creates a new BonesBlock
  116250. * @param name defines the block name
  116251. */
  116252. constructor(name: string);
  116253. /**
  116254. * Initialize the block and prepare the context for build
  116255. * @param state defines the state that will be used for the build
  116256. */
  116257. initialize(state: NodeMaterialBuildState): void;
  116258. /**
  116259. * Gets the current class name
  116260. * @returns the class name
  116261. */
  116262. getClassName(): string;
  116263. /**
  116264. * Gets the matrix indices input component
  116265. */
  116266. readonly matricesIndices: NodeMaterialConnectionPoint;
  116267. /**
  116268. * Gets the matrix weights input component
  116269. */
  116270. readonly matricesWeights: NodeMaterialConnectionPoint;
  116271. /**
  116272. * Gets the extra matrix indices input component
  116273. */
  116274. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  116275. /**
  116276. * Gets the extra matrix weights input component
  116277. */
  116278. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  116279. /**
  116280. * Gets the world input component
  116281. */
  116282. readonly world: NodeMaterialConnectionPoint;
  116283. /**
  116284. * Gets the output component
  116285. */
  116286. readonly output: NodeMaterialConnectionPoint;
  116287. autoConfigure(): void;
  116288. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  116289. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116290. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116291. protected _buildBlock(state: NodeMaterialBuildState): this;
  116292. }
  116293. }
  116294. declare module BABYLON {
  116295. /**
  116296. * Block used to add support for instances
  116297. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  116298. */
  116299. export class InstancesBlock extends NodeMaterialBlock {
  116300. /**
  116301. * Creates a new InstancesBlock
  116302. * @param name defines the block name
  116303. */
  116304. constructor(name: string);
  116305. /**
  116306. * Gets the current class name
  116307. * @returns the class name
  116308. */
  116309. getClassName(): string;
  116310. /**
  116311. * Gets the first world row input component
  116312. */
  116313. readonly world0: NodeMaterialConnectionPoint;
  116314. /**
  116315. * Gets the second world row input component
  116316. */
  116317. readonly world1: NodeMaterialConnectionPoint;
  116318. /**
  116319. * Gets the third world row input component
  116320. */
  116321. readonly world2: NodeMaterialConnectionPoint;
  116322. /**
  116323. * Gets the forth world row input component
  116324. */
  116325. readonly world3: NodeMaterialConnectionPoint;
  116326. /**
  116327. * Gets the world input component
  116328. */
  116329. readonly world: NodeMaterialConnectionPoint;
  116330. /**
  116331. * Gets the output component
  116332. */
  116333. readonly output: NodeMaterialConnectionPoint;
  116334. autoConfigure(): void;
  116335. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116336. protected _buildBlock(state: NodeMaterialBuildState): this;
  116337. }
  116338. }
  116339. declare module BABYLON {
  116340. /**
  116341. * Block used to add morph targets support to vertex shader
  116342. */
  116343. export class MorphTargetsBlock extends NodeMaterialBlock {
  116344. private _repeatableContentAnchor;
  116345. private _repeatebleContentGenerated;
  116346. /**
  116347. * Create a new MorphTargetsBlock
  116348. * @param name defines the block name
  116349. */
  116350. constructor(name: string);
  116351. /**
  116352. * Gets the current class name
  116353. * @returns the class name
  116354. */
  116355. getClassName(): string;
  116356. /**
  116357. * Gets the position input component
  116358. */
  116359. readonly position: NodeMaterialConnectionPoint;
  116360. /**
  116361. * Gets the normal input component
  116362. */
  116363. readonly normal: NodeMaterialConnectionPoint;
  116364. /**
  116365. * Gets the tangent input component
  116366. */
  116367. readonly tangent: NodeMaterialConnectionPoint;
  116368. /**
  116369. * Gets the tangent input component
  116370. */
  116371. readonly uv: NodeMaterialConnectionPoint;
  116372. /**
  116373. * Gets the position output component
  116374. */
  116375. readonly positionOutput: NodeMaterialConnectionPoint;
  116376. /**
  116377. * Gets the normal output component
  116378. */
  116379. readonly normalOutput: NodeMaterialConnectionPoint;
  116380. /**
  116381. * Gets the tangent output component
  116382. */
  116383. readonly tangentOutput: NodeMaterialConnectionPoint;
  116384. /**
  116385. * Gets the tangent output component
  116386. */
  116387. readonly uvOutput: NodeMaterialConnectionPoint;
  116388. initialize(state: NodeMaterialBuildState): void;
  116389. autoConfigure(): void;
  116390. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116391. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116392. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  116393. protected _buildBlock(state: NodeMaterialBuildState): this;
  116394. }
  116395. }
  116396. declare module BABYLON {
  116397. /**
  116398. * Block used to add an alpha test in the fragment shader
  116399. */
  116400. export class AlphaTestBlock extends NodeMaterialBlock {
  116401. /**
  116402. * Gets or sets the alpha value where alpha testing happens
  116403. */
  116404. alphaCutOff: number;
  116405. /**
  116406. * Create a new AlphaTestBlock
  116407. * @param name defines the block name
  116408. */
  116409. constructor(name: string);
  116410. /**
  116411. * Gets the current class name
  116412. * @returns the class name
  116413. */
  116414. getClassName(): string;
  116415. /**
  116416. * Gets the color input component
  116417. */
  116418. readonly color: NodeMaterialConnectionPoint;
  116419. /**
  116420. * Gets the alpha input component
  116421. */
  116422. readonly alpha: NodeMaterialConnectionPoint;
  116423. protected _buildBlock(state: NodeMaterialBuildState): this;
  116424. }
  116425. }
  116426. declare module BABYLON {
  116427. /**
  116428. * Block used to create a Color3/4 out of individual inputs (one for each component)
  116429. */
  116430. export class ColorMergerBlock extends NodeMaterialBlock {
  116431. /**
  116432. * Create a new ColorMergerBlock
  116433. * @param name defines the block name
  116434. */
  116435. constructor(name: string);
  116436. /**
  116437. * Gets the current class name
  116438. * @returns the class name
  116439. */
  116440. getClassName(): string;
  116441. /**
  116442. * Gets the r component (input)
  116443. */
  116444. readonly r: NodeMaterialConnectionPoint;
  116445. /**
  116446. * Gets the g component (input)
  116447. */
  116448. readonly g: NodeMaterialConnectionPoint;
  116449. /**
  116450. * Gets the b component (input)
  116451. */
  116452. readonly b: NodeMaterialConnectionPoint;
  116453. /**
  116454. * Gets the a component (input)
  116455. */
  116456. readonly a: NodeMaterialConnectionPoint;
  116457. /**
  116458. * Gets the rgba component (output)
  116459. */
  116460. readonly rgba: NodeMaterialConnectionPoint;
  116461. /**
  116462. * Gets the rgb component (output)
  116463. */
  116464. readonly rgb: NodeMaterialConnectionPoint;
  116465. protected _buildBlock(state: NodeMaterialBuildState): this;
  116466. }
  116467. }
  116468. declare module BABYLON {
  116469. /**
  116470. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  116471. */
  116472. export class VectorMergerBlock extends NodeMaterialBlock {
  116473. /**
  116474. * Create a new VectorMergerBlock
  116475. * @param name defines the block name
  116476. */
  116477. constructor(name: string);
  116478. /**
  116479. * Gets the current class name
  116480. * @returns the class name
  116481. */
  116482. getClassName(): string;
  116483. /**
  116484. * Gets the x component (input)
  116485. */
  116486. readonly x: NodeMaterialConnectionPoint;
  116487. /**
  116488. * Gets the y component (input)
  116489. */
  116490. readonly y: NodeMaterialConnectionPoint;
  116491. /**
  116492. * Gets the z component (input)
  116493. */
  116494. readonly z: NodeMaterialConnectionPoint;
  116495. /**
  116496. * Gets the w component (input)
  116497. */
  116498. readonly w: NodeMaterialConnectionPoint;
  116499. /**
  116500. * Gets the xyzw component (output)
  116501. */
  116502. readonly xyzw: NodeMaterialConnectionPoint;
  116503. /**
  116504. * Gets the xyz component (output)
  116505. */
  116506. readonly xyz: NodeMaterialConnectionPoint;
  116507. /**
  116508. * Gets the xy component (output)
  116509. */
  116510. readonly xy: NodeMaterialConnectionPoint;
  116511. protected _buildBlock(state: NodeMaterialBuildState): this;
  116512. }
  116513. }
  116514. declare module BABYLON {
  116515. /**
  116516. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  116517. */
  116518. export class ColorSplitterBlock extends NodeMaterialBlock {
  116519. /**
  116520. * Create a new ColorSplitterBlock
  116521. * @param name defines the block name
  116522. */
  116523. constructor(name: string);
  116524. /**
  116525. * Gets the current class name
  116526. * @returns the class name
  116527. */
  116528. getClassName(): string;
  116529. /**
  116530. * Gets the rgba component (input)
  116531. */
  116532. readonly rgba: NodeMaterialConnectionPoint;
  116533. /**
  116534. * Gets the rgb component (input)
  116535. */
  116536. readonly rgbIn: NodeMaterialConnectionPoint;
  116537. /**
  116538. * Gets the rgb component (output)
  116539. */
  116540. readonly rgbOut: NodeMaterialConnectionPoint;
  116541. /**
  116542. * Gets the r component (output)
  116543. */
  116544. readonly r: NodeMaterialConnectionPoint;
  116545. /**
  116546. * Gets the g component (output)
  116547. */
  116548. readonly g: NodeMaterialConnectionPoint;
  116549. /**
  116550. * Gets the b component (output)
  116551. */
  116552. readonly b: NodeMaterialConnectionPoint;
  116553. /**
  116554. * Gets the a component (output)
  116555. */
  116556. readonly a: NodeMaterialConnectionPoint;
  116557. protected _buildBlock(state: NodeMaterialBuildState): this;
  116558. }
  116559. }
  116560. declare module BABYLON {
  116561. /**
  116562. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  116563. */
  116564. export class VectorSplitterBlock extends NodeMaterialBlock {
  116565. /**
  116566. * Create a new VectorSplitterBlock
  116567. * @param name defines the block name
  116568. */
  116569. constructor(name: string);
  116570. /**
  116571. * Gets the current class name
  116572. * @returns the class name
  116573. */
  116574. getClassName(): string;
  116575. /**
  116576. * Gets the xyzw component (input)
  116577. */
  116578. readonly xyzw: NodeMaterialConnectionPoint;
  116579. /**
  116580. * Gets the xyz component (input)
  116581. */
  116582. readonly xyzIn: NodeMaterialConnectionPoint;
  116583. /**
  116584. * Gets the xyz component (output)
  116585. */
  116586. readonly xyzOut: NodeMaterialConnectionPoint;
  116587. /**
  116588. * Gets the xy component (output)
  116589. */
  116590. readonly xy: NodeMaterialConnectionPoint;
  116591. /**
  116592. * Gets the x component (output)
  116593. */
  116594. readonly x: NodeMaterialConnectionPoint;
  116595. /**
  116596. * Gets the y component (output)
  116597. */
  116598. readonly y: NodeMaterialConnectionPoint;
  116599. /**
  116600. * Gets the z component (output)
  116601. */
  116602. readonly z: NodeMaterialConnectionPoint;
  116603. /**
  116604. * Gets the w component (output)
  116605. */
  116606. readonly w: NodeMaterialConnectionPoint;
  116607. protected _buildBlock(state: NodeMaterialBuildState): this;
  116608. }
  116609. }
  116610. declare module BABYLON {
  116611. /**
  116612. * Block used to add image processing support to fragment shader
  116613. */
  116614. export class ImageProcessingBlock extends NodeMaterialBlock {
  116615. /**
  116616. * Create a new ImageProcessingBlock
  116617. * @param name defines the block name
  116618. */
  116619. constructor(name: string);
  116620. /**
  116621. * Gets the current class name
  116622. * @returns the class name
  116623. */
  116624. getClassName(): string;
  116625. /**
  116626. * Gets the color input component
  116627. */
  116628. readonly color: NodeMaterialConnectionPoint;
  116629. /**
  116630. * Gets the output component
  116631. */
  116632. readonly output: NodeMaterialConnectionPoint;
  116633. /**
  116634. * Initialize the block and prepare the context for build
  116635. * @param state defines the state that will be used for the build
  116636. */
  116637. initialize(state: NodeMaterialBuildState): void;
  116638. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  116639. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116640. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116641. protected _buildBlock(state: NodeMaterialBuildState): this;
  116642. }
  116643. }
  116644. declare module BABYLON {
  116645. /**
  116646. * Block used to add support for scene fog
  116647. */
  116648. export class FogBlock extends NodeMaterialBlock {
  116649. private _fogDistanceName;
  116650. private _fogParameters;
  116651. /**
  116652. * Create a new FogBlock
  116653. * @param name defines the block name
  116654. */
  116655. constructor(name: string);
  116656. /**
  116657. * Gets the current class name
  116658. * @returns the class name
  116659. */
  116660. getClassName(): string;
  116661. /**
  116662. * Gets the world position input component
  116663. */
  116664. readonly worldPosition: NodeMaterialConnectionPoint;
  116665. /**
  116666. * Gets the view input component
  116667. */
  116668. readonly view: NodeMaterialConnectionPoint;
  116669. /**
  116670. * Gets the color input component
  116671. */
  116672. readonly color: NodeMaterialConnectionPoint;
  116673. /**
  116674. * Gets the fog color input component
  116675. */
  116676. readonly fogColor: NodeMaterialConnectionPoint;
  116677. /**
  116678. * Gets the output component
  116679. */
  116680. readonly output: NodeMaterialConnectionPoint;
  116681. autoConfigure(): void;
  116682. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116683. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116684. protected _buildBlock(state: NodeMaterialBuildState): this;
  116685. }
  116686. }
  116687. declare module BABYLON {
  116688. /**
  116689. * Block used to add light in the fragment shader
  116690. */
  116691. export class LightBlock extends NodeMaterialBlock {
  116692. private _lightId;
  116693. /**
  116694. * Gets or sets the light associated with this block
  116695. */
  116696. light: Nullable<Light>;
  116697. /**
  116698. * Create a new LightBlock
  116699. * @param name defines the block name
  116700. */
  116701. constructor(name: string);
  116702. /**
  116703. * Gets the current class name
  116704. * @returns the class name
  116705. */
  116706. getClassName(): string;
  116707. /**
  116708. * Gets the world position input component
  116709. */
  116710. readonly worldPosition: NodeMaterialConnectionPoint;
  116711. /**
  116712. * Gets the world normal input component
  116713. */
  116714. readonly worldNormal: NodeMaterialConnectionPoint;
  116715. /**
  116716. * Gets the camera (or eye) position component
  116717. */
  116718. readonly cameraPosition: NodeMaterialConnectionPoint;
  116719. /**
  116720. * Gets the diffuse output component
  116721. */
  116722. readonly diffuseOutput: NodeMaterialConnectionPoint;
  116723. /**
  116724. * Gets the specular output component
  116725. */
  116726. readonly specularOutput: NodeMaterialConnectionPoint;
  116727. autoConfigure(): void;
  116728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116729. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116730. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116731. private _injectVertexCode;
  116732. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116733. serialize(): any;
  116734. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116735. }
  116736. }
  116737. declare module BABYLON {
  116738. /**
  116739. * Block used to multiply 2 values
  116740. */
  116741. export class MultiplyBlock extends NodeMaterialBlock {
  116742. /**
  116743. * Creates a new MultiplyBlock
  116744. * @param name defines the block name
  116745. */
  116746. constructor(name: string);
  116747. /**
  116748. * Gets the current class name
  116749. * @returns the class name
  116750. */
  116751. getClassName(): string;
  116752. /**
  116753. * Gets the left operand input component
  116754. */
  116755. readonly left: NodeMaterialConnectionPoint;
  116756. /**
  116757. * Gets the right operand input component
  116758. */
  116759. readonly right: NodeMaterialConnectionPoint;
  116760. /**
  116761. * Gets the output component
  116762. */
  116763. readonly output: NodeMaterialConnectionPoint;
  116764. protected _buildBlock(state: NodeMaterialBuildState): this;
  116765. }
  116766. }
  116767. declare module BABYLON {
  116768. /**
  116769. * Block used to add 2 vectors
  116770. */
  116771. export class AddBlock extends NodeMaterialBlock {
  116772. /**
  116773. * Creates a new AddBlock
  116774. * @param name defines the block name
  116775. */
  116776. constructor(name: string);
  116777. /**
  116778. * Gets the current class name
  116779. * @returns the class name
  116780. */
  116781. getClassName(): string;
  116782. /**
  116783. * Gets the left operand input component
  116784. */
  116785. readonly left: NodeMaterialConnectionPoint;
  116786. /**
  116787. * Gets the right operand input component
  116788. */
  116789. readonly right: NodeMaterialConnectionPoint;
  116790. /**
  116791. * Gets the output component
  116792. */
  116793. readonly output: NodeMaterialConnectionPoint;
  116794. protected _buildBlock(state: NodeMaterialBuildState): this;
  116795. }
  116796. }
  116797. declare module BABYLON {
  116798. /**
  116799. * Block used to clamp a float
  116800. */
  116801. export class ClampBlock extends NodeMaterialBlock {
  116802. /** Gets or sets the minimum range */
  116803. minimum: number;
  116804. /** Gets or sets the maximum range */
  116805. maximum: number;
  116806. /**
  116807. * Creates a new ClampBlock
  116808. * @param name defines the block name
  116809. */
  116810. constructor(name: string);
  116811. /**
  116812. * Gets the current class name
  116813. * @returns the class name
  116814. */
  116815. getClassName(): string;
  116816. /**
  116817. * Gets the value input component
  116818. */
  116819. readonly value: NodeMaterialConnectionPoint;
  116820. /**
  116821. * Gets the output component
  116822. */
  116823. readonly output: NodeMaterialConnectionPoint;
  116824. protected _buildBlock(state: NodeMaterialBuildState): this;
  116825. }
  116826. }
  116827. declare module BABYLON {
  116828. /**
  116829. * Block used to apply a cross product between 2 vectors
  116830. */
  116831. export class CrossBlock extends NodeMaterialBlock {
  116832. /**
  116833. * Creates a new CrossBlock
  116834. * @param name defines the block name
  116835. */
  116836. constructor(name: string);
  116837. /**
  116838. * Gets the current class name
  116839. * @returns the class name
  116840. */
  116841. getClassName(): string;
  116842. /**
  116843. * Gets the left operand input component
  116844. */
  116845. readonly left: NodeMaterialConnectionPoint;
  116846. /**
  116847. * Gets the right operand input component
  116848. */
  116849. readonly right: NodeMaterialConnectionPoint;
  116850. /**
  116851. * Gets the output component
  116852. */
  116853. readonly output: NodeMaterialConnectionPoint;
  116854. protected _buildBlock(state: NodeMaterialBuildState): this;
  116855. }
  116856. }
  116857. declare module BABYLON {
  116858. /**
  116859. * Block used to apply a dot product between 2 vectors
  116860. */
  116861. export class DotBlock extends NodeMaterialBlock {
  116862. /**
  116863. * Creates a new DotBlock
  116864. * @param name defines the block name
  116865. */
  116866. constructor(name: string);
  116867. /**
  116868. * Gets the current class name
  116869. * @returns the class name
  116870. */
  116871. getClassName(): string;
  116872. /**
  116873. * Gets the left operand input component
  116874. */
  116875. readonly left: NodeMaterialConnectionPoint;
  116876. /**
  116877. * Gets the right operand input component
  116878. */
  116879. readonly right: NodeMaterialConnectionPoint;
  116880. /**
  116881. * Gets the output component
  116882. */
  116883. readonly output: NodeMaterialConnectionPoint;
  116884. protected _buildBlock(state: NodeMaterialBuildState): this;
  116885. }
  116886. }
  116887. declare module BABYLON {
  116888. /**
  116889. * Block used to remap a float from a range to a new one
  116890. */
  116891. export class RemapBlock extends NodeMaterialBlock {
  116892. /**
  116893. * Gets or sets the source range
  116894. */
  116895. sourceRange: Vector2;
  116896. /**
  116897. * Gets or sets the target range
  116898. */
  116899. targetRange: Vector2;
  116900. /**
  116901. * Creates a new RemapBlock
  116902. * @param name defines the block name
  116903. */
  116904. constructor(name: string);
  116905. /**
  116906. * Gets the current class name
  116907. * @returns the class name
  116908. */
  116909. getClassName(): string;
  116910. /**
  116911. * Gets the input component
  116912. */
  116913. readonly input: NodeMaterialConnectionPoint;
  116914. /**
  116915. * Gets the output component
  116916. */
  116917. readonly output: NodeMaterialConnectionPoint;
  116918. protected _buildBlock(state: NodeMaterialBuildState): this;
  116919. }
  116920. }
  116921. declare module BABYLON {
  116922. /**
  116923. * Block used to normalize a vector
  116924. */
  116925. export class NormalizeBlock extends NodeMaterialBlock {
  116926. /**
  116927. * Creates a new NormalizeBlock
  116928. * @param name defines the block name
  116929. */
  116930. constructor(name: string);
  116931. /**
  116932. * Gets the current class name
  116933. * @returns the class name
  116934. */
  116935. getClassName(): string;
  116936. /**
  116937. * Gets the input component
  116938. */
  116939. readonly input: NodeMaterialConnectionPoint;
  116940. /**
  116941. * Gets the output component
  116942. */
  116943. readonly output: NodeMaterialConnectionPoint;
  116944. protected _buildBlock(state: NodeMaterialBuildState): this;
  116945. }
  116946. }
  116947. declare module BABYLON {
  116948. /**
  116949. * Effect Render Options
  116950. */
  116951. export interface IEffectRendererOptions {
  116952. /**
  116953. * Defines the vertices positions.
  116954. */
  116955. positions?: number[];
  116956. /**
  116957. * Defines the indices.
  116958. */
  116959. indices?: number[];
  116960. }
  116961. /**
  116962. * Helper class to render one or more effects
  116963. */
  116964. export class EffectRenderer {
  116965. private engine;
  116966. private static _DefaultOptions;
  116967. private _vertexBuffers;
  116968. private _indexBuffer;
  116969. private _ringBufferIndex;
  116970. private _ringScreenBuffer;
  116971. private _fullscreenViewport;
  116972. private _getNextFrameBuffer;
  116973. /**
  116974. * Creates an effect renderer
  116975. * @param engine the engine to use for rendering
  116976. * @param options defines the options of the effect renderer
  116977. */
  116978. constructor(engine: Engine, options?: IEffectRendererOptions);
  116979. /**
  116980. * Sets the current viewport in normalized coordinates 0-1
  116981. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  116982. */
  116983. setViewport(viewport?: Viewport): void;
  116984. /**
  116985. * Sets the current effect wrapper to use during draw.
  116986. * The effect needs to be ready before calling this api.
  116987. * This also sets the default full screen position attribute.
  116988. * @param effectWrapper Defines the effect to draw with
  116989. */
  116990. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  116991. /**
  116992. * Draws a full screen quad.
  116993. */
  116994. draw(): void;
  116995. /**
  116996. * renders one or more effects to a specified texture
  116997. * @param effectWrappers list of effects to renderer
  116998. * @param outputTexture texture to draw to, if null it will render to the screen
  116999. */
  117000. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  117001. /**
  117002. * Disposes of the effect renderer
  117003. */
  117004. dispose(): void;
  117005. }
  117006. /**
  117007. * Options to create an EffectWrapper
  117008. */
  117009. interface EffectWrapperCreationOptions {
  117010. /**
  117011. * Engine to use to create the effect
  117012. */
  117013. engine: Engine;
  117014. /**
  117015. * Fragment shader for the effect
  117016. */
  117017. fragmentShader: string;
  117018. /**
  117019. * Vertex shader for the effect
  117020. */
  117021. vertexShader: string;
  117022. /**
  117023. * Attributes to use in the shader
  117024. */
  117025. attributeNames?: Array<string>;
  117026. /**
  117027. * Uniforms to use in the shader
  117028. */
  117029. uniformNames?: Array<string>;
  117030. /**
  117031. * Texture sampler names to use in the shader
  117032. */
  117033. samplerNames?: Array<string>;
  117034. /**
  117035. * The friendly name of the effect displayed in Spector.
  117036. */
  117037. name?: string;
  117038. }
  117039. /**
  117040. * Wraps an effect to be used for rendering
  117041. */
  117042. export class EffectWrapper {
  117043. /**
  117044. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  117045. */
  117046. onApplyObservable: Observable<{}>;
  117047. /**
  117048. * The underlying effect
  117049. */
  117050. effect: Effect;
  117051. /**
  117052. * Creates an effect to be renderer
  117053. * @param creationOptions options to create the effect
  117054. */
  117055. constructor(creationOptions: EffectWrapperCreationOptions);
  117056. /**
  117057. * Disposes of the effect wrapper
  117058. */
  117059. dispose(): void;
  117060. }
  117061. }
  117062. declare module BABYLON {
  117063. /**
  117064. * Helper class to push actions to a pool of workers.
  117065. */
  117066. export class WorkerPool implements IDisposable {
  117067. private _workerInfos;
  117068. private _pendingActions;
  117069. /**
  117070. * Constructor
  117071. * @param workers Array of workers to use for actions
  117072. */
  117073. constructor(workers: Array<Worker>);
  117074. /**
  117075. * Terminates all workers and clears any pending actions.
  117076. */
  117077. dispose(): void;
  117078. /**
  117079. * Pushes an action to the worker pool. If all the workers are active, the action will be
  117080. * pended until a worker has completed its action.
  117081. * @param action The action to perform. Call onComplete when the action is complete.
  117082. */
  117083. push(action: (worker: Worker, onComplete: () => void) => void): void;
  117084. private _execute;
  117085. }
  117086. }
  117087. declare module BABYLON {
  117088. /**
  117089. * Configuration for Draco compression
  117090. */
  117091. export interface IDracoCompressionConfiguration {
  117092. /**
  117093. * Configuration for the decoder.
  117094. */
  117095. decoder: {
  117096. /**
  117097. * The url to the WebAssembly module.
  117098. */
  117099. wasmUrl?: string;
  117100. /**
  117101. * The url to the WebAssembly binary.
  117102. */
  117103. wasmBinaryUrl?: string;
  117104. /**
  117105. * The url to the fallback JavaScript module.
  117106. */
  117107. fallbackUrl?: string;
  117108. };
  117109. }
  117110. /**
  117111. * Draco compression (https://google.github.io/draco/)
  117112. *
  117113. * This class wraps the Draco module.
  117114. *
  117115. * **Encoder**
  117116. *
  117117. * The encoder is not currently implemented.
  117118. *
  117119. * **Decoder**
  117120. *
  117121. * 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.
  117122. *
  117123. * To update the configuration, use the following code:
  117124. * ```javascript
  117125. * DracoCompression.Configuration = {
  117126. * decoder: {
  117127. * wasmUrl: "<url to the WebAssembly library>",
  117128. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  117129. * fallbackUrl: "<url to the fallback JavaScript library>",
  117130. * }
  117131. * };
  117132. * ```
  117133. *
  117134. * 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.
  117135. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  117136. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  117137. *
  117138. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  117139. * ```javascript
  117140. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  117141. * ```
  117142. *
  117143. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  117144. */
  117145. export class DracoCompression implements IDisposable {
  117146. private _workerPoolPromise?;
  117147. private _decoderModulePromise?;
  117148. /**
  117149. * The configuration. Defaults to the following urls:
  117150. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  117151. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  117152. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  117153. */
  117154. static Configuration: IDracoCompressionConfiguration;
  117155. /**
  117156. * Returns true if the decoder configuration is available.
  117157. */
  117158. static readonly DecoderAvailable: boolean;
  117159. /**
  117160. * Default number of workers to create when creating the draco compression object.
  117161. */
  117162. static DefaultNumWorkers: number;
  117163. private static GetDefaultNumWorkers;
  117164. private static _Default;
  117165. /**
  117166. * Default instance for the draco compression object.
  117167. */
  117168. static readonly Default: DracoCompression;
  117169. /**
  117170. * Constructor
  117171. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  117172. */
  117173. constructor(numWorkers?: number);
  117174. /**
  117175. * Stop all async operations and release resources.
  117176. */
  117177. dispose(): void;
  117178. /**
  117179. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  117180. * @returns a promise that resolves when ready
  117181. */
  117182. whenReadyAsync(): Promise<void>;
  117183. /**
  117184. * Decode Draco compressed mesh data to vertex data.
  117185. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  117186. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  117187. * @returns A promise that resolves with the decoded vertex data
  117188. */
  117189. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  117190. [kind: string]: number;
  117191. }): Promise<VertexData>;
  117192. }
  117193. }
  117194. declare module BABYLON {
  117195. /**
  117196. * Class for building Constructive Solid Geometry
  117197. */
  117198. export class CSG {
  117199. private polygons;
  117200. /**
  117201. * The world matrix
  117202. */
  117203. matrix: Matrix;
  117204. /**
  117205. * Stores the position
  117206. */
  117207. position: Vector3;
  117208. /**
  117209. * Stores the rotation
  117210. */
  117211. rotation: Vector3;
  117212. /**
  117213. * Stores the rotation quaternion
  117214. */
  117215. rotationQuaternion: Nullable<Quaternion>;
  117216. /**
  117217. * Stores the scaling vector
  117218. */
  117219. scaling: Vector3;
  117220. /**
  117221. * Convert the Mesh to CSG
  117222. * @param mesh The Mesh to convert to CSG
  117223. * @returns A new CSG from the Mesh
  117224. */
  117225. static FromMesh(mesh: Mesh): CSG;
  117226. /**
  117227. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  117228. * @param polygons Polygons used to construct a CSG solid
  117229. */
  117230. private static FromPolygons;
  117231. /**
  117232. * Clones, or makes a deep copy, of the CSG
  117233. * @returns A new CSG
  117234. */
  117235. clone(): CSG;
  117236. /**
  117237. * Unions this CSG with another CSG
  117238. * @param csg The CSG to union against this CSG
  117239. * @returns The unioned CSG
  117240. */
  117241. union(csg: CSG): CSG;
  117242. /**
  117243. * Unions this CSG with another CSG in place
  117244. * @param csg The CSG to union against this CSG
  117245. */
  117246. unionInPlace(csg: CSG): void;
  117247. /**
  117248. * Subtracts this CSG with another CSG
  117249. * @param csg The CSG to subtract against this CSG
  117250. * @returns A new CSG
  117251. */
  117252. subtract(csg: CSG): CSG;
  117253. /**
  117254. * Subtracts this CSG with another CSG in place
  117255. * @param csg The CSG to subtact against this CSG
  117256. */
  117257. subtractInPlace(csg: CSG): void;
  117258. /**
  117259. * Intersect this CSG with another CSG
  117260. * @param csg The CSG to intersect against this CSG
  117261. * @returns A new CSG
  117262. */
  117263. intersect(csg: CSG): CSG;
  117264. /**
  117265. * Intersects this CSG with another CSG in place
  117266. * @param csg The CSG to intersect against this CSG
  117267. */
  117268. intersectInPlace(csg: CSG): void;
  117269. /**
  117270. * Return a new CSG solid with solid and empty space switched. This solid is
  117271. * not modified.
  117272. * @returns A new CSG solid with solid and empty space switched
  117273. */
  117274. inverse(): CSG;
  117275. /**
  117276. * Inverses the CSG in place
  117277. */
  117278. inverseInPlace(): void;
  117279. /**
  117280. * This is used to keep meshes transformations so they can be restored
  117281. * when we build back a Babylon Mesh
  117282. * NB : All CSG operations are performed in world coordinates
  117283. * @param csg The CSG to copy the transform attributes from
  117284. * @returns This CSG
  117285. */
  117286. copyTransformAttributes(csg: CSG): CSG;
  117287. /**
  117288. * Build Raw mesh from CSG
  117289. * Coordinates here are in world space
  117290. * @param name The name of the mesh geometry
  117291. * @param scene The Scene
  117292. * @param keepSubMeshes Specifies if the submeshes should be kept
  117293. * @returns A new Mesh
  117294. */
  117295. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  117296. /**
  117297. * Build Mesh from CSG taking material and transforms into account
  117298. * @param name The name of the Mesh
  117299. * @param material The material of the Mesh
  117300. * @param scene The Scene
  117301. * @param keepSubMeshes Specifies if submeshes should be kept
  117302. * @returns The new Mesh
  117303. */
  117304. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  117305. }
  117306. }
  117307. declare module BABYLON {
  117308. /**
  117309. * Class used to create a trail following a mesh
  117310. */
  117311. export class TrailMesh extends Mesh {
  117312. private _generator;
  117313. private _autoStart;
  117314. private _running;
  117315. private _diameter;
  117316. private _length;
  117317. private _sectionPolygonPointsCount;
  117318. private _sectionVectors;
  117319. private _sectionNormalVectors;
  117320. private _beforeRenderObserver;
  117321. /**
  117322. * @constructor
  117323. * @param name The value used by scene.getMeshByName() to do a lookup.
  117324. * @param generator The mesh to generate a trail.
  117325. * @param scene The scene to add this mesh to.
  117326. * @param diameter Diameter of trailing mesh. Default is 1.
  117327. * @param length Length of trailing mesh. Default is 60.
  117328. * @param autoStart Automatically start trailing mesh. Default true.
  117329. */
  117330. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  117331. /**
  117332. * "TrailMesh"
  117333. * @returns "TrailMesh"
  117334. */
  117335. getClassName(): string;
  117336. private _createMesh;
  117337. /**
  117338. * Start trailing mesh.
  117339. */
  117340. start(): void;
  117341. /**
  117342. * Stop trailing mesh.
  117343. */
  117344. stop(): void;
  117345. /**
  117346. * Update trailing mesh geometry.
  117347. */
  117348. update(): void;
  117349. /**
  117350. * Returns a new TrailMesh object.
  117351. * @param name is a string, the name given to the new mesh
  117352. * @param newGenerator use new generator object for cloned trail mesh
  117353. * @returns a new mesh
  117354. */
  117355. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  117356. /**
  117357. * Serializes this trail mesh
  117358. * @param serializationObject object to write serialization to
  117359. */
  117360. serialize(serializationObject: any): void;
  117361. /**
  117362. * Parses a serialized trail mesh
  117363. * @param parsedMesh the serialized mesh
  117364. * @param scene the scene to create the trail mesh in
  117365. * @returns the created trail mesh
  117366. */
  117367. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  117368. }
  117369. }
  117370. declare module BABYLON {
  117371. /**
  117372. * Class containing static functions to help procedurally build meshes
  117373. */
  117374. export class TiledBoxBuilder {
  117375. /**
  117376. * Creates a box mesh
  117377. * 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)
  117378. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117380. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117382. * @param name defines the name of the mesh
  117383. * @param options defines the options used to create the mesh
  117384. * @param scene defines the hosting scene
  117385. * @returns the box mesh
  117386. */
  117387. static CreateTiledBox(name: string, options: {
  117388. pattern?: number;
  117389. width?: number;
  117390. height?: number;
  117391. depth?: number;
  117392. tileSize?: number;
  117393. tileWidth?: number;
  117394. tileHeight?: number;
  117395. alignHorizontal?: number;
  117396. alignVertical?: number;
  117397. faceUV?: Vector4[];
  117398. faceColors?: Color4[];
  117399. sideOrientation?: number;
  117400. updatable?: boolean;
  117401. }, scene?: Nullable<Scene>): Mesh;
  117402. }
  117403. }
  117404. declare module BABYLON {
  117405. /**
  117406. * Class containing static functions to help procedurally build meshes
  117407. */
  117408. export class TorusKnotBuilder {
  117409. /**
  117410. * Creates a torus knot mesh
  117411. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  117412. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  117413. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  117414. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  117415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117418. * @param name defines the name of the mesh
  117419. * @param options defines the options used to create the mesh
  117420. * @param scene defines the hosting scene
  117421. * @returns the torus knot mesh
  117422. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  117423. */
  117424. static CreateTorusKnot(name: string, options: {
  117425. radius?: number;
  117426. tube?: number;
  117427. radialSegments?: number;
  117428. tubularSegments?: number;
  117429. p?: number;
  117430. q?: number;
  117431. updatable?: boolean;
  117432. sideOrientation?: number;
  117433. frontUVs?: Vector4;
  117434. backUVs?: Vector4;
  117435. }, scene: any): Mesh;
  117436. }
  117437. }
  117438. declare module BABYLON {
  117439. /**
  117440. * Polygon
  117441. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  117442. */
  117443. export class Polygon {
  117444. /**
  117445. * Creates a rectangle
  117446. * @param xmin bottom X coord
  117447. * @param ymin bottom Y coord
  117448. * @param xmax top X coord
  117449. * @param ymax top Y coord
  117450. * @returns points that make the resulting rectation
  117451. */
  117452. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  117453. /**
  117454. * Creates a circle
  117455. * @param radius radius of circle
  117456. * @param cx scale in x
  117457. * @param cy scale in y
  117458. * @param numberOfSides number of sides that make up the circle
  117459. * @returns points that make the resulting circle
  117460. */
  117461. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  117462. /**
  117463. * Creates a polygon from input string
  117464. * @param input Input polygon data
  117465. * @returns the parsed points
  117466. */
  117467. static Parse(input: string): Vector2[];
  117468. /**
  117469. * Starts building a polygon from x and y coordinates
  117470. * @param x x coordinate
  117471. * @param y y coordinate
  117472. * @returns the started path2
  117473. */
  117474. static StartingAt(x: number, y: number): Path2;
  117475. }
  117476. /**
  117477. * Builds a polygon
  117478. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  117479. */
  117480. export class PolygonMeshBuilder {
  117481. private _points;
  117482. private _outlinepoints;
  117483. private _holes;
  117484. private _name;
  117485. private _scene;
  117486. private _epoints;
  117487. private _eholes;
  117488. private _addToepoint;
  117489. /**
  117490. * Babylon reference to the earcut plugin.
  117491. */
  117492. bjsEarcut: any;
  117493. /**
  117494. * Creates a PolygonMeshBuilder
  117495. * @param name name of the builder
  117496. * @param contours Path of the polygon
  117497. * @param scene scene to add to when creating the mesh
  117498. * @param earcutInjection can be used to inject your own earcut reference
  117499. */
  117500. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  117501. /**
  117502. * Adds a whole within the polygon
  117503. * @param hole Array of points defining the hole
  117504. * @returns this
  117505. */
  117506. addHole(hole: Vector2[]): PolygonMeshBuilder;
  117507. /**
  117508. * Creates the polygon
  117509. * @param updatable If the mesh should be updatable
  117510. * @param depth The depth of the mesh created
  117511. * @returns the created mesh
  117512. */
  117513. build(updatable?: boolean, depth?: number): Mesh;
  117514. /**
  117515. * Creates the polygon
  117516. * @param depth The depth of the mesh created
  117517. * @returns the created VertexData
  117518. */
  117519. buildVertexData(depth?: number): VertexData;
  117520. /**
  117521. * Adds a side to the polygon
  117522. * @param positions points that make the polygon
  117523. * @param normals normals of the polygon
  117524. * @param uvs uvs of the polygon
  117525. * @param indices indices of the polygon
  117526. * @param bounds bounds of the polygon
  117527. * @param points points of the polygon
  117528. * @param depth depth of the polygon
  117529. * @param flip flip of the polygon
  117530. */
  117531. private addSide;
  117532. }
  117533. }
  117534. declare module BABYLON {
  117535. /**
  117536. * Class containing static functions to help procedurally build meshes
  117537. */
  117538. export class PolygonBuilder {
  117539. /**
  117540. * Creates a polygon mesh
  117541. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  117542. * * 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
  117543. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  117546. * * Remember you can only change the shape positions, not their number when updating a polygon
  117547. * @param name defines the name of the mesh
  117548. * @param options defines the options used to create the mesh
  117549. * @param scene defines the hosting scene
  117550. * @param earcutInjection can be used to inject your own earcut reference
  117551. * @returns the polygon mesh
  117552. */
  117553. static CreatePolygon(name: string, options: {
  117554. shape: Vector3[];
  117555. holes?: Vector3[][];
  117556. depth?: number;
  117557. faceUV?: Vector4[];
  117558. faceColors?: Color4[];
  117559. updatable?: boolean;
  117560. sideOrientation?: number;
  117561. frontUVs?: Vector4;
  117562. backUVs?: Vector4;
  117563. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117564. /**
  117565. * Creates an extruded polygon mesh, with depth in the Y direction.
  117566. * * 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)
  117567. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117568. * @param name defines the name of the mesh
  117569. * @param options defines the options used to create the mesh
  117570. * @param scene defines the hosting scene
  117571. * @param earcutInjection can be used to inject your own earcut reference
  117572. * @returns the polygon mesh
  117573. */
  117574. static ExtrudePolygon(name: string, options: {
  117575. shape: Vector3[];
  117576. holes?: Vector3[][];
  117577. depth?: number;
  117578. faceUV?: Vector4[];
  117579. faceColors?: Color4[];
  117580. updatable?: boolean;
  117581. sideOrientation?: number;
  117582. frontUVs?: Vector4;
  117583. backUVs?: Vector4;
  117584. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117585. }
  117586. }
  117587. declare module BABYLON {
  117588. /**
  117589. * Class containing static functions to help procedurally build meshes
  117590. */
  117591. export class LatheBuilder {
  117592. /**
  117593. * Creates lathe mesh.
  117594. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  117595. * * 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
  117596. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  117597. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  117598. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  117599. * * 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
  117600. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  117601. * * 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
  117602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117604. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117606. * @param name defines the name of the mesh
  117607. * @param options defines the options used to create the mesh
  117608. * @param scene defines the hosting scene
  117609. * @returns the lathe mesh
  117610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  117611. */
  117612. static CreateLathe(name: string, options: {
  117613. shape: Vector3[];
  117614. radius?: number;
  117615. tessellation?: number;
  117616. clip?: number;
  117617. arc?: number;
  117618. closed?: boolean;
  117619. updatable?: boolean;
  117620. sideOrientation?: number;
  117621. frontUVs?: Vector4;
  117622. backUVs?: Vector4;
  117623. cap?: number;
  117624. invertUV?: boolean;
  117625. }, scene?: Nullable<Scene>): Mesh;
  117626. }
  117627. }
  117628. declare module BABYLON {
  117629. /**
  117630. * Class containing static functions to help procedurally build meshes
  117631. */
  117632. export class TiledPlaneBuilder {
  117633. /**
  117634. * Creates a tiled plane mesh
  117635. * * The parameter `pattern` will, depending on value, do nothing or
  117636. * * * flip (reflect about central vertical) alternate tiles across and up
  117637. * * * flip every tile on alternate rows
  117638. * * * rotate (180 degs) alternate tiles across and up
  117639. * * * rotate every tile on alternate rows
  117640. * * * flip and rotate alternate tiles across and up
  117641. * * * flip and rotate every tile on alternate rows
  117642. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  117643. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  117644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117645. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117646. * * 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)
  117647. * * 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)
  117648. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117649. * @param name defines the name of the mesh
  117650. * @param options defines the options used to create the mesh
  117651. * @param scene defines the hosting scene
  117652. * @returns the box mesh
  117653. */
  117654. static CreateTiledPlane(name: string, options: {
  117655. pattern?: number;
  117656. tileSize?: number;
  117657. tileWidth?: number;
  117658. tileHeight?: number;
  117659. size?: number;
  117660. width?: number;
  117661. height?: number;
  117662. alignHorizontal?: number;
  117663. alignVertical?: number;
  117664. sideOrientation?: number;
  117665. frontUVs?: Vector4;
  117666. backUVs?: Vector4;
  117667. updatable?: boolean;
  117668. }, scene?: Nullable<Scene>): Mesh;
  117669. }
  117670. }
  117671. declare module BABYLON {
  117672. /**
  117673. * Class containing static functions to help procedurally build meshes
  117674. */
  117675. export class TubeBuilder {
  117676. /**
  117677. * Creates a tube mesh.
  117678. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117679. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  117680. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  117681. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  117682. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  117683. * * 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)
  117684. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  117685. * * 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
  117686. * * 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
  117687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117689. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117691. * @param name defines the name of the mesh
  117692. * @param options defines the options used to create the mesh
  117693. * @param scene defines the hosting scene
  117694. * @returns the tube mesh
  117695. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117696. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  117697. */
  117698. static CreateTube(name: string, options: {
  117699. path: Vector3[];
  117700. radius?: number;
  117701. tessellation?: number;
  117702. radiusFunction?: {
  117703. (i: number, distance: number): number;
  117704. };
  117705. cap?: number;
  117706. arc?: number;
  117707. updatable?: boolean;
  117708. sideOrientation?: number;
  117709. frontUVs?: Vector4;
  117710. backUVs?: Vector4;
  117711. instance?: Mesh;
  117712. invertUV?: boolean;
  117713. }, scene?: Nullable<Scene>): Mesh;
  117714. }
  117715. }
  117716. declare module BABYLON {
  117717. /**
  117718. * Class containing static functions to help procedurally build meshes
  117719. */
  117720. export class IcoSphereBuilder {
  117721. /**
  117722. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  117723. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  117724. * * 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`)
  117725. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  117726. * * 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
  117727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117730. * @param name defines the name of the mesh
  117731. * @param options defines the options used to create the mesh
  117732. * @param scene defines the hosting scene
  117733. * @returns the icosahedron mesh
  117734. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  117735. */
  117736. static CreateIcoSphere(name: string, options: {
  117737. radius?: number;
  117738. radiusX?: number;
  117739. radiusY?: number;
  117740. radiusZ?: number;
  117741. flat?: boolean;
  117742. subdivisions?: number;
  117743. sideOrientation?: number;
  117744. frontUVs?: Vector4;
  117745. backUVs?: Vector4;
  117746. updatable?: boolean;
  117747. }, scene?: Nullable<Scene>): Mesh;
  117748. }
  117749. }
  117750. declare module BABYLON {
  117751. /**
  117752. * Class containing static functions to help procedurally build meshes
  117753. */
  117754. export class DecalBuilder {
  117755. /**
  117756. * Creates a decal mesh.
  117757. * 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
  117758. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  117759. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  117760. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  117761. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  117762. * @param name defines the name of the mesh
  117763. * @param sourceMesh defines the mesh where the decal must be applied
  117764. * @param options defines the options used to create the mesh
  117765. * @param scene defines the hosting scene
  117766. * @returns the decal mesh
  117767. * @see https://doc.babylonjs.com/how_to/decals
  117768. */
  117769. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  117770. position?: Vector3;
  117771. normal?: Vector3;
  117772. size?: Vector3;
  117773. angle?: number;
  117774. }): Mesh;
  117775. }
  117776. }
  117777. declare module BABYLON {
  117778. /**
  117779. * Class containing static functions to help procedurally build meshes
  117780. */
  117781. export class MeshBuilder {
  117782. /**
  117783. * Creates a box mesh
  117784. * * The parameter `size` sets the size (float) of each box side (default 1)
  117785. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  117786. * * 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)
  117787. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117791. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117792. * @param name defines the name of the mesh
  117793. * @param options defines the options used to create the mesh
  117794. * @param scene defines the hosting scene
  117795. * @returns the box mesh
  117796. */
  117797. static CreateBox(name: string, options: {
  117798. size?: number;
  117799. width?: number;
  117800. height?: number;
  117801. depth?: number;
  117802. faceUV?: Vector4[];
  117803. faceColors?: Color4[];
  117804. sideOrientation?: number;
  117805. frontUVs?: Vector4;
  117806. backUVs?: Vector4;
  117807. updatable?: boolean;
  117808. }, scene?: Nullable<Scene>): Mesh;
  117809. /**
  117810. * Creates a tiled box mesh
  117811. * * faceTiles sets the pattern, tile size and number of tiles for a face
  117812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117813. * @param name defines the name of the mesh
  117814. * @param options defines the options used to create the mesh
  117815. * @param scene defines the hosting scene
  117816. * @returns the tiled box mesh
  117817. */
  117818. static CreateTiledBox(name: string, options: {
  117819. pattern?: number;
  117820. size?: number;
  117821. width?: number;
  117822. height?: number;
  117823. depth: number;
  117824. tileSize?: number;
  117825. tileWidth?: number;
  117826. tileHeight?: number;
  117827. faceUV?: Vector4[];
  117828. faceColors?: Color4[];
  117829. alignHorizontal?: number;
  117830. alignVertical?: number;
  117831. sideOrientation?: number;
  117832. updatable?: boolean;
  117833. }, scene?: Nullable<Scene>): Mesh;
  117834. /**
  117835. * Creates a sphere mesh
  117836. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117837. * * 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`)
  117838. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117839. * * 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
  117840. * * 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)
  117841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117844. * @param name defines the name of the mesh
  117845. * @param options defines the options used to create the mesh
  117846. * @param scene defines the hosting scene
  117847. * @returns the sphere mesh
  117848. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117849. */
  117850. static CreateSphere(name: string, options: {
  117851. segments?: number;
  117852. diameter?: number;
  117853. diameterX?: number;
  117854. diameterY?: number;
  117855. diameterZ?: number;
  117856. arc?: number;
  117857. slice?: number;
  117858. sideOrientation?: number;
  117859. frontUVs?: Vector4;
  117860. backUVs?: Vector4;
  117861. updatable?: boolean;
  117862. }, scene?: Nullable<Scene>): Mesh;
  117863. /**
  117864. * Creates a plane polygonal mesh. By default, this is a disc
  117865. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  117866. * * 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
  117867. * * 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
  117868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117871. * @param name defines the name of the mesh
  117872. * @param options defines the options used to create the mesh
  117873. * @param scene defines the hosting scene
  117874. * @returns the plane polygonal mesh
  117875. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  117876. */
  117877. static CreateDisc(name: string, options: {
  117878. radius?: number;
  117879. tessellation?: number;
  117880. arc?: number;
  117881. updatable?: boolean;
  117882. sideOrientation?: number;
  117883. frontUVs?: Vector4;
  117884. backUVs?: Vector4;
  117885. }, scene?: Nullable<Scene>): Mesh;
  117886. /**
  117887. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  117888. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  117889. * * 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`)
  117890. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  117891. * * 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
  117892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117895. * @param name defines the name of the mesh
  117896. * @param options defines the options used to create the mesh
  117897. * @param scene defines the hosting scene
  117898. * @returns the icosahedron mesh
  117899. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  117900. */
  117901. static CreateIcoSphere(name: string, options: {
  117902. radius?: number;
  117903. radiusX?: number;
  117904. radiusY?: number;
  117905. radiusZ?: number;
  117906. flat?: boolean;
  117907. subdivisions?: number;
  117908. sideOrientation?: number;
  117909. frontUVs?: Vector4;
  117910. backUVs?: Vector4;
  117911. updatable?: boolean;
  117912. }, scene?: Nullable<Scene>): Mesh;
  117913. /**
  117914. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117915. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117916. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117917. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117918. * * 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
  117919. * * 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
  117920. * * 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
  117921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117923. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117924. * * 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
  117925. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117926. * * 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
  117927. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117929. * @param name defines the name of the mesh
  117930. * @param options defines the options used to create the mesh
  117931. * @param scene defines the hosting scene
  117932. * @returns the ribbon mesh
  117933. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117934. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117935. */
  117936. static CreateRibbon(name: string, options: {
  117937. pathArray: Vector3[][];
  117938. closeArray?: boolean;
  117939. closePath?: boolean;
  117940. offset?: number;
  117941. updatable?: boolean;
  117942. sideOrientation?: number;
  117943. frontUVs?: Vector4;
  117944. backUVs?: Vector4;
  117945. instance?: Mesh;
  117946. invertUV?: boolean;
  117947. uvs?: Vector2[];
  117948. colors?: Color4[];
  117949. }, scene?: Nullable<Scene>): Mesh;
  117950. /**
  117951. * Creates a cylinder or a cone mesh
  117952. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  117953. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  117954. * * 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.
  117955. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  117956. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  117957. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  117958. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  117959. * * 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).
  117960. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  117961. * * 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).
  117962. * * 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
  117963. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  117964. * * 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
  117965. * * 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.
  117966. * * If `enclose` is false, a ring surface is one element.
  117967. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  117968. * * 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
  117969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117972. * @param name defines the name of the mesh
  117973. * @param options defines the options used to create the mesh
  117974. * @param scene defines the hosting scene
  117975. * @returns the cylinder mesh
  117976. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  117977. */
  117978. static CreateCylinder(name: string, options: {
  117979. height?: number;
  117980. diameterTop?: number;
  117981. diameterBottom?: number;
  117982. diameter?: number;
  117983. tessellation?: number;
  117984. subdivisions?: number;
  117985. arc?: number;
  117986. faceColors?: Color4[];
  117987. faceUV?: Vector4[];
  117988. updatable?: boolean;
  117989. hasRings?: boolean;
  117990. enclose?: boolean;
  117991. cap?: number;
  117992. sideOrientation?: number;
  117993. frontUVs?: Vector4;
  117994. backUVs?: Vector4;
  117995. }, scene?: Nullable<Scene>): Mesh;
  117996. /**
  117997. * Creates a torus mesh
  117998. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  117999. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  118000. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  118001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118004. * @param name defines the name of the mesh
  118005. * @param options defines the options used to create the mesh
  118006. * @param scene defines the hosting scene
  118007. * @returns the torus mesh
  118008. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  118009. */
  118010. static CreateTorus(name: string, options: {
  118011. diameter?: number;
  118012. thickness?: number;
  118013. tessellation?: number;
  118014. updatable?: boolean;
  118015. sideOrientation?: number;
  118016. frontUVs?: Vector4;
  118017. backUVs?: Vector4;
  118018. }, scene?: Nullable<Scene>): Mesh;
  118019. /**
  118020. * Creates a torus knot mesh
  118021. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  118022. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  118023. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  118024. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  118025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118028. * @param name defines the name of the mesh
  118029. * @param options defines the options used to create the mesh
  118030. * @param scene defines the hosting scene
  118031. * @returns the torus knot mesh
  118032. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  118033. */
  118034. static CreateTorusKnot(name: string, options: {
  118035. radius?: number;
  118036. tube?: number;
  118037. radialSegments?: number;
  118038. tubularSegments?: number;
  118039. p?: number;
  118040. q?: number;
  118041. updatable?: boolean;
  118042. sideOrientation?: number;
  118043. frontUVs?: Vector4;
  118044. backUVs?: Vector4;
  118045. }, scene?: Nullable<Scene>): Mesh;
  118046. /**
  118047. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118048. * * 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
  118049. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118050. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118051. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118052. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118053. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118054. * * 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
  118055. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118058. * @param name defines the name of the new line system
  118059. * @param options defines the options used to create the line system
  118060. * @param scene defines the hosting scene
  118061. * @returns a new line system mesh
  118062. */
  118063. static CreateLineSystem(name: string, options: {
  118064. lines: Vector3[][];
  118065. updatable?: boolean;
  118066. instance?: Nullable<LinesMesh>;
  118067. colors?: Nullable<Color4[][]>;
  118068. useVertexAlpha?: boolean;
  118069. }, scene: Nullable<Scene>): LinesMesh;
  118070. /**
  118071. * Creates a line mesh
  118072. * 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
  118073. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118074. * * The parameter `points` is an array successive Vector3
  118075. * * 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
  118076. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118077. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118078. * * When updating an instance, remember that only point positions can change, not the number of points
  118079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118081. * @param name defines the name of the new line system
  118082. * @param options defines the options used to create the line system
  118083. * @param scene defines the hosting scene
  118084. * @returns a new line mesh
  118085. */
  118086. static CreateLines(name: string, options: {
  118087. points: Vector3[];
  118088. updatable?: boolean;
  118089. instance?: Nullable<LinesMesh>;
  118090. colors?: Color4[];
  118091. useVertexAlpha?: boolean;
  118092. }, scene?: Nullable<Scene>): LinesMesh;
  118093. /**
  118094. * Creates a dashed line mesh
  118095. * * 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
  118096. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118097. * * The parameter `points` is an array successive Vector3
  118098. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118099. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118100. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118101. * * 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
  118102. * * When updating an instance, remember that only point positions can change, not the number of points
  118103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118104. * @param name defines the name of the mesh
  118105. * @param options defines the options used to create the mesh
  118106. * @param scene defines the hosting scene
  118107. * @returns the dashed line mesh
  118108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118109. */
  118110. static CreateDashedLines(name: string, options: {
  118111. points: Vector3[];
  118112. dashSize?: number;
  118113. gapSize?: number;
  118114. dashNb?: number;
  118115. updatable?: boolean;
  118116. instance?: LinesMesh;
  118117. }, scene?: Nullable<Scene>): LinesMesh;
  118118. /**
  118119. * 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.
  118120. * * 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.
  118121. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118122. * * 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.
  118123. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  118124. * * 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
  118125. * * 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
  118126. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  118127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  118130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118131. * @param name defines the name of the mesh
  118132. * @param options defines the options used to create the mesh
  118133. * @param scene defines the hosting scene
  118134. * @returns the extruded shape mesh
  118135. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118136. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118137. */
  118138. static ExtrudeShape(name: string, options: {
  118139. shape: Vector3[];
  118140. path: Vector3[];
  118141. scale?: number;
  118142. rotation?: number;
  118143. cap?: number;
  118144. updatable?: boolean;
  118145. sideOrientation?: number;
  118146. frontUVs?: Vector4;
  118147. backUVs?: Vector4;
  118148. instance?: Mesh;
  118149. invertUV?: boolean;
  118150. }, scene?: Nullable<Scene>): Mesh;
  118151. /**
  118152. * Creates an custom extruded shape mesh.
  118153. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  118154. * * 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.
  118155. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118156. * * 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
  118157. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  118158. * * 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
  118159. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118160. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118161. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118162. * * 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
  118163. * * 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
  118164. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118167. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118169. * @param name defines the name of the mesh
  118170. * @param options defines the options used to create the mesh
  118171. * @param scene defines the hosting scene
  118172. * @returns the custom extruded shape mesh
  118173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118174. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118176. */
  118177. static ExtrudeShapeCustom(name: string, options: {
  118178. shape: Vector3[];
  118179. path: Vector3[];
  118180. scaleFunction?: any;
  118181. rotationFunction?: any;
  118182. ribbonCloseArray?: boolean;
  118183. ribbonClosePath?: boolean;
  118184. cap?: number;
  118185. updatable?: boolean;
  118186. sideOrientation?: number;
  118187. frontUVs?: Vector4;
  118188. backUVs?: Vector4;
  118189. instance?: Mesh;
  118190. invertUV?: boolean;
  118191. }, scene?: Nullable<Scene>): Mesh;
  118192. /**
  118193. * Creates lathe mesh.
  118194. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  118195. * * 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
  118196. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  118197. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  118198. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  118199. * * 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
  118200. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  118201. * * 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
  118202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118204. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118206. * @param name defines the name of the mesh
  118207. * @param options defines the options used to create the mesh
  118208. * @param scene defines the hosting scene
  118209. * @returns the lathe mesh
  118210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  118211. */
  118212. static CreateLathe(name: string, options: {
  118213. shape: Vector3[];
  118214. radius?: number;
  118215. tessellation?: number;
  118216. clip?: number;
  118217. arc?: number;
  118218. closed?: boolean;
  118219. updatable?: boolean;
  118220. sideOrientation?: number;
  118221. frontUVs?: Vector4;
  118222. backUVs?: Vector4;
  118223. cap?: number;
  118224. invertUV?: boolean;
  118225. }, scene?: Nullable<Scene>): Mesh;
  118226. /**
  118227. * Creates a tiled plane mesh
  118228. * * You can set a limited pattern arrangement with the tiles
  118229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118232. * @param name defines the name of the mesh
  118233. * @param options defines the options used to create the mesh
  118234. * @param scene defines the hosting scene
  118235. * @returns the plane mesh
  118236. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  118237. */
  118238. static CreateTiledPlane(name: string, options: {
  118239. pattern?: number;
  118240. tileSize?: number;
  118241. tileWidth?: number;
  118242. tileHeight?: number;
  118243. size?: number;
  118244. width?: number;
  118245. height?: number;
  118246. alignHorizontal?: number;
  118247. alignVertical?: number;
  118248. sideOrientation?: number;
  118249. frontUVs?: Vector4;
  118250. backUVs?: Vector4;
  118251. updatable?: boolean;
  118252. }, scene?: Nullable<Scene>): Mesh;
  118253. /**
  118254. * Creates a plane mesh
  118255. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  118256. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  118257. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  118258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118261. * @param name defines the name of the mesh
  118262. * @param options defines the options used to create the mesh
  118263. * @param scene defines the hosting scene
  118264. * @returns the plane mesh
  118265. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  118266. */
  118267. static CreatePlane(name: string, options: {
  118268. size?: number;
  118269. width?: number;
  118270. height?: number;
  118271. sideOrientation?: number;
  118272. frontUVs?: Vector4;
  118273. backUVs?: Vector4;
  118274. updatable?: boolean;
  118275. sourcePlane?: Plane;
  118276. }, scene?: Nullable<Scene>): Mesh;
  118277. /**
  118278. * Creates a ground mesh
  118279. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  118280. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  118281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118282. * @param name defines the name of the mesh
  118283. * @param options defines the options used to create the mesh
  118284. * @param scene defines the hosting scene
  118285. * @returns the ground mesh
  118286. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  118287. */
  118288. static CreateGround(name: string, options: {
  118289. width?: number;
  118290. height?: number;
  118291. subdivisions?: number;
  118292. subdivisionsX?: number;
  118293. subdivisionsY?: number;
  118294. updatable?: boolean;
  118295. }, scene?: Nullable<Scene>): Mesh;
  118296. /**
  118297. * Creates a tiled ground mesh
  118298. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  118299. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  118300. * * 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
  118301. * * 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
  118302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118303. * @param name defines the name of the mesh
  118304. * @param options defines the options used to create the mesh
  118305. * @param scene defines the hosting scene
  118306. * @returns the tiled ground mesh
  118307. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  118308. */
  118309. static CreateTiledGround(name: string, options: {
  118310. xmin: number;
  118311. zmin: number;
  118312. xmax: number;
  118313. zmax: number;
  118314. subdivisions?: {
  118315. w: number;
  118316. h: number;
  118317. };
  118318. precision?: {
  118319. w: number;
  118320. h: number;
  118321. };
  118322. updatable?: boolean;
  118323. }, scene?: Nullable<Scene>): Mesh;
  118324. /**
  118325. * Creates a ground mesh from a height map
  118326. * * The parameter `url` sets the URL of the height map image resource.
  118327. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  118328. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  118329. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  118330. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  118331. * * 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.
  118332. * * 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).
  118333. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118335. * @param name defines the name of the mesh
  118336. * @param url defines the url to the height map
  118337. * @param options defines the options used to create the mesh
  118338. * @param scene defines the hosting scene
  118339. * @returns the ground mesh
  118340. * @see https://doc.babylonjs.com/babylon101/height_map
  118341. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  118342. */
  118343. static CreateGroundFromHeightMap(name: string, url: string, options: {
  118344. width?: number;
  118345. height?: number;
  118346. subdivisions?: number;
  118347. minHeight?: number;
  118348. maxHeight?: number;
  118349. colorFilter?: Color3;
  118350. alphaFilter?: number;
  118351. updatable?: boolean;
  118352. onReady?: (mesh: GroundMesh) => void;
  118353. }, scene?: Nullable<Scene>): GroundMesh;
  118354. /**
  118355. * Creates a polygon mesh
  118356. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  118357. * * 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
  118358. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  118361. * * Remember you can only change the shape positions, not their number when updating a polygon
  118362. * @param name defines the name of the mesh
  118363. * @param options defines the options used to create the mesh
  118364. * @param scene defines the hosting scene
  118365. * @param earcutInjection can be used to inject your own earcut reference
  118366. * @returns the polygon mesh
  118367. */
  118368. static CreatePolygon(name: string, options: {
  118369. shape: Vector3[];
  118370. holes?: Vector3[][];
  118371. depth?: number;
  118372. faceUV?: Vector4[];
  118373. faceColors?: Color4[];
  118374. updatable?: boolean;
  118375. sideOrientation?: number;
  118376. frontUVs?: Vector4;
  118377. backUVs?: Vector4;
  118378. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118379. /**
  118380. * Creates an extruded polygon mesh, with depth in the Y direction.
  118381. * * 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)
  118382. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118383. * @param name defines the name of the mesh
  118384. * @param options defines the options used to create the mesh
  118385. * @param scene defines the hosting scene
  118386. * @param earcutInjection can be used to inject your own earcut reference
  118387. * @returns the polygon mesh
  118388. */
  118389. static ExtrudePolygon(name: string, options: {
  118390. shape: Vector3[];
  118391. holes?: Vector3[][];
  118392. depth?: number;
  118393. faceUV?: Vector4[];
  118394. faceColors?: Color4[];
  118395. updatable?: boolean;
  118396. sideOrientation?: number;
  118397. frontUVs?: Vector4;
  118398. backUVs?: Vector4;
  118399. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118400. /**
  118401. * Creates a tube mesh.
  118402. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118403. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  118404. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  118405. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  118406. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  118407. * * 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)
  118408. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  118409. * * 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
  118410. * * 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
  118411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118413. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118415. * @param name defines the name of the mesh
  118416. * @param options defines the options used to create the mesh
  118417. * @param scene defines the hosting scene
  118418. * @returns the tube mesh
  118419. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118420. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  118421. */
  118422. static CreateTube(name: string, options: {
  118423. path: Vector3[];
  118424. radius?: number;
  118425. tessellation?: number;
  118426. radiusFunction?: {
  118427. (i: number, distance: number): number;
  118428. };
  118429. cap?: number;
  118430. arc?: number;
  118431. updatable?: boolean;
  118432. sideOrientation?: number;
  118433. frontUVs?: Vector4;
  118434. backUVs?: Vector4;
  118435. instance?: Mesh;
  118436. invertUV?: boolean;
  118437. }, scene?: Nullable<Scene>): Mesh;
  118438. /**
  118439. * Creates a polyhedron mesh
  118440. * * 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
  118441. * * The parameter `size` (positive float, default 1) sets the polygon size
  118442. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  118443. * * 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`
  118444. * * 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
  118445. * * 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)`)
  118446. * * 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
  118447. * * 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
  118448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118451. * @param name defines the name of the mesh
  118452. * @param options defines the options used to create the mesh
  118453. * @param scene defines the hosting scene
  118454. * @returns the polyhedron mesh
  118455. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  118456. */
  118457. static CreatePolyhedron(name: string, options: {
  118458. type?: number;
  118459. size?: number;
  118460. sizeX?: number;
  118461. sizeY?: number;
  118462. sizeZ?: number;
  118463. custom?: any;
  118464. faceUV?: Vector4[];
  118465. faceColors?: Color4[];
  118466. flat?: boolean;
  118467. updatable?: boolean;
  118468. sideOrientation?: number;
  118469. frontUVs?: Vector4;
  118470. backUVs?: Vector4;
  118471. }, scene?: Nullable<Scene>): Mesh;
  118472. /**
  118473. * Creates a decal mesh.
  118474. * 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
  118475. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  118476. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  118477. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  118478. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  118479. * @param name defines the name of the mesh
  118480. * @param sourceMesh defines the mesh where the decal must be applied
  118481. * @param options defines the options used to create the mesh
  118482. * @param scene defines the hosting scene
  118483. * @returns the decal mesh
  118484. * @see https://doc.babylonjs.com/how_to/decals
  118485. */
  118486. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  118487. position?: Vector3;
  118488. normal?: Vector3;
  118489. size?: Vector3;
  118490. angle?: number;
  118491. }): Mesh;
  118492. }
  118493. }
  118494. declare module BABYLON {
  118495. /**
  118496. * A simplifier interface for future simplification implementations
  118497. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118498. */
  118499. export interface ISimplifier {
  118500. /**
  118501. * Simplification of a given mesh according to the given settings.
  118502. * Since this requires computation, it is assumed that the function runs async.
  118503. * @param settings The settings of the simplification, including quality and distance
  118504. * @param successCallback A callback that will be called after the mesh was simplified.
  118505. * @param errorCallback in case of an error, this callback will be called. optional.
  118506. */
  118507. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  118508. }
  118509. /**
  118510. * Expected simplification settings.
  118511. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  118512. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118513. */
  118514. export interface ISimplificationSettings {
  118515. /**
  118516. * Gets or sets the expected quality
  118517. */
  118518. quality: number;
  118519. /**
  118520. * Gets or sets the distance when this optimized version should be used
  118521. */
  118522. distance: number;
  118523. /**
  118524. * Gets an already optimized mesh
  118525. */
  118526. optimizeMesh?: boolean;
  118527. }
  118528. /**
  118529. * Class used to specify simplification options
  118530. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118531. */
  118532. export class SimplificationSettings implements ISimplificationSettings {
  118533. /** expected quality */
  118534. quality: number;
  118535. /** distance when this optimized version should be used */
  118536. distance: number;
  118537. /** already optimized mesh */
  118538. optimizeMesh?: boolean | undefined;
  118539. /**
  118540. * Creates a SimplificationSettings
  118541. * @param quality expected quality
  118542. * @param distance distance when this optimized version should be used
  118543. * @param optimizeMesh already optimized mesh
  118544. */
  118545. constructor(
  118546. /** expected quality */
  118547. quality: number,
  118548. /** distance when this optimized version should be used */
  118549. distance: number,
  118550. /** already optimized mesh */
  118551. optimizeMesh?: boolean | undefined);
  118552. }
  118553. /**
  118554. * Interface used to define a simplification task
  118555. */
  118556. export interface ISimplificationTask {
  118557. /**
  118558. * Array of settings
  118559. */
  118560. settings: Array<ISimplificationSettings>;
  118561. /**
  118562. * Simplification type
  118563. */
  118564. simplificationType: SimplificationType;
  118565. /**
  118566. * Mesh to simplify
  118567. */
  118568. mesh: Mesh;
  118569. /**
  118570. * Callback called on success
  118571. */
  118572. successCallback?: () => void;
  118573. /**
  118574. * Defines if parallel processing can be used
  118575. */
  118576. parallelProcessing: boolean;
  118577. }
  118578. /**
  118579. * Queue used to order the simplification tasks
  118580. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118581. */
  118582. export class SimplificationQueue {
  118583. private _simplificationArray;
  118584. /**
  118585. * Gets a boolean indicating that the process is still running
  118586. */
  118587. running: boolean;
  118588. /**
  118589. * Creates a new queue
  118590. */
  118591. constructor();
  118592. /**
  118593. * Adds a new simplification task
  118594. * @param task defines a task to add
  118595. */
  118596. addTask(task: ISimplificationTask): void;
  118597. /**
  118598. * Execute next task
  118599. */
  118600. executeNext(): void;
  118601. /**
  118602. * Execute a simplification task
  118603. * @param task defines the task to run
  118604. */
  118605. runSimplification(task: ISimplificationTask): void;
  118606. private getSimplifier;
  118607. }
  118608. /**
  118609. * The implemented types of simplification
  118610. * At the moment only Quadratic Error Decimation is implemented
  118611. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118612. */
  118613. export enum SimplificationType {
  118614. /** Quadratic error decimation */
  118615. QUADRATIC = 0
  118616. }
  118617. }
  118618. declare module BABYLON {
  118619. interface Scene {
  118620. /** @hidden (Backing field) */
  118621. _simplificationQueue: SimplificationQueue;
  118622. /**
  118623. * Gets or sets the simplification queue attached to the scene
  118624. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118625. */
  118626. simplificationQueue: SimplificationQueue;
  118627. }
  118628. interface Mesh {
  118629. /**
  118630. * Simplify the mesh according to the given array of settings.
  118631. * Function will return immediately and will simplify async
  118632. * @param settings a collection of simplification settings
  118633. * @param parallelProcessing should all levels calculate parallel or one after the other
  118634. * @param simplificationType the type of simplification to run
  118635. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  118636. * @returns the current mesh
  118637. */
  118638. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  118639. }
  118640. /**
  118641. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  118642. * created in a scene
  118643. */
  118644. export class SimplicationQueueSceneComponent implements ISceneComponent {
  118645. /**
  118646. * The component name helpfull to identify the component in the list of scene components.
  118647. */
  118648. readonly name: string;
  118649. /**
  118650. * The scene the component belongs to.
  118651. */
  118652. scene: Scene;
  118653. /**
  118654. * Creates a new instance of the component for the given scene
  118655. * @param scene Defines the scene to register the component in
  118656. */
  118657. constructor(scene: Scene);
  118658. /**
  118659. * Registers the component in a given scene
  118660. */
  118661. register(): void;
  118662. /**
  118663. * Rebuilds the elements related to this component in case of
  118664. * context lost for instance.
  118665. */
  118666. rebuild(): void;
  118667. /**
  118668. * Disposes the component and the associated ressources
  118669. */
  118670. dispose(): void;
  118671. private _beforeCameraUpdate;
  118672. }
  118673. }
  118674. declare module BABYLON {
  118675. /**
  118676. * Navigation plugin interface to add navigation constrained by a navigation mesh
  118677. */
  118678. export interface INavigationEnginePlugin {
  118679. /**
  118680. * plugin name
  118681. */
  118682. name: string;
  118683. /**
  118684. * Creates a navigation mesh
  118685. * @param meshes array of all the geometry used to compute the navigatio mesh
  118686. * @param parameters bunch of parameters used to filter geometry
  118687. */
  118688. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  118689. /**
  118690. * Create a navigation mesh debug mesh
  118691. * @param scene is where the mesh will be added
  118692. * @returns debug display mesh
  118693. */
  118694. createDebugNavMesh(scene: Scene): Mesh;
  118695. /**
  118696. * Get a navigation mesh constrained position, closest to the parameter position
  118697. * @param position world position
  118698. * @returns the closest point to position constrained by the navigation mesh
  118699. */
  118700. getClosestPoint(position: Vector3): Vector3;
  118701. /**
  118702. * Get a navigation mesh constrained position, within a particular radius
  118703. * @param position world position
  118704. * @param maxRadius the maximum distance to the constrained world position
  118705. * @returns the closest point to position constrained by the navigation mesh
  118706. */
  118707. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  118708. /**
  118709. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  118710. * @param start world position
  118711. * @param end world position
  118712. * @returns array containing world position composing the path
  118713. */
  118714. computePath(start: Vector3, end: Vector3): Vector3[];
  118715. /**
  118716. * If this plugin is supported
  118717. * @returns true if plugin is supported
  118718. */
  118719. isSupported(): boolean;
  118720. /**
  118721. * Create a new Crowd so you can add agents
  118722. * @param maxAgents the maximum agent count in the crowd
  118723. * @param maxAgentRadius the maximum radius an agent can have
  118724. * @param scene to attach the crowd to
  118725. * @returns the crowd you can add agents to
  118726. */
  118727. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  118728. /**
  118729. * Release all resources
  118730. */
  118731. dispose(): void;
  118732. }
  118733. /**
  118734. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  118735. */
  118736. export interface ICrowd {
  118737. /**
  118738. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  118739. * You can attach anything to that node. The node position is updated in the scene update tick.
  118740. * @param pos world position that will be constrained by the navigation mesh
  118741. * @param parameters agent parameters
  118742. * @param transform hooked to the agent that will be update by the scene
  118743. * @returns agent index
  118744. */
  118745. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  118746. /**
  118747. * Returns the agent position in world space
  118748. * @param index agent index returned by addAgent
  118749. * @returns world space position
  118750. */
  118751. getAgentPosition(index: number): Vector3;
  118752. /**
  118753. * Gets the agent velocity in world space
  118754. * @param index agent index returned by addAgent
  118755. * @returns world space velocity
  118756. */
  118757. getAgentVelocity(index: number): Vector3;
  118758. /**
  118759. * remove a particular agent previously created
  118760. * @param index agent index returned by addAgent
  118761. */
  118762. removeAgent(index: number): void;
  118763. /**
  118764. * get the list of all agents attached to this crowd
  118765. * @returns list of agent indices
  118766. */
  118767. getAgents(): number[];
  118768. /**
  118769. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  118770. * @param deltaTime in seconds
  118771. */
  118772. update(deltaTime: number): void;
  118773. /**
  118774. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  118775. * @param index agent index returned by addAgent
  118776. * @param destination targeted world position
  118777. */
  118778. agentGoto(index: number, destination: Vector3): void;
  118779. /**
  118780. * Release all resources
  118781. */
  118782. dispose(): void;
  118783. }
  118784. /**
  118785. * Configures an agent
  118786. */
  118787. export interface IAgentParameters {
  118788. /**
  118789. * Agent radius. [Limit: >= 0]
  118790. */
  118791. radius: number;
  118792. /**
  118793. * Agent height. [Limit: > 0]
  118794. */
  118795. height: number;
  118796. /**
  118797. * Maximum allowed acceleration. [Limit: >= 0]
  118798. */
  118799. maxAcceleration: number;
  118800. /**
  118801. * Maximum allowed speed. [Limit: >= 0]
  118802. */
  118803. maxSpeed: number;
  118804. /**
  118805. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  118806. */
  118807. collisionQueryRange: number;
  118808. /**
  118809. * The path visibility optimization range. [Limit: > 0]
  118810. */
  118811. pathOptimizationRange: number;
  118812. /**
  118813. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  118814. */
  118815. separationWeight: number;
  118816. }
  118817. /**
  118818. * Configures the navigation mesh creation
  118819. */
  118820. export interface INavMeshParameters {
  118821. /**
  118822. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  118823. */
  118824. cs: number;
  118825. /**
  118826. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  118827. */
  118828. ch: number;
  118829. /**
  118830. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  118831. */
  118832. walkableSlopeAngle: number;
  118833. /**
  118834. * Minimum floor to 'ceiling' height that will still allow the floor area to
  118835. * be considered walkable. [Limit: >= 3] [Units: vx]
  118836. */
  118837. walkableHeight: number;
  118838. /**
  118839. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  118840. */
  118841. walkableClimb: number;
  118842. /**
  118843. * The distance to erode/shrink the walkable area of the heightfield away from
  118844. * obstructions. [Limit: >=0] [Units: vx]
  118845. */
  118846. walkableRadius: number;
  118847. /**
  118848. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  118849. */
  118850. maxEdgeLen: number;
  118851. /**
  118852. * The maximum distance a simplfied contour's border edges should deviate
  118853. * the original raw contour. [Limit: >=0] [Units: vx]
  118854. */
  118855. maxSimplificationError: number;
  118856. /**
  118857. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  118858. */
  118859. minRegionArea: number;
  118860. /**
  118861. * Any regions with a span count smaller than this value will, if possible,
  118862. * be merged with larger regions. [Limit: >=0] [Units: vx]
  118863. */
  118864. mergeRegionArea: number;
  118865. /**
  118866. * The maximum number of vertices allowed for polygons generated during the
  118867. * contour to polygon conversion process. [Limit: >= 3]
  118868. */
  118869. maxVertsPerPoly: number;
  118870. /**
  118871. * Sets the sampling distance to use when generating the detail mesh.
  118872. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  118873. */
  118874. detailSampleDist: number;
  118875. /**
  118876. * The maximum distance the detail mesh surface should deviate from heightfield
  118877. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  118878. */
  118879. detailSampleMaxError: number;
  118880. }
  118881. }
  118882. declare module BABYLON {
  118883. /**
  118884. * RecastJS navigation plugin
  118885. */
  118886. export class RecastJSPlugin implements INavigationEnginePlugin {
  118887. /**
  118888. * Reference to the Recast library
  118889. */
  118890. bjsRECAST: any;
  118891. /**
  118892. * plugin name
  118893. */
  118894. name: string;
  118895. /**
  118896. * the first navmesh created. We might extend this to support multiple navmeshes
  118897. */
  118898. navMesh: any;
  118899. /**
  118900. * Initializes the recastJS plugin
  118901. * @param recastInjection can be used to inject your own recast reference
  118902. */
  118903. constructor(recastInjection?: any);
  118904. /**
  118905. * Creates a navigation mesh
  118906. * @param meshes array of all the geometry used to compute the navigatio mesh
  118907. * @param parameters bunch of parameters used to filter geometry
  118908. */
  118909. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  118910. /**
  118911. * Create a navigation mesh debug mesh
  118912. * @param scene is where the mesh will be added
  118913. * @returns debug display mesh
  118914. */
  118915. createDebugNavMesh(scene: Scene): Mesh;
  118916. /**
  118917. * Get a navigation mesh constrained position, closest to the parameter position
  118918. * @param position world position
  118919. * @returns the closest point to position constrained by the navigation mesh
  118920. */
  118921. getClosestPoint(position: Vector3): Vector3;
  118922. /**
  118923. * Get a navigation mesh constrained position, within a particular radius
  118924. * @param position world position
  118925. * @param maxRadius the maximum distance to the constrained world position
  118926. * @returns the closest point to position constrained by the navigation mesh
  118927. */
  118928. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  118929. /**
  118930. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  118931. * @param start world position
  118932. * @param end world position
  118933. * @returns array containing world position composing the path
  118934. */
  118935. computePath(start: Vector3, end: Vector3): Vector3[];
  118936. /**
  118937. * Create a new Crowd so you can add agents
  118938. * @param maxAgents the maximum agent count in the crowd
  118939. * @param maxAgentRadius the maximum radius an agent can have
  118940. * @param scene to attach the crowd to
  118941. * @returns the crowd you can add agents to
  118942. */
  118943. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  118944. /**
  118945. * Disposes
  118946. */
  118947. dispose(): void;
  118948. /**
  118949. * If this plugin is supported
  118950. * @returns true if plugin is supported
  118951. */
  118952. isSupported(): boolean;
  118953. }
  118954. /**
  118955. * Recast detour crowd implementation
  118956. */
  118957. export class RecastJSCrowd implements ICrowd {
  118958. /**
  118959. * Recast/detour plugin
  118960. */
  118961. bjsRECASTPlugin: RecastJSPlugin;
  118962. /**
  118963. * Link to the detour crowd
  118964. */
  118965. recastCrowd: any;
  118966. /**
  118967. * One transform per agent
  118968. */
  118969. transforms: TransformNode[];
  118970. /**
  118971. * All agents created
  118972. */
  118973. agents: number[];
  118974. /**
  118975. * Link to the scene is kept to unregister the crowd from the scene
  118976. */
  118977. private _scene;
  118978. /**
  118979. * Observer for crowd updates
  118980. */
  118981. private _onBeforeAnimationsObserver;
  118982. /**
  118983. * Constructor
  118984. * @param plugin recastJS plugin
  118985. * @param maxAgents the maximum agent count in the crowd
  118986. * @param maxAgentRadius the maximum radius an agent can have
  118987. * @param scene to attach the crowd to
  118988. * @returns the crowd you can add agents to
  118989. */
  118990. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  118991. /**
  118992. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  118993. * You can attach anything to that node. The node position is updated in the scene update tick.
  118994. * @param pos world position that will be constrained by the navigation mesh
  118995. * @param parameters agent parameters
  118996. * @param transform hooked to the agent that will be update by the scene
  118997. * @returns agent index
  118998. */
  118999. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  119000. /**
  119001. * Returns the agent position in world space
  119002. * @param index agent index returned by addAgent
  119003. * @returns world space position
  119004. */
  119005. getAgentPosition(index: number): Vector3;
  119006. /**
  119007. * Returns the agent velocity in world space
  119008. * @param index agent index returned by addAgent
  119009. * @returns world space velocity
  119010. */
  119011. getAgentVelocity(index: number): Vector3;
  119012. /**
  119013. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  119014. * @param index agent index returned by addAgent
  119015. * @param destination targeted world position
  119016. */
  119017. agentGoto(index: number, destination: Vector3): void;
  119018. /**
  119019. * remove a particular agent previously created
  119020. * @param index agent index returned by addAgent
  119021. */
  119022. removeAgent(index: number): void;
  119023. /**
  119024. * get the list of all agents attached to this crowd
  119025. * @returns list of agent indices
  119026. */
  119027. getAgents(): number[];
  119028. /**
  119029. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  119030. * @param deltaTime in seconds
  119031. */
  119032. update(deltaTime: number): void;
  119033. /**
  119034. * Release all resources
  119035. */
  119036. dispose(): void;
  119037. }
  119038. }
  119039. declare module BABYLON {
  119040. /**
  119041. * Class used to enable access to IndexedDB
  119042. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  119043. */
  119044. export class Database implements IOfflineProvider {
  119045. private _callbackManifestChecked;
  119046. private _currentSceneUrl;
  119047. private _db;
  119048. private _enableSceneOffline;
  119049. private _enableTexturesOffline;
  119050. private _manifestVersionFound;
  119051. private _mustUpdateRessources;
  119052. private _hasReachedQuota;
  119053. private _isSupported;
  119054. private _idbFactory;
  119055. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  119056. private static IsUASupportingBlobStorage;
  119057. /**
  119058. * Gets a boolean indicating if Database storate is enabled (off by default)
  119059. */
  119060. static IDBStorageEnabled: boolean;
  119061. /**
  119062. * Gets a boolean indicating if scene must be saved in the database
  119063. */
  119064. readonly enableSceneOffline: boolean;
  119065. /**
  119066. * Gets a boolean indicating if textures must be saved in the database
  119067. */
  119068. readonly enableTexturesOffline: boolean;
  119069. /**
  119070. * Creates a new Database
  119071. * @param urlToScene defines the url to load the scene
  119072. * @param callbackManifestChecked defines the callback to use when manifest is checked
  119073. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  119074. */
  119075. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  119076. private static _ParseURL;
  119077. private static _ReturnFullUrlLocation;
  119078. private _checkManifestFile;
  119079. /**
  119080. * Open the database and make it available
  119081. * @param successCallback defines the callback to call on success
  119082. * @param errorCallback defines the callback to call on error
  119083. */
  119084. open(successCallback: () => void, errorCallback: () => void): void;
  119085. /**
  119086. * Loads an image from the database
  119087. * @param url defines the url to load from
  119088. * @param image defines the target DOM image
  119089. */
  119090. loadImage(url: string, image: HTMLImageElement): void;
  119091. private _loadImageFromDBAsync;
  119092. private _saveImageIntoDBAsync;
  119093. private _checkVersionFromDB;
  119094. private _loadVersionFromDBAsync;
  119095. private _saveVersionIntoDBAsync;
  119096. /**
  119097. * Loads a file from database
  119098. * @param url defines the URL to load from
  119099. * @param sceneLoaded defines a callback to call on success
  119100. * @param progressCallBack defines a callback to call when progress changed
  119101. * @param errorCallback defines a callback to call on error
  119102. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  119103. */
  119104. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  119105. private _loadFileAsync;
  119106. private _saveFileAsync;
  119107. /**
  119108. * Validates if xhr data is correct
  119109. * @param xhr defines the request to validate
  119110. * @param dataType defines the expected data type
  119111. * @returns true if data is correct
  119112. */
  119113. private static _ValidateXHRData;
  119114. }
  119115. }
  119116. declare module BABYLON {
  119117. /** @hidden */
  119118. export var gpuUpdateParticlesPixelShader: {
  119119. name: string;
  119120. shader: string;
  119121. };
  119122. }
  119123. declare module BABYLON {
  119124. /** @hidden */
  119125. export var gpuUpdateParticlesVertexShader: {
  119126. name: string;
  119127. shader: string;
  119128. };
  119129. }
  119130. declare module BABYLON {
  119131. /** @hidden */
  119132. export var clipPlaneFragmentDeclaration2: {
  119133. name: string;
  119134. shader: string;
  119135. };
  119136. }
  119137. declare module BABYLON {
  119138. /** @hidden */
  119139. export var gpuRenderParticlesPixelShader: {
  119140. name: string;
  119141. shader: string;
  119142. };
  119143. }
  119144. declare module BABYLON {
  119145. /** @hidden */
  119146. export var clipPlaneVertexDeclaration2: {
  119147. name: string;
  119148. shader: string;
  119149. };
  119150. }
  119151. declare module BABYLON {
  119152. /** @hidden */
  119153. export var gpuRenderParticlesVertexShader: {
  119154. name: string;
  119155. shader: string;
  119156. };
  119157. }
  119158. declare module BABYLON {
  119159. /**
  119160. * This represents a GPU particle system in Babylon
  119161. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  119162. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  119163. */
  119164. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  119165. /**
  119166. * The layer mask we are rendering the particles through.
  119167. */
  119168. layerMask: number;
  119169. private _capacity;
  119170. private _activeCount;
  119171. private _currentActiveCount;
  119172. private _accumulatedCount;
  119173. private _renderEffect;
  119174. private _updateEffect;
  119175. private _buffer0;
  119176. private _buffer1;
  119177. private _spriteBuffer;
  119178. private _updateVAO;
  119179. private _renderVAO;
  119180. private _targetIndex;
  119181. private _sourceBuffer;
  119182. private _targetBuffer;
  119183. private _engine;
  119184. private _currentRenderId;
  119185. private _started;
  119186. private _stopped;
  119187. private _timeDelta;
  119188. private _randomTexture;
  119189. private _randomTexture2;
  119190. private _attributesStrideSize;
  119191. private _updateEffectOptions;
  119192. private _randomTextureSize;
  119193. private _actualFrame;
  119194. private readonly _rawTextureWidth;
  119195. /**
  119196. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  119197. */
  119198. static readonly IsSupported: boolean;
  119199. /**
  119200. * An event triggered when the system is disposed.
  119201. */
  119202. onDisposeObservable: Observable<GPUParticleSystem>;
  119203. /**
  119204. * Gets the maximum number of particles active at the same time.
  119205. * @returns The max number of active particles.
  119206. */
  119207. getCapacity(): number;
  119208. /**
  119209. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  119210. * to override the particles.
  119211. */
  119212. forceDepthWrite: boolean;
  119213. /**
  119214. * Gets or set the number of active particles
  119215. */
  119216. activeParticleCount: number;
  119217. private _preWarmDone;
  119218. /**
  119219. * Is this system ready to be used/rendered
  119220. * @return true if the system is ready
  119221. */
  119222. isReady(): boolean;
  119223. /**
  119224. * Gets if the system has been started. (Note: this will still be true after stop is called)
  119225. * @returns True if it has been started, otherwise false.
  119226. */
  119227. isStarted(): boolean;
  119228. /**
  119229. * Starts the particle system and begins to emit
  119230. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  119231. */
  119232. start(delay?: number): void;
  119233. /**
  119234. * Stops the particle system.
  119235. */
  119236. stop(): void;
  119237. /**
  119238. * Remove all active particles
  119239. */
  119240. reset(): void;
  119241. /**
  119242. * Returns the string "GPUParticleSystem"
  119243. * @returns a string containing the class name
  119244. */
  119245. getClassName(): string;
  119246. private _colorGradientsTexture;
  119247. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  119248. /**
  119249. * Adds a new color gradient
  119250. * @param gradient defines the gradient to use (between 0 and 1)
  119251. * @param color1 defines the color to affect to the specified gradient
  119252. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  119253. * @returns the current particle system
  119254. */
  119255. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  119256. /**
  119257. * Remove a specific color gradient
  119258. * @param gradient defines the gradient to remove
  119259. * @returns the current particle system
  119260. */
  119261. removeColorGradient(gradient: number): GPUParticleSystem;
  119262. private _angularSpeedGradientsTexture;
  119263. private _sizeGradientsTexture;
  119264. private _velocityGradientsTexture;
  119265. private _limitVelocityGradientsTexture;
  119266. private _dragGradientsTexture;
  119267. private _addFactorGradient;
  119268. /**
  119269. * Adds a new size gradient
  119270. * @param gradient defines the gradient to use (between 0 and 1)
  119271. * @param factor defines the size factor to affect to the specified gradient
  119272. * @returns the current particle system
  119273. */
  119274. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  119275. /**
  119276. * Remove a specific size gradient
  119277. * @param gradient defines the gradient to remove
  119278. * @returns the current particle system
  119279. */
  119280. removeSizeGradient(gradient: number): GPUParticleSystem;
  119281. /**
  119282. * Adds a new angular speed gradient
  119283. * @param gradient defines the gradient to use (between 0 and 1)
  119284. * @param factor defines the angular speed to affect to the specified gradient
  119285. * @returns the current particle system
  119286. */
  119287. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  119288. /**
  119289. * Remove a specific angular speed gradient
  119290. * @param gradient defines the gradient to remove
  119291. * @returns the current particle system
  119292. */
  119293. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  119294. /**
  119295. * Adds a new velocity gradient
  119296. * @param gradient defines the gradient to use (between 0 and 1)
  119297. * @param factor defines the velocity to affect to the specified gradient
  119298. * @returns the current particle system
  119299. */
  119300. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  119301. /**
  119302. * Remove a specific velocity gradient
  119303. * @param gradient defines the gradient to remove
  119304. * @returns the current particle system
  119305. */
  119306. removeVelocityGradient(gradient: number): GPUParticleSystem;
  119307. /**
  119308. * Adds a new limit velocity gradient
  119309. * @param gradient defines the gradient to use (between 0 and 1)
  119310. * @param factor defines the limit velocity value to affect to the specified gradient
  119311. * @returns the current particle system
  119312. */
  119313. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  119314. /**
  119315. * Remove a specific limit velocity gradient
  119316. * @param gradient defines the gradient to remove
  119317. * @returns the current particle system
  119318. */
  119319. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  119320. /**
  119321. * Adds a new drag gradient
  119322. * @param gradient defines the gradient to use (between 0 and 1)
  119323. * @param factor defines the drag value to affect to the specified gradient
  119324. * @returns the current particle system
  119325. */
  119326. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  119327. /**
  119328. * Remove a specific drag gradient
  119329. * @param gradient defines the gradient to remove
  119330. * @returns the current particle system
  119331. */
  119332. removeDragGradient(gradient: number): GPUParticleSystem;
  119333. /**
  119334. * Not supported by GPUParticleSystem
  119335. * @param gradient defines the gradient to use (between 0 and 1)
  119336. * @param factor defines the emit rate value to affect to the specified gradient
  119337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119338. * @returns the current particle system
  119339. */
  119340. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119341. /**
  119342. * Not supported by GPUParticleSystem
  119343. * @param gradient defines the gradient to remove
  119344. * @returns the current particle system
  119345. */
  119346. removeEmitRateGradient(gradient: number): IParticleSystem;
  119347. /**
  119348. * Not supported by GPUParticleSystem
  119349. * @param gradient defines the gradient to use (between 0 and 1)
  119350. * @param factor defines the start size value to affect to the specified gradient
  119351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119352. * @returns the current particle system
  119353. */
  119354. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119355. /**
  119356. * Not supported by GPUParticleSystem
  119357. * @param gradient defines the gradient to remove
  119358. * @returns the current particle system
  119359. */
  119360. removeStartSizeGradient(gradient: number): IParticleSystem;
  119361. /**
  119362. * Not supported by GPUParticleSystem
  119363. * @param gradient defines the gradient to use (between 0 and 1)
  119364. * @param min defines the color remap minimal range
  119365. * @param max defines the color remap maximal range
  119366. * @returns the current particle system
  119367. */
  119368. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119369. /**
  119370. * Not supported by GPUParticleSystem
  119371. * @param gradient defines the gradient to remove
  119372. * @returns the current particle system
  119373. */
  119374. removeColorRemapGradient(): IParticleSystem;
  119375. /**
  119376. * Not supported by GPUParticleSystem
  119377. * @param gradient defines the gradient to use (between 0 and 1)
  119378. * @param min defines the alpha remap minimal range
  119379. * @param max defines the alpha remap maximal range
  119380. * @returns the current particle system
  119381. */
  119382. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119383. /**
  119384. * Not supported by GPUParticleSystem
  119385. * @param gradient defines the gradient to remove
  119386. * @returns the current particle system
  119387. */
  119388. removeAlphaRemapGradient(): IParticleSystem;
  119389. /**
  119390. * Not supported by GPUParticleSystem
  119391. * @param gradient defines the gradient to use (between 0 and 1)
  119392. * @param color defines the color to affect to the specified gradient
  119393. * @returns the current particle system
  119394. */
  119395. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  119396. /**
  119397. * Not supported by GPUParticleSystem
  119398. * @param gradient defines the gradient to remove
  119399. * @returns the current particle system
  119400. */
  119401. removeRampGradient(): IParticleSystem;
  119402. /**
  119403. * Not supported by GPUParticleSystem
  119404. * @returns the list of ramp gradients
  119405. */
  119406. getRampGradients(): Nullable<Array<Color3Gradient>>;
  119407. /**
  119408. * Not supported by GPUParticleSystem
  119409. * Gets or sets a boolean indicating that ramp gradients must be used
  119410. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  119411. */
  119412. useRampGradients: boolean;
  119413. /**
  119414. * Not supported by GPUParticleSystem
  119415. * @param gradient defines the gradient to use (between 0 and 1)
  119416. * @param factor defines the life time factor to affect to the specified gradient
  119417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119418. * @returns the current particle system
  119419. */
  119420. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119421. /**
  119422. * Not supported by GPUParticleSystem
  119423. * @param gradient defines the gradient to remove
  119424. * @returns the current particle system
  119425. */
  119426. removeLifeTimeGradient(gradient: number): IParticleSystem;
  119427. /**
  119428. * Instantiates a GPU particle system.
  119429. * 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.
  119430. * @param name The name of the particle system
  119431. * @param options The options used to create the system
  119432. * @param scene The scene the particle system belongs to
  119433. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  119434. */
  119435. constructor(name: string, options: Partial<{
  119436. capacity: number;
  119437. randomTextureSize: number;
  119438. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  119439. protected _reset(): void;
  119440. private _createUpdateVAO;
  119441. private _createRenderVAO;
  119442. private _initialize;
  119443. /** @hidden */
  119444. _recreateUpdateEffect(): void;
  119445. /** @hidden */
  119446. _recreateRenderEffect(): void;
  119447. /**
  119448. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  119449. * @param preWarm defines if we are in the pre-warmimg phase
  119450. */
  119451. animate(preWarm?: boolean): void;
  119452. private _createFactorGradientTexture;
  119453. private _createSizeGradientTexture;
  119454. private _createAngularSpeedGradientTexture;
  119455. private _createVelocityGradientTexture;
  119456. private _createLimitVelocityGradientTexture;
  119457. private _createDragGradientTexture;
  119458. private _createColorGradientTexture;
  119459. /**
  119460. * Renders the particle system in its current state
  119461. * @param preWarm defines if the system should only update the particles but not render them
  119462. * @returns the current number of particles
  119463. */
  119464. render(preWarm?: boolean): number;
  119465. /**
  119466. * Rebuilds the particle system
  119467. */
  119468. rebuild(): void;
  119469. private _releaseBuffers;
  119470. private _releaseVAOs;
  119471. /**
  119472. * Disposes the particle system and free the associated resources
  119473. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  119474. */
  119475. dispose(disposeTexture?: boolean): void;
  119476. /**
  119477. * Clones the particle system.
  119478. * @param name The name of the cloned object
  119479. * @param newEmitter The new emitter to use
  119480. * @returns the cloned particle system
  119481. */
  119482. clone(name: string, newEmitter: any): GPUParticleSystem;
  119483. /**
  119484. * Serializes the particle system to a JSON object.
  119485. * @returns the JSON object
  119486. */
  119487. serialize(): any;
  119488. /**
  119489. * Parses a JSON object to create a GPU particle system.
  119490. * @param parsedParticleSystem The JSON object to parse
  119491. * @param scene The scene to create the particle system in
  119492. * @param rootUrl The root url to use to load external dependencies like texture
  119493. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  119494. * @returns the parsed GPU particle system
  119495. */
  119496. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  119497. }
  119498. }
  119499. declare module BABYLON {
  119500. /**
  119501. * Represents a set of particle systems working together to create a specific effect
  119502. */
  119503. export class ParticleSystemSet implements IDisposable {
  119504. private _emitterCreationOptions;
  119505. private _emitterNode;
  119506. /**
  119507. * Gets the particle system list
  119508. */
  119509. systems: IParticleSystem[];
  119510. /**
  119511. * Gets the emitter node used with this set
  119512. */
  119513. readonly emitterNode: Nullable<TransformNode>;
  119514. /**
  119515. * Creates a new emitter mesh as a sphere
  119516. * @param options defines the options used to create the sphere
  119517. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  119518. * @param scene defines the hosting scene
  119519. */
  119520. setEmitterAsSphere(options: {
  119521. diameter: number;
  119522. segments: number;
  119523. color: Color3;
  119524. }, renderingGroupId: number, scene: Scene): void;
  119525. /**
  119526. * Starts all particle systems of the set
  119527. * @param emitter defines an optional mesh to use as emitter for the particle systems
  119528. */
  119529. start(emitter?: AbstractMesh): void;
  119530. /**
  119531. * Release all associated resources
  119532. */
  119533. dispose(): void;
  119534. /**
  119535. * Serialize the set into a JSON compatible object
  119536. * @returns a JSON compatible representation of the set
  119537. */
  119538. serialize(): any;
  119539. /**
  119540. * Parse a new ParticleSystemSet from a serialized source
  119541. * @param data defines a JSON compatible representation of the set
  119542. * @param scene defines the hosting scene
  119543. * @param gpu defines if we want GPU particles or CPU particles
  119544. * @returns a new ParticleSystemSet
  119545. */
  119546. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  119547. }
  119548. }
  119549. declare module BABYLON {
  119550. /**
  119551. * This class is made for on one-liner static method to help creating particle system set.
  119552. */
  119553. export class ParticleHelper {
  119554. /**
  119555. * Gets or sets base Assets URL
  119556. */
  119557. static BaseAssetsUrl: string;
  119558. /**
  119559. * Create a default particle system that you can tweak
  119560. * @param emitter defines the emitter to use
  119561. * @param capacity defines the system capacity (default is 500 particles)
  119562. * @param scene defines the hosting scene
  119563. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  119564. * @returns the new Particle system
  119565. */
  119566. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  119567. /**
  119568. * This is the main static method (one-liner) of this helper to create different particle systems
  119569. * @param type This string represents the type to the particle system to create
  119570. * @param scene The scene where the particle system should live
  119571. * @param gpu If the system will use gpu
  119572. * @returns the ParticleSystemSet created
  119573. */
  119574. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  119575. /**
  119576. * Static function used to export a particle system to a ParticleSystemSet variable.
  119577. * Please note that the emitter shape is not exported
  119578. * @param systems defines the particle systems to export
  119579. * @returns the created particle system set
  119580. */
  119581. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  119582. }
  119583. }
  119584. declare module BABYLON {
  119585. interface Engine {
  119586. /**
  119587. * Create an effect to use with particle systems.
  119588. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  119589. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  119590. * @param uniformsNames defines a list of attribute names
  119591. * @param samplers defines an array of string used to represent textures
  119592. * @param defines defines the string containing the defines to use to compile the shaders
  119593. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119594. * @param onCompiled defines a function to call when the effect creation is successful
  119595. * @param onError defines a function to call when the effect creation has failed
  119596. * @returns the new Effect
  119597. */
  119598. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  119599. }
  119600. interface Mesh {
  119601. /**
  119602. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  119603. * @returns an array of IParticleSystem
  119604. */
  119605. getEmittedParticleSystems(): IParticleSystem[];
  119606. /**
  119607. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  119608. * @returns an array of IParticleSystem
  119609. */
  119610. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  119611. }
  119612. /**
  119613. * @hidden
  119614. */
  119615. export var _IDoNeedToBeInTheBuild: number;
  119616. }
  119617. declare module BABYLON {
  119618. interface Scene {
  119619. /** @hidden (Backing field) */
  119620. _physicsEngine: Nullable<IPhysicsEngine>;
  119621. /**
  119622. * Gets the current physics engine
  119623. * @returns a IPhysicsEngine or null if none attached
  119624. */
  119625. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  119626. /**
  119627. * Enables physics to the current scene
  119628. * @param gravity defines the scene's gravity for the physics engine
  119629. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  119630. * @return a boolean indicating if the physics engine was initialized
  119631. */
  119632. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  119633. /**
  119634. * Disables and disposes the physics engine associated with the scene
  119635. */
  119636. disablePhysicsEngine(): void;
  119637. /**
  119638. * Gets a boolean indicating if there is an active physics engine
  119639. * @returns a boolean indicating if there is an active physics engine
  119640. */
  119641. isPhysicsEnabled(): boolean;
  119642. /**
  119643. * Deletes a physics compound impostor
  119644. * @param compound defines the compound to delete
  119645. */
  119646. deleteCompoundImpostor(compound: any): void;
  119647. /**
  119648. * An event triggered when physic simulation is about to be run
  119649. */
  119650. onBeforePhysicsObservable: Observable<Scene>;
  119651. /**
  119652. * An event triggered when physic simulation has been done
  119653. */
  119654. onAfterPhysicsObservable: Observable<Scene>;
  119655. }
  119656. interface AbstractMesh {
  119657. /** @hidden */
  119658. _physicsImpostor: Nullable<PhysicsImpostor>;
  119659. /**
  119660. * Gets or sets impostor used for physic simulation
  119661. * @see http://doc.babylonjs.com/features/physics_engine
  119662. */
  119663. physicsImpostor: Nullable<PhysicsImpostor>;
  119664. /**
  119665. * Gets the current physics impostor
  119666. * @see http://doc.babylonjs.com/features/physics_engine
  119667. * @returns a physics impostor or null
  119668. */
  119669. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  119670. /** Apply a physic impulse to the mesh
  119671. * @param force defines the force to apply
  119672. * @param contactPoint defines where to apply the force
  119673. * @returns the current mesh
  119674. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119675. */
  119676. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  119677. /**
  119678. * Creates a physic joint between two meshes
  119679. * @param otherMesh defines the other mesh to use
  119680. * @param pivot1 defines the pivot to use on this mesh
  119681. * @param pivot2 defines the pivot to use on the other mesh
  119682. * @param options defines additional options (can be plugin dependent)
  119683. * @returns the current mesh
  119684. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  119685. */
  119686. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  119687. /** @hidden */
  119688. _disposePhysicsObserver: Nullable<Observer<Node>>;
  119689. }
  119690. /**
  119691. * Defines the physics engine scene component responsible to manage a physics engine
  119692. */
  119693. export class PhysicsEngineSceneComponent implements ISceneComponent {
  119694. /**
  119695. * The component name helpful to identify the component in the list of scene components.
  119696. */
  119697. readonly name: string;
  119698. /**
  119699. * The scene the component belongs to.
  119700. */
  119701. scene: Scene;
  119702. /**
  119703. * Creates a new instance of the component for the given scene
  119704. * @param scene Defines the scene to register the component in
  119705. */
  119706. constructor(scene: Scene);
  119707. /**
  119708. * Registers the component in a given scene
  119709. */
  119710. register(): void;
  119711. /**
  119712. * Rebuilds the elements related to this component in case of
  119713. * context lost for instance.
  119714. */
  119715. rebuild(): void;
  119716. /**
  119717. * Disposes the component and the associated ressources
  119718. */
  119719. dispose(): void;
  119720. }
  119721. }
  119722. declare module BABYLON {
  119723. /**
  119724. * A helper for physics simulations
  119725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119726. */
  119727. export class PhysicsHelper {
  119728. private _scene;
  119729. private _physicsEngine;
  119730. /**
  119731. * Initializes the Physics helper
  119732. * @param scene Babylon.js scene
  119733. */
  119734. constructor(scene: Scene);
  119735. /**
  119736. * Applies a radial explosion impulse
  119737. * @param origin the origin of the explosion
  119738. * @param radiusOrEventOptions the radius or the options of radial explosion
  119739. * @param strength the explosion strength
  119740. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119741. * @returns A physics radial explosion event, or null
  119742. */
  119743. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  119744. /**
  119745. * Applies a radial explosion force
  119746. * @param origin the origin of the explosion
  119747. * @param radiusOrEventOptions the radius or the options of radial explosion
  119748. * @param strength the explosion strength
  119749. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119750. * @returns A physics radial explosion event, or null
  119751. */
  119752. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  119753. /**
  119754. * Creates a gravitational field
  119755. * @param origin the origin of the explosion
  119756. * @param radiusOrEventOptions the radius or the options of radial explosion
  119757. * @param strength the explosion strength
  119758. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119759. * @returns A physics gravitational field event, or null
  119760. */
  119761. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  119762. /**
  119763. * Creates a physics updraft event
  119764. * @param origin the origin of the updraft
  119765. * @param radiusOrEventOptions the radius or the options of the updraft
  119766. * @param strength the strength of the updraft
  119767. * @param height the height of the updraft
  119768. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  119769. * @returns A physics updraft event, or null
  119770. */
  119771. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  119772. /**
  119773. * Creates a physics vortex event
  119774. * @param origin the of the vortex
  119775. * @param radiusOrEventOptions the radius or the options of the vortex
  119776. * @param strength the strength of the vortex
  119777. * @param height the height of the vortex
  119778. * @returns a Physics vortex event, or null
  119779. * A physics vortex event or null
  119780. */
  119781. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  119782. }
  119783. /**
  119784. * Represents a physics radial explosion event
  119785. */
  119786. class PhysicsRadialExplosionEvent {
  119787. private _scene;
  119788. private _options;
  119789. private _sphere;
  119790. private _dataFetched;
  119791. /**
  119792. * Initializes a radial explosioin event
  119793. * @param _scene BabylonJS scene
  119794. * @param _options The options for the vortex event
  119795. */
  119796. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  119797. /**
  119798. * Returns the data related to the radial explosion event (sphere).
  119799. * @returns The radial explosion event data
  119800. */
  119801. getData(): PhysicsRadialExplosionEventData;
  119802. /**
  119803. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  119804. * @param impostor A physics imposter
  119805. * @param origin the origin of the explosion
  119806. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  119807. */
  119808. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  119809. /**
  119810. * Triggers affecterd impostors callbacks
  119811. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  119812. */
  119813. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  119814. /**
  119815. * Disposes the sphere.
  119816. * @param force Specifies if the sphere should be disposed by force
  119817. */
  119818. dispose(force?: boolean): void;
  119819. /*** Helpers ***/
  119820. private _prepareSphere;
  119821. private _intersectsWithSphere;
  119822. }
  119823. /**
  119824. * Represents a gravitational field event
  119825. */
  119826. class PhysicsGravitationalFieldEvent {
  119827. private _physicsHelper;
  119828. private _scene;
  119829. private _origin;
  119830. private _options;
  119831. private _tickCallback;
  119832. private _sphere;
  119833. private _dataFetched;
  119834. /**
  119835. * Initializes the physics gravitational field event
  119836. * @param _physicsHelper A physics helper
  119837. * @param _scene BabylonJS scene
  119838. * @param _origin The origin position of the gravitational field event
  119839. * @param _options The options for the vortex event
  119840. */
  119841. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  119842. /**
  119843. * Returns the data related to the gravitational field event (sphere).
  119844. * @returns A gravitational field event
  119845. */
  119846. getData(): PhysicsGravitationalFieldEventData;
  119847. /**
  119848. * Enables the gravitational field.
  119849. */
  119850. enable(): void;
  119851. /**
  119852. * Disables the gravitational field.
  119853. */
  119854. disable(): void;
  119855. /**
  119856. * Disposes the sphere.
  119857. * @param force The force to dispose from the gravitational field event
  119858. */
  119859. dispose(force?: boolean): void;
  119860. private _tick;
  119861. }
  119862. /**
  119863. * Represents a physics updraft event
  119864. */
  119865. class PhysicsUpdraftEvent {
  119866. private _scene;
  119867. private _origin;
  119868. private _options;
  119869. private _physicsEngine;
  119870. private _originTop;
  119871. private _originDirection;
  119872. private _tickCallback;
  119873. private _cylinder;
  119874. private _cylinderPosition;
  119875. private _dataFetched;
  119876. /**
  119877. * Initializes the physics updraft event
  119878. * @param _scene BabylonJS scene
  119879. * @param _origin The origin position of the updraft
  119880. * @param _options The options for the updraft event
  119881. */
  119882. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  119883. /**
  119884. * Returns the data related to the updraft event (cylinder).
  119885. * @returns A physics updraft event
  119886. */
  119887. getData(): PhysicsUpdraftEventData;
  119888. /**
  119889. * Enables the updraft.
  119890. */
  119891. enable(): void;
  119892. /**
  119893. * Disables the updraft.
  119894. */
  119895. disable(): void;
  119896. /**
  119897. * Disposes the cylinder.
  119898. * @param force Specifies if the updraft should be disposed by force
  119899. */
  119900. dispose(force?: boolean): void;
  119901. private getImpostorHitData;
  119902. private _tick;
  119903. /*** Helpers ***/
  119904. private _prepareCylinder;
  119905. private _intersectsWithCylinder;
  119906. }
  119907. /**
  119908. * Represents a physics vortex event
  119909. */
  119910. class PhysicsVortexEvent {
  119911. private _scene;
  119912. private _origin;
  119913. private _options;
  119914. private _physicsEngine;
  119915. private _originTop;
  119916. private _tickCallback;
  119917. private _cylinder;
  119918. private _cylinderPosition;
  119919. private _dataFetched;
  119920. /**
  119921. * Initializes the physics vortex event
  119922. * @param _scene The BabylonJS scene
  119923. * @param _origin The origin position of the vortex
  119924. * @param _options The options for the vortex event
  119925. */
  119926. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  119927. /**
  119928. * Returns the data related to the vortex event (cylinder).
  119929. * @returns The physics vortex event data
  119930. */
  119931. getData(): PhysicsVortexEventData;
  119932. /**
  119933. * Enables the vortex.
  119934. */
  119935. enable(): void;
  119936. /**
  119937. * Disables the cortex.
  119938. */
  119939. disable(): void;
  119940. /**
  119941. * Disposes the sphere.
  119942. * @param force
  119943. */
  119944. dispose(force?: boolean): void;
  119945. private getImpostorHitData;
  119946. private _tick;
  119947. /*** Helpers ***/
  119948. private _prepareCylinder;
  119949. private _intersectsWithCylinder;
  119950. }
  119951. /**
  119952. * Options fot the radial explosion event
  119953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119954. */
  119955. export class PhysicsRadialExplosionEventOptions {
  119956. /**
  119957. * The radius of the sphere for the radial explosion.
  119958. */
  119959. radius: number;
  119960. /**
  119961. * The strenth of the explosion.
  119962. */
  119963. strength: number;
  119964. /**
  119965. * The strenght of the force in correspondence to the distance of the affected object
  119966. */
  119967. falloff: PhysicsRadialImpulseFalloff;
  119968. /**
  119969. * Sphere options for the radial explosion.
  119970. */
  119971. sphere: {
  119972. segments: number;
  119973. diameter: number;
  119974. };
  119975. /**
  119976. * Sphere options for the radial explosion.
  119977. */
  119978. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  119979. }
  119980. /**
  119981. * Options fot the updraft event
  119982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119983. */
  119984. export class PhysicsUpdraftEventOptions {
  119985. /**
  119986. * The radius of the cylinder for the vortex
  119987. */
  119988. radius: number;
  119989. /**
  119990. * The strenth of the updraft.
  119991. */
  119992. strength: number;
  119993. /**
  119994. * The height of the cylinder for the updraft.
  119995. */
  119996. height: number;
  119997. /**
  119998. * The mode for the the updraft.
  119999. */
  120000. updraftMode: PhysicsUpdraftMode;
  120001. }
  120002. /**
  120003. * Options fot the vortex event
  120004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120005. */
  120006. export class PhysicsVortexEventOptions {
  120007. /**
  120008. * The radius of the cylinder for the vortex
  120009. */
  120010. radius: number;
  120011. /**
  120012. * The strenth of the vortex.
  120013. */
  120014. strength: number;
  120015. /**
  120016. * The height of the cylinder for the vortex.
  120017. */
  120018. height: number;
  120019. /**
  120020. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  120021. */
  120022. centripetalForceThreshold: number;
  120023. /**
  120024. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  120025. */
  120026. centripetalForceMultiplier: number;
  120027. /**
  120028. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  120029. */
  120030. centrifugalForceMultiplier: number;
  120031. /**
  120032. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  120033. */
  120034. updraftForceMultiplier: number;
  120035. }
  120036. /**
  120037. * The strenght of the force in correspondence to the distance of the affected object
  120038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120039. */
  120040. export enum PhysicsRadialImpulseFalloff {
  120041. /** Defines that impulse is constant in strength across it's whole radius */
  120042. Constant = 0,
  120043. /** Defines that impulse gets weaker if it's further from the origin */
  120044. Linear = 1
  120045. }
  120046. /**
  120047. * The strength of the force in correspondence to the distance of the affected object
  120048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120049. */
  120050. export enum PhysicsUpdraftMode {
  120051. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  120052. Center = 0,
  120053. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  120054. Perpendicular = 1
  120055. }
  120056. /**
  120057. * Interface for a physics hit data
  120058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120059. */
  120060. export interface PhysicsHitData {
  120061. /**
  120062. * The force applied at the contact point
  120063. */
  120064. force: Vector3;
  120065. /**
  120066. * The contact point
  120067. */
  120068. contactPoint: Vector3;
  120069. /**
  120070. * The distance from the origin to the contact point
  120071. */
  120072. distanceFromOrigin: number;
  120073. }
  120074. /**
  120075. * Interface for radial explosion event data
  120076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120077. */
  120078. export interface PhysicsRadialExplosionEventData {
  120079. /**
  120080. * A sphere used for the radial explosion event
  120081. */
  120082. sphere: Mesh;
  120083. }
  120084. /**
  120085. * Interface for gravitational field event data
  120086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120087. */
  120088. export interface PhysicsGravitationalFieldEventData {
  120089. /**
  120090. * A sphere mesh used for the gravitational field event
  120091. */
  120092. sphere: Mesh;
  120093. }
  120094. /**
  120095. * Interface for updraft event data
  120096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120097. */
  120098. export interface PhysicsUpdraftEventData {
  120099. /**
  120100. * A cylinder used for the updraft event
  120101. */
  120102. cylinder: Mesh;
  120103. }
  120104. /**
  120105. * Interface for vortex event data
  120106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120107. */
  120108. export interface PhysicsVortexEventData {
  120109. /**
  120110. * A cylinder used for the vortex event
  120111. */
  120112. cylinder: Mesh;
  120113. }
  120114. /**
  120115. * Interface for an affected physics impostor
  120116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120117. */
  120118. export interface PhysicsAffectedImpostorWithData {
  120119. /**
  120120. * The impostor affected by the effect
  120121. */
  120122. impostor: PhysicsImpostor;
  120123. /**
  120124. * The data about the hit/horce from the explosion
  120125. */
  120126. hitData: PhysicsHitData;
  120127. }
  120128. }
  120129. declare module BABYLON {
  120130. /** @hidden */
  120131. export var blackAndWhitePixelShader: {
  120132. name: string;
  120133. shader: string;
  120134. };
  120135. }
  120136. declare module BABYLON {
  120137. /**
  120138. * Post process used to render in black and white
  120139. */
  120140. export class BlackAndWhitePostProcess extends PostProcess {
  120141. /**
  120142. * Linear about to convert he result to black and white (default: 1)
  120143. */
  120144. degree: number;
  120145. /**
  120146. * Creates a black and white post process
  120147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  120148. * @param name The name of the effect.
  120149. * @param options The required width/height ratio to downsize to before computing the render pass.
  120150. * @param camera The camera to apply the render pass to.
  120151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120152. * @param engine The engine which the post process will be applied. (default: current engine)
  120153. * @param reusable If the post process can be reused on the same frame. (default: false)
  120154. */
  120155. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120156. }
  120157. }
  120158. declare module BABYLON {
  120159. /**
  120160. * This represents a set of one or more post processes in Babylon.
  120161. * A post process can be used to apply a shader to a texture after it is rendered.
  120162. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120163. */
  120164. export class PostProcessRenderEffect {
  120165. private _postProcesses;
  120166. private _getPostProcesses;
  120167. private _singleInstance;
  120168. private _cameras;
  120169. private _indicesForCamera;
  120170. /**
  120171. * Name of the effect
  120172. * @hidden
  120173. */
  120174. _name: string;
  120175. /**
  120176. * Instantiates a post process render effect.
  120177. * A post process can be used to apply a shader to a texture after it is rendered.
  120178. * @param engine The engine the effect is tied to
  120179. * @param name The name of the effect
  120180. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  120181. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  120182. */
  120183. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  120184. /**
  120185. * Checks if all the post processes in the effect are supported.
  120186. */
  120187. readonly isSupported: boolean;
  120188. /**
  120189. * Updates the current state of the effect
  120190. * @hidden
  120191. */
  120192. _update(): void;
  120193. /**
  120194. * Attaches the effect on cameras
  120195. * @param cameras The camera to attach to.
  120196. * @hidden
  120197. */
  120198. _attachCameras(cameras: Camera): void;
  120199. /**
  120200. * Attaches the effect on cameras
  120201. * @param cameras The camera to attach to.
  120202. * @hidden
  120203. */
  120204. _attachCameras(cameras: Camera[]): void;
  120205. /**
  120206. * Detaches the effect on cameras
  120207. * @param cameras The camera to detatch from.
  120208. * @hidden
  120209. */
  120210. _detachCameras(cameras: Camera): void;
  120211. /**
  120212. * Detatches the effect on cameras
  120213. * @param cameras The camera to detatch from.
  120214. * @hidden
  120215. */
  120216. _detachCameras(cameras: Camera[]): void;
  120217. /**
  120218. * Enables the effect on given cameras
  120219. * @param cameras The camera to enable.
  120220. * @hidden
  120221. */
  120222. _enable(cameras: Camera): void;
  120223. /**
  120224. * Enables the effect on given cameras
  120225. * @param cameras The camera to enable.
  120226. * @hidden
  120227. */
  120228. _enable(cameras: Nullable<Camera[]>): void;
  120229. /**
  120230. * Disables the effect on the given cameras
  120231. * @param cameras The camera to disable.
  120232. * @hidden
  120233. */
  120234. _disable(cameras: Camera): void;
  120235. /**
  120236. * Disables the effect on the given cameras
  120237. * @param cameras The camera to disable.
  120238. * @hidden
  120239. */
  120240. _disable(cameras: Nullable<Camera[]>): void;
  120241. /**
  120242. * Gets a list of the post processes contained in the effect.
  120243. * @param camera The camera to get the post processes on.
  120244. * @returns The list of the post processes in the effect.
  120245. */
  120246. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  120247. }
  120248. }
  120249. declare module BABYLON {
  120250. /** @hidden */
  120251. export var extractHighlightsPixelShader: {
  120252. name: string;
  120253. shader: string;
  120254. };
  120255. }
  120256. declare module BABYLON {
  120257. /**
  120258. * 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.
  120259. */
  120260. export class ExtractHighlightsPostProcess extends PostProcess {
  120261. /**
  120262. * The luminance threshold, pixels below this value will be set to black.
  120263. */
  120264. threshold: number;
  120265. /** @hidden */
  120266. _exposure: number;
  120267. /**
  120268. * Post process which has the input texture to be used when performing highlight extraction
  120269. * @hidden
  120270. */
  120271. _inputPostProcess: Nullable<PostProcess>;
  120272. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120273. }
  120274. }
  120275. declare module BABYLON {
  120276. /** @hidden */
  120277. export var bloomMergePixelShader: {
  120278. name: string;
  120279. shader: string;
  120280. };
  120281. }
  120282. declare module BABYLON {
  120283. /**
  120284. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  120285. */
  120286. export class BloomMergePostProcess extends PostProcess {
  120287. /** Weight of the bloom to be added to the original input. */
  120288. weight: number;
  120289. /**
  120290. * Creates a new instance of @see BloomMergePostProcess
  120291. * @param name The name of the effect.
  120292. * @param originalFromInput Post process which's input will be used for the merge.
  120293. * @param blurred Blurred highlights post process which's output will be used.
  120294. * @param weight Weight of the bloom to be added to the original input.
  120295. * @param options The required width/height ratio to downsize to before computing the render pass.
  120296. * @param camera The camera to apply the render pass to.
  120297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120298. * @param engine The engine which the post process will be applied. (default: current engine)
  120299. * @param reusable If the post process can be reused on the same frame. (default: false)
  120300. * @param textureType Type of textures used when performing the post process. (default: 0)
  120301. * @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)
  120302. */
  120303. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  120304. /** Weight of the bloom to be added to the original input. */
  120305. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120306. }
  120307. }
  120308. declare module BABYLON {
  120309. /**
  120310. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  120311. */
  120312. export class BloomEffect extends PostProcessRenderEffect {
  120313. private bloomScale;
  120314. /**
  120315. * @hidden Internal
  120316. */
  120317. _effects: Array<PostProcess>;
  120318. /**
  120319. * @hidden Internal
  120320. */
  120321. _downscale: ExtractHighlightsPostProcess;
  120322. private _blurX;
  120323. private _blurY;
  120324. private _merge;
  120325. /**
  120326. * The luminance threshold to find bright areas of the image to bloom.
  120327. */
  120328. threshold: number;
  120329. /**
  120330. * The strength of the bloom.
  120331. */
  120332. weight: number;
  120333. /**
  120334. * Specifies the size of the bloom blur kernel, relative to the final output size
  120335. */
  120336. kernel: number;
  120337. /**
  120338. * Creates a new instance of @see BloomEffect
  120339. * @param scene The scene the effect belongs to.
  120340. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  120341. * @param bloomKernel The size of the kernel to be used when applying the blur.
  120342. * @param bloomWeight The the strength of bloom.
  120343. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120344. * @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)
  120345. */
  120346. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  120347. /**
  120348. * Disposes each of the internal effects for a given camera.
  120349. * @param camera The camera to dispose the effect on.
  120350. */
  120351. disposeEffects(camera: Camera): void;
  120352. /**
  120353. * @hidden Internal
  120354. */
  120355. _updateEffects(): void;
  120356. /**
  120357. * Internal
  120358. * @returns if all the contained post processes are ready.
  120359. * @hidden
  120360. */
  120361. _isReady(): boolean;
  120362. }
  120363. }
  120364. declare module BABYLON {
  120365. /** @hidden */
  120366. export var chromaticAberrationPixelShader: {
  120367. name: string;
  120368. shader: string;
  120369. };
  120370. }
  120371. declare module BABYLON {
  120372. /**
  120373. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  120374. */
  120375. export class ChromaticAberrationPostProcess extends PostProcess {
  120376. /**
  120377. * The amount of seperation of rgb channels (default: 30)
  120378. */
  120379. aberrationAmount: number;
  120380. /**
  120381. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  120382. */
  120383. radialIntensity: number;
  120384. /**
  120385. * 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))
  120386. */
  120387. direction: Vector2;
  120388. /**
  120389. * 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))
  120390. */
  120391. centerPosition: Vector2;
  120392. /**
  120393. * Creates a new instance ChromaticAberrationPostProcess
  120394. * @param name The name of the effect.
  120395. * @param screenWidth The width of the screen to apply the effect on.
  120396. * @param screenHeight The height of the screen to apply the effect on.
  120397. * @param options The required width/height ratio to downsize to before computing the render pass.
  120398. * @param camera The camera to apply the render pass to.
  120399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120400. * @param engine The engine which the post process will be applied. (default: current engine)
  120401. * @param reusable If the post process can be reused on the same frame. (default: false)
  120402. * @param textureType Type of textures used when performing the post process. (default: 0)
  120403. * @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)
  120404. */
  120405. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120406. }
  120407. }
  120408. declare module BABYLON {
  120409. /** @hidden */
  120410. export var circleOfConfusionPixelShader: {
  120411. name: string;
  120412. shader: string;
  120413. };
  120414. }
  120415. declare module BABYLON {
  120416. /**
  120417. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  120418. */
  120419. export class CircleOfConfusionPostProcess extends PostProcess {
  120420. /**
  120421. * 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.
  120422. */
  120423. lensSize: number;
  120424. /**
  120425. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  120426. */
  120427. fStop: number;
  120428. /**
  120429. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  120430. */
  120431. focusDistance: number;
  120432. /**
  120433. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  120434. */
  120435. focalLength: number;
  120436. private _depthTexture;
  120437. /**
  120438. * Creates a new instance CircleOfConfusionPostProcess
  120439. * @param name The name of the effect.
  120440. * @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.
  120441. * @param options The required width/height ratio to downsize to before computing the render pass.
  120442. * @param camera The camera to apply the render pass to.
  120443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120444. * @param engine The engine which the post process will be applied. (default: current engine)
  120445. * @param reusable If the post process can be reused on the same frame. (default: false)
  120446. * @param textureType Type of textures used when performing the post process. (default: 0)
  120447. * @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)
  120448. */
  120449. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120450. /**
  120451. * 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.
  120452. */
  120453. depthTexture: RenderTargetTexture;
  120454. }
  120455. }
  120456. declare module BABYLON {
  120457. /** @hidden */
  120458. export var colorCorrectionPixelShader: {
  120459. name: string;
  120460. shader: string;
  120461. };
  120462. }
  120463. declare module BABYLON {
  120464. /**
  120465. *
  120466. * This post-process allows the modification of rendered colors by using
  120467. * a 'look-up table' (LUT). This effect is also called Color Grading.
  120468. *
  120469. * The object needs to be provided an url to a texture containing the color
  120470. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  120471. * Use an image editing software to tweak the LUT to match your needs.
  120472. *
  120473. * For an example of a color LUT, see here:
  120474. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  120475. * For explanations on color grading, see here:
  120476. * @see http://udn.epicgames.com/Three/ColorGrading.html
  120477. *
  120478. */
  120479. export class ColorCorrectionPostProcess extends PostProcess {
  120480. private _colorTableTexture;
  120481. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120482. }
  120483. }
  120484. declare module BABYLON {
  120485. /** @hidden */
  120486. export var convolutionPixelShader: {
  120487. name: string;
  120488. shader: string;
  120489. };
  120490. }
  120491. declare module BABYLON {
  120492. /**
  120493. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  120494. * input texture to perform effects such as edge detection or sharpening
  120495. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  120496. */
  120497. export class ConvolutionPostProcess extends PostProcess {
  120498. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  120499. kernel: number[];
  120500. /**
  120501. * Creates a new instance ConvolutionPostProcess
  120502. * @param name The name of the effect.
  120503. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  120504. * @param options The required width/height ratio to downsize to before computing the render pass.
  120505. * @param camera The camera to apply the render pass to.
  120506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120507. * @param engine The engine which the post process will be applied. (default: current engine)
  120508. * @param reusable If the post process can be reused on the same frame. (default: false)
  120509. * @param textureType Type of textures used when performing the post process. (default: 0)
  120510. */
  120511. constructor(name: string,
  120512. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  120513. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120514. /**
  120515. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120516. */
  120517. static EdgeDetect0Kernel: number[];
  120518. /**
  120519. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120520. */
  120521. static EdgeDetect1Kernel: number[];
  120522. /**
  120523. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120524. */
  120525. static EdgeDetect2Kernel: number[];
  120526. /**
  120527. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120528. */
  120529. static SharpenKernel: number[];
  120530. /**
  120531. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120532. */
  120533. static EmbossKernel: number[];
  120534. /**
  120535. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120536. */
  120537. static GaussianKernel: number[];
  120538. }
  120539. }
  120540. declare module BABYLON {
  120541. /**
  120542. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  120543. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  120544. * based on samples that have a large difference in distance than the center pixel.
  120545. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  120546. */
  120547. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  120548. direction: Vector2;
  120549. /**
  120550. * Creates a new instance CircleOfConfusionPostProcess
  120551. * @param name The name of the effect.
  120552. * @param scene The scene the effect belongs to.
  120553. * @param direction The direction the blur should be applied.
  120554. * @param kernel The size of the kernel used to blur.
  120555. * @param options The required width/height ratio to downsize to before computing the render pass.
  120556. * @param camera The camera to apply the render pass to.
  120557. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  120558. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  120559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120560. * @param engine The engine which the post process will be applied. (default: current engine)
  120561. * @param reusable If the post process can be reused on the same frame. (default: false)
  120562. * @param textureType Type of textures used when performing the post process. (default: 0)
  120563. * @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)
  120564. */
  120565. 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);
  120566. }
  120567. }
  120568. declare module BABYLON {
  120569. /** @hidden */
  120570. export var depthOfFieldMergePixelShader: {
  120571. name: string;
  120572. shader: string;
  120573. };
  120574. }
  120575. declare module BABYLON {
  120576. /**
  120577. * Options to be set when merging outputs from the default pipeline.
  120578. */
  120579. export class DepthOfFieldMergePostProcessOptions {
  120580. /**
  120581. * The original image to merge on top of
  120582. */
  120583. originalFromInput: PostProcess;
  120584. /**
  120585. * Parameters to perform the merge of the depth of field effect
  120586. */
  120587. depthOfField?: {
  120588. circleOfConfusion: PostProcess;
  120589. blurSteps: Array<PostProcess>;
  120590. };
  120591. /**
  120592. * Parameters to perform the merge of bloom effect
  120593. */
  120594. bloom?: {
  120595. blurred: PostProcess;
  120596. weight: number;
  120597. };
  120598. }
  120599. /**
  120600. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  120601. */
  120602. export class DepthOfFieldMergePostProcess extends PostProcess {
  120603. private blurSteps;
  120604. /**
  120605. * Creates a new instance of DepthOfFieldMergePostProcess
  120606. * @param name The name of the effect.
  120607. * @param originalFromInput Post process which's input will be used for the merge.
  120608. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  120609. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  120610. * @param options The required width/height ratio to downsize to before computing the render pass.
  120611. * @param camera The camera to apply the render pass to.
  120612. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120613. * @param engine The engine which the post process will be applied. (default: current engine)
  120614. * @param reusable If the post process can be reused on the same frame. (default: false)
  120615. * @param textureType Type of textures used when performing the post process. (default: 0)
  120616. * @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)
  120617. */
  120618. 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);
  120619. /**
  120620. * Updates the effect with the current post process compile time values and recompiles the shader.
  120621. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  120622. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  120623. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  120624. * @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
  120625. * @param onCompiled Called when the shader has been compiled.
  120626. * @param onError Called if there is an error when compiling a shader.
  120627. */
  120628. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  120629. }
  120630. }
  120631. declare module BABYLON {
  120632. /**
  120633. * Specifies the level of max blur that should be applied when using the depth of field effect
  120634. */
  120635. export enum DepthOfFieldEffectBlurLevel {
  120636. /**
  120637. * Subtle blur
  120638. */
  120639. Low = 0,
  120640. /**
  120641. * Medium blur
  120642. */
  120643. Medium = 1,
  120644. /**
  120645. * Large blur
  120646. */
  120647. High = 2
  120648. }
  120649. /**
  120650. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  120651. */
  120652. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  120653. private _circleOfConfusion;
  120654. /**
  120655. * @hidden Internal, blurs from high to low
  120656. */
  120657. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  120658. private _depthOfFieldBlurY;
  120659. private _dofMerge;
  120660. /**
  120661. * @hidden Internal post processes in depth of field effect
  120662. */
  120663. _effects: Array<PostProcess>;
  120664. /**
  120665. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  120666. */
  120667. focalLength: number;
  120668. /**
  120669. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  120670. */
  120671. fStop: number;
  120672. /**
  120673. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  120674. */
  120675. focusDistance: number;
  120676. /**
  120677. * 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.
  120678. */
  120679. lensSize: number;
  120680. /**
  120681. * Creates a new instance DepthOfFieldEffect
  120682. * @param scene The scene the effect belongs to.
  120683. * @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.
  120684. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120685. * @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)
  120686. */
  120687. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  120688. /**
  120689. * Get the current class name of the current effet
  120690. * @returns "DepthOfFieldEffect"
  120691. */
  120692. getClassName(): string;
  120693. /**
  120694. * 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.
  120695. */
  120696. depthTexture: RenderTargetTexture;
  120697. /**
  120698. * Disposes each of the internal effects for a given camera.
  120699. * @param camera The camera to dispose the effect on.
  120700. */
  120701. disposeEffects(camera: Camera): void;
  120702. /**
  120703. * @hidden Internal
  120704. */
  120705. _updateEffects(): void;
  120706. /**
  120707. * Internal
  120708. * @returns if all the contained post processes are ready.
  120709. * @hidden
  120710. */
  120711. _isReady(): boolean;
  120712. }
  120713. }
  120714. declare module BABYLON {
  120715. /** @hidden */
  120716. export var displayPassPixelShader: {
  120717. name: string;
  120718. shader: string;
  120719. };
  120720. }
  120721. declare module BABYLON {
  120722. /**
  120723. * DisplayPassPostProcess which produces an output the same as it's input
  120724. */
  120725. export class DisplayPassPostProcess extends PostProcess {
  120726. /**
  120727. * Creates the DisplayPassPostProcess
  120728. * @param name The name of the effect.
  120729. * @param options The required width/height ratio to downsize to before computing the render pass.
  120730. * @param camera The camera to apply the render pass to.
  120731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120732. * @param engine The engine which the post process will be applied. (default: current engine)
  120733. * @param reusable If the post process can be reused on the same frame. (default: false)
  120734. */
  120735. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120736. }
  120737. }
  120738. declare module BABYLON {
  120739. /** @hidden */
  120740. export var filterPixelShader: {
  120741. name: string;
  120742. shader: string;
  120743. };
  120744. }
  120745. declare module BABYLON {
  120746. /**
  120747. * Applies a kernel filter to the image
  120748. */
  120749. export class FilterPostProcess extends PostProcess {
  120750. /** The matrix to be applied to the image */
  120751. kernelMatrix: Matrix;
  120752. /**
  120753. *
  120754. * @param name The name of the effect.
  120755. * @param kernelMatrix The matrix to be applied to the image
  120756. * @param options The required width/height ratio to downsize to before computing the render pass.
  120757. * @param camera The camera to apply the render pass to.
  120758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120759. * @param engine The engine which the post process will be applied. (default: current engine)
  120760. * @param reusable If the post process can be reused on the same frame. (default: false)
  120761. */
  120762. constructor(name: string,
  120763. /** The matrix to be applied to the image */
  120764. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120765. }
  120766. }
  120767. declare module BABYLON {
  120768. /** @hidden */
  120769. export var fxaaPixelShader: {
  120770. name: string;
  120771. shader: string;
  120772. };
  120773. }
  120774. declare module BABYLON {
  120775. /** @hidden */
  120776. export var fxaaVertexShader: {
  120777. name: string;
  120778. shader: string;
  120779. };
  120780. }
  120781. declare module BABYLON {
  120782. /**
  120783. * Fxaa post process
  120784. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  120785. */
  120786. export class FxaaPostProcess extends PostProcess {
  120787. /** @hidden */
  120788. texelWidth: number;
  120789. /** @hidden */
  120790. texelHeight: number;
  120791. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120792. private _getDefines;
  120793. }
  120794. }
  120795. declare module BABYLON {
  120796. /** @hidden */
  120797. export var grainPixelShader: {
  120798. name: string;
  120799. shader: string;
  120800. };
  120801. }
  120802. declare module BABYLON {
  120803. /**
  120804. * The GrainPostProcess adds noise to the image at mid luminance levels
  120805. */
  120806. export class GrainPostProcess extends PostProcess {
  120807. /**
  120808. * The intensity of the grain added (default: 30)
  120809. */
  120810. intensity: number;
  120811. /**
  120812. * If the grain should be randomized on every frame
  120813. */
  120814. animated: boolean;
  120815. /**
  120816. * Creates a new instance of @see GrainPostProcess
  120817. * @param name The name of the effect.
  120818. * @param options The required width/height ratio to downsize to before computing the render pass.
  120819. * @param camera The camera to apply the render pass to.
  120820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120821. * @param engine The engine which the post process will be applied. (default: current engine)
  120822. * @param reusable If the post process can be reused on the same frame. (default: false)
  120823. * @param textureType Type of textures used when performing the post process. (default: 0)
  120824. * @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)
  120825. */
  120826. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120827. }
  120828. }
  120829. declare module BABYLON {
  120830. /** @hidden */
  120831. export var highlightsPixelShader: {
  120832. name: string;
  120833. shader: string;
  120834. };
  120835. }
  120836. declare module BABYLON {
  120837. /**
  120838. * Extracts highlights from the image
  120839. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120840. */
  120841. export class HighlightsPostProcess extends PostProcess {
  120842. /**
  120843. * Extracts highlights from the image
  120844. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120845. * @param name The name of the effect.
  120846. * @param options The required width/height ratio to downsize to before computing the render pass.
  120847. * @param camera The camera to apply the render pass to.
  120848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120849. * @param engine The engine which the post process will be applied. (default: current engine)
  120850. * @param reusable If the post process can be reused on the same frame. (default: false)
  120851. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  120852. */
  120853. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120854. }
  120855. }
  120856. declare module BABYLON {
  120857. /** @hidden */
  120858. export var mrtFragmentDeclaration: {
  120859. name: string;
  120860. shader: string;
  120861. };
  120862. }
  120863. declare module BABYLON {
  120864. /** @hidden */
  120865. export var geometryPixelShader: {
  120866. name: string;
  120867. shader: string;
  120868. };
  120869. }
  120870. declare module BABYLON {
  120871. /** @hidden */
  120872. export var geometryVertexShader: {
  120873. name: string;
  120874. shader: string;
  120875. };
  120876. }
  120877. declare module BABYLON {
  120878. /** @hidden */
  120879. interface ISavedTransformationMatrix {
  120880. world: Matrix;
  120881. viewProjection: Matrix;
  120882. }
  120883. /**
  120884. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  120885. */
  120886. export class GeometryBufferRenderer {
  120887. /**
  120888. * Constant used to retrieve the position texture index in the G-Buffer textures array
  120889. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  120890. */
  120891. static readonly POSITION_TEXTURE_TYPE: number;
  120892. /**
  120893. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  120894. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  120895. */
  120896. static readonly VELOCITY_TEXTURE_TYPE: number;
  120897. /**
  120898. * Dictionary used to store the previous transformation matrices of each rendered mesh
  120899. * in order to compute objects velocities when enableVelocity is set to "true"
  120900. * @hidden
  120901. */
  120902. _previousTransformationMatrices: {
  120903. [index: number]: ISavedTransformationMatrix;
  120904. };
  120905. /**
  120906. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  120907. * in order to compute objects velocities when enableVelocity is set to "true"
  120908. * @hidden
  120909. */
  120910. _previousBonesTransformationMatrices: {
  120911. [index: number]: Float32Array;
  120912. };
  120913. /**
  120914. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  120915. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  120916. */
  120917. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  120918. private _scene;
  120919. private _multiRenderTarget;
  120920. private _ratio;
  120921. private _enablePosition;
  120922. private _enableVelocity;
  120923. private _positionIndex;
  120924. private _velocityIndex;
  120925. protected _effect: Effect;
  120926. protected _cachedDefines: string;
  120927. /**
  120928. * Set the render list (meshes to be rendered) used in the G buffer.
  120929. */
  120930. renderList: Mesh[];
  120931. /**
  120932. * Gets wether or not G buffer are supported by the running hardware.
  120933. * This requires draw buffer supports
  120934. */
  120935. readonly isSupported: boolean;
  120936. /**
  120937. * Returns the index of the given texture type in the G-Buffer textures array
  120938. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  120939. * @returns the index of the given texture type in the G-Buffer textures array
  120940. */
  120941. getTextureIndex(textureType: number): number;
  120942. /**
  120943. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  120944. */
  120945. /**
  120946. * Sets whether or not objects positions are enabled for the G buffer.
  120947. */
  120948. enablePosition: boolean;
  120949. /**
  120950. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  120951. */
  120952. /**
  120953. * Sets wether or not objects velocities are enabled for the G buffer.
  120954. */
  120955. enableVelocity: boolean;
  120956. /**
  120957. * Gets the scene associated with the buffer.
  120958. */
  120959. readonly scene: Scene;
  120960. /**
  120961. * Gets the ratio used by the buffer during its creation.
  120962. * How big is the buffer related to the main canvas.
  120963. */
  120964. readonly ratio: number;
  120965. /** @hidden */
  120966. static _SceneComponentInitialization: (scene: Scene) => void;
  120967. /**
  120968. * Creates a new G Buffer for the scene
  120969. * @param scene The scene the buffer belongs to
  120970. * @param ratio How big is the buffer related to the main canvas.
  120971. */
  120972. constructor(scene: Scene, ratio?: number);
  120973. /**
  120974. * Checks wether everything is ready to render a submesh to the G buffer.
  120975. * @param subMesh the submesh to check readiness for
  120976. * @param useInstances is the mesh drawn using instance or not
  120977. * @returns true if ready otherwise false
  120978. */
  120979. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120980. /**
  120981. * Gets the current underlying G Buffer.
  120982. * @returns the buffer
  120983. */
  120984. getGBuffer(): MultiRenderTarget;
  120985. /**
  120986. * Gets the number of samples used to render the buffer (anti aliasing).
  120987. */
  120988. /**
  120989. * Sets the number of samples used to render the buffer (anti aliasing).
  120990. */
  120991. samples: number;
  120992. /**
  120993. * Disposes the renderer and frees up associated resources.
  120994. */
  120995. dispose(): void;
  120996. protected _createRenderTargets(): void;
  120997. private _copyBonesTransformationMatrices;
  120998. }
  120999. }
  121000. declare module BABYLON {
  121001. interface Scene {
  121002. /** @hidden (Backing field) */
  121003. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  121004. /**
  121005. * Gets or Sets the current geometry buffer associated to the scene.
  121006. */
  121007. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  121008. /**
  121009. * Enables a GeometryBufferRender and associates it with the scene
  121010. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  121011. * @returns the GeometryBufferRenderer
  121012. */
  121013. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  121014. /**
  121015. * Disables the GeometryBufferRender associated with the scene
  121016. */
  121017. disableGeometryBufferRenderer(): void;
  121018. }
  121019. /**
  121020. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  121021. * in several rendering techniques.
  121022. */
  121023. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  121024. /**
  121025. * The component name helpful to identify the component in the list of scene components.
  121026. */
  121027. readonly name: string;
  121028. /**
  121029. * The scene the component belongs to.
  121030. */
  121031. scene: Scene;
  121032. /**
  121033. * Creates a new instance of the component for the given scene
  121034. * @param scene Defines the scene to register the component in
  121035. */
  121036. constructor(scene: Scene);
  121037. /**
  121038. * Registers the component in a given scene
  121039. */
  121040. register(): void;
  121041. /**
  121042. * Rebuilds the elements related to this component in case of
  121043. * context lost for instance.
  121044. */
  121045. rebuild(): void;
  121046. /**
  121047. * Disposes the component and the associated ressources
  121048. */
  121049. dispose(): void;
  121050. private _gatherRenderTargets;
  121051. }
  121052. }
  121053. declare module BABYLON {
  121054. /** @hidden */
  121055. export var motionBlurPixelShader: {
  121056. name: string;
  121057. shader: string;
  121058. };
  121059. }
  121060. declare module BABYLON {
  121061. /**
  121062. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  121063. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  121064. * As an example, all you have to do is to create the post-process:
  121065. * var mb = new BABYLON.MotionBlurPostProcess(
  121066. * 'mb', // The name of the effect.
  121067. * scene, // The scene containing the objects to blur according to their velocity.
  121068. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  121069. * camera // The camera to apply the render pass to.
  121070. * );
  121071. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  121072. */
  121073. export class MotionBlurPostProcess extends PostProcess {
  121074. /**
  121075. * Defines how much the image is blurred by the movement. Default value is equal to 1
  121076. */
  121077. motionStrength: number;
  121078. /**
  121079. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  121080. */
  121081. /**
  121082. * Sets the number of iterations to be used for motion blur quality
  121083. */
  121084. motionBlurSamples: number;
  121085. private _motionBlurSamples;
  121086. private _geometryBufferRenderer;
  121087. /**
  121088. * Creates a new instance MotionBlurPostProcess
  121089. * @param name The name of the effect.
  121090. * @param scene The scene containing the objects to blur according to their velocity.
  121091. * @param options The required width/height ratio to downsize to before computing the render pass.
  121092. * @param camera The camera to apply the render pass to.
  121093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121094. * @param engine The engine which the post process will be applied. (default: current engine)
  121095. * @param reusable If the post process can be reused on the same frame. (default: false)
  121096. * @param textureType Type of textures used when performing the post process. (default: 0)
  121097. * @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)
  121098. */
  121099. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121100. /**
  121101. * Excludes the given skinned mesh from computing bones velocities.
  121102. * 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.
  121103. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  121104. */
  121105. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  121106. /**
  121107. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  121108. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  121109. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  121110. */
  121111. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  121112. /**
  121113. * Disposes the post process.
  121114. * @param camera The camera to dispose the post process on.
  121115. */
  121116. dispose(camera?: Camera): void;
  121117. }
  121118. }
  121119. declare module BABYLON {
  121120. /** @hidden */
  121121. export var refractionPixelShader: {
  121122. name: string;
  121123. shader: string;
  121124. };
  121125. }
  121126. declare module BABYLON {
  121127. /**
  121128. * Post process which applies a refractin texture
  121129. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  121130. */
  121131. export class RefractionPostProcess extends PostProcess {
  121132. /** the base color of the refraction (used to taint the rendering) */
  121133. color: Color3;
  121134. /** simulated refraction depth */
  121135. depth: number;
  121136. /** the coefficient of the base color (0 to remove base color tainting) */
  121137. colorLevel: number;
  121138. private _refTexture;
  121139. private _ownRefractionTexture;
  121140. /**
  121141. * Gets or sets the refraction texture
  121142. * Please note that you are responsible for disposing the texture if you set it manually
  121143. */
  121144. refractionTexture: Texture;
  121145. /**
  121146. * Initializes the RefractionPostProcess
  121147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  121148. * @param name The name of the effect.
  121149. * @param refractionTextureUrl Url of the refraction texture to use
  121150. * @param color the base color of the refraction (used to taint the rendering)
  121151. * @param depth simulated refraction depth
  121152. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  121153. * @param camera The camera to apply the render pass to.
  121154. * @param options The required width/height ratio to downsize to before computing the render pass.
  121155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121156. * @param engine The engine which the post process will be applied. (default: current engine)
  121157. * @param reusable If the post process can be reused on the same frame. (default: false)
  121158. */
  121159. constructor(name: string, refractionTextureUrl: string,
  121160. /** the base color of the refraction (used to taint the rendering) */
  121161. color: Color3,
  121162. /** simulated refraction depth */
  121163. depth: number,
  121164. /** the coefficient of the base color (0 to remove base color tainting) */
  121165. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121166. /**
  121167. * Disposes of the post process
  121168. * @param camera Camera to dispose post process on
  121169. */
  121170. dispose(camera: Camera): void;
  121171. }
  121172. }
  121173. declare module BABYLON {
  121174. /** @hidden */
  121175. export var sharpenPixelShader: {
  121176. name: string;
  121177. shader: string;
  121178. };
  121179. }
  121180. declare module BABYLON {
  121181. /**
  121182. * The SharpenPostProcess applies a sharpen kernel to every pixel
  121183. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121184. */
  121185. export class SharpenPostProcess extends PostProcess {
  121186. /**
  121187. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  121188. */
  121189. colorAmount: number;
  121190. /**
  121191. * How much sharpness should be applied (default: 0.3)
  121192. */
  121193. edgeAmount: number;
  121194. /**
  121195. * Creates a new instance ConvolutionPostProcess
  121196. * @param name The name of the effect.
  121197. * @param options The required width/height ratio to downsize to before computing the render pass.
  121198. * @param camera The camera to apply the render pass to.
  121199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121200. * @param engine The engine which the post process will be applied. (default: current engine)
  121201. * @param reusable If the post process can be reused on the same frame. (default: false)
  121202. * @param textureType Type of textures used when performing the post process. (default: 0)
  121203. * @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)
  121204. */
  121205. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121206. }
  121207. }
  121208. declare module BABYLON {
  121209. /**
  121210. * PostProcessRenderPipeline
  121211. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121212. */
  121213. export class PostProcessRenderPipeline {
  121214. private engine;
  121215. private _renderEffects;
  121216. private _renderEffectsForIsolatedPass;
  121217. /**
  121218. * List of inspectable custom properties (used by the Inspector)
  121219. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  121220. */
  121221. inspectableCustomProperties: IInspectable[];
  121222. /**
  121223. * @hidden
  121224. */
  121225. protected _cameras: Camera[];
  121226. /** @hidden */
  121227. _name: string;
  121228. /**
  121229. * Gets pipeline name
  121230. */
  121231. readonly name: string;
  121232. /**
  121233. * Initializes a PostProcessRenderPipeline
  121234. * @param engine engine to add the pipeline to
  121235. * @param name name of the pipeline
  121236. */
  121237. constructor(engine: Engine, name: string);
  121238. /**
  121239. * Gets the class name
  121240. * @returns "PostProcessRenderPipeline"
  121241. */
  121242. getClassName(): string;
  121243. /**
  121244. * If all the render effects in the pipeline are supported
  121245. */
  121246. readonly isSupported: boolean;
  121247. /**
  121248. * Adds an effect to the pipeline
  121249. * @param renderEffect the effect to add
  121250. */
  121251. addEffect(renderEffect: PostProcessRenderEffect): void;
  121252. /** @hidden */
  121253. _rebuild(): void;
  121254. /** @hidden */
  121255. _enableEffect(renderEffectName: string, cameras: Camera): void;
  121256. /** @hidden */
  121257. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  121258. /** @hidden */
  121259. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  121260. /** @hidden */
  121261. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  121262. /** @hidden */
  121263. _attachCameras(cameras: Camera, unique: boolean): void;
  121264. /** @hidden */
  121265. _attachCameras(cameras: Camera[], unique: boolean): void;
  121266. /** @hidden */
  121267. _detachCameras(cameras: Camera): void;
  121268. /** @hidden */
  121269. _detachCameras(cameras: Nullable<Camera[]>): void;
  121270. /** @hidden */
  121271. _update(): void;
  121272. /** @hidden */
  121273. _reset(): void;
  121274. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  121275. /**
  121276. * Disposes of the pipeline
  121277. */
  121278. dispose(): void;
  121279. }
  121280. }
  121281. declare module BABYLON {
  121282. /**
  121283. * PostProcessRenderPipelineManager class
  121284. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121285. */
  121286. export class PostProcessRenderPipelineManager {
  121287. private _renderPipelines;
  121288. /**
  121289. * Initializes a PostProcessRenderPipelineManager
  121290. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121291. */
  121292. constructor();
  121293. /**
  121294. * Gets the list of supported render pipelines
  121295. */
  121296. readonly supportedPipelines: PostProcessRenderPipeline[];
  121297. /**
  121298. * Adds a pipeline to the manager
  121299. * @param renderPipeline The pipeline to add
  121300. */
  121301. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  121302. /**
  121303. * Attaches a camera to the pipeline
  121304. * @param renderPipelineName The name of the pipeline to attach to
  121305. * @param cameras the camera to attach
  121306. * @param unique if the camera can be attached multiple times to the pipeline
  121307. */
  121308. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  121309. /**
  121310. * Detaches a camera from the pipeline
  121311. * @param renderPipelineName The name of the pipeline to detach from
  121312. * @param cameras the camera to detach
  121313. */
  121314. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  121315. /**
  121316. * Enables an effect by name on a pipeline
  121317. * @param renderPipelineName the name of the pipeline to enable the effect in
  121318. * @param renderEffectName the name of the effect to enable
  121319. * @param cameras the cameras that the effect should be enabled on
  121320. */
  121321. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  121322. /**
  121323. * Disables an effect by name on a pipeline
  121324. * @param renderPipelineName the name of the pipeline to disable the effect in
  121325. * @param renderEffectName the name of the effect to disable
  121326. * @param cameras the cameras that the effect should be disabled on
  121327. */
  121328. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  121329. /**
  121330. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  121331. */
  121332. update(): void;
  121333. /** @hidden */
  121334. _rebuild(): void;
  121335. /**
  121336. * Disposes of the manager and pipelines
  121337. */
  121338. dispose(): void;
  121339. }
  121340. }
  121341. declare module BABYLON {
  121342. interface Scene {
  121343. /** @hidden (Backing field) */
  121344. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121345. /**
  121346. * Gets the postprocess render pipeline manager
  121347. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121348. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121349. */
  121350. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121351. }
  121352. /**
  121353. * Defines the Render Pipeline scene component responsible to rendering pipelines
  121354. */
  121355. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  121356. /**
  121357. * The component name helpfull to identify the component in the list of scene components.
  121358. */
  121359. readonly name: string;
  121360. /**
  121361. * The scene the component belongs to.
  121362. */
  121363. scene: Scene;
  121364. /**
  121365. * Creates a new instance of the component for the given scene
  121366. * @param scene Defines the scene to register the component in
  121367. */
  121368. constructor(scene: Scene);
  121369. /**
  121370. * Registers the component in a given scene
  121371. */
  121372. register(): void;
  121373. /**
  121374. * Rebuilds the elements related to this component in case of
  121375. * context lost for instance.
  121376. */
  121377. rebuild(): void;
  121378. /**
  121379. * Disposes the component and the associated ressources
  121380. */
  121381. dispose(): void;
  121382. private _gatherRenderTargets;
  121383. }
  121384. }
  121385. declare module BABYLON {
  121386. /**
  121387. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  121388. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121389. */
  121390. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  121391. private _scene;
  121392. private _camerasToBeAttached;
  121393. /**
  121394. * ID of the sharpen post process,
  121395. */
  121396. private readonly SharpenPostProcessId;
  121397. /**
  121398. * @ignore
  121399. * ID of the image processing post process;
  121400. */
  121401. readonly ImageProcessingPostProcessId: string;
  121402. /**
  121403. * @ignore
  121404. * ID of the Fast Approximate Anti-Aliasing post process;
  121405. */
  121406. readonly FxaaPostProcessId: string;
  121407. /**
  121408. * ID of the chromatic aberration post process,
  121409. */
  121410. private readonly ChromaticAberrationPostProcessId;
  121411. /**
  121412. * ID of the grain post process
  121413. */
  121414. private readonly GrainPostProcessId;
  121415. /**
  121416. * Sharpen post process which will apply a sharpen convolution to enhance edges
  121417. */
  121418. sharpen: SharpenPostProcess;
  121419. private _sharpenEffect;
  121420. private bloom;
  121421. /**
  121422. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  121423. */
  121424. depthOfField: DepthOfFieldEffect;
  121425. /**
  121426. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  121427. */
  121428. fxaa: FxaaPostProcess;
  121429. /**
  121430. * Image post processing pass used to perform operations such as tone mapping or color grading.
  121431. */
  121432. imageProcessing: ImageProcessingPostProcess;
  121433. /**
  121434. * Chromatic aberration post process which will shift rgb colors in the image
  121435. */
  121436. chromaticAberration: ChromaticAberrationPostProcess;
  121437. private _chromaticAberrationEffect;
  121438. /**
  121439. * Grain post process which add noise to the image
  121440. */
  121441. grain: GrainPostProcess;
  121442. private _grainEffect;
  121443. /**
  121444. * Glow post process which adds a glow to emissive areas of the image
  121445. */
  121446. private _glowLayer;
  121447. /**
  121448. * Animations which can be used to tweak settings over a period of time
  121449. */
  121450. animations: Animation[];
  121451. private _imageProcessingConfigurationObserver;
  121452. private _sharpenEnabled;
  121453. private _bloomEnabled;
  121454. private _depthOfFieldEnabled;
  121455. private _depthOfFieldBlurLevel;
  121456. private _fxaaEnabled;
  121457. private _imageProcessingEnabled;
  121458. private _defaultPipelineTextureType;
  121459. private _bloomScale;
  121460. private _chromaticAberrationEnabled;
  121461. private _grainEnabled;
  121462. private _buildAllowed;
  121463. /**
  121464. * Gets active scene
  121465. */
  121466. readonly scene: Scene;
  121467. /**
  121468. * Enable or disable the sharpen process from the pipeline
  121469. */
  121470. sharpenEnabled: boolean;
  121471. private _resizeObserver;
  121472. private _hardwareScaleLevel;
  121473. private _bloomKernel;
  121474. /**
  121475. * Specifies the size of the bloom blur kernel, relative to the final output size
  121476. */
  121477. bloomKernel: number;
  121478. /**
  121479. * Specifies the weight of the bloom in the final rendering
  121480. */
  121481. private _bloomWeight;
  121482. /**
  121483. * Specifies the luma threshold for the area that will be blurred by the bloom
  121484. */
  121485. private _bloomThreshold;
  121486. private _hdr;
  121487. /**
  121488. * The strength of the bloom.
  121489. */
  121490. bloomWeight: number;
  121491. /**
  121492. * The strength of the bloom.
  121493. */
  121494. bloomThreshold: number;
  121495. /**
  121496. * The scale of the bloom, lower value will provide better performance.
  121497. */
  121498. bloomScale: number;
  121499. /**
  121500. * Enable or disable the bloom from the pipeline
  121501. */
  121502. bloomEnabled: boolean;
  121503. private _rebuildBloom;
  121504. /**
  121505. * If the depth of field is enabled.
  121506. */
  121507. depthOfFieldEnabled: boolean;
  121508. /**
  121509. * Blur level of the depth of field effect. (Higher blur will effect performance)
  121510. */
  121511. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  121512. /**
  121513. * If the anti aliasing is enabled.
  121514. */
  121515. fxaaEnabled: boolean;
  121516. private _samples;
  121517. /**
  121518. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  121519. */
  121520. samples: number;
  121521. /**
  121522. * If image processing is enabled.
  121523. */
  121524. imageProcessingEnabled: boolean;
  121525. /**
  121526. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  121527. */
  121528. glowLayerEnabled: boolean;
  121529. /**
  121530. * Gets the glow layer (or null if not defined)
  121531. */
  121532. readonly glowLayer: Nullable<GlowLayer>;
  121533. /**
  121534. * Enable or disable the chromaticAberration process from the pipeline
  121535. */
  121536. chromaticAberrationEnabled: boolean;
  121537. /**
  121538. * Enable or disable the grain process from the pipeline
  121539. */
  121540. grainEnabled: boolean;
  121541. /**
  121542. * @constructor
  121543. * @param name - The rendering pipeline name (default: "")
  121544. * @param hdr - If high dynamic range textures should be used (default: true)
  121545. * @param scene - The scene linked to this pipeline (default: the last created scene)
  121546. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  121547. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  121548. */
  121549. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  121550. /**
  121551. * Get the class name
  121552. * @returns "DefaultRenderingPipeline"
  121553. */
  121554. getClassName(): string;
  121555. /**
  121556. * Force the compilation of the entire pipeline.
  121557. */
  121558. prepare(): void;
  121559. private _hasCleared;
  121560. private _prevPostProcess;
  121561. private _prevPrevPostProcess;
  121562. private _setAutoClearAndTextureSharing;
  121563. private _depthOfFieldSceneObserver;
  121564. private _buildPipeline;
  121565. private _disposePostProcesses;
  121566. /**
  121567. * Adds a camera to the pipeline
  121568. * @param camera the camera to be added
  121569. */
  121570. addCamera(camera: Camera): void;
  121571. /**
  121572. * Removes a camera from the pipeline
  121573. * @param camera the camera to remove
  121574. */
  121575. removeCamera(camera: Camera): void;
  121576. /**
  121577. * Dispose of the pipeline and stop all post processes
  121578. */
  121579. dispose(): void;
  121580. /**
  121581. * Serialize the rendering pipeline (Used when exporting)
  121582. * @returns the serialized object
  121583. */
  121584. serialize(): any;
  121585. /**
  121586. * Parse the serialized pipeline
  121587. * @param source Source pipeline.
  121588. * @param scene The scene to load the pipeline to.
  121589. * @param rootUrl The URL of the serialized pipeline.
  121590. * @returns An instantiated pipeline from the serialized object.
  121591. */
  121592. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  121593. }
  121594. }
  121595. declare module BABYLON {
  121596. /** @hidden */
  121597. export var lensHighlightsPixelShader: {
  121598. name: string;
  121599. shader: string;
  121600. };
  121601. }
  121602. declare module BABYLON {
  121603. /** @hidden */
  121604. export var depthOfFieldPixelShader: {
  121605. name: string;
  121606. shader: string;
  121607. };
  121608. }
  121609. declare module BABYLON {
  121610. /**
  121611. * BABYLON.JS Chromatic Aberration GLSL Shader
  121612. * Author: Olivier Guyot
  121613. * Separates very slightly R, G and B colors on the edges of the screen
  121614. * Inspired by Francois Tarlier & Martins Upitis
  121615. */
  121616. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  121617. /**
  121618. * @ignore
  121619. * The chromatic aberration PostProcess id in the pipeline
  121620. */
  121621. LensChromaticAberrationEffect: string;
  121622. /**
  121623. * @ignore
  121624. * The highlights enhancing PostProcess id in the pipeline
  121625. */
  121626. HighlightsEnhancingEffect: string;
  121627. /**
  121628. * @ignore
  121629. * The depth-of-field PostProcess id in the pipeline
  121630. */
  121631. LensDepthOfFieldEffect: string;
  121632. private _scene;
  121633. private _depthTexture;
  121634. private _grainTexture;
  121635. private _chromaticAberrationPostProcess;
  121636. private _highlightsPostProcess;
  121637. private _depthOfFieldPostProcess;
  121638. private _edgeBlur;
  121639. private _grainAmount;
  121640. private _chromaticAberration;
  121641. private _distortion;
  121642. private _highlightsGain;
  121643. private _highlightsThreshold;
  121644. private _dofDistance;
  121645. private _dofAperture;
  121646. private _dofDarken;
  121647. private _dofPentagon;
  121648. private _blurNoise;
  121649. /**
  121650. * @constructor
  121651. *
  121652. * Effect parameters are as follow:
  121653. * {
  121654. * chromatic_aberration: number; // from 0 to x (1 for realism)
  121655. * edge_blur: number; // from 0 to x (1 for realism)
  121656. * distortion: number; // from 0 to x (1 for realism)
  121657. * grain_amount: number; // from 0 to 1
  121658. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  121659. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  121660. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  121661. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  121662. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  121663. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  121664. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  121665. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  121666. * }
  121667. * Note: if an effect parameter is unset, effect is disabled
  121668. *
  121669. * @param name The rendering pipeline name
  121670. * @param parameters - An object containing all parameters (see above)
  121671. * @param scene The scene linked to this pipeline
  121672. * @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)
  121673. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121674. */
  121675. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  121676. /**
  121677. * Get the class name
  121678. * @returns "LensRenderingPipeline"
  121679. */
  121680. getClassName(): string;
  121681. /**
  121682. * Gets associated scene
  121683. */
  121684. readonly scene: Scene;
  121685. /**
  121686. * Gets or sets the edge blur
  121687. */
  121688. edgeBlur: number;
  121689. /**
  121690. * Gets or sets the grain amount
  121691. */
  121692. grainAmount: number;
  121693. /**
  121694. * Gets or sets the chromatic aberration amount
  121695. */
  121696. chromaticAberration: number;
  121697. /**
  121698. * Gets or sets the depth of field aperture
  121699. */
  121700. dofAperture: number;
  121701. /**
  121702. * Gets or sets the edge distortion
  121703. */
  121704. edgeDistortion: number;
  121705. /**
  121706. * Gets or sets the depth of field distortion
  121707. */
  121708. dofDistortion: number;
  121709. /**
  121710. * Gets or sets the darken out of focus amount
  121711. */
  121712. darkenOutOfFocus: number;
  121713. /**
  121714. * Gets or sets a boolean indicating if blur noise is enabled
  121715. */
  121716. blurNoise: boolean;
  121717. /**
  121718. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  121719. */
  121720. pentagonBokeh: boolean;
  121721. /**
  121722. * Gets or sets the highlight grain amount
  121723. */
  121724. highlightsGain: number;
  121725. /**
  121726. * Gets or sets the highlight threshold
  121727. */
  121728. highlightsThreshold: number;
  121729. /**
  121730. * Sets the amount of blur at the edges
  121731. * @param amount blur amount
  121732. */
  121733. setEdgeBlur(amount: number): void;
  121734. /**
  121735. * Sets edge blur to 0
  121736. */
  121737. disableEdgeBlur(): void;
  121738. /**
  121739. * Sets the amout of grain
  121740. * @param amount Amount of grain
  121741. */
  121742. setGrainAmount(amount: number): void;
  121743. /**
  121744. * Set grain amount to 0
  121745. */
  121746. disableGrain(): void;
  121747. /**
  121748. * Sets the chromatic aberration amount
  121749. * @param amount amount of chromatic aberration
  121750. */
  121751. setChromaticAberration(amount: number): void;
  121752. /**
  121753. * Sets chromatic aberration amount to 0
  121754. */
  121755. disableChromaticAberration(): void;
  121756. /**
  121757. * Sets the EdgeDistortion amount
  121758. * @param amount amount of EdgeDistortion
  121759. */
  121760. setEdgeDistortion(amount: number): void;
  121761. /**
  121762. * Sets edge distortion to 0
  121763. */
  121764. disableEdgeDistortion(): void;
  121765. /**
  121766. * Sets the FocusDistance amount
  121767. * @param amount amount of FocusDistance
  121768. */
  121769. setFocusDistance(amount: number): void;
  121770. /**
  121771. * Disables depth of field
  121772. */
  121773. disableDepthOfField(): void;
  121774. /**
  121775. * Sets the Aperture amount
  121776. * @param amount amount of Aperture
  121777. */
  121778. setAperture(amount: number): void;
  121779. /**
  121780. * Sets the DarkenOutOfFocus amount
  121781. * @param amount amount of DarkenOutOfFocus
  121782. */
  121783. setDarkenOutOfFocus(amount: number): void;
  121784. private _pentagonBokehIsEnabled;
  121785. /**
  121786. * Creates a pentagon bokeh effect
  121787. */
  121788. enablePentagonBokeh(): void;
  121789. /**
  121790. * Disables the pentagon bokeh effect
  121791. */
  121792. disablePentagonBokeh(): void;
  121793. /**
  121794. * Enables noise blur
  121795. */
  121796. enableNoiseBlur(): void;
  121797. /**
  121798. * Disables noise blur
  121799. */
  121800. disableNoiseBlur(): void;
  121801. /**
  121802. * Sets the HighlightsGain amount
  121803. * @param amount amount of HighlightsGain
  121804. */
  121805. setHighlightsGain(amount: number): void;
  121806. /**
  121807. * Sets the HighlightsThreshold amount
  121808. * @param amount amount of HighlightsThreshold
  121809. */
  121810. setHighlightsThreshold(amount: number): void;
  121811. /**
  121812. * Disables highlights
  121813. */
  121814. disableHighlights(): void;
  121815. /**
  121816. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  121817. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  121818. */
  121819. dispose(disableDepthRender?: boolean): void;
  121820. private _createChromaticAberrationPostProcess;
  121821. private _createHighlightsPostProcess;
  121822. private _createDepthOfFieldPostProcess;
  121823. private _createGrainTexture;
  121824. }
  121825. }
  121826. declare module BABYLON {
  121827. /** @hidden */
  121828. export var ssao2PixelShader: {
  121829. name: string;
  121830. shader: string;
  121831. };
  121832. }
  121833. declare module BABYLON {
  121834. /** @hidden */
  121835. export var ssaoCombinePixelShader: {
  121836. name: string;
  121837. shader: string;
  121838. };
  121839. }
  121840. declare module BABYLON {
  121841. /**
  121842. * Render pipeline to produce ssao effect
  121843. */
  121844. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  121845. /**
  121846. * @ignore
  121847. * The PassPostProcess id in the pipeline that contains the original scene color
  121848. */
  121849. SSAOOriginalSceneColorEffect: string;
  121850. /**
  121851. * @ignore
  121852. * The SSAO PostProcess id in the pipeline
  121853. */
  121854. SSAORenderEffect: string;
  121855. /**
  121856. * @ignore
  121857. * The horizontal blur PostProcess id in the pipeline
  121858. */
  121859. SSAOBlurHRenderEffect: string;
  121860. /**
  121861. * @ignore
  121862. * The vertical blur PostProcess id in the pipeline
  121863. */
  121864. SSAOBlurVRenderEffect: string;
  121865. /**
  121866. * @ignore
  121867. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  121868. */
  121869. SSAOCombineRenderEffect: string;
  121870. /**
  121871. * The output strength of the SSAO post-process. Default value is 1.0.
  121872. */
  121873. totalStrength: number;
  121874. /**
  121875. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  121876. */
  121877. maxZ: number;
  121878. /**
  121879. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  121880. */
  121881. minZAspect: number;
  121882. private _samples;
  121883. /**
  121884. * Number of samples used for the SSAO calculations. Default value is 8
  121885. */
  121886. samples: number;
  121887. private _textureSamples;
  121888. /**
  121889. * Number of samples to use for antialiasing
  121890. */
  121891. textureSamples: number;
  121892. /**
  121893. * Ratio object used for SSAO ratio and blur ratio
  121894. */
  121895. private _ratio;
  121896. /**
  121897. * Dynamically generated sphere sampler.
  121898. */
  121899. private _sampleSphere;
  121900. /**
  121901. * Blur filter offsets
  121902. */
  121903. private _samplerOffsets;
  121904. private _expensiveBlur;
  121905. /**
  121906. * If bilateral blur should be used
  121907. */
  121908. expensiveBlur: boolean;
  121909. /**
  121910. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  121911. */
  121912. radius: number;
  121913. /**
  121914. * The base color of the SSAO post-process
  121915. * The final result is "base + ssao" between [0, 1]
  121916. */
  121917. base: number;
  121918. /**
  121919. * Support test.
  121920. */
  121921. static readonly IsSupported: boolean;
  121922. private _scene;
  121923. private _depthTexture;
  121924. private _normalTexture;
  121925. private _randomTexture;
  121926. private _originalColorPostProcess;
  121927. private _ssaoPostProcess;
  121928. private _blurHPostProcess;
  121929. private _blurVPostProcess;
  121930. private _ssaoCombinePostProcess;
  121931. private _firstUpdate;
  121932. /**
  121933. * Gets active scene
  121934. */
  121935. readonly scene: Scene;
  121936. /**
  121937. * @constructor
  121938. * @param name The rendering pipeline name
  121939. * @param scene The scene linked to this pipeline
  121940. * @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 }
  121941. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121942. */
  121943. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  121944. /**
  121945. * Get the class name
  121946. * @returns "SSAO2RenderingPipeline"
  121947. */
  121948. getClassName(): string;
  121949. /**
  121950. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  121951. */
  121952. dispose(disableGeometryBufferRenderer?: boolean): void;
  121953. private _createBlurPostProcess;
  121954. /** @hidden */
  121955. _rebuild(): void;
  121956. private _bits;
  121957. private _radicalInverse_VdC;
  121958. private _hammersley;
  121959. private _hemisphereSample_uniform;
  121960. private _generateHemisphere;
  121961. private _createSSAOPostProcess;
  121962. private _createSSAOCombinePostProcess;
  121963. private _createRandomTexture;
  121964. /**
  121965. * Serialize the rendering pipeline (Used when exporting)
  121966. * @returns the serialized object
  121967. */
  121968. serialize(): any;
  121969. /**
  121970. * Parse the serialized pipeline
  121971. * @param source Source pipeline.
  121972. * @param scene The scene to load the pipeline to.
  121973. * @param rootUrl The URL of the serialized pipeline.
  121974. * @returns An instantiated pipeline from the serialized object.
  121975. */
  121976. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  121977. }
  121978. }
  121979. declare module BABYLON {
  121980. /** @hidden */
  121981. export var ssaoPixelShader: {
  121982. name: string;
  121983. shader: string;
  121984. };
  121985. }
  121986. declare module BABYLON {
  121987. /**
  121988. * Render pipeline to produce ssao effect
  121989. */
  121990. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  121991. /**
  121992. * @ignore
  121993. * The PassPostProcess id in the pipeline that contains the original scene color
  121994. */
  121995. SSAOOriginalSceneColorEffect: string;
  121996. /**
  121997. * @ignore
  121998. * The SSAO PostProcess id in the pipeline
  121999. */
  122000. SSAORenderEffect: string;
  122001. /**
  122002. * @ignore
  122003. * The horizontal blur PostProcess id in the pipeline
  122004. */
  122005. SSAOBlurHRenderEffect: string;
  122006. /**
  122007. * @ignore
  122008. * The vertical blur PostProcess id in the pipeline
  122009. */
  122010. SSAOBlurVRenderEffect: string;
  122011. /**
  122012. * @ignore
  122013. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  122014. */
  122015. SSAOCombineRenderEffect: string;
  122016. /**
  122017. * The output strength of the SSAO post-process. Default value is 1.0.
  122018. */
  122019. totalStrength: number;
  122020. /**
  122021. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  122022. */
  122023. radius: number;
  122024. /**
  122025. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  122026. * Must not be equal to fallOff and superior to fallOff.
  122027. * Default value is 0.0075
  122028. */
  122029. area: number;
  122030. /**
  122031. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  122032. * Must not be equal to area and inferior to area.
  122033. * Default value is 0.000001
  122034. */
  122035. fallOff: number;
  122036. /**
  122037. * The base color of the SSAO post-process
  122038. * The final result is "base + ssao" between [0, 1]
  122039. */
  122040. base: number;
  122041. private _scene;
  122042. private _depthTexture;
  122043. private _randomTexture;
  122044. private _originalColorPostProcess;
  122045. private _ssaoPostProcess;
  122046. private _blurHPostProcess;
  122047. private _blurVPostProcess;
  122048. private _ssaoCombinePostProcess;
  122049. private _firstUpdate;
  122050. /**
  122051. * Gets active scene
  122052. */
  122053. readonly scene: Scene;
  122054. /**
  122055. * @constructor
  122056. * @param name - The rendering pipeline name
  122057. * @param scene - The scene linked to this pipeline
  122058. * @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 }
  122059. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  122060. */
  122061. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  122062. /**
  122063. * Get the class name
  122064. * @returns "SSAORenderingPipeline"
  122065. */
  122066. getClassName(): string;
  122067. /**
  122068. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  122069. */
  122070. dispose(disableDepthRender?: boolean): void;
  122071. private _createBlurPostProcess;
  122072. /** @hidden */
  122073. _rebuild(): void;
  122074. private _createSSAOPostProcess;
  122075. private _createSSAOCombinePostProcess;
  122076. private _createRandomTexture;
  122077. }
  122078. }
  122079. declare module BABYLON {
  122080. /** @hidden */
  122081. export var standardPixelShader: {
  122082. name: string;
  122083. shader: string;
  122084. };
  122085. }
  122086. declare module BABYLON {
  122087. /**
  122088. * Standard rendering pipeline
  122089. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122090. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  122091. */
  122092. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  122093. /**
  122094. * Public members
  122095. */
  122096. /**
  122097. * Post-process which contains the original scene color before the pipeline applies all the effects
  122098. */
  122099. originalPostProcess: Nullable<PostProcess>;
  122100. /**
  122101. * Post-process used to down scale an image x4
  122102. */
  122103. downSampleX4PostProcess: Nullable<PostProcess>;
  122104. /**
  122105. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  122106. */
  122107. brightPassPostProcess: Nullable<PostProcess>;
  122108. /**
  122109. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  122110. */
  122111. blurHPostProcesses: PostProcess[];
  122112. /**
  122113. * Post-process array storing all the vertical blur post-processes used by the pipeline
  122114. */
  122115. blurVPostProcesses: PostProcess[];
  122116. /**
  122117. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  122118. */
  122119. textureAdderPostProcess: Nullable<PostProcess>;
  122120. /**
  122121. * Post-process used to create volumetric lighting effect
  122122. */
  122123. volumetricLightPostProcess: Nullable<PostProcess>;
  122124. /**
  122125. * Post-process used to smooth the previous volumetric light post-process on the X axis
  122126. */
  122127. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  122128. /**
  122129. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  122130. */
  122131. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  122132. /**
  122133. * Post-process used to merge the volumetric light effect and the real scene color
  122134. */
  122135. volumetricLightMergePostProces: Nullable<PostProcess>;
  122136. /**
  122137. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  122138. */
  122139. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  122140. /**
  122141. * Base post-process used to calculate the average luminance of the final image for HDR
  122142. */
  122143. luminancePostProcess: Nullable<PostProcess>;
  122144. /**
  122145. * Post-processes used to create down sample post-processes in order to get
  122146. * the average luminance of the final image for HDR
  122147. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  122148. */
  122149. luminanceDownSamplePostProcesses: PostProcess[];
  122150. /**
  122151. * Post-process used to create a HDR effect (light adaptation)
  122152. */
  122153. hdrPostProcess: Nullable<PostProcess>;
  122154. /**
  122155. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  122156. */
  122157. textureAdderFinalPostProcess: Nullable<PostProcess>;
  122158. /**
  122159. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  122160. */
  122161. lensFlareFinalPostProcess: Nullable<PostProcess>;
  122162. /**
  122163. * Post-process used to merge the final HDR post-process and the real scene color
  122164. */
  122165. hdrFinalPostProcess: Nullable<PostProcess>;
  122166. /**
  122167. * Post-process used to create a lens flare effect
  122168. */
  122169. lensFlarePostProcess: Nullable<PostProcess>;
  122170. /**
  122171. * Post-process that merges the result of the lens flare post-process and the real scene color
  122172. */
  122173. lensFlareComposePostProcess: Nullable<PostProcess>;
  122174. /**
  122175. * Post-process used to create a motion blur effect
  122176. */
  122177. motionBlurPostProcess: Nullable<PostProcess>;
  122178. /**
  122179. * Post-process used to create a depth of field effect
  122180. */
  122181. depthOfFieldPostProcess: Nullable<PostProcess>;
  122182. /**
  122183. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  122184. */
  122185. fxaaPostProcess: Nullable<FxaaPostProcess>;
  122186. /**
  122187. * Represents the brightness threshold in order to configure the illuminated surfaces
  122188. */
  122189. brightThreshold: number;
  122190. /**
  122191. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  122192. */
  122193. blurWidth: number;
  122194. /**
  122195. * Sets if the blur for highlighted surfaces must be only horizontal
  122196. */
  122197. horizontalBlur: boolean;
  122198. /**
  122199. * Gets the overall exposure used by the pipeline
  122200. */
  122201. /**
  122202. * Sets the overall exposure used by the pipeline
  122203. */
  122204. exposure: number;
  122205. /**
  122206. * Texture used typically to simulate "dirty" on camera lens
  122207. */
  122208. lensTexture: Nullable<Texture>;
  122209. /**
  122210. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  122211. */
  122212. volumetricLightCoefficient: number;
  122213. /**
  122214. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  122215. */
  122216. volumetricLightPower: number;
  122217. /**
  122218. * Used the set the blur intensity to smooth the volumetric lights
  122219. */
  122220. volumetricLightBlurScale: number;
  122221. /**
  122222. * Light (spot or directional) used to generate the volumetric lights rays
  122223. * The source light must have a shadow generate so the pipeline can get its
  122224. * depth map
  122225. */
  122226. sourceLight: Nullable<SpotLight | DirectionalLight>;
  122227. /**
  122228. * For eye adaptation, represents the minimum luminance the eye can see
  122229. */
  122230. hdrMinimumLuminance: number;
  122231. /**
  122232. * For eye adaptation, represents the decrease luminance speed
  122233. */
  122234. hdrDecreaseRate: number;
  122235. /**
  122236. * For eye adaptation, represents the increase luminance speed
  122237. */
  122238. hdrIncreaseRate: number;
  122239. /**
  122240. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  122241. */
  122242. /**
  122243. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  122244. */
  122245. hdrAutoExposure: boolean;
  122246. /**
  122247. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  122248. */
  122249. lensColorTexture: Nullable<Texture>;
  122250. /**
  122251. * The overall strengh for the lens flare effect
  122252. */
  122253. lensFlareStrength: number;
  122254. /**
  122255. * Dispersion coefficient for lens flare ghosts
  122256. */
  122257. lensFlareGhostDispersal: number;
  122258. /**
  122259. * Main lens flare halo width
  122260. */
  122261. lensFlareHaloWidth: number;
  122262. /**
  122263. * Based on the lens distortion effect, defines how much the lens flare result
  122264. * is distorted
  122265. */
  122266. lensFlareDistortionStrength: number;
  122267. /**
  122268. * Lens star texture must be used to simulate rays on the flares and is available
  122269. * in the documentation
  122270. */
  122271. lensStarTexture: Nullable<Texture>;
  122272. /**
  122273. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  122274. * flare effect by taking account of the dirt texture
  122275. */
  122276. lensFlareDirtTexture: Nullable<Texture>;
  122277. /**
  122278. * Represents the focal length for the depth of field effect
  122279. */
  122280. depthOfFieldDistance: number;
  122281. /**
  122282. * Represents the blur intensity for the blurred part of the depth of field effect
  122283. */
  122284. depthOfFieldBlurWidth: number;
  122285. /**
  122286. * Gets how much the image is blurred by the movement while using the motion blur post-process
  122287. */
  122288. /**
  122289. * Sets how much the image is blurred by the movement while using the motion blur post-process
  122290. */
  122291. motionStrength: number;
  122292. /**
  122293. * Gets wether or not the motion blur post-process is object based or screen based.
  122294. */
  122295. /**
  122296. * Sets wether or not the motion blur post-process should be object based or screen based
  122297. */
  122298. objectBasedMotionBlur: boolean;
  122299. /**
  122300. * List of animations for the pipeline (IAnimatable implementation)
  122301. */
  122302. animations: Animation[];
  122303. /**
  122304. * Private members
  122305. */
  122306. private _scene;
  122307. private _currentDepthOfFieldSource;
  122308. private _basePostProcess;
  122309. private _fixedExposure;
  122310. private _currentExposure;
  122311. private _hdrAutoExposure;
  122312. private _hdrCurrentLuminance;
  122313. private _motionStrength;
  122314. private _isObjectBasedMotionBlur;
  122315. private _floatTextureType;
  122316. private _ratio;
  122317. private _bloomEnabled;
  122318. private _depthOfFieldEnabled;
  122319. private _vlsEnabled;
  122320. private _lensFlareEnabled;
  122321. private _hdrEnabled;
  122322. private _motionBlurEnabled;
  122323. private _fxaaEnabled;
  122324. private _motionBlurSamples;
  122325. private _volumetricLightStepsCount;
  122326. private _samples;
  122327. /**
  122328. * @ignore
  122329. * Specifies if the bloom pipeline is enabled
  122330. */
  122331. BloomEnabled: boolean;
  122332. /**
  122333. * @ignore
  122334. * Specifies if the depth of field pipeline is enabed
  122335. */
  122336. DepthOfFieldEnabled: boolean;
  122337. /**
  122338. * @ignore
  122339. * Specifies if the lens flare pipeline is enabed
  122340. */
  122341. LensFlareEnabled: boolean;
  122342. /**
  122343. * @ignore
  122344. * Specifies if the HDR pipeline is enabled
  122345. */
  122346. HDREnabled: boolean;
  122347. /**
  122348. * @ignore
  122349. * Specifies if the volumetric lights scattering effect is enabled
  122350. */
  122351. VLSEnabled: boolean;
  122352. /**
  122353. * @ignore
  122354. * Specifies if the motion blur effect is enabled
  122355. */
  122356. MotionBlurEnabled: boolean;
  122357. /**
  122358. * Specifies if anti-aliasing is enabled
  122359. */
  122360. fxaaEnabled: boolean;
  122361. /**
  122362. * Specifies the number of steps used to calculate the volumetric lights
  122363. * Typically in interval [50, 200]
  122364. */
  122365. volumetricLightStepsCount: number;
  122366. /**
  122367. * Specifies the number of samples used for the motion blur effect
  122368. * Typically in interval [16, 64]
  122369. */
  122370. motionBlurSamples: number;
  122371. /**
  122372. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  122373. */
  122374. samples: number;
  122375. /**
  122376. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122377. * @constructor
  122378. * @param name The rendering pipeline name
  122379. * @param scene The scene linked to this pipeline
  122380. * @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)
  122381. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  122382. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122383. */
  122384. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  122385. private _buildPipeline;
  122386. private _createDownSampleX4PostProcess;
  122387. private _createBrightPassPostProcess;
  122388. private _createBlurPostProcesses;
  122389. private _createTextureAdderPostProcess;
  122390. private _createVolumetricLightPostProcess;
  122391. private _createLuminancePostProcesses;
  122392. private _createHdrPostProcess;
  122393. private _createLensFlarePostProcess;
  122394. private _createDepthOfFieldPostProcess;
  122395. private _createMotionBlurPostProcess;
  122396. private _getDepthTexture;
  122397. private _disposePostProcesses;
  122398. /**
  122399. * Dispose of the pipeline and stop all post processes
  122400. */
  122401. dispose(): void;
  122402. /**
  122403. * Serialize the rendering pipeline (Used when exporting)
  122404. * @returns the serialized object
  122405. */
  122406. serialize(): any;
  122407. /**
  122408. * Parse the serialized pipeline
  122409. * @param source Source pipeline.
  122410. * @param scene The scene to load the pipeline to.
  122411. * @param rootUrl The URL of the serialized pipeline.
  122412. * @returns An instantiated pipeline from the serialized object.
  122413. */
  122414. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  122415. /**
  122416. * Luminance steps
  122417. */
  122418. static LuminanceSteps: number;
  122419. }
  122420. }
  122421. declare module BABYLON {
  122422. /** @hidden */
  122423. export var tonemapPixelShader: {
  122424. name: string;
  122425. shader: string;
  122426. };
  122427. }
  122428. declare module BABYLON {
  122429. /** Defines operator used for tonemapping */
  122430. export enum TonemappingOperator {
  122431. /** Hable */
  122432. Hable = 0,
  122433. /** Reinhard */
  122434. Reinhard = 1,
  122435. /** HejiDawson */
  122436. HejiDawson = 2,
  122437. /** Photographic */
  122438. Photographic = 3
  122439. }
  122440. /**
  122441. * Defines a post process to apply tone mapping
  122442. */
  122443. export class TonemapPostProcess extends PostProcess {
  122444. private _operator;
  122445. /** Defines the required exposure adjustement */
  122446. exposureAdjustment: number;
  122447. /**
  122448. * Creates a new TonemapPostProcess
  122449. * @param name defines the name of the postprocess
  122450. * @param _operator defines the operator to use
  122451. * @param exposureAdjustment defines the required exposure adjustement
  122452. * @param camera defines the camera to use (can be null)
  122453. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  122454. * @param engine defines the hosting engine (can be ignore if camera is set)
  122455. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  122456. */
  122457. constructor(name: string, _operator: TonemappingOperator,
  122458. /** Defines the required exposure adjustement */
  122459. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  122460. }
  122461. }
  122462. declare module BABYLON {
  122463. /** @hidden */
  122464. export var depthVertexShader: {
  122465. name: string;
  122466. shader: string;
  122467. };
  122468. }
  122469. declare module BABYLON {
  122470. /** @hidden */
  122471. export var volumetricLightScatteringPixelShader: {
  122472. name: string;
  122473. shader: string;
  122474. };
  122475. }
  122476. declare module BABYLON {
  122477. /** @hidden */
  122478. export var volumetricLightScatteringPassPixelShader: {
  122479. name: string;
  122480. shader: string;
  122481. };
  122482. }
  122483. declare module BABYLON {
  122484. /**
  122485. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  122486. */
  122487. export class VolumetricLightScatteringPostProcess extends PostProcess {
  122488. private _volumetricLightScatteringPass;
  122489. private _volumetricLightScatteringRTT;
  122490. private _viewPort;
  122491. private _screenCoordinates;
  122492. private _cachedDefines;
  122493. /**
  122494. * If not undefined, the mesh position is computed from the attached node position
  122495. */
  122496. attachedNode: {
  122497. position: Vector3;
  122498. };
  122499. /**
  122500. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  122501. */
  122502. customMeshPosition: Vector3;
  122503. /**
  122504. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  122505. */
  122506. useCustomMeshPosition: boolean;
  122507. /**
  122508. * If the post-process should inverse the light scattering direction
  122509. */
  122510. invert: boolean;
  122511. /**
  122512. * The internal mesh used by the post-process
  122513. */
  122514. mesh: Mesh;
  122515. /**
  122516. * @hidden
  122517. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  122518. */
  122519. useDiffuseColor: boolean;
  122520. /**
  122521. * Array containing the excluded meshes not rendered in the internal pass
  122522. */
  122523. excludedMeshes: AbstractMesh[];
  122524. /**
  122525. * Controls the overall intensity of the post-process
  122526. */
  122527. exposure: number;
  122528. /**
  122529. * Dissipates each sample's contribution in range [0, 1]
  122530. */
  122531. decay: number;
  122532. /**
  122533. * Controls the overall intensity of each sample
  122534. */
  122535. weight: number;
  122536. /**
  122537. * Controls the density of each sample
  122538. */
  122539. density: number;
  122540. /**
  122541. * @constructor
  122542. * @param name The post-process name
  122543. * @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)
  122544. * @param camera The camera that the post-process will be attached to
  122545. * @param mesh The mesh used to create the light scattering
  122546. * @param samples The post-process quality, default 100
  122547. * @param samplingModeThe post-process filtering mode
  122548. * @param engine The babylon engine
  122549. * @param reusable If the post-process is reusable
  122550. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  122551. */
  122552. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  122553. /**
  122554. * Returns the string "VolumetricLightScatteringPostProcess"
  122555. * @returns "VolumetricLightScatteringPostProcess"
  122556. */
  122557. getClassName(): string;
  122558. private _isReady;
  122559. /**
  122560. * Sets the new light position for light scattering effect
  122561. * @param position The new custom light position
  122562. */
  122563. setCustomMeshPosition(position: Vector3): void;
  122564. /**
  122565. * Returns the light position for light scattering effect
  122566. * @return Vector3 The custom light position
  122567. */
  122568. getCustomMeshPosition(): Vector3;
  122569. /**
  122570. * Disposes the internal assets and detaches the post-process from the camera
  122571. */
  122572. dispose(camera: Camera): void;
  122573. /**
  122574. * Returns the render target texture used by the post-process
  122575. * @return the render target texture used by the post-process
  122576. */
  122577. getPass(): RenderTargetTexture;
  122578. private _meshExcluded;
  122579. private _createPass;
  122580. private _updateMeshScreenCoordinates;
  122581. /**
  122582. * Creates a default mesh for the Volumeric Light Scattering post-process
  122583. * @param name The mesh name
  122584. * @param scene The scene where to create the mesh
  122585. * @return the default mesh
  122586. */
  122587. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  122588. }
  122589. }
  122590. declare module BABYLON {
  122591. interface Scene {
  122592. /** @hidden (Backing field) */
  122593. _boundingBoxRenderer: BoundingBoxRenderer;
  122594. /** @hidden (Backing field) */
  122595. _forceShowBoundingBoxes: boolean;
  122596. /**
  122597. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  122598. */
  122599. forceShowBoundingBoxes: boolean;
  122600. /**
  122601. * Gets the bounding box renderer associated with the scene
  122602. * @returns a BoundingBoxRenderer
  122603. */
  122604. getBoundingBoxRenderer(): BoundingBoxRenderer;
  122605. }
  122606. interface AbstractMesh {
  122607. /** @hidden (Backing field) */
  122608. _showBoundingBox: boolean;
  122609. /**
  122610. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  122611. */
  122612. showBoundingBox: boolean;
  122613. }
  122614. /**
  122615. * Component responsible of rendering the bounding box of the meshes in a scene.
  122616. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  122617. */
  122618. export class BoundingBoxRenderer implements ISceneComponent {
  122619. /**
  122620. * The component name helpfull to identify the component in the list of scene components.
  122621. */
  122622. readonly name: string;
  122623. /**
  122624. * The scene the component belongs to.
  122625. */
  122626. scene: Scene;
  122627. /**
  122628. * Color of the bounding box lines placed in front of an object
  122629. */
  122630. frontColor: Color3;
  122631. /**
  122632. * Color of the bounding box lines placed behind an object
  122633. */
  122634. backColor: Color3;
  122635. /**
  122636. * Defines if the renderer should show the back lines or not
  122637. */
  122638. showBackLines: boolean;
  122639. /**
  122640. * @hidden
  122641. */
  122642. renderList: SmartArray<BoundingBox>;
  122643. private _colorShader;
  122644. private _vertexBuffers;
  122645. private _indexBuffer;
  122646. private _fillIndexBuffer;
  122647. private _fillIndexData;
  122648. /**
  122649. * Instantiates a new bounding box renderer in a scene.
  122650. * @param scene the scene the renderer renders in
  122651. */
  122652. constructor(scene: Scene);
  122653. /**
  122654. * Registers the component in a given scene
  122655. */
  122656. register(): void;
  122657. private _evaluateSubMesh;
  122658. private _activeMesh;
  122659. private _prepareRessources;
  122660. private _createIndexBuffer;
  122661. /**
  122662. * Rebuilds the elements related to this component in case of
  122663. * context lost for instance.
  122664. */
  122665. rebuild(): void;
  122666. /**
  122667. * @hidden
  122668. */
  122669. reset(): void;
  122670. /**
  122671. * Render the bounding boxes of a specific rendering group
  122672. * @param renderingGroupId defines the rendering group to render
  122673. */
  122674. render(renderingGroupId: number): void;
  122675. /**
  122676. * In case of occlusion queries, we can render the occlusion bounding box through this method
  122677. * @param mesh Define the mesh to render the occlusion bounding box for
  122678. */
  122679. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  122680. /**
  122681. * Dispose and release the resources attached to this renderer.
  122682. */
  122683. dispose(): void;
  122684. }
  122685. }
  122686. declare module BABYLON {
  122687. /** @hidden */
  122688. export var depthPixelShader: {
  122689. name: string;
  122690. shader: string;
  122691. };
  122692. }
  122693. declare module BABYLON {
  122694. /**
  122695. * This represents a depth renderer in Babylon.
  122696. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  122697. */
  122698. export class DepthRenderer {
  122699. private _scene;
  122700. private _depthMap;
  122701. private _effect;
  122702. private readonly _storeNonLinearDepth;
  122703. private readonly _clearColor;
  122704. /** Get if the depth renderer is using packed depth or not */
  122705. readonly isPacked: boolean;
  122706. private _cachedDefines;
  122707. private _camera;
  122708. /**
  122709. * Specifiess that the depth renderer will only be used within
  122710. * the camera it is created for.
  122711. * This can help forcing its rendering during the camera processing.
  122712. */
  122713. useOnlyInActiveCamera: boolean;
  122714. /** @hidden */
  122715. static _SceneComponentInitialization: (scene: Scene) => void;
  122716. /**
  122717. * Instantiates a depth renderer
  122718. * @param scene The scene the renderer belongs to
  122719. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  122720. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  122721. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  122722. */
  122723. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  122724. /**
  122725. * Creates the depth rendering effect and checks if the effect is ready.
  122726. * @param subMesh The submesh to be used to render the depth map of
  122727. * @param useInstances If multiple world instances should be used
  122728. * @returns if the depth renderer is ready to render the depth map
  122729. */
  122730. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122731. /**
  122732. * Gets the texture which the depth map will be written to.
  122733. * @returns The depth map texture
  122734. */
  122735. getDepthMap(): RenderTargetTexture;
  122736. /**
  122737. * Disposes of the depth renderer.
  122738. */
  122739. dispose(): void;
  122740. }
  122741. }
  122742. declare module BABYLON {
  122743. interface Scene {
  122744. /** @hidden (Backing field) */
  122745. _depthRenderer: {
  122746. [id: string]: DepthRenderer;
  122747. };
  122748. /**
  122749. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  122750. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  122751. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  122752. * @returns the created depth renderer
  122753. */
  122754. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  122755. /**
  122756. * Disables a depth renderer for a given camera
  122757. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  122758. */
  122759. disableDepthRenderer(camera?: Nullable<Camera>): void;
  122760. }
  122761. /**
  122762. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  122763. * in several rendering techniques.
  122764. */
  122765. export class DepthRendererSceneComponent implements ISceneComponent {
  122766. /**
  122767. * The component name helpfull to identify the component in the list of scene components.
  122768. */
  122769. readonly name: string;
  122770. /**
  122771. * The scene the component belongs to.
  122772. */
  122773. scene: Scene;
  122774. /**
  122775. * Creates a new instance of the component for the given scene
  122776. * @param scene Defines the scene to register the component in
  122777. */
  122778. constructor(scene: Scene);
  122779. /**
  122780. * Registers the component in a given scene
  122781. */
  122782. register(): void;
  122783. /**
  122784. * Rebuilds the elements related to this component in case of
  122785. * context lost for instance.
  122786. */
  122787. rebuild(): void;
  122788. /**
  122789. * Disposes the component and the associated ressources
  122790. */
  122791. dispose(): void;
  122792. private _gatherRenderTargets;
  122793. private _gatherActiveCameraRenderTargets;
  122794. }
  122795. }
  122796. declare module BABYLON {
  122797. /** @hidden */
  122798. export var outlinePixelShader: {
  122799. name: string;
  122800. shader: string;
  122801. };
  122802. }
  122803. declare module BABYLON {
  122804. /** @hidden */
  122805. export var outlineVertexShader: {
  122806. name: string;
  122807. shader: string;
  122808. };
  122809. }
  122810. declare module BABYLON {
  122811. interface Scene {
  122812. /** @hidden */
  122813. _outlineRenderer: OutlineRenderer;
  122814. /**
  122815. * Gets the outline renderer associated with the scene
  122816. * @returns a OutlineRenderer
  122817. */
  122818. getOutlineRenderer(): OutlineRenderer;
  122819. }
  122820. interface AbstractMesh {
  122821. /** @hidden (Backing field) */
  122822. _renderOutline: boolean;
  122823. /**
  122824. * Gets or sets a boolean indicating if the outline must be rendered as well
  122825. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  122826. */
  122827. renderOutline: boolean;
  122828. /** @hidden (Backing field) */
  122829. _renderOverlay: boolean;
  122830. /**
  122831. * Gets or sets a boolean indicating if the overlay must be rendered as well
  122832. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  122833. */
  122834. renderOverlay: boolean;
  122835. }
  122836. /**
  122837. * This class is responsible to draw bothe outline/overlay of meshes.
  122838. * It should not be used directly but through the available method on mesh.
  122839. */
  122840. export class OutlineRenderer implements ISceneComponent {
  122841. /**
  122842. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  122843. */
  122844. private static _StencilReference;
  122845. /**
  122846. * The name of the component. Each component must have a unique name.
  122847. */
  122848. name: string;
  122849. /**
  122850. * The scene the component belongs to.
  122851. */
  122852. scene: Scene;
  122853. /**
  122854. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  122855. */
  122856. zOffset: number;
  122857. private _engine;
  122858. private _effect;
  122859. private _cachedDefines;
  122860. private _savedDepthWrite;
  122861. /**
  122862. * Instantiates a new outline renderer. (There could be only one per scene).
  122863. * @param scene Defines the scene it belongs to
  122864. */
  122865. constructor(scene: Scene);
  122866. /**
  122867. * Register the component to one instance of a scene.
  122868. */
  122869. register(): void;
  122870. /**
  122871. * Rebuilds the elements related to this component in case of
  122872. * context lost for instance.
  122873. */
  122874. rebuild(): void;
  122875. /**
  122876. * Disposes the component and the associated ressources.
  122877. */
  122878. dispose(): void;
  122879. /**
  122880. * Renders the outline in the canvas.
  122881. * @param subMesh Defines the sumesh to render
  122882. * @param batch Defines the batch of meshes in case of instances
  122883. * @param useOverlay Defines if the rendering is for the overlay or the outline
  122884. */
  122885. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  122886. /**
  122887. * Returns whether or not the outline renderer is ready for a given submesh.
  122888. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  122889. * @param subMesh Defines the submesh to check readyness for
  122890. * @param useInstances Defines wheter wee are trying to render instances or not
  122891. * @returns true if ready otherwise false
  122892. */
  122893. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122894. private _beforeRenderingMesh;
  122895. private _afterRenderingMesh;
  122896. }
  122897. }
  122898. declare module BABYLON {
  122899. /**
  122900. * Defines the list of states available for a task inside a AssetsManager
  122901. */
  122902. export enum AssetTaskState {
  122903. /**
  122904. * Initialization
  122905. */
  122906. INIT = 0,
  122907. /**
  122908. * Running
  122909. */
  122910. RUNNING = 1,
  122911. /**
  122912. * Done
  122913. */
  122914. DONE = 2,
  122915. /**
  122916. * Error
  122917. */
  122918. ERROR = 3
  122919. }
  122920. /**
  122921. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  122922. */
  122923. export abstract class AbstractAssetTask {
  122924. /**
  122925. * Task name
  122926. */ name: string;
  122927. /**
  122928. * Callback called when the task is successful
  122929. */
  122930. onSuccess: (task: any) => void;
  122931. /**
  122932. * Callback called when the task is not successful
  122933. */
  122934. onError: (task: any, message?: string, exception?: any) => void;
  122935. /**
  122936. * Creates a new AssetsManager
  122937. * @param name defines the name of the task
  122938. */
  122939. constructor(
  122940. /**
  122941. * Task name
  122942. */ name: string);
  122943. private _isCompleted;
  122944. private _taskState;
  122945. private _errorObject;
  122946. /**
  122947. * Get if the task is completed
  122948. */
  122949. readonly isCompleted: boolean;
  122950. /**
  122951. * Gets the current state of the task
  122952. */
  122953. readonly taskState: AssetTaskState;
  122954. /**
  122955. * Gets the current error object (if task is in error)
  122956. */
  122957. readonly errorObject: {
  122958. message?: string;
  122959. exception?: any;
  122960. };
  122961. /**
  122962. * Internal only
  122963. * @hidden
  122964. */
  122965. _setErrorObject(message?: string, exception?: any): void;
  122966. /**
  122967. * Execute the current task
  122968. * @param scene defines the scene where you want your assets to be loaded
  122969. * @param onSuccess is a callback called when the task is successfully executed
  122970. * @param onError is a callback called if an error occurs
  122971. */
  122972. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122973. /**
  122974. * Execute the current task
  122975. * @param scene defines the scene where you want your assets to be loaded
  122976. * @param onSuccess is a callback called when the task is successfully executed
  122977. * @param onError is a callback called if an error occurs
  122978. */
  122979. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122980. /**
  122981. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  122982. * This can be used with failed tasks that have the reason for failure fixed.
  122983. */
  122984. reset(): void;
  122985. private onErrorCallback;
  122986. private onDoneCallback;
  122987. }
  122988. /**
  122989. * Define the interface used by progress events raised during assets loading
  122990. */
  122991. export interface IAssetsProgressEvent {
  122992. /**
  122993. * Defines the number of remaining tasks to process
  122994. */
  122995. remainingCount: number;
  122996. /**
  122997. * Defines the total number of tasks
  122998. */
  122999. totalCount: number;
  123000. /**
  123001. * Defines the task that was just processed
  123002. */
  123003. task: AbstractAssetTask;
  123004. }
  123005. /**
  123006. * Class used to share progress information about assets loading
  123007. */
  123008. export class AssetsProgressEvent implements IAssetsProgressEvent {
  123009. /**
  123010. * Defines the number of remaining tasks to process
  123011. */
  123012. remainingCount: number;
  123013. /**
  123014. * Defines the total number of tasks
  123015. */
  123016. totalCount: number;
  123017. /**
  123018. * Defines the task that was just processed
  123019. */
  123020. task: AbstractAssetTask;
  123021. /**
  123022. * Creates a AssetsProgressEvent
  123023. * @param remainingCount defines the number of remaining tasks to process
  123024. * @param totalCount defines the total number of tasks
  123025. * @param task defines the task that was just processed
  123026. */
  123027. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  123028. }
  123029. /**
  123030. * Define a task used by AssetsManager to load meshes
  123031. */
  123032. export class MeshAssetTask extends AbstractAssetTask {
  123033. /**
  123034. * Defines the name of the task
  123035. */
  123036. name: string;
  123037. /**
  123038. * Defines the list of mesh's names you want to load
  123039. */
  123040. meshesNames: any;
  123041. /**
  123042. * Defines the root url to use as a base to load your meshes and associated resources
  123043. */
  123044. rootUrl: string;
  123045. /**
  123046. * Defines the filename of the scene to load from
  123047. */
  123048. sceneFilename: string;
  123049. /**
  123050. * Gets the list of loaded meshes
  123051. */
  123052. loadedMeshes: Array<AbstractMesh>;
  123053. /**
  123054. * Gets the list of loaded particle systems
  123055. */
  123056. loadedParticleSystems: Array<IParticleSystem>;
  123057. /**
  123058. * Gets the list of loaded skeletons
  123059. */
  123060. loadedSkeletons: Array<Skeleton>;
  123061. /**
  123062. * Gets the list of loaded animation groups
  123063. */
  123064. loadedAnimationGroups: Array<AnimationGroup>;
  123065. /**
  123066. * Callback called when the task is successful
  123067. */
  123068. onSuccess: (task: MeshAssetTask) => void;
  123069. /**
  123070. * Callback called when the task is successful
  123071. */
  123072. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  123073. /**
  123074. * Creates a new MeshAssetTask
  123075. * @param name defines the name of the task
  123076. * @param meshesNames defines the list of mesh's names you want to load
  123077. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  123078. * @param sceneFilename defines the filename of the scene to load from
  123079. */
  123080. constructor(
  123081. /**
  123082. * Defines the name of the task
  123083. */
  123084. name: string,
  123085. /**
  123086. * Defines the list of mesh's names you want to load
  123087. */
  123088. meshesNames: any,
  123089. /**
  123090. * Defines the root url to use as a base to load your meshes and associated resources
  123091. */
  123092. rootUrl: string,
  123093. /**
  123094. * Defines the filename of the scene to load from
  123095. */
  123096. sceneFilename: string);
  123097. /**
  123098. * Execute the current task
  123099. * @param scene defines the scene where you want your assets to be loaded
  123100. * @param onSuccess is a callback called when the task is successfully executed
  123101. * @param onError is a callback called if an error occurs
  123102. */
  123103. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123104. }
  123105. /**
  123106. * Define a task used by AssetsManager to load text content
  123107. */
  123108. export class TextFileAssetTask extends AbstractAssetTask {
  123109. /**
  123110. * Defines the name of the task
  123111. */
  123112. name: string;
  123113. /**
  123114. * Defines the location of the file to load
  123115. */
  123116. url: string;
  123117. /**
  123118. * Gets the loaded text string
  123119. */
  123120. text: string;
  123121. /**
  123122. * Callback called when the task is successful
  123123. */
  123124. onSuccess: (task: TextFileAssetTask) => void;
  123125. /**
  123126. * Callback called when the task is successful
  123127. */
  123128. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  123129. /**
  123130. * Creates a new TextFileAssetTask object
  123131. * @param name defines the name of the task
  123132. * @param url defines the location of the file to load
  123133. */
  123134. constructor(
  123135. /**
  123136. * Defines the name of the task
  123137. */
  123138. name: string,
  123139. /**
  123140. * Defines the location of the file to load
  123141. */
  123142. url: string);
  123143. /**
  123144. * Execute the current task
  123145. * @param scene defines the scene where you want your assets to be loaded
  123146. * @param onSuccess is a callback called when the task is successfully executed
  123147. * @param onError is a callback called if an error occurs
  123148. */
  123149. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123150. }
  123151. /**
  123152. * Define a task used by AssetsManager to load binary data
  123153. */
  123154. export class BinaryFileAssetTask extends AbstractAssetTask {
  123155. /**
  123156. * Defines the name of the task
  123157. */
  123158. name: string;
  123159. /**
  123160. * Defines the location of the file to load
  123161. */
  123162. url: string;
  123163. /**
  123164. * Gets the lodaded data (as an array buffer)
  123165. */
  123166. data: ArrayBuffer;
  123167. /**
  123168. * Callback called when the task is successful
  123169. */
  123170. onSuccess: (task: BinaryFileAssetTask) => void;
  123171. /**
  123172. * Callback called when the task is successful
  123173. */
  123174. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  123175. /**
  123176. * Creates a new BinaryFileAssetTask object
  123177. * @param name defines the name of the new task
  123178. * @param url defines the location of the file to load
  123179. */
  123180. constructor(
  123181. /**
  123182. * Defines the name of the task
  123183. */
  123184. name: string,
  123185. /**
  123186. * Defines the location of the file to load
  123187. */
  123188. url: string);
  123189. /**
  123190. * Execute the current task
  123191. * @param scene defines the scene where you want your assets to be loaded
  123192. * @param onSuccess is a callback called when the task is successfully executed
  123193. * @param onError is a callback called if an error occurs
  123194. */
  123195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123196. }
  123197. /**
  123198. * Define a task used by AssetsManager to load images
  123199. */
  123200. export class ImageAssetTask extends AbstractAssetTask {
  123201. /**
  123202. * Defines the name of the task
  123203. */
  123204. name: string;
  123205. /**
  123206. * Defines the location of the image to load
  123207. */
  123208. url: string;
  123209. /**
  123210. * Gets the loaded images
  123211. */
  123212. image: HTMLImageElement;
  123213. /**
  123214. * Callback called when the task is successful
  123215. */
  123216. onSuccess: (task: ImageAssetTask) => void;
  123217. /**
  123218. * Callback called when the task is successful
  123219. */
  123220. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  123221. /**
  123222. * Creates a new ImageAssetTask
  123223. * @param name defines the name of the task
  123224. * @param url defines the location of the image to load
  123225. */
  123226. constructor(
  123227. /**
  123228. * Defines the name of the task
  123229. */
  123230. name: string,
  123231. /**
  123232. * Defines the location of the image to load
  123233. */
  123234. url: string);
  123235. /**
  123236. * Execute the current task
  123237. * @param scene defines the scene where you want your assets to be loaded
  123238. * @param onSuccess is a callback called when the task is successfully executed
  123239. * @param onError is a callback called if an error occurs
  123240. */
  123241. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123242. }
  123243. /**
  123244. * Defines the interface used by texture loading tasks
  123245. */
  123246. export interface ITextureAssetTask<TEX extends BaseTexture> {
  123247. /**
  123248. * Gets the loaded texture
  123249. */
  123250. texture: TEX;
  123251. }
  123252. /**
  123253. * Define a task used by AssetsManager to load 2D textures
  123254. */
  123255. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  123256. /**
  123257. * Defines the name of the task
  123258. */
  123259. name: string;
  123260. /**
  123261. * Defines the location of the file to load
  123262. */
  123263. url: string;
  123264. /**
  123265. * Defines if mipmap should not be generated (default is false)
  123266. */
  123267. noMipmap?: boolean | undefined;
  123268. /**
  123269. * Defines if texture must be inverted on Y axis (default is false)
  123270. */
  123271. invertY?: boolean | undefined;
  123272. /**
  123273. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123274. */
  123275. samplingMode: number;
  123276. /**
  123277. * Gets the loaded texture
  123278. */
  123279. texture: Texture;
  123280. /**
  123281. * Callback called when the task is successful
  123282. */
  123283. onSuccess: (task: TextureAssetTask) => void;
  123284. /**
  123285. * Callback called when the task is successful
  123286. */
  123287. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  123288. /**
  123289. * Creates a new TextureAssetTask object
  123290. * @param name defines the name of the task
  123291. * @param url defines the location of the file to load
  123292. * @param noMipmap defines if mipmap should not be generated (default is false)
  123293. * @param invertY defines if texture must be inverted on Y axis (default is false)
  123294. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123295. */
  123296. constructor(
  123297. /**
  123298. * Defines the name of the task
  123299. */
  123300. name: string,
  123301. /**
  123302. * Defines the location of the file to load
  123303. */
  123304. url: string,
  123305. /**
  123306. * Defines if mipmap should not be generated (default is false)
  123307. */
  123308. noMipmap?: boolean | undefined,
  123309. /**
  123310. * Defines if texture must be inverted on Y axis (default is false)
  123311. */
  123312. invertY?: boolean | undefined,
  123313. /**
  123314. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123315. */
  123316. samplingMode?: number);
  123317. /**
  123318. * Execute the current task
  123319. * @param scene defines the scene where you want your assets to be loaded
  123320. * @param onSuccess is a callback called when the task is successfully executed
  123321. * @param onError is a callback called if an error occurs
  123322. */
  123323. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123324. }
  123325. /**
  123326. * Define a task used by AssetsManager to load cube textures
  123327. */
  123328. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  123329. /**
  123330. * Defines the name of the task
  123331. */
  123332. name: string;
  123333. /**
  123334. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123335. */
  123336. url: string;
  123337. /**
  123338. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123339. */
  123340. extensions?: string[] | undefined;
  123341. /**
  123342. * Defines if mipmaps should not be generated (default is false)
  123343. */
  123344. noMipmap?: boolean | undefined;
  123345. /**
  123346. * Defines the explicit list of files (undefined by default)
  123347. */
  123348. files?: string[] | undefined;
  123349. /**
  123350. * Gets the loaded texture
  123351. */
  123352. texture: CubeTexture;
  123353. /**
  123354. * Callback called when the task is successful
  123355. */
  123356. onSuccess: (task: CubeTextureAssetTask) => void;
  123357. /**
  123358. * Callback called when the task is successful
  123359. */
  123360. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  123361. /**
  123362. * Creates a new CubeTextureAssetTask
  123363. * @param name defines the name of the task
  123364. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123365. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123366. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123367. * @param files defines the explicit list of files (undefined by default)
  123368. */
  123369. constructor(
  123370. /**
  123371. * Defines the name of the task
  123372. */
  123373. name: string,
  123374. /**
  123375. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123376. */
  123377. url: string,
  123378. /**
  123379. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123380. */
  123381. extensions?: string[] | undefined,
  123382. /**
  123383. * Defines if mipmaps should not be generated (default is false)
  123384. */
  123385. noMipmap?: boolean | undefined,
  123386. /**
  123387. * Defines the explicit list of files (undefined by default)
  123388. */
  123389. files?: string[] | undefined);
  123390. /**
  123391. * Execute the current task
  123392. * @param scene defines the scene where you want your assets to be loaded
  123393. * @param onSuccess is a callback called when the task is successfully executed
  123394. * @param onError is a callback called if an error occurs
  123395. */
  123396. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123397. }
  123398. /**
  123399. * Define a task used by AssetsManager to load HDR cube textures
  123400. */
  123401. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  123402. /**
  123403. * Defines the name of the task
  123404. */
  123405. name: string;
  123406. /**
  123407. * Defines the location of the file to load
  123408. */
  123409. url: string;
  123410. /**
  123411. * Defines the desired size (the more it increases the longer the generation will be)
  123412. */
  123413. size: number;
  123414. /**
  123415. * Defines if mipmaps should not be generated (default is false)
  123416. */
  123417. noMipmap: boolean;
  123418. /**
  123419. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123420. */
  123421. generateHarmonics: boolean;
  123422. /**
  123423. * 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)
  123424. */
  123425. gammaSpace: boolean;
  123426. /**
  123427. * Internal Use Only
  123428. */
  123429. reserved: boolean;
  123430. /**
  123431. * Gets the loaded texture
  123432. */
  123433. texture: HDRCubeTexture;
  123434. /**
  123435. * Callback called when the task is successful
  123436. */
  123437. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  123438. /**
  123439. * Callback called when the task is successful
  123440. */
  123441. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  123442. /**
  123443. * Creates a new HDRCubeTextureAssetTask object
  123444. * @param name defines the name of the task
  123445. * @param url defines the location of the file to load
  123446. * @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.
  123447. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123448. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123449. * @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)
  123450. * @param reserved Internal use only
  123451. */
  123452. constructor(
  123453. /**
  123454. * Defines the name of the task
  123455. */
  123456. name: string,
  123457. /**
  123458. * Defines the location of the file to load
  123459. */
  123460. url: string,
  123461. /**
  123462. * Defines the desired size (the more it increases the longer the generation will be)
  123463. */
  123464. size: number,
  123465. /**
  123466. * Defines if mipmaps should not be generated (default is false)
  123467. */
  123468. noMipmap?: boolean,
  123469. /**
  123470. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123471. */
  123472. generateHarmonics?: boolean,
  123473. /**
  123474. * 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)
  123475. */
  123476. gammaSpace?: boolean,
  123477. /**
  123478. * Internal Use Only
  123479. */
  123480. reserved?: boolean);
  123481. /**
  123482. * Execute the current task
  123483. * @param scene defines the scene where you want your assets to be loaded
  123484. * @param onSuccess is a callback called when the task is successfully executed
  123485. * @param onError is a callback called if an error occurs
  123486. */
  123487. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123488. }
  123489. /**
  123490. * Define a task used by AssetsManager to load Equirectangular cube textures
  123491. */
  123492. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  123493. /**
  123494. * Defines the name of the task
  123495. */
  123496. name: string;
  123497. /**
  123498. * Defines the location of the file to load
  123499. */
  123500. url: string;
  123501. /**
  123502. * Defines the desired size (the more it increases the longer the generation will be)
  123503. */
  123504. size: number;
  123505. /**
  123506. * Defines if mipmaps should not be generated (default is false)
  123507. */
  123508. noMipmap: boolean;
  123509. /**
  123510. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  123511. * but the standard material would require them in Gamma space) (default is true)
  123512. */
  123513. gammaSpace: boolean;
  123514. /**
  123515. * Gets the loaded texture
  123516. */
  123517. texture: EquiRectangularCubeTexture;
  123518. /**
  123519. * Callback called when the task is successful
  123520. */
  123521. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  123522. /**
  123523. * Callback called when the task is successful
  123524. */
  123525. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  123526. /**
  123527. * Creates a new EquiRectangularCubeTextureAssetTask object
  123528. * @param name defines the name of the task
  123529. * @param url defines the location of the file to load
  123530. * @param size defines the desired size (the more it increases the longer the generation will be)
  123531. * If the size is omitted this implies you are using a preprocessed cubemap.
  123532. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123533. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  123534. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  123535. * (default is true)
  123536. */
  123537. constructor(
  123538. /**
  123539. * Defines the name of the task
  123540. */
  123541. name: string,
  123542. /**
  123543. * Defines the location of the file to load
  123544. */
  123545. url: string,
  123546. /**
  123547. * Defines the desired size (the more it increases the longer the generation will be)
  123548. */
  123549. size: number,
  123550. /**
  123551. * Defines if mipmaps should not be generated (default is false)
  123552. */
  123553. noMipmap?: boolean,
  123554. /**
  123555. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  123556. * but the standard material would require them in Gamma space) (default is true)
  123557. */
  123558. gammaSpace?: boolean);
  123559. /**
  123560. * Execute the current task
  123561. * @param scene defines the scene where you want your assets to be loaded
  123562. * @param onSuccess is a callback called when the task is successfully executed
  123563. * @param onError is a callback called if an error occurs
  123564. */
  123565. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123566. }
  123567. /**
  123568. * This class can be used to easily import assets into a scene
  123569. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  123570. */
  123571. export class AssetsManager {
  123572. private _scene;
  123573. private _isLoading;
  123574. protected _tasks: AbstractAssetTask[];
  123575. protected _waitingTasksCount: number;
  123576. protected _totalTasksCount: number;
  123577. /**
  123578. * Callback called when all tasks are processed
  123579. */
  123580. onFinish: (tasks: AbstractAssetTask[]) => void;
  123581. /**
  123582. * Callback called when a task is successful
  123583. */
  123584. onTaskSuccess: (task: AbstractAssetTask) => void;
  123585. /**
  123586. * Callback called when a task had an error
  123587. */
  123588. onTaskError: (task: AbstractAssetTask) => void;
  123589. /**
  123590. * Callback called when a task is done (whatever the result is)
  123591. */
  123592. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  123593. /**
  123594. * Observable called when all tasks are processed
  123595. */
  123596. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  123597. /**
  123598. * Observable called when a task had an error
  123599. */
  123600. onTaskErrorObservable: Observable<AbstractAssetTask>;
  123601. /**
  123602. * Observable called when all tasks were executed
  123603. */
  123604. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  123605. /**
  123606. * Observable called when a task is done (whatever the result is)
  123607. */
  123608. onProgressObservable: Observable<IAssetsProgressEvent>;
  123609. /**
  123610. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  123611. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123612. */
  123613. useDefaultLoadingScreen: boolean;
  123614. /**
  123615. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  123616. * when all assets have been downloaded.
  123617. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  123618. */
  123619. autoHideLoadingUI: boolean;
  123620. /**
  123621. * Creates a new AssetsManager
  123622. * @param scene defines the scene to work on
  123623. */
  123624. constructor(scene: Scene);
  123625. /**
  123626. * Add a MeshAssetTask to the list of active tasks
  123627. * @param taskName defines the name of the new task
  123628. * @param meshesNames defines the name of meshes to load
  123629. * @param rootUrl defines the root url to use to locate files
  123630. * @param sceneFilename defines the filename of the scene file
  123631. * @returns a new MeshAssetTask object
  123632. */
  123633. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  123634. /**
  123635. * Add a TextFileAssetTask to the list of active tasks
  123636. * @param taskName defines the name of the new task
  123637. * @param url defines the url of the file to load
  123638. * @returns a new TextFileAssetTask object
  123639. */
  123640. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  123641. /**
  123642. * Add a BinaryFileAssetTask to the list of active tasks
  123643. * @param taskName defines the name of the new task
  123644. * @param url defines the url of the file to load
  123645. * @returns a new BinaryFileAssetTask object
  123646. */
  123647. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  123648. /**
  123649. * Add a ImageAssetTask to the list of active tasks
  123650. * @param taskName defines the name of the new task
  123651. * @param url defines the url of the file to load
  123652. * @returns a new ImageAssetTask object
  123653. */
  123654. addImageTask(taskName: string, url: string): ImageAssetTask;
  123655. /**
  123656. * Add a TextureAssetTask to the list of active tasks
  123657. * @param taskName defines the name of the new task
  123658. * @param url defines the url of the file to load
  123659. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123660. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  123661. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  123662. * @returns a new TextureAssetTask object
  123663. */
  123664. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  123665. /**
  123666. * Add a CubeTextureAssetTask to the list of active tasks
  123667. * @param taskName defines the name of the new task
  123668. * @param url defines the url of the file to load
  123669. * @param extensions defines the extension to use to load the cube map (can be null)
  123670. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123671. * @param files defines the list of files to load (can be null)
  123672. * @returns a new CubeTextureAssetTask object
  123673. */
  123674. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  123675. /**
  123676. *
  123677. * Add a HDRCubeTextureAssetTask to the list of active tasks
  123678. * @param taskName defines the name of the new task
  123679. * @param url defines the url of the file to load
  123680. * @param size defines the size you want for the cubemap (can be null)
  123681. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123682. * @param generateHarmonics defines if you want to automatically generate (true by default)
  123683. * @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)
  123684. * @param reserved Internal use only
  123685. * @returns a new HDRCubeTextureAssetTask object
  123686. */
  123687. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  123688. /**
  123689. *
  123690. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  123691. * @param taskName defines the name of the new task
  123692. * @param url defines the url of the file to load
  123693. * @param size defines the size you want for the cubemap (can be null)
  123694. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123695. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  123696. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  123697. * @returns a new EquiRectangularCubeTextureAssetTask object
  123698. */
  123699. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  123700. /**
  123701. * Remove a task from the assets manager.
  123702. * @param task the task to remove
  123703. */
  123704. removeTask(task: AbstractAssetTask): void;
  123705. private _decreaseWaitingTasksCount;
  123706. private _runTask;
  123707. /**
  123708. * Reset the AssetsManager and remove all tasks
  123709. * @return the current instance of the AssetsManager
  123710. */
  123711. reset(): AssetsManager;
  123712. /**
  123713. * Start the loading process
  123714. * @return the current instance of the AssetsManager
  123715. */
  123716. load(): AssetsManager;
  123717. /**
  123718. * Start the loading process as an async operation
  123719. * @return a promise returning the list of failed tasks
  123720. */
  123721. loadAsync(): Promise<void>;
  123722. }
  123723. }
  123724. declare module BABYLON {
  123725. /**
  123726. * Wrapper class for promise with external resolve and reject.
  123727. */
  123728. export class Deferred<T> {
  123729. /**
  123730. * The promise associated with this deferred object.
  123731. */
  123732. readonly promise: Promise<T>;
  123733. private _resolve;
  123734. private _reject;
  123735. /**
  123736. * The resolve method of the promise associated with this deferred object.
  123737. */
  123738. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  123739. /**
  123740. * The reject method of the promise associated with this deferred object.
  123741. */
  123742. readonly reject: (reason?: any) => void;
  123743. /**
  123744. * Constructor for this deferred object.
  123745. */
  123746. constructor();
  123747. }
  123748. }
  123749. declare module BABYLON {
  123750. /**
  123751. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  123752. */
  123753. export class MeshExploder {
  123754. private _centerMesh;
  123755. private _meshes;
  123756. private _meshesOrigins;
  123757. private _toCenterVectors;
  123758. private _scaledDirection;
  123759. private _newPosition;
  123760. private _centerPosition;
  123761. /**
  123762. * Explodes meshes from a center mesh.
  123763. * @param meshes The meshes to explode.
  123764. * @param centerMesh The mesh to be center of explosion.
  123765. */
  123766. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  123767. private _setCenterMesh;
  123768. /**
  123769. * Get class name
  123770. * @returns "MeshExploder"
  123771. */
  123772. getClassName(): string;
  123773. /**
  123774. * "Exploded meshes"
  123775. * @returns Array of meshes with the centerMesh at index 0.
  123776. */
  123777. getMeshes(): Array<Mesh>;
  123778. /**
  123779. * Explodes meshes giving a specific direction
  123780. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  123781. */
  123782. explode(direction?: number): void;
  123783. }
  123784. }
  123785. declare module BABYLON {
  123786. /**
  123787. * Class used to help managing file picking and drag'n'drop
  123788. */
  123789. export class FilesInput {
  123790. /**
  123791. * List of files ready to be loaded
  123792. */
  123793. static readonly FilesToLoad: {
  123794. [key: string]: File;
  123795. };
  123796. /**
  123797. * Callback called when a file is processed
  123798. */
  123799. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  123800. private _engine;
  123801. private _currentScene;
  123802. private _sceneLoadedCallback;
  123803. private _progressCallback;
  123804. private _additionalRenderLoopLogicCallback;
  123805. private _textureLoadingCallback;
  123806. private _startingProcessingFilesCallback;
  123807. private _onReloadCallback;
  123808. private _errorCallback;
  123809. private _elementToMonitor;
  123810. private _sceneFileToLoad;
  123811. private _filesToLoad;
  123812. /**
  123813. * Creates a new FilesInput
  123814. * @param engine defines the rendering engine
  123815. * @param scene defines the hosting scene
  123816. * @param sceneLoadedCallback callback called when scene is loaded
  123817. * @param progressCallback callback called to track progress
  123818. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  123819. * @param textureLoadingCallback callback called when a texture is loading
  123820. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  123821. * @param onReloadCallback callback called when a reload is requested
  123822. * @param errorCallback callback call if an error occurs
  123823. */
  123824. 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);
  123825. private _dragEnterHandler;
  123826. private _dragOverHandler;
  123827. private _dropHandler;
  123828. /**
  123829. * Calls this function to listen to drag'n'drop events on a specific DOM element
  123830. * @param elementToMonitor defines the DOM element to track
  123831. */
  123832. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  123833. /**
  123834. * Release all associated resources
  123835. */
  123836. dispose(): void;
  123837. private renderFunction;
  123838. private drag;
  123839. private drop;
  123840. private _traverseFolder;
  123841. private _processFiles;
  123842. /**
  123843. * Load files from a drop event
  123844. * @param event defines the drop event to use as source
  123845. */
  123846. loadFiles(event: any): void;
  123847. private _processReload;
  123848. /**
  123849. * Reload the current scene from the loaded files
  123850. */
  123851. reload(): void;
  123852. }
  123853. }
  123854. declare module BABYLON {
  123855. /**
  123856. * Defines the root class used to create scene optimization to use with SceneOptimizer
  123857. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123858. */
  123859. export class SceneOptimization {
  123860. /**
  123861. * Defines the priority of this optimization (0 by default which means first in the list)
  123862. */
  123863. priority: number;
  123864. /**
  123865. * Gets a string describing the action executed by the current optimization
  123866. * @returns description string
  123867. */
  123868. getDescription(): string;
  123869. /**
  123870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123871. * @param scene defines the current scene where to apply this optimization
  123872. * @param optimizer defines the current optimizer
  123873. * @returns true if everything that can be done was applied
  123874. */
  123875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123876. /**
  123877. * Creates the SceneOptimization object
  123878. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123879. * @param desc defines the description associated with the optimization
  123880. */
  123881. constructor(
  123882. /**
  123883. * Defines the priority of this optimization (0 by default which means first in the list)
  123884. */
  123885. priority?: number);
  123886. }
  123887. /**
  123888. * Defines an optimization used to reduce the size of render target textures
  123889. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123890. */
  123891. export class TextureOptimization extends SceneOptimization {
  123892. /**
  123893. * Defines the priority of this optimization (0 by default which means first in the list)
  123894. */
  123895. priority: number;
  123896. /**
  123897. * 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
  123898. */
  123899. maximumSize: number;
  123900. /**
  123901. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123902. */
  123903. step: number;
  123904. /**
  123905. * Gets a string describing the action executed by the current optimization
  123906. * @returns description string
  123907. */
  123908. getDescription(): string;
  123909. /**
  123910. * Creates the TextureOptimization object
  123911. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123912. * @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
  123913. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123914. */
  123915. constructor(
  123916. /**
  123917. * Defines the priority of this optimization (0 by default which means first in the list)
  123918. */
  123919. priority?: number,
  123920. /**
  123921. * 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
  123922. */
  123923. maximumSize?: number,
  123924. /**
  123925. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123926. */
  123927. step?: number);
  123928. /**
  123929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123930. * @param scene defines the current scene where to apply this optimization
  123931. * @param optimizer defines the current optimizer
  123932. * @returns true if everything that can be done was applied
  123933. */
  123934. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123935. }
  123936. /**
  123937. * Defines an optimization used to increase or decrease the rendering resolution
  123938. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123939. */
  123940. export class HardwareScalingOptimization extends SceneOptimization {
  123941. /**
  123942. * Defines the priority of this optimization (0 by default which means first in the list)
  123943. */
  123944. priority: number;
  123945. /**
  123946. * Defines the maximum scale to use (2 by default)
  123947. */
  123948. maximumScale: number;
  123949. /**
  123950. * Defines the step to use between two passes (0.5 by default)
  123951. */
  123952. step: number;
  123953. private _currentScale;
  123954. private _directionOffset;
  123955. /**
  123956. * Gets a string describing the action executed by the current optimization
  123957. * @return description string
  123958. */
  123959. getDescription(): string;
  123960. /**
  123961. * Creates the HardwareScalingOptimization object
  123962. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123963. * @param maximumScale defines the maximum scale to use (2 by default)
  123964. * @param step defines the step to use between two passes (0.5 by default)
  123965. */
  123966. constructor(
  123967. /**
  123968. * Defines the priority of this optimization (0 by default which means first in the list)
  123969. */
  123970. priority?: number,
  123971. /**
  123972. * Defines the maximum scale to use (2 by default)
  123973. */
  123974. maximumScale?: number,
  123975. /**
  123976. * Defines the step to use between two passes (0.5 by default)
  123977. */
  123978. step?: number);
  123979. /**
  123980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123981. * @param scene defines the current scene where to apply this optimization
  123982. * @param optimizer defines the current optimizer
  123983. * @returns true if everything that can be done was applied
  123984. */
  123985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123986. }
  123987. /**
  123988. * Defines an optimization used to remove shadows
  123989. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123990. */
  123991. export class ShadowsOptimization extends SceneOptimization {
  123992. /**
  123993. * Gets a string describing the action executed by the current optimization
  123994. * @return description string
  123995. */
  123996. getDescription(): string;
  123997. /**
  123998. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123999. * @param scene defines the current scene where to apply this optimization
  124000. * @param optimizer defines the current optimizer
  124001. * @returns true if everything that can be done was applied
  124002. */
  124003. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124004. }
  124005. /**
  124006. * Defines an optimization used to turn post-processes off
  124007. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124008. */
  124009. export class PostProcessesOptimization extends SceneOptimization {
  124010. /**
  124011. * Gets a string describing the action executed by the current optimization
  124012. * @return description string
  124013. */
  124014. getDescription(): string;
  124015. /**
  124016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124017. * @param scene defines the current scene where to apply this optimization
  124018. * @param optimizer defines the current optimizer
  124019. * @returns true if everything that can be done was applied
  124020. */
  124021. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124022. }
  124023. /**
  124024. * Defines an optimization used to turn lens flares off
  124025. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124026. */
  124027. export class LensFlaresOptimization extends SceneOptimization {
  124028. /**
  124029. * Gets a string describing the action executed by the current optimization
  124030. * @return description string
  124031. */
  124032. getDescription(): string;
  124033. /**
  124034. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124035. * @param scene defines the current scene where to apply this optimization
  124036. * @param optimizer defines the current optimizer
  124037. * @returns true if everything that can be done was applied
  124038. */
  124039. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124040. }
  124041. /**
  124042. * Defines an optimization based on user defined callback.
  124043. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124044. */
  124045. export class CustomOptimization extends SceneOptimization {
  124046. /**
  124047. * Callback called to apply the custom optimization.
  124048. */
  124049. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  124050. /**
  124051. * Callback called to get custom description
  124052. */
  124053. onGetDescription: () => string;
  124054. /**
  124055. * Gets a string describing the action executed by the current optimization
  124056. * @returns description string
  124057. */
  124058. getDescription(): string;
  124059. /**
  124060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124061. * @param scene defines the current scene where to apply this optimization
  124062. * @param optimizer defines the current optimizer
  124063. * @returns true if everything that can be done was applied
  124064. */
  124065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124066. }
  124067. /**
  124068. * Defines an optimization used to turn particles off
  124069. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124070. */
  124071. export class ParticlesOptimization extends SceneOptimization {
  124072. /**
  124073. * Gets a string describing the action executed by the current optimization
  124074. * @return description string
  124075. */
  124076. getDescription(): string;
  124077. /**
  124078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124079. * @param scene defines the current scene where to apply this optimization
  124080. * @param optimizer defines the current optimizer
  124081. * @returns true if everything that can be done was applied
  124082. */
  124083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124084. }
  124085. /**
  124086. * Defines an optimization used to turn render targets off
  124087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124088. */
  124089. export class RenderTargetsOptimization extends SceneOptimization {
  124090. /**
  124091. * Gets a string describing the action executed by the current optimization
  124092. * @return description string
  124093. */
  124094. getDescription(): string;
  124095. /**
  124096. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124097. * @param scene defines the current scene where to apply this optimization
  124098. * @param optimizer defines the current optimizer
  124099. * @returns true if everything that can be done was applied
  124100. */
  124101. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124102. }
  124103. /**
  124104. * Defines an optimization used to merge meshes with compatible materials
  124105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124106. */
  124107. export class MergeMeshesOptimization extends SceneOptimization {
  124108. private static _UpdateSelectionTree;
  124109. /**
  124110. * Gets or sets a boolean which defines if optimization octree has to be updated
  124111. */
  124112. /**
  124113. * Gets or sets a boolean which defines if optimization octree has to be updated
  124114. */
  124115. static UpdateSelectionTree: boolean;
  124116. /**
  124117. * Gets a string describing the action executed by the current optimization
  124118. * @return description string
  124119. */
  124120. getDescription(): string;
  124121. private _canBeMerged;
  124122. /**
  124123. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124124. * @param scene defines the current scene where to apply this optimization
  124125. * @param optimizer defines the current optimizer
  124126. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  124127. * @returns true if everything that can be done was applied
  124128. */
  124129. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  124130. }
  124131. /**
  124132. * Defines a list of options used by SceneOptimizer
  124133. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124134. */
  124135. export class SceneOptimizerOptions {
  124136. /**
  124137. * Defines the target frame rate to reach (60 by default)
  124138. */
  124139. targetFrameRate: number;
  124140. /**
  124141. * Defines the interval between two checkes (2000ms by default)
  124142. */
  124143. trackerDuration: number;
  124144. /**
  124145. * Gets the list of optimizations to apply
  124146. */
  124147. optimizations: SceneOptimization[];
  124148. /**
  124149. * Creates a new list of options used by SceneOptimizer
  124150. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  124151. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  124152. */
  124153. constructor(
  124154. /**
  124155. * Defines the target frame rate to reach (60 by default)
  124156. */
  124157. targetFrameRate?: number,
  124158. /**
  124159. * Defines the interval between two checkes (2000ms by default)
  124160. */
  124161. trackerDuration?: number);
  124162. /**
  124163. * Add a new optimization
  124164. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  124165. * @returns the current SceneOptimizerOptions
  124166. */
  124167. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  124168. /**
  124169. * Add a new custom optimization
  124170. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  124171. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  124172. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124173. * @returns the current SceneOptimizerOptions
  124174. */
  124175. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  124176. /**
  124177. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  124178. * @param targetFrameRate defines the target frame rate (60 by default)
  124179. * @returns a SceneOptimizerOptions object
  124180. */
  124181. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124182. /**
  124183. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  124184. * @param targetFrameRate defines the target frame rate (60 by default)
  124185. * @returns a SceneOptimizerOptions object
  124186. */
  124187. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124188. /**
  124189. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  124190. * @param targetFrameRate defines the target frame rate (60 by default)
  124191. * @returns a SceneOptimizerOptions object
  124192. */
  124193. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124194. }
  124195. /**
  124196. * Class used to run optimizations in order to reach a target frame rate
  124197. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124198. */
  124199. export class SceneOptimizer implements IDisposable {
  124200. private _isRunning;
  124201. private _options;
  124202. private _scene;
  124203. private _currentPriorityLevel;
  124204. private _targetFrameRate;
  124205. private _trackerDuration;
  124206. private _currentFrameRate;
  124207. private _sceneDisposeObserver;
  124208. private _improvementMode;
  124209. /**
  124210. * Defines an observable called when the optimizer reaches the target frame rate
  124211. */
  124212. onSuccessObservable: Observable<SceneOptimizer>;
  124213. /**
  124214. * Defines an observable called when the optimizer enables an optimization
  124215. */
  124216. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  124217. /**
  124218. * Defines an observable called when the optimizer is not able to reach the target frame rate
  124219. */
  124220. onFailureObservable: Observable<SceneOptimizer>;
  124221. /**
  124222. * Gets a boolean indicating if the optimizer is in improvement mode
  124223. */
  124224. readonly isInImprovementMode: boolean;
  124225. /**
  124226. * Gets the current priority level (0 at start)
  124227. */
  124228. readonly currentPriorityLevel: number;
  124229. /**
  124230. * Gets the current frame rate checked by the SceneOptimizer
  124231. */
  124232. readonly currentFrameRate: number;
  124233. /**
  124234. * Gets or sets the current target frame rate (60 by default)
  124235. */
  124236. /**
  124237. * Gets or sets the current target frame rate (60 by default)
  124238. */
  124239. targetFrameRate: number;
  124240. /**
  124241. * Gets or sets the current interval between two checks (every 2000ms by default)
  124242. */
  124243. /**
  124244. * Gets or sets the current interval between two checks (every 2000ms by default)
  124245. */
  124246. trackerDuration: number;
  124247. /**
  124248. * Gets the list of active optimizations
  124249. */
  124250. readonly optimizations: SceneOptimization[];
  124251. /**
  124252. * Creates a new SceneOptimizer
  124253. * @param scene defines the scene to work on
  124254. * @param options defines the options to use with the SceneOptimizer
  124255. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  124256. * @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)
  124257. */
  124258. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  124259. /**
  124260. * Stops the current optimizer
  124261. */
  124262. stop(): void;
  124263. /**
  124264. * Reset the optimizer to initial step (current priority level = 0)
  124265. */
  124266. reset(): void;
  124267. /**
  124268. * Start the optimizer. By default it will try to reach a specific framerate
  124269. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  124270. */
  124271. start(): void;
  124272. private _checkCurrentState;
  124273. /**
  124274. * Release all resources
  124275. */
  124276. dispose(): void;
  124277. /**
  124278. * Helper function to create a SceneOptimizer with one single line of code
  124279. * @param scene defines the scene to work on
  124280. * @param options defines the options to use with the SceneOptimizer
  124281. * @param onSuccess defines a callback to call on success
  124282. * @param onFailure defines a callback to call on failure
  124283. * @returns the new SceneOptimizer object
  124284. */
  124285. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  124286. }
  124287. }
  124288. declare module BABYLON {
  124289. /**
  124290. * Class used to serialize a scene into a string
  124291. */
  124292. export class SceneSerializer {
  124293. /**
  124294. * Clear cache used by a previous serialization
  124295. */
  124296. static ClearCache(): void;
  124297. /**
  124298. * Serialize a scene into a JSON compatible object
  124299. * @param scene defines the scene to serialize
  124300. * @returns a JSON compatible object
  124301. */
  124302. static Serialize(scene: Scene): any;
  124303. /**
  124304. * Serialize a mesh into a JSON compatible object
  124305. * @param toSerialize defines the mesh to serialize
  124306. * @param withParents defines if parents must be serialized as well
  124307. * @param withChildren defines if children must be serialized as well
  124308. * @returns a JSON compatible object
  124309. */
  124310. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  124311. }
  124312. }
  124313. declare module BABYLON {
  124314. /**
  124315. * Class used to host texture specific utilities
  124316. */
  124317. export class TextureTools {
  124318. /**
  124319. * Uses the GPU to create a copy texture rescaled at a given size
  124320. * @param texture Texture to copy from
  124321. * @param width defines the desired width
  124322. * @param height defines the desired height
  124323. * @param useBilinearMode defines if bilinear mode has to be used
  124324. * @return the generated texture
  124325. */
  124326. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  124327. }
  124328. }
  124329. declare module BABYLON {
  124330. /**
  124331. * This represents the different options available for the video capture.
  124332. */
  124333. export interface VideoRecorderOptions {
  124334. /** Defines the mime type of the video. */
  124335. mimeType: string;
  124336. /** Defines the FPS the video should be recorded at. */
  124337. fps: number;
  124338. /** Defines the chunk size for the recording data. */
  124339. recordChunckSize: number;
  124340. /** The audio tracks to attach to the recording. */
  124341. audioTracks?: MediaStreamTrack[];
  124342. }
  124343. /**
  124344. * This can help with recording videos from BabylonJS.
  124345. * This is based on the available WebRTC functionalities of the browser.
  124346. *
  124347. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  124348. */
  124349. export class VideoRecorder {
  124350. private static readonly _defaultOptions;
  124351. /**
  124352. * Returns whether or not the VideoRecorder is available in your browser.
  124353. * @param engine Defines the Babylon Engine.
  124354. * @returns true if supported otherwise false.
  124355. */
  124356. static IsSupported(engine: Engine): boolean;
  124357. private readonly _options;
  124358. private _canvas;
  124359. private _mediaRecorder;
  124360. private _recordedChunks;
  124361. private _fileName;
  124362. private _resolve;
  124363. private _reject;
  124364. /**
  124365. * True when a recording is already in progress.
  124366. */
  124367. readonly isRecording: boolean;
  124368. /**
  124369. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  124370. * @param engine Defines the BabylonJS Engine you wish to record.
  124371. * @param options Defines options that can be used to customize the capture.
  124372. */
  124373. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  124374. /**
  124375. * Stops the current recording before the default capture timeout passed in the startRecording function.
  124376. */
  124377. stopRecording(): void;
  124378. /**
  124379. * Starts recording the canvas for a max duration specified in parameters.
  124380. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  124381. * If null no automatic download will start and you can rely on the promise to get the data back.
  124382. * @param maxDuration Defines the maximum recording time in seconds.
  124383. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  124384. * @return A promise callback at the end of the recording with the video data in Blob.
  124385. */
  124386. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  124387. /**
  124388. * Releases internal resources used during the recording.
  124389. */
  124390. dispose(): void;
  124391. private _handleDataAvailable;
  124392. private _handleError;
  124393. private _handleStop;
  124394. }
  124395. }
  124396. declare module BABYLON {
  124397. /**
  124398. * Class containing a set of static utilities functions for screenshots
  124399. */
  124400. export class ScreenshotTools {
  124401. /**
  124402. * Captures a screenshot of the current rendering
  124403. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124404. * @param engine defines the rendering engine
  124405. * @param camera defines the source camera
  124406. * @param size This parameter can be set to a single number or to an object with the
  124407. * following (optional) properties: precision, width, height. If a single number is passed,
  124408. * it will be used for both width and height. If an object is passed, the screenshot size
  124409. * will be derived from the parameters. The precision property is a multiplier allowing
  124410. * rendering at a higher or lower resolution
  124411. * @param successCallback defines the callback receives a single parameter which contains the
  124412. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124413. * src parameter of an <img> to display it
  124414. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124415. * Check your browser for supported MIME types
  124416. */
  124417. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  124418. /**
  124419. * Captures a screenshot of the current rendering
  124420. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124421. * @param engine defines the rendering engine
  124422. * @param camera defines the source camera
  124423. * @param size This parameter can be set to a single number or to an object with the
  124424. * following (optional) properties: precision, width, height. If a single number is passed,
  124425. * it will be used for both width and height. If an object is passed, the screenshot size
  124426. * will be derived from the parameters. The precision property is a multiplier allowing
  124427. * rendering at a higher or lower resolution
  124428. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124429. * Check your browser for supported MIME types
  124430. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  124431. * to the src parameter of an <img> to display it
  124432. */
  124433. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  124434. /**
  124435. * Generates an image screenshot from the specified camera.
  124436. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124437. * @param engine The engine to use for rendering
  124438. * @param camera The camera to use for rendering
  124439. * @param size This parameter can be set to a single number or to an object with the
  124440. * following (optional) properties: precision, width, height. If a single number is passed,
  124441. * it will be used for both width and height. If an object is passed, the screenshot size
  124442. * will be derived from the parameters. The precision property is a multiplier allowing
  124443. * rendering at a higher or lower resolution
  124444. * @param successCallback The callback receives a single parameter which contains the
  124445. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124446. * src parameter of an <img> to display it
  124447. * @param mimeType The MIME type of the screenshot image (default: image/png).
  124448. * Check your browser for supported MIME types
  124449. * @param samples Texture samples (default: 1)
  124450. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  124451. * @param fileName A name for for the downloaded file.
  124452. */
  124453. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  124454. /**
  124455. * Generates an image screenshot from the specified camera.
  124456. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124457. * @param engine The engine to use for rendering
  124458. * @param camera The camera to use for rendering
  124459. * @param size This parameter can be set to a single number or to an object with the
  124460. * following (optional) properties: precision, width, height. If a single number is passed,
  124461. * it will be used for both width and height. If an object is passed, the screenshot size
  124462. * will be derived from the parameters. The precision property is a multiplier allowing
  124463. * rendering at a higher or lower resolution
  124464. * @param mimeType The MIME type of the screenshot image (default: image/png).
  124465. * Check your browser for supported MIME types
  124466. * @param samples Texture samples (default: 1)
  124467. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  124468. * @param fileName A name for for the downloaded file.
  124469. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  124470. * to the src parameter of an <img> to display it
  124471. */
  124472. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  124473. }
  124474. }
  124475. declare module BABYLON {
  124476. /**
  124477. * A cursor which tracks a point on a path
  124478. */
  124479. export class PathCursor {
  124480. private path;
  124481. /**
  124482. * Stores path cursor callbacks for when an onchange event is triggered
  124483. */
  124484. private _onchange;
  124485. /**
  124486. * The value of the path cursor
  124487. */
  124488. value: number;
  124489. /**
  124490. * The animation array of the path cursor
  124491. */
  124492. animations: Animation[];
  124493. /**
  124494. * Initializes the path cursor
  124495. * @param path The path to track
  124496. */
  124497. constructor(path: Path2);
  124498. /**
  124499. * Gets the cursor point on the path
  124500. * @returns A point on the path cursor at the cursor location
  124501. */
  124502. getPoint(): Vector3;
  124503. /**
  124504. * Moves the cursor ahead by the step amount
  124505. * @param step The amount to move the cursor forward
  124506. * @returns This path cursor
  124507. */
  124508. moveAhead(step?: number): PathCursor;
  124509. /**
  124510. * Moves the cursor behind by the step amount
  124511. * @param step The amount to move the cursor back
  124512. * @returns This path cursor
  124513. */
  124514. moveBack(step?: number): PathCursor;
  124515. /**
  124516. * Moves the cursor by the step amount
  124517. * If the step amount is greater than one, an exception is thrown
  124518. * @param step The amount to move the cursor
  124519. * @returns This path cursor
  124520. */
  124521. move(step: number): PathCursor;
  124522. /**
  124523. * Ensures that the value is limited between zero and one
  124524. * @returns This path cursor
  124525. */
  124526. private ensureLimits;
  124527. /**
  124528. * Runs onchange callbacks on change (used by the animation engine)
  124529. * @returns This path cursor
  124530. */
  124531. private raiseOnChange;
  124532. /**
  124533. * Executes a function on change
  124534. * @param f A path cursor onchange callback
  124535. * @returns This path cursor
  124536. */
  124537. onchange(f: (cursor: PathCursor) => void): PathCursor;
  124538. }
  124539. }
  124540. declare module BABYLON {
  124541. /** @hidden */
  124542. export var blurPixelShader: {
  124543. name: string;
  124544. shader: string;
  124545. };
  124546. }
  124547. declare module BABYLON {
  124548. /** @hidden */
  124549. export var pointCloudVertexDeclaration: {
  124550. name: string;
  124551. shader: string;
  124552. };
  124553. }
  124554. // Mixins
  124555. interface Window {
  124556. mozIndexedDB: IDBFactory;
  124557. webkitIndexedDB: IDBFactory;
  124558. msIndexedDB: IDBFactory;
  124559. webkitURL: typeof URL;
  124560. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  124561. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  124562. WebGLRenderingContext: WebGLRenderingContext;
  124563. MSGesture: MSGesture;
  124564. CANNON: any;
  124565. AudioContext: AudioContext;
  124566. webkitAudioContext: AudioContext;
  124567. PointerEvent: any;
  124568. Math: Math;
  124569. Uint8Array: Uint8ArrayConstructor;
  124570. Float32Array: Float32ArrayConstructor;
  124571. mozURL: typeof URL;
  124572. msURL: typeof URL;
  124573. VRFrameData: any; // WebVR, from specs 1.1
  124574. DracoDecoderModule: any;
  124575. setImmediate(handler: (...args: any[]) => void): number;
  124576. }
  124577. interface HTMLCanvasElement {
  124578. requestPointerLock(): void;
  124579. msRequestPointerLock?(): void;
  124580. mozRequestPointerLock?(): void;
  124581. webkitRequestPointerLock?(): void;
  124582. /** Track wether a record is in progress */
  124583. isRecording: boolean;
  124584. /** Capture Stream method defined by some browsers */
  124585. captureStream(fps?: number): MediaStream;
  124586. }
  124587. interface CanvasRenderingContext2D {
  124588. msImageSmoothingEnabled: boolean;
  124589. }
  124590. interface MouseEvent {
  124591. mozMovementX: number;
  124592. mozMovementY: number;
  124593. webkitMovementX: number;
  124594. webkitMovementY: number;
  124595. msMovementX: number;
  124596. msMovementY: number;
  124597. }
  124598. interface Navigator {
  124599. mozGetVRDevices: (any: any) => any;
  124600. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124601. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124602. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124603. webkitGetGamepads(): Gamepad[];
  124604. msGetGamepads(): Gamepad[];
  124605. webkitGamepads(): Gamepad[];
  124606. }
  124607. interface HTMLVideoElement {
  124608. mozSrcObject: any;
  124609. }
  124610. interface Math {
  124611. fround(x: number): number;
  124612. imul(a: number, b: number): number;
  124613. }
  124614. interface WebGLRenderingContext {
  124615. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  124616. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  124617. vertexAttribDivisor(index: number, divisor: number): void;
  124618. createVertexArray(): any;
  124619. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  124620. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  124621. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  124622. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  124623. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  124624. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  124625. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  124626. // Queries
  124627. createQuery(): WebGLQuery;
  124628. deleteQuery(query: WebGLQuery): void;
  124629. beginQuery(target: number, query: WebGLQuery): void;
  124630. endQuery(target: number): void;
  124631. getQueryParameter(query: WebGLQuery, pname: number): any;
  124632. getQuery(target: number, pname: number): any;
  124633. MAX_SAMPLES: number;
  124634. RGBA8: number;
  124635. READ_FRAMEBUFFER: number;
  124636. DRAW_FRAMEBUFFER: number;
  124637. UNIFORM_BUFFER: number;
  124638. HALF_FLOAT_OES: number;
  124639. RGBA16F: number;
  124640. RGBA32F: number;
  124641. R32F: number;
  124642. RG32F: number;
  124643. RGB32F: number;
  124644. R16F: number;
  124645. RG16F: number;
  124646. RGB16F: number;
  124647. RED: number;
  124648. RG: number;
  124649. R8: number;
  124650. RG8: number;
  124651. UNSIGNED_INT_24_8: number;
  124652. DEPTH24_STENCIL8: number;
  124653. /* Multiple Render Targets */
  124654. drawBuffers(buffers: number[]): void;
  124655. readBuffer(src: number): void;
  124656. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  124657. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  124658. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  124659. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  124660. // Occlusion Query
  124661. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  124662. ANY_SAMPLES_PASSED: number;
  124663. QUERY_RESULT_AVAILABLE: number;
  124664. QUERY_RESULT: number;
  124665. }
  124666. interface WebGLProgram {
  124667. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  124668. }
  124669. interface EXT_disjoint_timer_query {
  124670. QUERY_COUNTER_BITS_EXT: number;
  124671. TIME_ELAPSED_EXT: number;
  124672. TIMESTAMP_EXT: number;
  124673. GPU_DISJOINT_EXT: number;
  124674. QUERY_RESULT_EXT: number;
  124675. QUERY_RESULT_AVAILABLE_EXT: number;
  124676. queryCounterEXT(query: WebGLQuery, target: number): void;
  124677. createQueryEXT(): WebGLQuery;
  124678. beginQueryEXT(target: number, query: WebGLQuery): void;
  124679. endQueryEXT(target: number): void;
  124680. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  124681. deleteQueryEXT(query: WebGLQuery): void;
  124682. }
  124683. interface WebGLUniformLocation {
  124684. _currentState: any;
  124685. }
  124686. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  124687. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  124688. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  124689. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  124690. interface WebGLRenderingContext {
  124691. readonly RASTERIZER_DISCARD: number;
  124692. readonly DEPTH_COMPONENT24: number;
  124693. readonly TEXTURE_3D: number;
  124694. readonly TEXTURE_2D_ARRAY: number;
  124695. readonly TEXTURE_COMPARE_FUNC: number;
  124696. readonly TEXTURE_COMPARE_MODE: number;
  124697. readonly COMPARE_REF_TO_TEXTURE: number;
  124698. readonly TEXTURE_WRAP_R: number;
  124699. readonly HALF_FLOAT: number;
  124700. readonly RGB8: number;
  124701. readonly RED_INTEGER: number;
  124702. readonly RG_INTEGER: number;
  124703. readonly RGB_INTEGER: number;
  124704. readonly RGBA_INTEGER: number;
  124705. readonly R8_SNORM: number;
  124706. readonly RG8_SNORM: number;
  124707. readonly RGB8_SNORM: number;
  124708. readonly RGBA8_SNORM: number;
  124709. readonly R8I: number;
  124710. readonly RG8I: number;
  124711. readonly RGB8I: number;
  124712. readonly RGBA8I: number;
  124713. readonly R8UI: number;
  124714. readonly RG8UI: number;
  124715. readonly RGB8UI: number;
  124716. readonly RGBA8UI: number;
  124717. readonly R16I: number;
  124718. readonly RG16I: number;
  124719. readonly RGB16I: number;
  124720. readonly RGBA16I: number;
  124721. readonly R16UI: number;
  124722. readonly RG16UI: number;
  124723. readonly RGB16UI: number;
  124724. readonly RGBA16UI: number;
  124725. readonly R32I: number;
  124726. readonly RG32I: number;
  124727. readonly RGB32I: number;
  124728. readonly RGBA32I: number;
  124729. readonly R32UI: number;
  124730. readonly RG32UI: number;
  124731. readonly RGB32UI: number;
  124732. readonly RGBA32UI: number;
  124733. readonly RGB10_A2UI: number;
  124734. readonly R11F_G11F_B10F: number;
  124735. readonly RGB9_E5: number;
  124736. readonly RGB10_A2: number;
  124737. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  124738. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  124739. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  124740. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  124741. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  124742. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  124743. 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;
  124744. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  124745. readonly TRANSFORM_FEEDBACK: number;
  124746. readonly INTERLEAVED_ATTRIBS: number;
  124747. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  124748. createTransformFeedback(): WebGLTransformFeedback;
  124749. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  124750. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  124751. beginTransformFeedback(primitiveMode: number): void;
  124752. endTransformFeedback(): void;
  124753. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  124754. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124755. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124756. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124757. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  124758. }
  124759. interface ImageBitmap {
  124760. readonly width: number;
  124761. readonly height: number;
  124762. close(): void;
  124763. }
  124764. interface WebGLQuery extends WebGLObject {
  124765. }
  124766. declare var WebGLQuery: {
  124767. prototype: WebGLQuery;
  124768. new(): WebGLQuery;
  124769. };
  124770. interface WebGLSampler extends WebGLObject {
  124771. }
  124772. declare var WebGLSampler: {
  124773. prototype: WebGLSampler;
  124774. new(): WebGLSampler;
  124775. };
  124776. interface WebGLSync extends WebGLObject {
  124777. }
  124778. declare var WebGLSync: {
  124779. prototype: WebGLSync;
  124780. new(): WebGLSync;
  124781. };
  124782. interface WebGLTransformFeedback extends WebGLObject {
  124783. }
  124784. declare var WebGLTransformFeedback: {
  124785. prototype: WebGLTransformFeedback;
  124786. new(): WebGLTransformFeedback;
  124787. };
  124788. interface WebGLVertexArrayObject extends WebGLObject {
  124789. }
  124790. declare var WebGLVertexArrayObject: {
  124791. prototype: WebGLVertexArrayObject;
  124792. new(): WebGLVertexArrayObject;
  124793. };
  124794. // Type definitions for WebVR API
  124795. // Project: https://w3c.github.io/webvr/
  124796. // Definitions by: six a <https://github.com/lostfictions>
  124797. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  124798. interface VRDisplay extends EventTarget {
  124799. /**
  124800. * Dictionary of capabilities describing the VRDisplay.
  124801. */
  124802. readonly capabilities: VRDisplayCapabilities;
  124803. /**
  124804. * z-depth defining the far plane of the eye view frustum
  124805. * enables mapping of values in the render target depth
  124806. * attachment to scene coordinates. Initially set to 10000.0.
  124807. */
  124808. depthFar: number;
  124809. /**
  124810. * z-depth defining the near plane of the eye view frustum
  124811. * enables mapping of values in the render target depth
  124812. * attachment to scene coordinates. Initially set to 0.01.
  124813. */
  124814. depthNear: number;
  124815. /**
  124816. * An identifier for this distinct VRDisplay. Used as an
  124817. * association point in the Gamepad API.
  124818. */
  124819. readonly displayId: number;
  124820. /**
  124821. * A display name, a user-readable name identifying it.
  124822. */
  124823. readonly displayName: string;
  124824. readonly isConnected: boolean;
  124825. readonly isPresenting: boolean;
  124826. /**
  124827. * If this VRDisplay supports room-scale experiences, the optional
  124828. * stage attribute contains details on the room-scale parameters.
  124829. */
  124830. readonly stageParameters: VRStageParameters | null;
  124831. /**
  124832. * Passing the value returned by `requestAnimationFrame` to
  124833. * `cancelAnimationFrame` will unregister the callback.
  124834. * @param handle Define the hanle of the request to cancel
  124835. */
  124836. cancelAnimationFrame(handle: number): void;
  124837. /**
  124838. * Stops presenting to the VRDisplay.
  124839. * @returns a promise to know when it stopped
  124840. */
  124841. exitPresent(): Promise<void>;
  124842. /**
  124843. * Return the current VREyeParameters for the given eye.
  124844. * @param whichEye Define the eye we want the parameter for
  124845. * @returns the eye parameters
  124846. */
  124847. getEyeParameters(whichEye: string): VREyeParameters;
  124848. /**
  124849. * Populates the passed VRFrameData with the information required to render
  124850. * the current frame.
  124851. * @param frameData Define the data structure to populate
  124852. * @returns true if ok otherwise false
  124853. */
  124854. getFrameData(frameData: VRFrameData): boolean;
  124855. /**
  124856. * Get the layers currently being presented.
  124857. * @returns the list of VR layers
  124858. */
  124859. getLayers(): VRLayer[];
  124860. /**
  124861. * Return a VRPose containing the future predicted pose of the VRDisplay
  124862. * when the current frame will be presented. The value returned will not
  124863. * change until JavaScript has returned control to the browser.
  124864. *
  124865. * The VRPose will contain the position, orientation, velocity,
  124866. * and acceleration of each of these properties.
  124867. * @returns the pose object
  124868. */
  124869. getPose(): VRPose;
  124870. /**
  124871. * Return the current instantaneous pose of the VRDisplay, with no
  124872. * prediction applied.
  124873. * @returns the current instantaneous pose
  124874. */
  124875. getImmediatePose(): VRPose;
  124876. /**
  124877. * The callback passed to `requestAnimationFrame` will be called
  124878. * any time a new frame should be rendered. When the VRDisplay is
  124879. * presenting the callback will be called at the native refresh
  124880. * rate of the HMD. When not presenting this function acts
  124881. * identically to how window.requestAnimationFrame acts. Content should
  124882. * make no assumptions of frame rate or vsync behavior as the HMD runs
  124883. * asynchronously from other displays and at differing refresh rates.
  124884. * @param callback Define the eaction to run next frame
  124885. * @returns the request handle it
  124886. */
  124887. requestAnimationFrame(callback: FrameRequestCallback): number;
  124888. /**
  124889. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  124890. * Repeat calls while already presenting will update the VRLayers being displayed.
  124891. * @param layers Define the list of layer to present
  124892. * @returns a promise to know when the request has been fulfilled
  124893. */
  124894. requestPresent(layers: VRLayer[]): Promise<void>;
  124895. /**
  124896. * Reset the pose for this display, treating its current position and
  124897. * orientation as the "origin/zero" values. VRPose.position,
  124898. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  124899. * updated when calling resetPose(). This should be called in only
  124900. * sitting-space experiences.
  124901. */
  124902. resetPose(): void;
  124903. /**
  124904. * The VRLayer provided to the VRDisplay will be captured and presented
  124905. * in the HMD. Calling this function has the same effect on the source
  124906. * canvas as any other operation that uses its source image, and canvases
  124907. * created without preserveDrawingBuffer set to true will be cleared.
  124908. * @param pose Define the pose to submit
  124909. */
  124910. submitFrame(pose?: VRPose): void;
  124911. }
  124912. declare var VRDisplay: {
  124913. prototype: VRDisplay;
  124914. new(): VRDisplay;
  124915. };
  124916. interface VRLayer {
  124917. leftBounds?: number[] | Float32Array | null;
  124918. rightBounds?: number[] | Float32Array | null;
  124919. source?: HTMLCanvasElement | null;
  124920. }
  124921. interface VRDisplayCapabilities {
  124922. readonly canPresent: boolean;
  124923. readonly hasExternalDisplay: boolean;
  124924. readonly hasOrientation: boolean;
  124925. readonly hasPosition: boolean;
  124926. readonly maxLayers: number;
  124927. }
  124928. interface VREyeParameters {
  124929. /** @deprecated */
  124930. readonly fieldOfView: VRFieldOfView;
  124931. readonly offset: Float32Array;
  124932. readonly renderHeight: number;
  124933. readonly renderWidth: number;
  124934. }
  124935. interface VRFieldOfView {
  124936. readonly downDegrees: number;
  124937. readonly leftDegrees: number;
  124938. readonly rightDegrees: number;
  124939. readonly upDegrees: number;
  124940. }
  124941. interface VRFrameData {
  124942. readonly leftProjectionMatrix: Float32Array;
  124943. readonly leftViewMatrix: Float32Array;
  124944. readonly pose: VRPose;
  124945. readonly rightProjectionMatrix: Float32Array;
  124946. readonly rightViewMatrix: Float32Array;
  124947. readonly timestamp: number;
  124948. }
  124949. interface VRPose {
  124950. readonly angularAcceleration: Float32Array | null;
  124951. readonly angularVelocity: Float32Array | null;
  124952. readonly linearAcceleration: Float32Array | null;
  124953. readonly linearVelocity: Float32Array | null;
  124954. readonly orientation: Float32Array | null;
  124955. readonly position: Float32Array | null;
  124956. readonly timestamp: number;
  124957. }
  124958. interface VRStageParameters {
  124959. sittingToStandingTransform?: Float32Array;
  124960. sizeX?: number;
  124961. sizeY?: number;
  124962. }
  124963. interface Navigator {
  124964. getVRDisplays(): Promise<VRDisplay[]>;
  124965. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  124966. }
  124967. interface Window {
  124968. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  124969. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  124970. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  124971. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  124972. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  124973. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  124974. }
  124975. interface Gamepad {
  124976. readonly displayId: number;
  124977. }
  124978. type XRSessionMode =
  124979. | "inline"
  124980. | "immersive-vr"
  124981. | "immersive-ar";
  124982. type XRReferenceSpaceType =
  124983. | "viewer"
  124984. | "local"
  124985. | "local-floor"
  124986. | "bounded-floor"
  124987. | "unbounded";
  124988. type XREnvironmentBlendMode =
  124989. | "opaque"
  124990. | "additive"
  124991. | "alpha-blend";
  124992. type XRVisibilityState =
  124993. | "visible"
  124994. | "visible-blurred"
  124995. | "hidden";
  124996. type XRHandedness =
  124997. | "none"
  124998. | "left"
  124999. | "right";
  125000. type XRTargetRayMode =
  125001. | "gaze"
  125002. | "tracked-pointer"
  125003. | "screen";
  125004. type XREye =
  125005. | "none"
  125006. | "left"
  125007. | "right";
  125008. interface XRSpace extends EventTarget {
  125009. }
  125010. interface XRRenderState {
  125011. depthNear?: number;
  125012. depthFar?: number;
  125013. inlineVerticalFieldOfView?: number;
  125014. baseLayer?: XRWebGLLayer;
  125015. }
  125016. interface XRInputSource {
  125017. handedness: XRHandedness;
  125018. targetRayMode: XRTargetRayMode;
  125019. targetRaySpace: XRSpace;
  125020. gripSpace: XRSpace | undefined;
  125021. gamepad: Gamepad | undefined;
  125022. profiles: Array<string>;
  125023. }
  125024. interface XRSession {
  125025. addEventListener: Function;
  125026. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  125027. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  125028. requestAnimationFrame: Function;
  125029. end(): Promise<void>;
  125030. renderState: XRRenderState;
  125031. inputSources: Array<XRInputSource>;
  125032. }
  125033. interface XRReferenceSpace extends XRSpace {
  125034. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  125035. onreset: any;
  125036. }
  125037. interface XRFrame {
  125038. session: XRSession;
  125039. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  125040. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  125041. }
  125042. interface XRViewerPose extends XRPose {
  125043. views: Array<XRView>;
  125044. }
  125045. interface XRPose {
  125046. transform: XRRigidTransform;
  125047. emulatedPosition: boolean;
  125048. }
  125049. declare var XRWebGLLayer: {
  125050. prototype: XRWebGLLayer;
  125051. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  125052. };
  125053. interface XRWebGLLayer {
  125054. framebuffer: WebGLFramebuffer;
  125055. framebufferWidth: number;
  125056. framebufferHeight: number;
  125057. getViewport: Function;
  125058. }
  125059. interface XRRigidTransform {
  125060. position: DOMPointReadOnly;
  125061. orientation: DOMPointReadOnly;
  125062. matrix: Float32Array;
  125063. inverse: XRRigidTransform;
  125064. }
  125065. interface XRView {
  125066. eye: XREye;
  125067. projectionMatrix: Float32Array;
  125068. transform: XRRigidTransform;
  125069. }
  125070. interface XRInputSourceChangeEvent {
  125071. session: XRSession;
  125072. removed: Array<XRInputSource>;
  125073. added: Array<XRInputSource>;
  125074. }